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,93 @@
1
+ # Copyright (C) 2004-2006 Laurent Sansonetti
2
+ # Copyright (C) 2008 Joseph Method
3
+ # Modifications Copyright (C) 2011 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
+ class CellRendererToggle < Gtk::CellRendererToggle
21
+ attr_accessor :text
22
+ type_register
23
+ install_property(GLib::Param::String.new(
24
+ 'text',
25
+ 'text',
26
+ 'Some damn value',
27
+ '',
28
+ GLib::Param::READABLE | GLib::Param::WRITABLE))
29
+ end
30
+
31
+ class Gtk::ActionGroup
32
+ def [](x)
33
+ get_action(x)
34
+ end
35
+ end
36
+
37
+ class Gtk::IconView
38
+ def freeze
39
+ @old_model = model
40
+ self.model = nil
41
+ end
42
+
43
+ def unfreeze
44
+ self.model = @old_model
45
+ end
46
+ end
47
+
48
+ class Gtk::TreeView
49
+ def freeze
50
+ @old_model = model
51
+ self.model = nil
52
+ end
53
+
54
+ def unfreeze
55
+ self.model = @old_model
56
+ end
57
+ end
58
+
59
+ class Alexandria::Library
60
+ def action_name
61
+ 'MoveIn' + name.gsub(/\s/, '')
62
+ end
63
+ end
64
+
65
+ class Alexandria::BookProviders::AbstractProvider
66
+ def action_name
67
+ 'At' + name
68
+ end
69
+ end
70
+
71
+ module Pango
72
+ def self.ellipsizable?
73
+ @ellipsizable ||= Pango.constants.include?('ELLIPSIZE_END')
74
+ end
75
+ end
76
+
77
+ module Alexandria
78
+ module UI
79
+ def self.display_help(parent = nil, section = nil)
80
+ section_index = ''
81
+ if section
82
+ section_index = "##{section}"
83
+ end
84
+ exec("gnome-help ghelp:alexandria#{section_index}") if fork.nil?
85
+ rescue
86
+ log.error(self) { 'Unable to load help browser' }
87
+ ErrorDialog.new(parent, _('Unable to launch the help browser'),
88
+ _('Could not display help for Alexandria. ' \
89
+ 'There was an error launching the system ' \
90
+ 'help browser.'))
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,75 @@
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
+ # Ideally this would be a subclass of GtkComboBox, but...
19
+ class Gtk::ComboBox
20
+ include GetText
21
+ extend GetText
22
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
23
+
24
+ def populate_with_libraries(libraries, selected_library)
25
+ libraries_names = libraries.map(&:name)
26
+ if selected_library
27
+ libraries_names.delete selected_library.name
28
+ libraries_names.unshift selected_library.name
29
+ end
30
+ clear
31
+ set_row_separator_func do |_model, iter|
32
+ iter[1] == '-'
33
+ end
34
+ self.model = Gtk::ListStore.new(Gdk::Pixbuf, String, TrueClass)
35
+ libraries_names.each do |library_name|
36
+ iter = model.append
37
+ iter[0] = Alexandria::UI::Icons::LIBRARY_SMALL
38
+ iter[1] = library_name
39
+ iter[2] = false
40
+ end
41
+ model.append[1] = '-'
42
+ iter = model.append
43
+ iter[0] = Alexandria::UI::Icons::LIBRARY_SMALL
44
+ iter[1] = _('New Library')
45
+ iter[2] = true
46
+ renderer = Gtk::CellRendererPixbuf.new
47
+ pack_start(renderer, false)
48
+ set_attributes(renderer, pixbuf: 0)
49
+ renderer = Gtk::CellRendererText.new
50
+ pack_start(renderer, true)
51
+ set_attributes(renderer, text: 1)
52
+ self.active = 0
53
+ # self.sensitive = libraries.length > 1
54
+ # This prohibits us from adding a "New Library" from this combo
55
+ # when we only have a single library
56
+ end
57
+
58
+ def selection_from_libraries(libraries)
59
+ iter = active_iter
60
+ is_new = false
61
+ library = nil
62
+ if iter[2]
63
+ name = Alexandria::Library.generate_new_name(libraries)
64
+ library = Alexandria::Library.load(name)
65
+ libraries << library
66
+ is_new = true
67
+ else
68
+ library = libraries.find do |x|
69
+ x.name == active_iter[1]
70
+ end
71
+ end
72
+ raise unless library
73
+ [library, is_new]
74
+ end
75
+ end
@@ -0,0 +1,310 @@
1
+ # Copyright (C) 2004-2006 Laurent Sansonetti
2
+ # Copyright (C) 2008 Joseph Method
3
+ # Copyright (C) 2010 Cathal Mc Ginley
4
+ # Modifications Copyright (C) 2011 Matijs van Zuijlen
5
+ #
6
+ # Alexandria is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU General Public License aso
8
+ # published by the Free Software Foundation; either version 2 of the
9
+ # License, or (at your option) any later version.
10
+ #
11
+ # Alexandria is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public
17
+ # License along with Alexandria; see the file COPYING. If not,
18
+ # write to the Free Software Foundation, Inc., 51 Franklin Street,
19
+ # Fifth Floor, Boston, MA 02110-1301 USA.
20
+
21
+ module Alexandria
22
+ module UI
23
+ include Logging
24
+ include GetText
25
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
26
+ class ListViewManager
27
+ include Logging
28
+ include GetText
29
+ include DragAndDropable
30
+ BOOKS_TARGET_TABLE = [['ALEXANDRIA_BOOKS', Gtk::Drag::TARGET_SAME_APP, 0]]
31
+
32
+ MAX_RATING_STARS = 5
33
+ module Columns
34
+ COVER_LIST, COVER_ICON, TITLE, TITLE_REDUCED, AUTHORS,
35
+ ISBN, PUBLISHER, PUBLISH_DATE, EDITION, RATING, IDENT,
36
+ NOTES, REDD, OWN, WANT, TAGS, LOANED_TO = (0..17).to_a
37
+ end
38
+
39
+ def initialize(_listview, parent)
40
+ @parent = parent
41
+ @prefs = @parent.prefs
42
+ @listview = @parent.listview
43
+ @listview_model = @parent.listview_model
44
+ @filtered_model = @parent.filtered_model
45
+ @model = @parent.model
46
+ @actiongroup = @parent.actiongroup
47
+ setup_books_listview
48
+ end
49
+
50
+ def setup_title_column
51
+ title = _('Title')
52
+ log.debug { 'Create listview column for %s' % title }
53
+ column = Gtk::TreeViewColumn.new(title)
54
+ column.widget = Gtk::Label.new(title).show
55
+ renderer = Gtk::CellRendererPixbuf.new
56
+ column.pack_start(renderer, false)
57
+ column.set_cell_data_func(renderer) do |_col, cell, _model, iter|
58
+ iter = @listview_model.convert_iter_to_child_iter(iter)
59
+ iter = @filtered_model.convert_iter_to_child_iter(iter)
60
+ cell.pixbuf = iter[Columns::COVER_LIST]
61
+ end
62
+ renderer = Gtk::CellRendererText.new
63
+ renderer.ellipsize = Pango::ELLIPSIZE_END if Pango.ellipsizable?
64
+ # Editable tree views are behaving strangely
65
+ # make_renderer_editable renderer
66
+
67
+ column.pack_start(renderer, true)
68
+
69
+ column.set_cell_data_func(renderer) do |_col, cell, _model, iter|
70
+ iter = @listview_model.convert_iter_to_child_iter(iter)
71
+ iter = @filtered_model.convert_iter_to_child_iter(iter)
72
+ cell.text, cell.editable = iter[Columns::TITLE], false # true
73
+ end
74
+
75
+ column.sort_column_id = Columns::TITLE
76
+ column.resizable = true
77
+ @listview.append_column(column)
78
+ end
79
+
80
+ def make_renderer_editable(renderer)
81
+ renderer.signal_connect('editing_started') do |_cell, entry, _path_string|
82
+ log.debug { 'editing_started' }
83
+ entry.complete_titles
84
+ end
85
+
86
+ renderer.signal_connect('edited') do |_cell, path_string, new_string|
87
+ log.debug { 'edited' }
88
+ path = Gtk::TreePath.new(path_string)
89
+ path = @listview_model.convert_path_to_child_path(path)
90
+ path = @filtered_model.convert_path_to_child_path(path)
91
+ iter = @listview.model.get_iter(path)
92
+ book = @parent.book_from_iter(@parent.selected_library, iter)
93
+ book.title = new_string
94
+ @listview.freeze
95
+ @iconview.freeze
96
+ @parent.fill_iter_with_book(iter, book)
97
+ @iconview.unfreeze
98
+ @listview.unfreeze
99
+ end
100
+ end
101
+
102
+ TEXT_COLUMNS = [
103
+ [_('Authors'), Columns::AUTHORS],
104
+ [_('ISBN'), Columns::ISBN],
105
+ [_('Publisher'), Columns::PUBLISHER],
106
+ [_('Publish Year'), Columns::PUBLISH_DATE],
107
+ [_('Binding'), Columns::EDITION],
108
+ [_('Loaned To'), Columns::LOANED_TO]
109
+ ]
110
+ CHECK_COLUMNS = [
111
+ [_('Read'), Columns::REDD],
112
+ [_('Own'), Columns::OWN],
113
+ [_('Want'), Columns::WANT]
114
+ ]
115
+
116
+ def setup_books_listview
117
+ log.debug { 'setup_books_listview' }
118
+ @listview.model = @listview_model
119
+ setup_title_column
120
+ TEXT_COLUMNS.each do |title, iterid|
121
+ setup_text_column title, iterid
122
+ end
123
+ CHECK_COLUMNS.each do |title, iterid|
124
+ setup_check_column title, iterid
125
+ end
126
+ setup_rating_column
127
+ @listview.selection.mode = Gtk::SELECTION_MULTIPLE
128
+ @listview.selection.signal_connect('changed') do
129
+ log.debug { 'changed' }
130
+ @parent.on_books_selection_changed
131
+ end
132
+ setup_tags_column
133
+ setup_listview_hack
134
+ setup_view_source_dnd(@listview)
135
+ end
136
+
137
+ def setup_tags_column
138
+ # adding tags column...
139
+ title = _('Tags')
140
+ log.debug { 'Create listview column for tags...' }
141
+ renderer = Gtk::CellRendererText.new
142
+ renderer.ellipsize = Pango::ELLIPSIZE_END if Pango.ellipsizable?
143
+ column = Gtk::TreeViewColumn.new(title, renderer,
144
+ text: Columns::TAGS)
145
+ column.widget = Gtk::Label.new(title).show
146
+ column.sort_column_id = Columns::TAGS
147
+ column.resizable = true
148
+ @listview.append_column(column)
149
+ end
150
+
151
+ def setup_listview_hack
152
+ @listview.signal_connect('row-activated') do
153
+ # Dirty hack to avoid the beginning of a drag within this
154
+ # handler.
155
+ log.debug { 'row-activated' }
156
+ Gtk.timeout_add(100) do
157
+ @actiongroup['Properties'].activate
158
+ false
159
+ end
160
+ end
161
+ end
162
+
163
+ def setup_rating_column
164
+ title = _('Rating')
165
+ log.debug { 'Create listview column for %s...' % title }
166
+ column = Gtk::TreeViewColumn.new(title)
167
+ column.widget = Gtk::Label.new(title).show
168
+ column.sizing = Gtk::TreeViewColumn::FIXED
169
+ column.fixed_width = column.min_width = column.max_width =
170
+ (Icons::STAR_SET.width + 1) * MAX_RATING_STARS
171
+ MAX_RATING_STARS.times do |i|
172
+ renderer = Gtk::CellRendererPixbuf.new
173
+ column.pack_start(renderer, false)
174
+ column.set_cell_data_func(renderer) do |_col, cell, _model, iter|
175
+ iter = @listview_model.convert_iter_to_child_iter(iter)
176
+ iter = @filtered_model.convert_iter_to_child_iter(iter)
177
+ rating = (iter[Columns::RATING] - MAX_RATING_STARS).abs
178
+ cell.pixbuf = rating >= i.succ ?
179
+ Icons::STAR_SET : Icons::STAR_UNSET
180
+ end
181
+ end
182
+ column.sort_column_id = Columns::RATING
183
+ column.resizable = false
184
+ @listview.append_column(column)
185
+ end
186
+
187
+ def setup_check_column(title, iterid)
188
+ renderer = CellRendererToggle.new
189
+ renderer.activatable = true
190
+ renderer.signal_connect('toggled') do |_rndrr, path|
191
+ begin
192
+ tree_path = Gtk::TreePath.new(path)
193
+ child_path = @listview_model.convert_path_to_child_path(tree_path)
194
+ if child_path
195
+ unfiltered_path = @filtered_model.convert_path_to_child_path(child_path)
196
+ # FIX this sometimes returns a nil path for iconview...
197
+ if unfiltered_path
198
+ iter = @model.get_iter(unfiltered_path)
199
+ if iter
200
+ book = @parent.book_from_iter(@parent.selected_library, iter)
201
+ toggle_state = case iterid
202
+ when Columns::REDD then book.redd
203
+ when Columns::OWN then book.own
204
+ when Columns::WANT then book.want
205
+ end
206
+ # invert toggle_state
207
+ unless iterid == Columns::WANT && book.own
208
+ toggle_state = !toggle_state
209
+ case iterid
210
+ when Columns::REDD then book.redd = toggle_state
211
+ when Columns::OWN then book.own = toggle_state
212
+ when Columns::WANT then book.want = toggle_state
213
+ end
214
+ iter[iterid] = toggle_state
215
+ lib = @parent.selected_library
216
+ lib.save(book)
217
+ end
218
+ end
219
+ end
220
+
221
+ end
222
+ rescue => e
223
+ log.error { "toggle failed for path #{path} #{e}\n" + e.backtrace.join("\n") }
224
+ end
225
+
226
+ end
227
+ column = Gtk::TreeViewColumn.new(title, renderer, text: iterid)
228
+ column.widget = Gtk::Label.new(title).show
229
+ column.sort_column_id = iterid
230
+ column.resizable = true
231
+ log.debug { 'Create listview column for %s...' % title }
232
+ setup_column = proc do |iter, cell, col|
233
+ state = iter[col]
234
+ cell.set_active(state)
235
+ cell.activatable = true
236
+ end
237
+ log.debug { "Setting cell_data_func for #{renderer}" }
238
+ column.set_cell_data_func(renderer) do |_col, cell, _model, iter|
239
+ iter = @listview_model.convert_iter_to_child_iter(iter)
240
+ iter = @filtered_model.convert_iter_to_child_iter(iter)
241
+ case iterid
242
+ when 12
243
+ setup_column.call(iter, cell, Columns::REDD)
244
+ when 13
245
+ setup_column.call(iter, cell, Columns::OWN)
246
+ when 14
247
+ setup_column.call(iter, cell, Columns::WANT)
248
+ own_state = iter[Columns::OWN]
249
+ cell.inconsistent = own_state
250
+ end
251
+ end
252
+ log.debug { "append_column #{column}" }
253
+ @listview.append_column(column)
254
+ end
255
+
256
+ def setup_text_column(title, iterid)
257
+ log.debug { 'Create listview column for %s...' % title }
258
+ renderer = Gtk::CellRendererText.new
259
+ renderer.ellipsize = Pango::ELLIPSIZE_END if Pango.ellipsizable?
260
+ column = Gtk::TreeViewColumn.new(title, renderer,
261
+ text: iterid)
262
+ column.widget = Gtk::Label.new(title).show
263
+ column.sort_column_id = iterid
264
+ column.resizable = true
265
+ @listview.append_column(column)
266
+ end
267
+
268
+ def setup_listview_columns_visibility
269
+ log.debug { 'setup_listview_columns_visibility' }
270
+ # Show or hide list view columns according to the preferences.
271
+ cols_visibility = [
272
+ @prefs.col_authors_visible,
273
+ @prefs.col_isbn_visible,
274
+ @prefs.col_publisher_visible,
275
+ @prefs.col_publish_date_visible,
276
+ @prefs.col_edition_visible,
277
+ @prefs.col_loaned_to_visible,
278
+ @prefs.col_redd_visible,
279
+ @prefs.col_own_visible,
280
+ @prefs.col_want_visible,
281
+ @prefs.col_rating_visible,
282
+ @prefs.col_tags_visible
283
+ ]
284
+ cols = @listview.columns[1..-1] # skip "Title"
285
+ cols.each_index do |i|
286
+ cols[i].visible = cols_visibility[i]
287
+ end
288
+ log.debug { 'Columns visibility: ' + cols.map { |col| "#{col.title} #{col.visible?}" }.join(', ') }
289
+ end
290
+
291
+ # Sets the width of each column based on any respective
292
+ # preference value stored.
293
+ def setup_listview_columns_width
294
+ log.debug { "setup_listview_columns_width #{@prefs.cols_width}" }
295
+ if @prefs.cols_width
296
+ cols_width = YAML.load(@prefs.cols_width)
297
+ log.debug { "cols_width: #{cols_width.inspect }" }
298
+ @listview.columns.each do |c|
299
+ if cols_width.key?(c.title)
300
+ log.debug { "#{c.title} : #{cols_width[c.title]}" }
301
+ c.sizing = Gtk::TreeViewColumn::FIXED
302
+ c.fixed_width = cols_width[c.title]
303
+ end
304
+ end
305
+ end
306
+ log.debug { 'Columns width: ' + @listview.columns.map { |col| "#{col.title} #{col.width}" }.join(', ') }
307
+ end
308
+ end
309
+ end
310
+ end