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.
Files changed (293) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rubocop.yml +68 -0
  4. data/.rubocop_todo.yml +200 -0
  5. data/CHANGELOG.md +23 -0
  6. data/COPYING +339 -0
  7. data/ChangeLog.0 +3598 -0
  8. data/Gemfile +9 -0
  9. data/INSTALL.rdoc +156 -0
  10. data/PACKAGING +36 -0
  11. data/README.md +88 -0
  12. data/RELEASE_CHECKLIST +18 -0
  13. data/Rakefile +264 -0
  14. data/TODO +24 -0
  15. data/alexandria-book-collection-manager.gemspec +35 -0
  16. data/alexandria.desktop.in +10 -0
  17. data/bin/alexandria +82 -0
  18. data/doc/AUTHORS +60 -0
  19. data/doc/BUGS +31 -0
  20. data/doc/FAQ +369 -0
  21. data/doc/HACKING +19 -0
  22. data/doc/NEWS +341 -0
  23. data/doc/alexandria.1 +120 -0
  24. data/doc/cuecat_support.rdoc +67 -0
  25. data/lib/alexandria.rb +85 -0
  26. data/lib/alexandria/about.rb +82 -0
  27. data/lib/alexandria/book_providers.rb +411 -0
  28. data/lib/alexandria/book_providers/adlibris.rb +235 -0
  29. data/lib/alexandria/book_providers/amazon_aws.rb +261 -0
  30. data/lib/alexandria/book_providers/amazon_ecs_util.rb +405 -0
  31. data/lib/alexandria/book_providers/barnes_and_noble.rb +229 -0
  32. data/lib/alexandria/book_providers/bol_it.rb +162 -0
  33. data/lib/alexandria/book_providers/deastore.rb +277 -0
  34. data/lib/alexandria/book_providers/douban.rb +135 -0
  35. data/lib/alexandria/book_providers/ibs_it.rb +149 -0
  36. data/lib/alexandria/book_providers/mcu.rb +177 -0
  37. data/lib/alexandria/book_providers/proxis.rb +205 -0
  38. data/lib/alexandria/book_providers/pseudomarc.rb +185 -0
  39. data/lib/alexandria/book_providers/renaud.rb +142 -0
  40. data/lib/alexandria/book_providers/siciliano.rb +271 -0
  41. data/lib/alexandria/book_providers/thalia.rb +197 -0
  42. data/lib/alexandria/book_providers/web.rb +59 -0
  43. data/lib/alexandria/book_providers/webster_it.rb +173 -0
  44. data/lib/alexandria/book_providers/worldcat.rb +251 -0
  45. data/lib/alexandria/book_providers/z3950.rb +422 -0
  46. data/lib/alexandria/config.rb +8 -0
  47. data/lib/alexandria/console.rb +31 -0
  48. data/lib/alexandria/execution_queue.rb +96 -0
  49. data/lib/alexandria/export_library.rb +536 -0
  50. data/lib/alexandria/import_library.rb +316 -0
  51. data/lib/alexandria/import_library_csv.rb +270 -0
  52. data/lib/alexandria/logging.rb +159 -0
  53. data/lib/alexandria/models/book.rb +72 -0
  54. data/lib/alexandria/models/library.rb +714 -0
  55. data/lib/alexandria/net.rb +53 -0
  56. data/lib/alexandria/preferences.rb +324 -0
  57. data/lib/alexandria/scanners.rb +42 -0
  58. data/lib/alexandria/scanners/cuecat.rb +118 -0
  59. data/lib/alexandria/scanners/keyboard.rb +57 -0
  60. data/lib/alexandria/smart_library.rb +525 -0
  61. data/lib/alexandria/ui.rb +53 -0
  62. data/lib/alexandria/ui/builder_base.rb +43 -0
  63. data/lib/alexandria/ui/callbacks.rb +389 -0
  64. data/lib/alexandria/ui/completion_models.rb +228 -0
  65. data/lib/alexandria/ui/dialogs/about_dialog.rb +59 -0
  66. data/lib/alexandria/ui/dialogs/acquire_dialog.rb +640 -0
  67. data/lib/alexandria/ui/dialogs/alert_dialog.rb +68 -0
  68. data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +43 -0
  69. data/lib/alexandria/ui/dialogs/barcode_animation.rb +159 -0
  70. data/lib/alexandria/ui/dialogs/book_properties_dialog.rb +210 -0
  71. data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +432 -0
  72. data/lib/alexandria/ui/dialogs/export_dialog.rb +172 -0
  73. data/lib/alexandria/ui/dialogs/import_dialog.rb +205 -0
  74. data/lib/alexandria/ui/dialogs/misc_dialogs.rb +85 -0
  75. data/lib/alexandria/ui/dialogs/new_book_dialog.rb +639 -0
  76. data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +153 -0
  77. data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +67 -0
  78. data/lib/alexandria/ui/dialogs/preferences_dialog.rb +587 -0
  79. data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +56 -0
  80. data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +432 -0
  81. data/lib/alexandria/ui/dndable.rb +81 -0
  82. data/lib/alexandria/ui/gtk_thread_help.rb +88 -0
  83. data/lib/alexandria/ui/icons.rb +100 -0
  84. data/lib/alexandria/ui/iconview.rb +91 -0
  85. data/lib/alexandria/ui/iconview_tooltips.rb +162 -0
  86. data/lib/alexandria/ui/init.rb +93 -0
  87. data/lib/alexandria/ui/libraries_combo.rb +75 -0
  88. data/lib/alexandria/ui/listview.rb +310 -0
  89. data/lib/alexandria/ui/main_app.rb +67 -0
  90. data/lib/alexandria/ui/multi_drag_treeview.rb +150 -0
  91. data/lib/alexandria/ui/sidepane.rb +194 -0
  92. data/lib/alexandria/ui/sound.rb +107 -0
  93. data/lib/alexandria/ui/ui_manager.rb +1308 -0
  94. data/lib/alexandria/undo_manager.rb +78 -0
  95. data/lib/alexandria/utils.rb +30 -0
  96. data/lib/alexandria/version.rb +24 -0
  97. data/lib/alexandria/web_themes.rb +75 -0
  98. data/misc/sounds/README +15 -0
  99. data/misc/sounds/bad_scan.csd +62 -0
  100. data/misc/sounds/good_scan.csd +61 -0
  101. data/misc/sounds/scanning.csd +46 -0
  102. data/po/ChangeLog +488 -0
  103. data/po/Makefile +44 -0
  104. data/po/README +29 -0
  105. data/po/commit-po +72 -0
  106. data/po/cs.po +1437 -0
  107. data/po/cy.po +1521 -0
  108. data/po/de.po +1400 -0
  109. data/po/el.po +1379 -0
  110. data/po/es.po +1376 -0
  111. data/po/fr.po +1420 -0
  112. data/po/ga.po +1359 -0
  113. data/po/gl.po +1397 -0
  114. data/po/it.po +1406 -0
  115. data/po/ja.po +1355 -0
  116. data/po/mk.po +1373 -0
  117. data/po/nb.po +1386 -0
  118. data/po/nl.po +1405 -0
  119. data/po/pl.po +1373 -0
  120. data/po/pt.po +1398 -0
  121. data/po/pt_BR.po +1409 -0
  122. data/po/ru.po +1372 -0
  123. data/po/sk.po +1380 -0
  124. data/po/sv.po +1402 -0
  125. data/po/uk.po +1423 -0
  126. data/po/zh_TW.po +1394 -0
  127. data/schemas/alexandria.schemas +300 -0
  128. data/share/alexandria/glade/acquire_dialog__builder.glade +201 -0
  129. data/share/alexandria/glade/book_properties_dialog__builder.glade +910 -0
  130. data/share/alexandria/glade/main_app__builder.glade +229 -0
  131. data/share/alexandria/glade/new_book_dialog__builder.glade +379 -0
  132. data/share/alexandria/glade/preferences_dialog__builder.glade +733 -0
  133. data/share/alexandria/icons/alexandria.png +0 -0
  134. data/share/alexandria/icons/alexandria_small.png +0 -0
  135. data/share/alexandria/icons/book.png +0 -0
  136. data/share/alexandria/icons/book_icon.png +0 -0
  137. data/share/alexandria/icons/book_small.png +0 -0
  138. data/share/alexandria/icons/cuecat.png +0 -0
  139. data/share/alexandria/icons/cuecat_inactive.png +0 -0
  140. data/share/alexandria/icons/favorite_tag.png +0 -0
  141. data/share/alexandria/icons/less.png +0 -0
  142. data/share/alexandria/icons/library.png +0 -0
  143. data/share/alexandria/icons/library_small.png +0 -0
  144. data/share/alexandria/icons/lookup.png +0 -0
  145. data/share/alexandria/icons/more.png +0 -0
  146. data/share/alexandria/icons/no_cover.png +0 -0
  147. data/share/alexandria/icons/smart_library.png +0 -0
  148. data/share/alexandria/icons/smart_library_small.png +0 -0
  149. data/share/alexandria/icons/star_set.png +0 -0
  150. data/share/alexandria/icons/star_unset.png +0 -0
  151. data/share/alexandria/icons/view_as_icons.png +0 -0
  152. data/share/alexandria/icons/view_as_list.png +0 -0
  153. data/share/alexandria/ui/menus.xml +91 -0
  154. data/share/alexandria/ui/popups.xml +91 -0
  155. data/share/alexandria/web-themes/clean/clean.css +85 -0
  156. data/share/alexandria/web-themes/clean/preview.jpg +0 -0
  157. data/share/alexandria/web-themes/list/list.css +105 -0
  158. data/share/alexandria/web-themes/list/preview.jpg +0 -0
  159. data/share/app-icon/16x16/alexandria.png +0 -0
  160. data/share/app-icon/16x16/alexandria.svg +263 -0
  161. data/share/app-icon/22x22/alexandria.png +0 -0
  162. data/share/app-icon/22x22/alexandria.svg +465 -0
  163. data/share/app-icon/24x24/alexandria.png +0 -0
  164. data/share/app-icon/32x32/alexandria.png +0 -0
  165. data/share/app-icon/32x32/alexandria.svg +813 -0
  166. data/share/app-icon/32x32/alexandria.xpm +241 -0
  167. data/share/app-icon/48x48/alexandria.png +0 -0
  168. data/share/app-icon/scalable/alexandria.svg +700 -0
  169. data/share/gnome/help/alexandria/C/about.xml +44 -0
  170. data/share/gnome/help/alexandria/C/adding-books.xml +339 -0
  171. data/share/gnome/help/alexandria/C/alexandria.xml +185 -0
  172. data/share/gnome/help/alexandria/C/bugs.xml +18 -0
  173. data/share/gnome/help/alexandria/C/editing-book-properties.xml +124 -0
  174. data/share/gnome/help/alexandria/C/exporting.xml +81 -0
  175. data/share/gnome/help/alexandria/C/figures/adding_books_acquire_from_scanner_process.png +0 -0
  176. data/share/gnome/help/alexandria/C/figures/adding_books_add_by_isbn.png +0 -0
  177. data/share/gnome/help/alexandria/C/figures/adding_books_isbn_import.png +0 -0
  178. data/share/gnome/help/alexandria/C/figures/adding_books_manual_details.png +0 -0
  179. data/share/gnome/help/alexandria/C/figures/adding_books_rename_library_after_import.png +0 -0
  180. data/share/gnome/help/alexandria/C/figures/adding_books_search_results.png +0 -0
  181. data/share/gnome/help/alexandria/C/figures/editing_book_properties_info.png +0 -0
  182. data/share/gnome/help/alexandria/C/figures/editing_book_properties_loaning.png +0 -0
  183. data/share/gnome/help/alexandria/C/figures/exporting_information_html.png +0 -0
  184. data/share/gnome/help/alexandria/C/figures/getting_started_first_launched.png +0 -0
  185. data/share/gnome/help/alexandria/C/figures/searching_filtering_views_list_view.png +0 -0
  186. data/share/gnome/help/alexandria/C/figures/searching_filtering_views_list_view_search.png +0 -0
  187. data/share/gnome/help/alexandria/C/figures/settings_providers_new_z3950.png +0 -0
  188. data/share/gnome/help/alexandria/C/figures/smart_libraries_new_smart_library.png +0 -0
  189. data/share/gnome/help/alexandria/C/figures/working_with_libraries_library_pane.png +0 -0
  190. data/share/gnome/help/alexandria/C/getting-started.xml +154 -0
  191. data/share/gnome/help/alexandria/C/gnu-fdl-1.2.xml +543 -0
  192. data/share/gnome/help/alexandria/C/introduction.xml +142 -0
  193. data/share/gnome/help/alexandria/C/searching.xml +90 -0
  194. data/share/gnome/help/alexandria/C/settings.xml +140 -0
  195. data/share/gnome/help/alexandria/C/smart-libraries.xml +160 -0
  196. data/share/gnome/help/alexandria/C/working-with-libraries.xml +76 -0
  197. data/share/gnome/help/alexandria/ChangeLog +99 -0
  198. data/share/gnome/help/alexandria/fr/alexandria.xml +2292 -0
  199. data/share/gnome/help/alexandria/fr/figures/alexandria_add_button.png +0 -0
  200. data/share/gnome/help/alexandria/fr/figures/alexandria_add_by_isbn_1.png +0 -0
  201. data/share/gnome/help/alexandria/fr/figures/alexandria_add_by_search_1.png +0 -0
  202. data/share/gnome/help/alexandria/fr/figures/alexandria_add_manually.png +0 -0
  203. data/share/gnome/help/alexandria/fr/figures/alexandria_add_z3950.png +0 -0
  204. data/share/gnome/help/alexandria/fr/figures/alexandria_close_button.png +0 -0
  205. data/share/gnome/help/alexandria/fr/figures/alexandria_edit_info.png +0 -0
  206. data/share/gnome/help/alexandria/fr/figures/alexandria_export_web_page.png +0 -0
  207. data/share/gnome/help/alexandria/fr/figures/alexandria_importing.png +0 -0
  208. data/share/gnome/help/alexandria/fr/figures/alexandria_library_pane.png +0 -0
  209. data/share/gnome/help/alexandria/fr/figures/alexandria_list_view.png +0 -0
  210. data/share/gnome/help/alexandria/fr/figures/alexandria_list_view_search.png +0 -0
  211. data/share/gnome/help/alexandria/fr/figures/alexandria_loaning.png +0 -0
  212. data/share/gnome/help/alexandria/fr/figures/alexandria_main_window.png +0 -0
  213. data/share/gnome/help/alexandria/fr/figures/alexandria_remove_button.png +0 -0
  214. data/share/gnome/help/alexandria/ja/about.xml +33 -0
  215. data/share/gnome/help/alexandria/ja/adding-books.xml +314 -0
  216. data/share/gnome/help/alexandria/ja/alexandria.xml +172 -0
  217. data/share/gnome/help/alexandria/ja/bugs.xml +11 -0
  218. data/share/gnome/help/alexandria/ja/editing-book-properties.xml +100 -0
  219. data/share/gnome/help/alexandria/ja/exporting.xml +98 -0
  220. data/share/gnome/help/alexandria/ja/figures/adding_books_acquire_from_scanner_process.png +0 -0
  221. data/share/gnome/help/alexandria/ja/figures/adding_books_add_by_isbn.png +0 -0
  222. data/share/gnome/help/alexandria/ja/figures/adding_books_isbn_import.png +0 -0
  223. data/share/gnome/help/alexandria/ja/figures/adding_books_manual_details.png +0 -0
  224. data/share/gnome/help/alexandria/ja/figures/adding_books_rename_library_after_import.png +0 -0
  225. data/share/gnome/help/alexandria/ja/figures/adding_books_search_results.png +0 -0
  226. data/share/gnome/help/alexandria/ja/figures/editing_book_properties_info.png +0 -0
  227. data/share/gnome/help/alexandria/ja/figures/editing_book_properties_loaning.png +0 -0
  228. data/share/gnome/help/alexandria/ja/figures/exporting_information_html.png +0 -0
  229. data/share/gnome/help/alexandria/ja/figures/getting_started_first_launched.png +0 -0
  230. data/share/gnome/help/alexandria/ja/figures/searching_filtering_views_list_view.png +0 -0
  231. data/share/gnome/help/alexandria/ja/figures/searching_filtering_views_list_view_search.png +0 -0
  232. data/share/gnome/help/alexandria/ja/figures/settings_providers_new_z3950.png +0 -0
  233. data/share/gnome/help/alexandria/ja/figures/smart_libraries_new_smart_library.png +0 -0
  234. data/share/gnome/help/alexandria/ja/figures/working_with_libraries_library_pane.png +0 -0
  235. data/share/gnome/help/alexandria/ja/getting-started.xml +144 -0
  236. data/share/gnome/help/alexandria/ja/gnu-fdl-1.2.xml +541 -0
  237. data/share/gnome/help/alexandria/ja/introduction.xml +134 -0
  238. data/share/gnome/help/alexandria/ja/searching.xml +104 -0
  239. data/share/gnome/help/alexandria/ja/settings.xml +129 -0
  240. data/share/gnome/help/alexandria/ja/smart-libraries.xml +140 -0
  241. data/share/gnome/help/alexandria/ja/working-with-libraries.xml +88 -0
  242. data/share/menu/alexandria +7 -0
  243. data/share/omf/alexandria/alexandria-C.omf.in +27 -0
  244. data/share/omf/alexandria/alexandria-fr.omf.in +30 -0
  245. data/share/sounds/alexandria/bad_scan.ogg +0 -0
  246. data/share/sounds/alexandria/bad_scan.wav +0 -0
  247. data/share/sounds/alexandria/good_scan.ogg +0 -0
  248. data/share/sounds/alexandria/good_scan.wav +0 -0
  249. data/share/sounds/alexandria/scanning.ogg +0 -0
  250. data/share/sounds/alexandria/scanning.wav +0 -0
  251. data/spec/alexandria/library_spec.rb +205 -0
  252. data/spec/alexandria/preferences_spec.rb +22 -0
  253. data/spec/alexandria/scanners/cuecat_spec.rb +68 -0
  254. data/spec/alexandria/smart_library_spec.rb +22 -0
  255. data/spec/alexandria/ui/dialogs_spec.rb +90 -0
  256. data/spec/alexandria/ui/iconview_spec.rb +27 -0
  257. data/spec/alexandria/ui/listview_spec.rb +28 -0
  258. data/spec/alexandria/ui/main_app_spec.rb +48 -0
  259. data/spec/alexandria/ui/sidepane_spec.rb +27 -0
  260. data/spec/alexandria/ui/ui_manager_spec.rb +26 -0
  261. data/spec/alexandria/ui/ui_utilities_spec.rb +60 -0
  262. data/spec/alexandria/utilities_spec.rb +50 -0
  263. data/spec/data/libraries/0.6.1-noisbn/My Library/0201398257.yaml +10 -0
  264. data/spec/data/libraries/0.6.1-noisbn/My Library/1565920007.yaml +10 -0
  265. data/spec/data/libraries/0.6.1/My Library/0192812173.yaml +9 -0
  266. data/spec/data/libraries/0.6.1/My Library/0201398257.cover +0 -0
  267. data/spec/data/libraries/0.6.1/My Library/0201398257.yaml +10 -0
  268. data/spec/data/libraries/0.6.1/My Library/1565920007.yaml +10 -0
  269. data/spec/data/libraries/0.6.2/My Library/9780140266146.cover +0 -0
  270. data/spec/data/libraries/0.6.2/My Library/9780140266146.yaml +16 -0
  271. data/spec/data/libraries/0.6.2/My Library/9780140278781.cover +0 -0
  272. data/spec/data/libraries/0.6.2/My Library/9780140278781.yaml +21 -0
  273. data/spec/data/libraries/0.6.2/My Library/9780571147168.cover +0 -0
  274. data/spec/data/libraries/0.6.2/My Library/9780571147168.yaml +20 -0
  275. data/spec/data/libraries/0.6.2/My Library/9780575079038.cover +0 -0
  276. data/spec/data/libraries/0.6.2/My Library/9780575079038.yaml +20 -0
  277. data/spec/data/libraries/0.6.2/My Library/9780755322800.cover +0 -0
  278. data/spec/data/libraries/0.6.2/My Library/9780755322800.yaml +20 -0
  279. data/spec/spec_helper.rb +46 -0
  280. data/tasks/rdoc.rake +6 -0
  281. data/tasks/setup.rb +30 -0
  282. data/tasks/spec.rake +29 -0
  283. data/tasks/test.rake +38 -0
  284. data/test/application_test.rb +39 -0
  285. data/test/book_test.rb +34 -0
  286. data/test/data/isbns.txt +3 -0
  287. data/test/isbn_test.rb +68 -0
  288. data/test/providers_test.rb +254 -0
  289. data/test/test_helper.rb +42 -0
  290. data/util/rake/fileinstall.rb +313 -0
  291. data/util/rake/gettextgenerate.rb +158 -0
  292. data/util/rake/omfgenerate.rb +79 -0
  293. 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