alexandria-book-collection-manager 0.6.9.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rubocop.yml +68 -0
- data/.rubocop_todo.yml +200 -0
- data/CHANGELOG.md +23 -0
- data/COPYING +339 -0
- data/ChangeLog.0 +3598 -0
- data/Gemfile +9 -0
- data/INSTALL.rdoc +156 -0
- data/PACKAGING +36 -0
- data/README.md +88 -0
- data/RELEASE_CHECKLIST +18 -0
- data/Rakefile +264 -0
- data/TODO +24 -0
- data/alexandria-book-collection-manager.gemspec +35 -0
- data/alexandria.desktop.in +10 -0
- data/bin/alexandria +82 -0
- data/doc/AUTHORS +60 -0
- data/doc/BUGS +31 -0
- data/doc/FAQ +369 -0
- data/doc/HACKING +19 -0
- data/doc/NEWS +341 -0
- data/doc/alexandria.1 +120 -0
- data/doc/cuecat_support.rdoc +67 -0
- data/lib/alexandria.rb +85 -0
- data/lib/alexandria/about.rb +82 -0
- data/lib/alexandria/book_providers.rb +411 -0
- data/lib/alexandria/book_providers/adlibris.rb +235 -0
- data/lib/alexandria/book_providers/amazon_aws.rb +261 -0
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +405 -0
- data/lib/alexandria/book_providers/barnes_and_noble.rb +229 -0
- data/lib/alexandria/book_providers/bol_it.rb +162 -0
- data/lib/alexandria/book_providers/deastore.rb +277 -0
- data/lib/alexandria/book_providers/douban.rb +135 -0
- data/lib/alexandria/book_providers/ibs_it.rb +149 -0
- data/lib/alexandria/book_providers/mcu.rb +177 -0
- data/lib/alexandria/book_providers/proxis.rb +205 -0
- data/lib/alexandria/book_providers/pseudomarc.rb +185 -0
- data/lib/alexandria/book_providers/renaud.rb +142 -0
- data/lib/alexandria/book_providers/siciliano.rb +271 -0
- data/lib/alexandria/book_providers/thalia.rb +197 -0
- data/lib/alexandria/book_providers/web.rb +59 -0
- data/lib/alexandria/book_providers/webster_it.rb +173 -0
- data/lib/alexandria/book_providers/worldcat.rb +251 -0
- data/lib/alexandria/book_providers/z3950.rb +422 -0
- data/lib/alexandria/config.rb +8 -0
- data/lib/alexandria/console.rb +31 -0
- data/lib/alexandria/execution_queue.rb +96 -0
- data/lib/alexandria/export_library.rb +536 -0
- data/lib/alexandria/import_library.rb +316 -0
- data/lib/alexandria/import_library_csv.rb +270 -0
- data/lib/alexandria/logging.rb +159 -0
- data/lib/alexandria/models/book.rb +72 -0
- data/lib/alexandria/models/library.rb +714 -0
- data/lib/alexandria/net.rb +53 -0
- data/lib/alexandria/preferences.rb +324 -0
- data/lib/alexandria/scanners.rb +42 -0
- data/lib/alexandria/scanners/cuecat.rb +118 -0
- data/lib/alexandria/scanners/keyboard.rb +57 -0
- data/lib/alexandria/smart_library.rb +525 -0
- data/lib/alexandria/ui.rb +53 -0
- data/lib/alexandria/ui/builder_base.rb +43 -0
- data/lib/alexandria/ui/callbacks.rb +389 -0
- data/lib/alexandria/ui/completion_models.rb +228 -0
- data/lib/alexandria/ui/dialogs/about_dialog.rb +59 -0
- data/lib/alexandria/ui/dialogs/acquire_dialog.rb +640 -0
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +68 -0
- data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +43 -0
- data/lib/alexandria/ui/dialogs/barcode_animation.rb +159 -0
- data/lib/alexandria/ui/dialogs/book_properties_dialog.rb +210 -0
- data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +432 -0
- data/lib/alexandria/ui/dialogs/export_dialog.rb +172 -0
- data/lib/alexandria/ui/dialogs/import_dialog.rb +205 -0
- data/lib/alexandria/ui/dialogs/misc_dialogs.rb +85 -0
- data/lib/alexandria/ui/dialogs/new_book_dialog.rb +639 -0
- data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +153 -0
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +67 -0
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +587 -0
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +56 -0
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +432 -0
- data/lib/alexandria/ui/dndable.rb +81 -0
- data/lib/alexandria/ui/gtk_thread_help.rb +88 -0
- data/lib/alexandria/ui/icons.rb +100 -0
- data/lib/alexandria/ui/iconview.rb +91 -0
- data/lib/alexandria/ui/iconview_tooltips.rb +162 -0
- data/lib/alexandria/ui/init.rb +93 -0
- data/lib/alexandria/ui/libraries_combo.rb +75 -0
- data/lib/alexandria/ui/listview.rb +310 -0
- data/lib/alexandria/ui/main_app.rb +67 -0
- data/lib/alexandria/ui/multi_drag_treeview.rb +150 -0
- data/lib/alexandria/ui/sidepane.rb +194 -0
- data/lib/alexandria/ui/sound.rb +107 -0
- data/lib/alexandria/ui/ui_manager.rb +1308 -0
- data/lib/alexandria/undo_manager.rb +78 -0
- data/lib/alexandria/utils.rb +30 -0
- data/lib/alexandria/version.rb +24 -0
- data/lib/alexandria/web_themes.rb +75 -0
- data/misc/sounds/README +15 -0
- data/misc/sounds/bad_scan.csd +62 -0
- data/misc/sounds/good_scan.csd +61 -0
- data/misc/sounds/scanning.csd +46 -0
- data/po/ChangeLog +488 -0
- data/po/Makefile +44 -0
- data/po/README +29 -0
- data/po/commit-po +72 -0
- data/po/cs.po +1437 -0
- data/po/cy.po +1521 -0
- data/po/de.po +1400 -0
- data/po/el.po +1379 -0
- data/po/es.po +1376 -0
- data/po/fr.po +1420 -0
- data/po/ga.po +1359 -0
- data/po/gl.po +1397 -0
- data/po/it.po +1406 -0
- data/po/ja.po +1355 -0
- data/po/mk.po +1373 -0
- data/po/nb.po +1386 -0
- data/po/nl.po +1405 -0
- data/po/pl.po +1373 -0
- data/po/pt.po +1398 -0
- data/po/pt_BR.po +1409 -0
- data/po/ru.po +1372 -0
- data/po/sk.po +1380 -0
- data/po/sv.po +1402 -0
- data/po/uk.po +1423 -0
- data/po/zh_TW.po +1394 -0
- data/schemas/alexandria.schemas +300 -0
- data/share/alexandria/glade/acquire_dialog__builder.glade +201 -0
- data/share/alexandria/glade/book_properties_dialog__builder.glade +910 -0
- data/share/alexandria/glade/main_app__builder.glade +229 -0
- data/share/alexandria/glade/new_book_dialog__builder.glade +379 -0
- data/share/alexandria/glade/preferences_dialog__builder.glade +733 -0
- data/share/alexandria/icons/alexandria.png +0 -0
- data/share/alexandria/icons/alexandria_small.png +0 -0
- data/share/alexandria/icons/book.png +0 -0
- data/share/alexandria/icons/book_icon.png +0 -0
- data/share/alexandria/icons/book_small.png +0 -0
- data/share/alexandria/icons/cuecat.png +0 -0
- data/share/alexandria/icons/cuecat_inactive.png +0 -0
- data/share/alexandria/icons/favorite_tag.png +0 -0
- data/share/alexandria/icons/less.png +0 -0
- data/share/alexandria/icons/library.png +0 -0
- data/share/alexandria/icons/library_small.png +0 -0
- data/share/alexandria/icons/lookup.png +0 -0
- data/share/alexandria/icons/more.png +0 -0
- data/share/alexandria/icons/no_cover.png +0 -0
- data/share/alexandria/icons/smart_library.png +0 -0
- data/share/alexandria/icons/smart_library_small.png +0 -0
- data/share/alexandria/icons/star_set.png +0 -0
- data/share/alexandria/icons/star_unset.png +0 -0
- data/share/alexandria/icons/view_as_icons.png +0 -0
- data/share/alexandria/icons/view_as_list.png +0 -0
- data/share/alexandria/ui/menus.xml +91 -0
- data/share/alexandria/ui/popups.xml +91 -0
- data/share/alexandria/web-themes/clean/clean.css +85 -0
- data/share/alexandria/web-themes/clean/preview.jpg +0 -0
- data/share/alexandria/web-themes/list/list.css +105 -0
- data/share/alexandria/web-themes/list/preview.jpg +0 -0
- data/share/app-icon/16x16/alexandria.png +0 -0
- data/share/app-icon/16x16/alexandria.svg +263 -0
- data/share/app-icon/22x22/alexandria.png +0 -0
- data/share/app-icon/22x22/alexandria.svg +465 -0
- data/share/app-icon/24x24/alexandria.png +0 -0
- data/share/app-icon/32x32/alexandria.png +0 -0
- data/share/app-icon/32x32/alexandria.svg +813 -0
- data/share/app-icon/32x32/alexandria.xpm +241 -0
- data/share/app-icon/48x48/alexandria.png +0 -0
- data/share/app-icon/scalable/alexandria.svg +700 -0
- data/share/gnome/help/alexandria/C/about.xml +44 -0
- data/share/gnome/help/alexandria/C/adding-books.xml +339 -0
- data/share/gnome/help/alexandria/C/alexandria.xml +185 -0
- data/share/gnome/help/alexandria/C/bugs.xml +18 -0
- data/share/gnome/help/alexandria/C/editing-book-properties.xml +124 -0
- data/share/gnome/help/alexandria/C/exporting.xml +81 -0
- data/share/gnome/help/alexandria/C/figures/adding_books_acquire_from_scanner_process.png +0 -0
- data/share/gnome/help/alexandria/C/figures/adding_books_add_by_isbn.png +0 -0
- data/share/gnome/help/alexandria/C/figures/adding_books_isbn_import.png +0 -0
- data/share/gnome/help/alexandria/C/figures/adding_books_manual_details.png +0 -0
- data/share/gnome/help/alexandria/C/figures/adding_books_rename_library_after_import.png +0 -0
- data/share/gnome/help/alexandria/C/figures/adding_books_search_results.png +0 -0
- data/share/gnome/help/alexandria/C/figures/editing_book_properties_info.png +0 -0
- data/share/gnome/help/alexandria/C/figures/editing_book_properties_loaning.png +0 -0
- data/share/gnome/help/alexandria/C/figures/exporting_information_html.png +0 -0
- data/share/gnome/help/alexandria/C/figures/getting_started_first_launched.png +0 -0
- data/share/gnome/help/alexandria/C/figures/searching_filtering_views_list_view.png +0 -0
- data/share/gnome/help/alexandria/C/figures/searching_filtering_views_list_view_search.png +0 -0
- data/share/gnome/help/alexandria/C/figures/settings_providers_new_z3950.png +0 -0
- data/share/gnome/help/alexandria/C/figures/smart_libraries_new_smart_library.png +0 -0
- data/share/gnome/help/alexandria/C/figures/working_with_libraries_library_pane.png +0 -0
- data/share/gnome/help/alexandria/C/getting-started.xml +154 -0
- data/share/gnome/help/alexandria/C/gnu-fdl-1.2.xml +543 -0
- data/share/gnome/help/alexandria/C/introduction.xml +142 -0
- data/share/gnome/help/alexandria/C/searching.xml +90 -0
- data/share/gnome/help/alexandria/C/settings.xml +140 -0
- data/share/gnome/help/alexandria/C/smart-libraries.xml +160 -0
- data/share/gnome/help/alexandria/C/working-with-libraries.xml +76 -0
- data/share/gnome/help/alexandria/ChangeLog +99 -0
- data/share/gnome/help/alexandria/fr/alexandria.xml +2292 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_add_button.png +0 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_add_by_isbn_1.png +0 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_add_by_search_1.png +0 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_add_manually.png +0 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_add_z3950.png +0 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_close_button.png +0 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_edit_info.png +0 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_export_web_page.png +0 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_importing.png +0 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_library_pane.png +0 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_list_view.png +0 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_list_view_search.png +0 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_loaning.png +0 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_main_window.png +0 -0
- data/share/gnome/help/alexandria/fr/figures/alexandria_remove_button.png +0 -0
- data/share/gnome/help/alexandria/ja/about.xml +33 -0
- data/share/gnome/help/alexandria/ja/adding-books.xml +314 -0
- data/share/gnome/help/alexandria/ja/alexandria.xml +172 -0
- data/share/gnome/help/alexandria/ja/bugs.xml +11 -0
- data/share/gnome/help/alexandria/ja/editing-book-properties.xml +100 -0
- data/share/gnome/help/alexandria/ja/exporting.xml +98 -0
- data/share/gnome/help/alexandria/ja/figures/adding_books_acquire_from_scanner_process.png +0 -0
- data/share/gnome/help/alexandria/ja/figures/adding_books_add_by_isbn.png +0 -0
- data/share/gnome/help/alexandria/ja/figures/adding_books_isbn_import.png +0 -0
- data/share/gnome/help/alexandria/ja/figures/adding_books_manual_details.png +0 -0
- data/share/gnome/help/alexandria/ja/figures/adding_books_rename_library_after_import.png +0 -0
- data/share/gnome/help/alexandria/ja/figures/adding_books_search_results.png +0 -0
- data/share/gnome/help/alexandria/ja/figures/editing_book_properties_info.png +0 -0
- data/share/gnome/help/alexandria/ja/figures/editing_book_properties_loaning.png +0 -0
- data/share/gnome/help/alexandria/ja/figures/exporting_information_html.png +0 -0
- data/share/gnome/help/alexandria/ja/figures/getting_started_first_launched.png +0 -0
- data/share/gnome/help/alexandria/ja/figures/searching_filtering_views_list_view.png +0 -0
- data/share/gnome/help/alexandria/ja/figures/searching_filtering_views_list_view_search.png +0 -0
- data/share/gnome/help/alexandria/ja/figures/settings_providers_new_z3950.png +0 -0
- data/share/gnome/help/alexandria/ja/figures/smart_libraries_new_smart_library.png +0 -0
- data/share/gnome/help/alexandria/ja/figures/working_with_libraries_library_pane.png +0 -0
- data/share/gnome/help/alexandria/ja/getting-started.xml +144 -0
- data/share/gnome/help/alexandria/ja/gnu-fdl-1.2.xml +541 -0
- data/share/gnome/help/alexandria/ja/introduction.xml +134 -0
- data/share/gnome/help/alexandria/ja/searching.xml +104 -0
- data/share/gnome/help/alexandria/ja/settings.xml +129 -0
- data/share/gnome/help/alexandria/ja/smart-libraries.xml +140 -0
- data/share/gnome/help/alexandria/ja/working-with-libraries.xml +88 -0
- data/share/menu/alexandria +7 -0
- data/share/omf/alexandria/alexandria-C.omf.in +27 -0
- data/share/omf/alexandria/alexandria-fr.omf.in +30 -0
- data/share/sounds/alexandria/bad_scan.ogg +0 -0
- data/share/sounds/alexandria/bad_scan.wav +0 -0
- data/share/sounds/alexandria/good_scan.ogg +0 -0
- data/share/sounds/alexandria/good_scan.wav +0 -0
- data/share/sounds/alexandria/scanning.ogg +0 -0
- data/share/sounds/alexandria/scanning.wav +0 -0
- data/spec/alexandria/library_spec.rb +205 -0
- data/spec/alexandria/preferences_spec.rb +22 -0
- data/spec/alexandria/scanners/cuecat_spec.rb +68 -0
- data/spec/alexandria/smart_library_spec.rb +22 -0
- data/spec/alexandria/ui/dialogs_spec.rb +90 -0
- data/spec/alexandria/ui/iconview_spec.rb +27 -0
- data/spec/alexandria/ui/listview_spec.rb +28 -0
- data/spec/alexandria/ui/main_app_spec.rb +48 -0
- data/spec/alexandria/ui/sidepane_spec.rb +27 -0
- data/spec/alexandria/ui/ui_manager_spec.rb +26 -0
- data/spec/alexandria/ui/ui_utilities_spec.rb +60 -0
- data/spec/alexandria/utilities_spec.rb +50 -0
- data/spec/data/libraries/0.6.1-noisbn/My Library/0201398257.yaml +10 -0
- data/spec/data/libraries/0.6.1-noisbn/My Library/1565920007.yaml +10 -0
- data/spec/data/libraries/0.6.1/My Library/0192812173.yaml +9 -0
- data/spec/data/libraries/0.6.1/My Library/0201398257.cover +0 -0
- data/spec/data/libraries/0.6.1/My Library/0201398257.yaml +10 -0
- data/spec/data/libraries/0.6.1/My Library/1565920007.yaml +10 -0
- data/spec/data/libraries/0.6.2/My Library/9780140266146.cover +0 -0
- data/spec/data/libraries/0.6.2/My Library/9780140266146.yaml +16 -0
- data/spec/data/libraries/0.6.2/My Library/9780140278781.cover +0 -0
- data/spec/data/libraries/0.6.2/My Library/9780140278781.yaml +21 -0
- data/spec/data/libraries/0.6.2/My Library/9780571147168.cover +0 -0
- data/spec/data/libraries/0.6.2/My Library/9780571147168.yaml +20 -0
- data/spec/data/libraries/0.6.2/My Library/9780575079038.cover +0 -0
- data/spec/data/libraries/0.6.2/My Library/9780575079038.yaml +20 -0
- data/spec/data/libraries/0.6.2/My Library/9780755322800.cover +0 -0
- data/spec/data/libraries/0.6.2/My Library/9780755322800.yaml +20 -0
- data/spec/spec_helper.rb +46 -0
- data/tasks/rdoc.rake +6 -0
- data/tasks/setup.rb +30 -0
- data/tasks/spec.rake +29 -0
- data/tasks/test.rake +38 -0
- data/test/application_test.rb +39 -0
- data/test/book_test.rb +34 -0
- data/test/data/isbns.txt +3 -0
- data/test/isbn_test.rb +68 -0
- data/test/providers_test.rb +254 -0
- data/test/test_helper.rb +42 -0
- data/util/rake/fileinstall.rb +313 -0
- data/util/rake/gettextgenerate.rb +158 -0
- data/util/rake/omfgenerate.rb +79 -0
- metadata +452 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
|
+
#
|
3
|
+
# Alexandria is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU General Public License as
|
5
|
+
# published by the Free Software Foundation; either version 2 of the
|
6
|
+
# License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# Alexandria is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public
|
14
|
+
# License along with Alexandria; see the file COPYING. If not,
|
15
|
+
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
16
|
+
# Fifth Floor, Boston, MA 02110-1301 USA.
|
17
|
+
|
18
|
+
module Alexandria
|
19
|
+
module UI
|
20
|
+
class SmartLibraryPropertiesDialog < SmartLibraryPropertiesDialogBase
|
21
|
+
include GetText
|
22
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
|
23
|
+
|
24
|
+
def initialize(parent, smart_library, &block)
|
25
|
+
super(parent)
|
26
|
+
|
27
|
+
add_buttons([Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
|
28
|
+
[Gtk::Stock::SAVE, Gtk::Dialog::RESPONSE_OK])
|
29
|
+
|
30
|
+
self.title = _("Properties for '%s'") % smart_library.name
|
31
|
+
self.default_response = Gtk::Dialog::RESPONSE_CANCEL
|
32
|
+
|
33
|
+
show_all
|
34
|
+
smart_library.rules.each { |x| insert_new_rule(x) }
|
35
|
+
update_rules_header_box(smart_library.predicate_operator_rule)
|
36
|
+
|
37
|
+
while (response = run) != Gtk::Dialog::RESPONSE_CANCEL
|
38
|
+
if response == Gtk::Dialog::RESPONSE_HELP
|
39
|
+
Alexandria::UI.display_help(self, 'edit-smart-library')
|
40
|
+
elsif response == Gtk::Dialog::RESPONSE_OK
|
41
|
+
if user_confirms_possible_weirdnesses_before_saving?
|
42
|
+
smart_library.rules = smart_library_rules
|
43
|
+
smart_library.predicate_operator_rule =
|
44
|
+
predicate_operator_rule
|
45
|
+
smart_library.save
|
46
|
+
block.call(smart_library)
|
47
|
+
break
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
destroy
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,432 @@
|
|
1
|
+
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
|
+
# Modifications Copyright (C) 2011 Matijs van Zuijlen
|
3
|
+
#
|
4
|
+
# Alexandria is free software; you can redistribute it and/or
|
5
|
+
# modify it under the terms of the GNU General Public License as
|
6
|
+
# published by the Free Software Foundation; either version 2 of the
|
7
|
+
# License, or (at your option) any later version.
|
8
|
+
#
|
9
|
+
# Alexandria is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
# General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public
|
15
|
+
# License along with Alexandria; see the file COPYING. If not,
|
16
|
+
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
17
|
+
# Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
+
|
19
|
+
module Alexandria
|
20
|
+
module UI
|
21
|
+
class SmartLibraryPropertiesDialogBase < Gtk::Dialog
|
22
|
+
include Logging
|
23
|
+
include GetText
|
24
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
|
25
|
+
|
26
|
+
attr_reader :predicate_operator_rule
|
27
|
+
|
28
|
+
def initialize(parent)
|
29
|
+
super('', parent, Gtk::Dialog::MODAL,
|
30
|
+
[Gtk::Stock::HELP, Gtk::Dialog::RESPONSE_HELP])
|
31
|
+
|
32
|
+
self.window_position = Gtk::Window::POS_CENTER
|
33
|
+
self.has_separator = false
|
34
|
+
self.resizable = true
|
35
|
+
self.border_width = 4
|
36
|
+
vbox.border_width = 12
|
37
|
+
|
38
|
+
main_box = Gtk::VBox.new
|
39
|
+
main_box.border_width = 4
|
40
|
+
main_box.spacing = 8
|
41
|
+
|
42
|
+
vbox << main_box
|
43
|
+
|
44
|
+
@smart_library_rules = []
|
45
|
+
|
46
|
+
@rules_header_box = Gtk::HBox.new
|
47
|
+
@rules_header_box.spacing = 2
|
48
|
+
|
49
|
+
@rules_box = Gtk::VBox.new
|
50
|
+
@rules_box.spacing = 8
|
51
|
+
@rules_box.border_width = 8
|
52
|
+
|
53
|
+
scrollview = Gtk::ScrolledWindow.new
|
54
|
+
scrollview.hscrollbar_policy = Gtk::POLICY_NEVER
|
55
|
+
scrollview.vscrollbar_policy = Gtk::POLICY_AUTOMATIC
|
56
|
+
scrollview.set_size_request(-1, 125)
|
57
|
+
scrollview.add_with_viewport(@rules_box)
|
58
|
+
|
59
|
+
main_box.pack_start(@rules_header_box, false, false, 0)
|
60
|
+
main_box << scrollview
|
61
|
+
setup_calendar_widgets
|
62
|
+
end
|
63
|
+
|
64
|
+
#########
|
65
|
+
protected
|
66
|
+
#########
|
67
|
+
|
68
|
+
def smart_library_rules
|
69
|
+
fill_smart_library_rules_values
|
70
|
+
@smart_library_rules
|
71
|
+
end
|
72
|
+
|
73
|
+
def has_weirdnesses?
|
74
|
+
fill_smart_library_rules_values
|
75
|
+
smart_library_rules.each do |rule|
|
76
|
+
return true if rule.value == ''
|
77
|
+
end
|
78
|
+
false
|
79
|
+
end
|
80
|
+
|
81
|
+
def user_confirms_possible_weirdnesses_before_saving?
|
82
|
+
return true unless has_weirdnesses?
|
83
|
+
dialog = AlertDialog.new(
|
84
|
+
self,
|
85
|
+
_('Empty or conflictive condition'),
|
86
|
+
Gtk::Stock::DIALOG_QUESTION,
|
87
|
+
[[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
|
88
|
+
[_('_Save However'), Gtk::Dialog::RESPONSE_YES]],
|
89
|
+
_('This smart library contains one or more conditions ' \
|
90
|
+
'which are empty or conflict with each other. This is ' \
|
91
|
+
'likely to result in never matching a book. Are you ' \
|
92
|
+
'sure you want to save this library?'))
|
93
|
+
dialog.default_response = Gtk::Dialog::RESPONSE_CANCEL
|
94
|
+
dialog.show_all
|
95
|
+
confirmed = dialog.run == Gtk::Dialog::RESPONSE_YES
|
96
|
+
dialog.destroy
|
97
|
+
confirmed
|
98
|
+
end
|
99
|
+
|
100
|
+
def update_rules_header_box(predicate_operator_rule = SmartLibrary::ALL_RULES)
|
101
|
+
@rules_header_box.children.each { |x| @rules_header_box.remove(x) }
|
102
|
+
|
103
|
+
if @rules_box.children.length > 1
|
104
|
+
label1 = Gtk::Label.new
|
105
|
+
label1.set_alignment(0.0, 0.5)
|
106
|
+
label1.text = _('Match')
|
107
|
+
|
108
|
+
cb = Gtk::ComboBox.new
|
109
|
+
[_('all'), _('any')].each { |x| cb.append_text(x) }
|
110
|
+
cb.signal_connect('changed') do
|
111
|
+
@predicate_operator_rule = cb.active == 0 ? SmartLibrary::ALL_RULES : SmartLibrary::ANY_RULE
|
112
|
+
end
|
113
|
+
cb.active =
|
114
|
+
predicate_operator_rule == SmartLibrary::ALL_RULES ? 0 : 1
|
115
|
+
|
116
|
+
label2 = Gtk::Label.new
|
117
|
+
label2.set_alignment(0.0, 0.5)
|
118
|
+
label2.text = _('of the following rules:')
|
119
|
+
|
120
|
+
@rules_header_box.pack_start(label1, false, false, 0)
|
121
|
+
@rules_header_box.pack_start(cb, false, false, 0)
|
122
|
+
@rules_header_box.pack_start(label2, false, false, 0)
|
123
|
+
else
|
124
|
+
label = Gtk::Label.new
|
125
|
+
label.set_alignment(0.0, 0.5)
|
126
|
+
label.text = _('Match the following rule:')
|
127
|
+
@rules_header_box << label
|
128
|
+
@predicate_operator_rule = SmartLibrary::ALL_RULES
|
129
|
+
end
|
130
|
+
|
131
|
+
@rules_header_box.show_all
|
132
|
+
end
|
133
|
+
|
134
|
+
def insert_new_rule(rule = nil)
|
135
|
+
rule_box = Gtk::HBox.new
|
136
|
+
rule_box.spacing = 8
|
137
|
+
|
138
|
+
left_operand_combo = Gtk::ComboBox.new
|
139
|
+
operator_combo = Gtk::ComboBox.new
|
140
|
+
operator_model = Gtk::ListStore.new(String)
|
141
|
+
# we can't just pass the model to the combo constructor,
|
142
|
+
# it doesn't seem to work properly
|
143
|
+
operator_combo.model = operator_model
|
144
|
+
|
145
|
+
value_entry = Gtk::Entry.new
|
146
|
+
|
147
|
+
date_entry = Gtk::Entry.new
|
148
|
+
date_entry.primary_icon_name = Gtk::Stock::EDIT
|
149
|
+
date_entry.primary_icon_activatable = true
|
150
|
+
date_entry.signal_connect('icon-press') do |entry, primary, _icon|
|
151
|
+
if primary.nick == 'primary'
|
152
|
+
display_calendar_popup(entry)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# Really hide the time part of the date entry, as the constructor
|
157
|
+
# does not seem to do it...
|
158
|
+
# ##date_entry.children[2..3].each { |x| date_entry.remove(x) }
|
159
|
+
# ##date_entry.spacing = 8
|
160
|
+
entry_label = Gtk::Label.new('')
|
161
|
+
|
162
|
+
add_button = Gtk::Button.new('')
|
163
|
+
add_button.remove(add_button.children.first)
|
164
|
+
add_button << Gtk::Image.new(Gtk::Stock::ADD,
|
165
|
+
Gtk::IconSize::BUTTON)
|
166
|
+
|
167
|
+
add_button.signal_connect('clicked') { insert_new_rule }
|
168
|
+
|
169
|
+
remove_button = Gtk::Button.new('')
|
170
|
+
remove_button.remove(remove_button.children.first)
|
171
|
+
remove_button << Gtk::Image.new(Gtk::Stock::REMOVE,
|
172
|
+
Gtk::IconSize::BUTTON)
|
173
|
+
|
174
|
+
remove_button.signal_connect('clicked') do |_button|
|
175
|
+
idx = @rules_box.children.index(rule_box)
|
176
|
+
raise if idx.nil?
|
177
|
+
@smart_library_rules.delete_at(idx)
|
178
|
+
@rules_box.remove(rule_box)
|
179
|
+
sensitize_remove_rule_buttons
|
180
|
+
update_rules_header_box
|
181
|
+
end
|
182
|
+
|
183
|
+
operands = SmartLibrary::Rule::Operands::LEFT
|
184
|
+
operands.each do |operand|
|
185
|
+
left_operand_combo.append_text(operand.name)
|
186
|
+
end
|
187
|
+
operator_combo.signal_connect('changed') do
|
188
|
+
operand = operands[left_operand_combo.active]
|
189
|
+
operations = SmartLibrary::Rule.operations_for_operand(operand)
|
190
|
+
operation = operations[operator_combo.active]
|
191
|
+
|
192
|
+
value_entry.visible = date_entry.visible =
|
193
|
+
entry_label.visible = false
|
194
|
+
right_operand = operation.last
|
195
|
+
unless right_operand.nil?
|
196
|
+
entry = case right_operand.klass.name
|
197
|
+
when 'Time'
|
198
|
+
date_entry
|
199
|
+
else
|
200
|
+
value_entry
|
201
|
+
end
|
202
|
+
entry.visible = true
|
203
|
+
unless right_operand.name.nil?
|
204
|
+
entry_label.text = right_operand.name
|
205
|
+
entry_label.visible = true
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
idx = @rules_box.children.index(rule_box)
|
210
|
+
new_rule = @smart_library_rules[idx]
|
211
|
+
if new_rule.nil?
|
212
|
+
new_rule = SmartLibrary::Rule.new(operand,
|
213
|
+
operation.first,
|
214
|
+
nil)
|
215
|
+
@smart_library_rules << new_rule
|
216
|
+
end
|
217
|
+
new_rule.operand = operand
|
218
|
+
new_rule.operation = operation.first
|
219
|
+
new_rule.value = nil
|
220
|
+
end
|
221
|
+
left_operand_combo.signal_connect('changed') do
|
222
|
+
operand = operands[left_operand_combo.active]
|
223
|
+
operator_combo.freeze_notify do
|
224
|
+
operator_combo.model.clear
|
225
|
+
operations = SmartLibrary::Rule.operations_for_operand(operand)
|
226
|
+
operations.each do |operation|
|
227
|
+
operator = operation.first
|
228
|
+
iter = operator_combo.model.append
|
229
|
+
iter[0] = operator.name
|
230
|
+
end
|
231
|
+
operator_combo.active = 0
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
rule_box.pack_start(left_operand_combo, false, false, 0)
|
236
|
+
rule_box.pack_start(operator_combo, false, false, 0)
|
237
|
+
rule_box.pack_start(value_entry)
|
238
|
+
rule_box.pack_start(date_entry)
|
239
|
+
rule_box.pack_start(entry_label, false, false, 0)
|
240
|
+
rule_box.pack_end(remove_button, false, false, 0)
|
241
|
+
rule_box.pack_end(add_button, false, false, 0)
|
242
|
+
|
243
|
+
rule_box.show_all
|
244
|
+
value_entry.visible = date_entry.visible = entry_label.visible =
|
245
|
+
false
|
246
|
+
|
247
|
+
@rules_box.pack_start(rule_box, false, true, 0)
|
248
|
+
|
249
|
+
if rule
|
250
|
+
operand_idx = operands.index(rule.operand)
|
251
|
+
operations =
|
252
|
+
SmartLibrary::Rule.operations_for_operand(rule.operand)
|
253
|
+
operation_idx = operations.map(&:first).index(rule.operation)
|
254
|
+
|
255
|
+
if !operand_idx.nil? and !operation_idx.nil?
|
256
|
+
left_operand_combo.active = operand_idx
|
257
|
+
operator_combo.active = operation_idx
|
258
|
+
unless rule.value.nil?
|
259
|
+
case rule.value
|
260
|
+
when String
|
261
|
+
value_entry.text = rule.value
|
262
|
+
when Time
|
263
|
+
date_entry.text = format_date(rule.value)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
else
|
268
|
+
left_operand_combo.active = 0
|
269
|
+
end
|
270
|
+
|
271
|
+
@rules_box.check_resize # force a layout
|
272
|
+
update_rules_header_box
|
273
|
+
sensitize_remove_rule_buttons
|
274
|
+
end
|
275
|
+
|
276
|
+
def sensitize_remove_rule_buttons
|
277
|
+
boxes = @rules_box.children
|
278
|
+
state = boxes.length > 1
|
279
|
+
boxes.each do |box|
|
280
|
+
button = box.children[-1]
|
281
|
+
if button.is_a?(Gtk::Button)
|
282
|
+
button.sensitive = state
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
def fill_smart_library_rules_values
|
288
|
+
@rules_box.children.each_with_index do |box, i|
|
289
|
+
entry, date = box.children[2..3]
|
290
|
+
value = nil
|
291
|
+
if entry.visible?
|
292
|
+
value = entry.text.strip
|
293
|
+
elsif date.visible?
|
294
|
+
begin
|
295
|
+
value = parse_date(date.text)
|
296
|
+
rescue => ex
|
297
|
+
trace = ex.backtrace.join("\n > ")
|
298
|
+
log.warn { "Possibly invalid date entered #{ex.message}" }
|
299
|
+
log.warn { "Date widget returned #{date.text} / #{trace}" }
|
300
|
+
# user entered some non-date...
|
301
|
+
# default to current time, for the moment
|
302
|
+
value = Time.now
|
303
|
+
end
|
304
|
+
end
|
305
|
+
@smart_library_rules[i].value = value
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
# COPIED and PASTED from book_properties_dialog_base
|
310
|
+
|
311
|
+
def setup_calendar_widgets
|
312
|
+
@popup_displayed = false
|
313
|
+
@calendar_popup = Gtk::Window.new # Gtk::Window::POPUP)
|
314
|
+
# @calendar_popup.modal = true
|
315
|
+
@calendar_popup.decorated = false
|
316
|
+
@calendar_popup.skip_taskbar_hint = true
|
317
|
+
@calendar_popup.skip_pager_hint = true
|
318
|
+
@calendar_popup.events = [Gdk::Event::FOCUS_CHANGE_MASK]
|
319
|
+
|
320
|
+
@calendar_popup.set_transient_for(self)
|
321
|
+
@calendar_popup.set_type_hint(Gdk::Window::TYPE_HINT_DIALOG)
|
322
|
+
@calendar_popup.name = 'calendar-popup'
|
323
|
+
@calendar_popup.resizable = false
|
324
|
+
# @calendar_popup.border_width = 4
|
325
|
+
# @calendar_popup.app_paintable = true
|
326
|
+
|
327
|
+
@calendar_popup.signal_connect('focus-out-event') do |_popup, _event|
|
328
|
+
hide_calendar_popup
|
329
|
+
false
|
330
|
+
end
|
331
|
+
|
332
|
+
@calendar = Gtk::Calendar.new
|
333
|
+
@calendar_popup.add(@calendar)
|
334
|
+
|
335
|
+
@calendar.signal_connect('day-selected') do
|
336
|
+
date_arr = @calendar.date
|
337
|
+
year = date_arr[0]
|
338
|
+
month = date_arr[1] # + 1 # gtk : months 0-indexed, Time.gm : 1-index
|
339
|
+
day = date_arr[2]
|
340
|
+
if @calendar_popup_for_entry
|
341
|
+
time = Time.gm(year, month, day)
|
342
|
+
@calendar_popup_for_entry.text = format_date(time)
|
343
|
+
end
|
344
|
+
|
345
|
+
end
|
346
|
+
|
347
|
+
@calendar.signal_connect('day-selected-double-click') do
|
348
|
+
date_arr = @calendar.date
|
349
|
+
year = date_arr[0]
|
350
|
+
month = date_arr[1] # + 1 # gtk : months 0-indexed, Time.gm : 1-index
|
351
|
+
day = date_arr[2]
|
352
|
+
if @calendar_popup_for_entry
|
353
|
+
time = Time.gm(year, month, day)
|
354
|
+
@calendar_popup_for_entry.text = format_date(time)
|
355
|
+
end
|
356
|
+
hide_calendar_popup
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
def hide_calendar_popup
|
361
|
+
@calendar_popup_for_entry = nil
|
362
|
+
|
363
|
+
@calendar_popup.hide_all
|
364
|
+
self.modal = true
|
365
|
+
|
366
|
+
Gtk.timeout_add(150) do
|
367
|
+
|
368
|
+
# If we set @popup_displayed=false immediately, then a click
|
369
|
+
# event on the primary icon of the Entry simultaneous with
|
370
|
+
# the focus-out-event of the Calendar causes the Calendar to
|
371
|
+
# pop up again milliseconds after being closed.
|
372
|
+
#
|
373
|
+
# This is never what the user intends.
|
374
|
+
#
|
375
|
+
# So we add a small delay before the primary icon's event
|
376
|
+
# handler is told to pop up the calendar in response to
|
377
|
+
# clicks.
|
378
|
+
|
379
|
+
@popup_displayed = false
|
380
|
+
false
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
def display_calendar_popup(entry)
|
385
|
+
if @popup_displayed
|
386
|
+
hide_calendar_popup
|
387
|
+
else
|
388
|
+
@calendar_popup_for_entry = entry
|
389
|
+
unless entry.text.strip.empty?
|
390
|
+
time = parse_date(entry.text)
|
391
|
+
unless time.nil?
|
392
|
+
@calendar.year = time.year
|
393
|
+
@calendar.month = time.month - 1
|
394
|
+
@calendar.day = time.day
|
395
|
+
end
|
396
|
+
end
|
397
|
+
self.modal = false
|
398
|
+
@calendar_popup.move(*get_entry_popup_coords(entry))
|
399
|
+
@calendar_popup.show_all
|
400
|
+
@popup_displayed = true
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
def get_entry_popup_coords(entry)
|
405
|
+
gdk_win = entry.parent_window
|
406
|
+
x, y = gdk_win.origin
|
407
|
+
alloc = entry.allocation
|
408
|
+
x += alloc.x
|
409
|
+
y += alloc.y
|
410
|
+
y += alloc.height
|
411
|
+
# x = [0, x].max
|
412
|
+
# y = [0, y].max
|
413
|
+
[x, y]
|
414
|
+
end
|
415
|
+
|
416
|
+
def parse_date(datestring)
|
417
|
+
date_format = '%d/%m/%Y' # or '%m/%d/%Y' for USA and Canada ; or '%Y-%m-%d' for most of Asia
|
418
|
+
## http://en.wikipedia.org/wiki/Calendar_date#Middle_endian_forms.2C_starting_with_the_month
|
419
|
+
begin
|
420
|
+
d = Date.strptime(datestring, date_format)
|
421
|
+
Time.gm(d.year, d.month, d.day)
|
422
|
+
rescue
|
423
|
+
nil
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
def format_date(datetime)
|
428
|
+
datetime.strftime('%d/%m/%Y')
|
429
|
+
end
|
430
|
+
end
|
431
|
+
end
|
432
|
+
end
|