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,53 @@
|
|
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
|
+
require 'gdk_pixbuf2'
|
19
|
+
|
20
|
+
require 'alexandria/ui/gtk_thread_help'
|
21
|
+
require 'alexandria/ui/icons'
|
22
|
+
require 'alexandria/ui/builder_base'
|
23
|
+
require 'alexandria/ui/completion_models'
|
24
|
+
require 'alexandria/ui/libraries_combo'
|
25
|
+
require 'alexandria/ui/multi_drag_treeview'
|
26
|
+
require 'alexandria/ui/main_app'
|
27
|
+
|
28
|
+
module Alexandria
|
29
|
+
module UI
|
30
|
+
include Logging
|
31
|
+
def self.init_icons
|
32
|
+
log.info { 'Initializing Icons...' }
|
33
|
+
Icons.init
|
34
|
+
end
|
35
|
+
def self.start_main_app
|
36
|
+
puts '==========================' if $DEBUG
|
37
|
+
log.info { 'Starting MainApp...' }
|
38
|
+
puts '==========================' if $DEBUG
|
39
|
+
MainApp.instance
|
40
|
+
end
|
41
|
+
def self.start_gtk
|
42
|
+
puts '====================================' if $DEBUG
|
43
|
+
log.info { 'Starting Gtk...' }
|
44
|
+
puts '====================================' if $DEBUG
|
45
|
+
Gtk.main_with_queue
|
46
|
+
end
|
47
|
+
def self.main
|
48
|
+
init_icons
|
49
|
+
start_main_app
|
50
|
+
start_gtk
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Copyright (C) 2011 Cathal Mc Ginley
|
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 BuilderBase
|
21
|
+
def initialize(filename, widget_names)
|
22
|
+
file = File.join(Alexandria::Config::DATA_DIR, 'glade', filename)
|
23
|
+
builder = Gtk::Builder.new
|
24
|
+
builder.add_from_file(file)
|
25
|
+
builder.connect_signals do |handler|
|
26
|
+
begin
|
27
|
+
method(handler)
|
28
|
+
rescue => ex
|
29
|
+
puts "Error: #{ex}" if $DEBUG
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
widget_names.each do |name|
|
34
|
+
begin
|
35
|
+
instance_variable_set("@#{name}".intern, builder[name.to_s])
|
36
|
+
rescue => err
|
37
|
+
puts "Error: #{err}" if $DEBUG
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,389 @@
|
|
1
|
+
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
|
+
# Copyright (C) 2008 Joseph Method
|
3
|
+
# Copyright (C) 2011, 2014 Matijs van Zuijlen
|
4
|
+
#
|
5
|
+
# Alexandria is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU General Public License as
|
7
|
+
# published by the Free Software Foundation; either version 2 of the
|
8
|
+
# License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# Alexandria is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public
|
16
|
+
# License along with Alexandria; see the file COPYING. If not,
|
17
|
+
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
18
|
+
# Fifth Floor, Boston, MA 02110-1301 USA.
|
19
|
+
|
20
|
+
module Alexandria
|
21
|
+
module UI
|
22
|
+
module Callbacks
|
23
|
+
include Logging
|
24
|
+
|
25
|
+
def on_new(_widget, _event)
|
26
|
+
name = Library.generate_new_name(@libraries.all_libraries)
|
27
|
+
library = Library.load(name)
|
28
|
+
@libraries.add_library(library)
|
29
|
+
append_library(library, true)
|
30
|
+
setup_move_actions
|
31
|
+
library.add_observer(self)
|
32
|
+
end
|
33
|
+
|
34
|
+
def on_new_smart(_widget, _event)
|
35
|
+
NewSmartLibraryDialog.new(@main_app) do |smart_library|
|
36
|
+
smart_library.refilter
|
37
|
+
@libraries.add_library(smart_library)
|
38
|
+
append_library(smart_library, true)
|
39
|
+
smart_library.save
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def on_add_book(_widget, _event)
|
44
|
+
log.info { 'on_add_book' }
|
45
|
+
NewBookDialog.new(@main_app, selected_library) do |_books, library, is_new|
|
46
|
+
if is_new
|
47
|
+
append_library(library, true)
|
48
|
+
setup_move_actions
|
49
|
+
elsif selected_library != library
|
50
|
+
select_library(library)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def on_add_book_manual(_widget, _event)
|
56
|
+
library = selected_library
|
57
|
+
NewBookDialogManual.new(@main_app, library) { |_book|
|
58
|
+
refresh_books
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
def on_import(_widget, _event)
|
63
|
+
ImportDialog.new(@main_app) do |library, bad_isbns, failed_isbns|
|
64
|
+
unless bad_isbns.empty?
|
65
|
+
log.debug { 'bad_isbn' }
|
66
|
+
message = _('The following lines are not valid ISBNs and were not imported:')
|
67
|
+
bad_isbn_warn = BadIsbnsDialog.new(@main_app, message, bad_isbns)
|
68
|
+
bad_isbn_warn.signal_connect('response') { bad_isbn_warn.destroy }
|
69
|
+
end
|
70
|
+
unless failed_isbns.nil? || failed_isbns.empty?
|
71
|
+
log.debug { "failed lookup of #{failed_isbns.size} ISBNs" }
|
72
|
+
message = _('Books could not be found for the following ISBNs:')
|
73
|
+
failed_lookup = BadIsbnsDialog.new(@main_app, message, failed_isbns)
|
74
|
+
failed_lookup.signal_connect('response') { failed_lookup.destroy }
|
75
|
+
end
|
76
|
+
@libraries.add_library(library)
|
77
|
+
append_library(library, true)
|
78
|
+
setup_move_actions
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def on_window_state_event(_window, event)
|
83
|
+
log.debug { 'window-state-event' }
|
84
|
+
if event.is_a?(Gdk::EventWindowState)
|
85
|
+
@maximized = event.new_window_state == Gdk::EventWindowState::MAXIMIZED
|
86
|
+
end
|
87
|
+
log.debug { 'end window-state-event' }
|
88
|
+
end
|
89
|
+
|
90
|
+
def on_toolbar_view_as_changed(cb)
|
91
|
+
log.debug { 'changed' }
|
92
|
+
action = case cb.active
|
93
|
+
when 0
|
94
|
+
@actiongroup['AsIcons']
|
95
|
+
when 1
|
96
|
+
@actiongroup['AsList']
|
97
|
+
end
|
98
|
+
action.active = true
|
99
|
+
end
|
100
|
+
|
101
|
+
def on_window_destroy(_window)
|
102
|
+
log.debug { 'destroy' }
|
103
|
+
@actiongroup['Quit'].activate
|
104
|
+
end
|
105
|
+
|
106
|
+
def on_toolbar_filter_entry_changed(_entry)
|
107
|
+
log.debug { 'changed' }
|
108
|
+
@filter_entry.text.strip!
|
109
|
+
@iconview.freeze
|
110
|
+
@filtered_model.refilter
|
111
|
+
@iconview.unfreeze
|
112
|
+
end
|
113
|
+
|
114
|
+
def on_criterion_combobox_changed(cb)
|
115
|
+
log.debug { 'changed' }
|
116
|
+
@filter_books_mode = cb.active
|
117
|
+
@filter_entry.text.strip!
|
118
|
+
@iconview.freeze
|
119
|
+
@filtered_model.refilter
|
120
|
+
@iconview.unfreeze
|
121
|
+
end
|
122
|
+
|
123
|
+
def on_export(_widget, _event)
|
124
|
+
ExportDialog.new(@main_app, selected_library, library_sort_order)
|
125
|
+
rescue => ex
|
126
|
+
log.error { "problem with immediate export #{ex} try again" }
|
127
|
+
ErrorDialog.new(@main_app, _('Export failed'),
|
128
|
+
_('Try letting this library load ' \
|
129
|
+
'completely before exporting.'))
|
130
|
+
end
|
131
|
+
|
132
|
+
def on_acquire(_widget, _event)
|
133
|
+
AcquireDialog.new(@main_app,
|
134
|
+
selected_library) do |_books, library, is_new|
|
135
|
+
if is_new
|
136
|
+
append_library(library, true)
|
137
|
+
setup_move_actions
|
138
|
+
elsif selected_library != library
|
139
|
+
select_library(library)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def on_properties(_widget, _event)
|
145
|
+
if @library_listview.focus? or selected_books.empty?
|
146
|
+
library = selected_library
|
147
|
+
if library.is_a?(SmartLibrary)
|
148
|
+
SmartLibraryPropertiesDialog.new(@main_app, library) do
|
149
|
+
library.refilter
|
150
|
+
refresh_books
|
151
|
+
end
|
152
|
+
end
|
153
|
+
else
|
154
|
+
books = selected_books
|
155
|
+
if books.length == 1
|
156
|
+
book = books.first
|
157
|
+
BookPropertiesDialog.new(@main_app,
|
158
|
+
selected_library,
|
159
|
+
book) # { |modified_book| }
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def on_quit(_widget, _event)
|
165
|
+
save_preferences
|
166
|
+
Gtk.main_quit
|
167
|
+
# @libraries.really_save_all_books
|
168
|
+
@libraries.really_delete_deleted_libraries
|
169
|
+
@libraries.all_regular_libraries.each(&:really_delete_deleted_books)
|
170
|
+
end
|
171
|
+
|
172
|
+
def on_undo(_widget, _event)
|
173
|
+
UndoManager.instance.undo!
|
174
|
+
end
|
175
|
+
|
176
|
+
def on_redo(_widget, _event)
|
177
|
+
UndoManager.instance.redo!
|
178
|
+
end
|
179
|
+
|
180
|
+
def on_select_all(_widget, _event)
|
181
|
+
log.debug { 'on_select_all' }
|
182
|
+
case @notebook.page
|
183
|
+
when 0
|
184
|
+
@iconview.select_all
|
185
|
+
when 1
|
186
|
+
@listview.selection.select_all
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def on_deselect_all(_widget, _event)
|
191
|
+
log.debug { 'on_deselect_all' }
|
192
|
+
case @notebook.page
|
193
|
+
when 0
|
194
|
+
@iconview.unselect_all
|
195
|
+
when 1
|
196
|
+
@listview.selection.unselect_all
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def on_set_rating
|
201
|
+
(0..MAX_RATING_STARS).map do |rating|
|
202
|
+
proc do
|
203
|
+
books = selected_books
|
204
|
+
library = selected_library
|
205
|
+
books.each do |book|
|
206
|
+
log.debug { "set #{book.title} rating to #{rating}" }
|
207
|
+
book.rating = rating
|
208
|
+
library.save(book)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def on_rename(_widget, _event)
|
215
|
+
iter = @library_listview.selection.selected
|
216
|
+
@library_listview.set_cursor(iter.path,
|
217
|
+
@library_listview.get_column(0),
|
218
|
+
true)
|
219
|
+
end
|
220
|
+
|
221
|
+
def on_delete(_widget, _event)
|
222
|
+
library = selected_library
|
223
|
+
|
224
|
+
if selected_books.empty?
|
225
|
+
books = nil
|
226
|
+
else
|
227
|
+
books = selected_books
|
228
|
+
end
|
229
|
+
# books = @library_listview.focus? ? nil : selected_books
|
230
|
+
is_smart = library.is_a?(SmartLibrary)
|
231
|
+
last_library = (@libraries.all_regular_libraries.length == 1)
|
232
|
+
if books.nil? && !is_smart && last_library
|
233
|
+
log.warn { 'Attempted to delete last library, fix GUI' }
|
234
|
+
return
|
235
|
+
end
|
236
|
+
if library.empty? or ReallyDeleteDialog.new(@main_app,
|
237
|
+
library,
|
238
|
+
books).ok?
|
239
|
+
undoable_delete(library, books)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def on_clear_search_results(_widget, _event)
|
244
|
+
@filter_entry.text = ''
|
245
|
+
@iconview.freeze
|
246
|
+
@filtered_model.refilter
|
247
|
+
@iconview.unfreeze
|
248
|
+
end
|
249
|
+
|
250
|
+
def on_search(_widget, _event)
|
251
|
+
@filter_entry.grab_focus
|
252
|
+
end
|
253
|
+
|
254
|
+
def on_preferences(_widget, _event)
|
255
|
+
PreferencesDialog.new(@main_app) do
|
256
|
+
@listview_manager.setup_listview_columns_visibility
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def on_submit_bug_report(_widget, _event)
|
261
|
+
open_web_browser(BUGREPORT_URL)
|
262
|
+
end
|
263
|
+
|
264
|
+
def on_help(_widget, _event)
|
265
|
+
Alexandria::UI.display_help(@main_app)
|
266
|
+
end
|
267
|
+
|
268
|
+
def on_about(_widget, _event)
|
269
|
+
ad = AboutDialog.new(@main_app)
|
270
|
+
ad.signal_connect('response') do
|
271
|
+
log.debug { 'destroy about' }
|
272
|
+
ad.destroy
|
273
|
+
end
|
274
|
+
ad.show
|
275
|
+
end
|
276
|
+
|
277
|
+
def connect_signals
|
278
|
+
standard_actions = [
|
279
|
+
['LibraryMenu', nil, _('_Library')],
|
280
|
+
['New', Gtk::Stock::NEW, _('_New Library'), '<control>L', _('Create a new library'), method(:on_new)],
|
281
|
+
['NewSmart', nil, _('New _Smart Library...'), '<control><shift>L', _('Create a new smart library'), method(:on_new_smart)],
|
282
|
+
['AddBook', Gtk::Stock::ADD, _('_Add Book...'), '<control>N', _('Add a new book from the Internet'), method(:on_add_book)],
|
283
|
+
['AddBookManual', nil, _('Add Book _Manually...'), '<control><shift>N', _('Add a new book manually'), method(:on_add_book_manual)],
|
284
|
+
['Import', nil, _('_Import...'), '<control>I', _('Import a library'), method(:on_import)],
|
285
|
+
['Export', nil, _('_Export...'), '<control><shift>E', _('Export the selected library'), method(:on_export)],
|
286
|
+
['Acquire', nil, _('A_cquire from Scanner...'), '<control><shift>S', _('Acquire books from a scanner'), method(:on_acquire)],
|
287
|
+
['Properties', Gtk::Stock::PROPERTIES, _('_Properties'), nil, _('Edit the properties of the selected book'), method(:on_properties)],
|
288
|
+
['Quit', Gtk::Stock::QUIT, _('_Quit'), '<control>Q', _('Quit the program'), method(:on_quit)],
|
289
|
+
['EditMenu', nil, _('_Edit')],
|
290
|
+
['Undo', Gtk::Stock::UNDO, _('_Undo'), '<control>Z', _('Undo the last action'), method(:on_undo)],
|
291
|
+
['Redo', Gtk::Stock::REDO, _('_Redo'), '<control><shift>Z', _('Redo the undone action'), method(:on_redo)],
|
292
|
+
['SelectAll', nil, _('_Select All'), '<control>A', _('Select all visible books'), method(:on_select_all)],
|
293
|
+
['DeselectAll', nil, _('Dese_lect All'), '<control><shift>A', _('Deselect everything'), method(:on_deselect_all)],
|
294
|
+
['SetRating', nil, _('My _Rating')],
|
295
|
+
['SetRating0', nil, _('None'), nil, nil, proc { on_set_rating[0].call }],
|
296
|
+
['SetRating1', nil, _('One Star'), nil, nil, proc { on_set_rating[1].call }],
|
297
|
+
['SetRating2', nil, _('Two Stars'), nil, nil, proc { on_set_rating[2].call }],
|
298
|
+
['SetRating3', nil, _('Three Stars'), nil, nil, proc { on_set_rating[3].call }],
|
299
|
+
['SetRating4', nil, _('Four Stars'), nil, nil, proc { on_set_rating[4].call }],
|
300
|
+
['SetRating5', nil, _('Five Stars'), nil, nil, proc { on_set_rating[5].call }],
|
301
|
+
['Move', nil, _('_Move')],
|
302
|
+
['Rename', nil, _('_Rename'), nil, nil, method(:on_rename)],
|
303
|
+
['Delete', Gtk::Stock::DELETE, _('_Delete'), 'Delete', _('Delete the selected books or library'), method(:on_delete)],
|
304
|
+
['Search', Gtk::Stock::FIND, _('_Search'), '<control>F', _('Filter books'), method(:on_search)],
|
305
|
+
['ClearSearchResult', Gtk::Stock::CLEAR, _('_Clear Results'), '<control><alt>B', _('Clear the search results'), method(:on_clear_search_results)],
|
306
|
+
['Preferences', Gtk::Stock::PREFERENCES, _('_Preferences'), '<control>O', _("Change Alexandria's settings"), method(:on_preferences)],
|
307
|
+
['ViewMenu', nil, _('_View')],
|
308
|
+
['ArrangeIcons', nil, _('Arran_ge Icons')],
|
309
|
+
['OnlineInformation', nil, _('Display Online _Information')],
|
310
|
+
|
311
|
+
['HelpMenu', nil, _('_Help')],
|
312
|
+
['SubmitBugReport', Gtk::Stock::EDIT, _('Submit _Bug Report'), nil, _('Submit a bug report to the developers'), method(:on_submit_bug_report)],
|
313
|
+
['Help', Gtk::Stock::HELP, _('Contents'), 'F1', _("View Alexandria's manual"), method(:on_help)],
|
314
|
+
['About', Gtk::Stock::ABOUT, _('_About'), nil, _('Show information about Alexandria'), method(:on_about)],
|
315
|
+
]
|
316
|
+
|
317
|
+
on_view_sidepane = proc do |_actiongroup, action|
|
318
|
+
log.debug { 'on_view_sidepane' }
|
319
|
+
@paned.child1.visible = action.active?
|
320
|
+
end
|
321
|
+
|
322
|
+
on_view_toolbar = proc do |_actiongroup, action|
|
323
|
+
log.debug { 'on_view_toolbar' }
|
324
|
+
@toolbar.parent.visible = action.active?
|
325
|
+
end
|
326
|
+
|
327
|
+
on_view_statusbar = proc do |_actiongroup, action|
|
328
|
+
log.debug { 'on_view_statusbar' }
|
329
|
+
@appbar.visible = action.active?
|
330
|
+
end
|
331
|
+
|
332
|
+
on_reverse_order = proc do |_actiongroup, action|
|
333
|
+
log.debug { 'on_reverse_order' }
|
334
|
+
Preferences.instance.reverse_icons = action.active?
|
335
|
+
Preferences.instance.save!
|
336
|
+
setup_books_iconview_sorting
|
337
|
+
end
|
338
|
+
|
339
|
+
toggle_actions = [
|
340
|
+
['Sidepane', nil, _('Side _Pane'), 'F9', nil,
|
341
|
+
on_view_sidepane, true],
|
342
|
+
['Toolbar', nil, _('_Toolbar'), nil, nil,
|
343
|
+
on_view_toolbar, true],
|
344
|
+
['Statusbar', nil, _('_Statusbar'), nil, nil,
|
345
|
+
on_view_statusbar, true],
|
346
|
+
['ReversedOrder', nil, _('Re_versed Order'), nil, nil,
|
347
|
+
on_reverse_order],
|
348
|
+
]
|
349
|
+
|
350
|
+
view_as_actions = [
|
351
|
+
['AsIcons', nil, _('View as _Icons'), nil, nil, 0],
|
352
|
+
['AsList', nil, _('View as _List'), nil, nil, 1]
|
353
|
+
]
|
354
|
+
|
355
|
+
arrange_icons_actions = [
|
356
|
+
['ByTitle', nil, _('By _Title'), nil, nil, 0],
|
357
|
+
['ByAuthors', nil, _('By _Authors'), nil, nil, 1],
|
358
|
+
['ByISBN', nil, _('By _ISBN'), nil, nil, 2],
|
359
|
+
['ByPublisher', nil, _('By _Publisher'), nil, nil, 3],
|
360
|
+
['ByEdition', nil, _('By _Binding'), nil, nil, 4],
|
361
|
+
['ByRating', nil, _('By _Rating'), nil, nil, 5]
|
362
|
+
]
|
363
|
+
providers_actions = BookProviders.map do |provider|
|
364
|
+
[provider.action_name, Gtk::Stock::JUMP_TO,
|
365
|
+
_('At _%s') % provider.fullname, nil, nil,
|
366
|
+
proc { open_web_browser(provider.url(selected_books.first)) }]
|
367
|
+
end
|
368
|
+
|
369
|
+
log.debug { 'Adding actions to @actiongroup' }
|
370
|
+
|
371
|
+
@actiongroup = Gtk::ActionGroup.new('actions')
|
372
|
+
@actiongroup.add_actions(standard_actions)
|
373
|
+
@actiongroup.add_actions(providers_actions)
|
374
|
+
@actiongroup.add_toggle_actions(toggle_actions)
|
375
|
+
@actiongroup.add_radio_actions(view_as_actions) do |_action, current|
|
376
|
+
@notebook.page = current.current_value
|
377
|
+
hid = @toolbar_view_as_signal_hid
|
378
|
+
@toolbar_view_as.signal_handler_block(hid) do
|
379
|
+
@toolbar_view_as.active = current.current_value
|
380
|
+
end
|
381
|
+
end
|
382
|
+
@actiongroup.add_radio_actions(arrange_icons_actions) do |_action, current|
|
383
|
+
@prefs.arrange_icons_mode = current.current_value
|
384
|
+
setup_books_iconview_sorting
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|