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,67 @@
1
+ # Copyright (C) 2004-2006 Laurent Sansonetti
2
+ # Copyright (C) 2007 Cathal Mc Ginley
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
+ require 'alexandria/ui/dialogs/alert_dialog'
21
+ # misc_dialogs depends on alert_dialog
22
+ require 'alexandria/ui/dialogs/misc_dialogs'
23
+ require 'alexandria/ui/dialogs/about_dialog'
24
+ require 'alexandria/ui/dialogs/book_properties_dialog_base'
25
+ require 'alexandria/ui/dialogs/book_properties_dialog'
26
+ require 'alexandria/ui/dialogs/new_book_dialog_manual'
27
+ require 'alexandria/ui/dialogs/new_book_dialog'
28
+ require 'alexandria/ui/dialogs/preferences_dialog'
29
+ require 'alexandria/ui/dialogs/export_dialog'
30
+ require 'alexandria/ui/dialogs/import_dialog'
31
+ require 'alexandria/ui/dialogs/acquire_dialog'
32
+ require 'alexandria/ui/dialogs/smart_library_properties_dialog_base'
33
+ require 'alexandria/ui/dialogs/smart_library_properties_dialog'
34
+ require 'alexandria/ui/dialogs/new_smart_library_dialog'
35
+ require 'alexandria/ui/dialogs/bad_isbns_dialog'
36
+ require 'alexandria/ui/dndable'
37
+ require 'alexandria/ui/init'
38
+ require 'alexandria/ui/ui_manager'
39
+ require 'alexandria/ui/listview'
40
+ require 'alexandria/ui/iconview'
41
+ require 'alexandria/ui/sidepane'
42
+
43
+ module Alexandria
44
+ module UI
45
+ include Logging
46
+ include GetText
47
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
48
+
49
+ class MainApp
50
+ include Logging
51
+ include GetText
52
+ MAX_RATING_STARS = 5
53
+ include Singleton
54
+ attr_accessor :main_app, :libraries, :actiongroup, :appbar, :prefs
55
+ attr_accessor :ui_manager
56
+ def initialize
57
+ log.info { 'Starting MainApp' }
58
+ @ui_manager = UIManager.new self
59
+ @actiongroup = @ui_manager.actiongroup
60
+ @appbar = @ui_manager.appbar
61
+ @prefs = @ui_manager.prefs
62
+ @main_app = @ui_manager.main_app
63
+ @ui_manager.show
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,150 @@
1
+ # Copyright (C) 2004-2006 Laurent Sansonetti
2
+ # Modifications Copyright (C) 2011 Matijs van Zuijlen
3
+ #
4
+ # Alexandria is free software; you can redistribute it and/or
5
+ # modify it under the terms of the GNU General Public License as
6
+ # published by the Free Software Foundation; either version 2 of the
7
+ # License, or (at your option) any later version.
8
+ #
9
+ # Alexandria is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public
15
+ # License along with Alexandria; see the file COPYING. If not,
16
+ # write to the Free Software Foundation, Inc., 51 Franklin Street,
17
+ # Fifth Floor, Boston, MA 02110-1301 USA.
18
+
19
+ class Gdk::Event
20
+ def ==(obj)
21
+ obj.is_a?(self.class) and time == obj.time and x == obj.x and y == obj.y and button == obj.button
22
+ end
23
+ end
24
+
25
+ class Gtk::TreeView
26
+ # include Alexandria::Logging
27
+
28
+ class Context < Struct.new(:pressed_button,
29
+ :x,
30
+ :y,
31
+ :cell_x,
32
+ :cell_y,
33
+ :button_press_handler,
34
+ :motion_notify_handler,
35
+ :button_release_handler,
36
+ :drag_data_get_handler,
37
+ :events,
38
+ :source_start_button_mask,
39
+ :source_targets,
40
+ :source_actions,
41
+ :pending_event,
42
+ :drag_context)
43
+
44
+ def initialize(*ary)
45
+ super
46
+ self.events ||= []
47
+ end
48
+
49
+ def pending_event?
50
+ pending_event
51
+ end
52
+ end
53
+
54
+ alias_method :old_enable_model_drag_source, :enable_model_drag_source
55
+ def enable_model_drag_source(start_button_mask, targets, actions)
56
+ old_enable_model_drag_source(start_button_mask, targets, actions)
57
+
58
+ @context = Context.new
59
+ @context.source_start_button_mask = start_button_mask
60
+ @context.source_targets = Gtk::TargetList.new(targets)
61
+ @context.source_actions = actions
62
+
63
+ @context.button_press_handler =
64
+ signal_connect('button_press_event') do |_widget, event, _data|
65
+ button_press_event(event)
66
+ end
67
+ end
68
+
69
+ def drag_context
70
+ @context.drag_context
71
+ end
72
+
73
+ #######
74
+ private
75
+ #######
76
+
77
+ def stop_drag_check
78
+ raise if @context.nil?
79
+ @context.events.clear
80
+ @context.pending_event = false
81
+ signal_handler_disconnect(@context.motion_notify_handler)
82
+ signal_handler_disconnect(@context.button_release_handler)
83
+ end
84
+
85
+ def button_release_event(_event)
86
+ @context.events.each { |evnt| Gtk.propagate_event(self, evnt) }
87
+ stop_drag_check
88
+ false
89
+ end
90
+
91
+ def motion_notify_event(event)
92
+ if Gtk::Drag.threshold?(self, @context.x, @context.y, event.x, event.y)
93
+ stop_drag_check
94
+ paths = []
95
+ selection.selected_each { |_model, path, _iter| paths << path }
96
+ @context.drag_context = Gtk::Drag.begin(self,
97
+ @context.source_targets,
98
+ @context.source_actions,
99
+ @context.pressed_button,
100
+ event)
101
+ end
102
+ true
103
+ end
104
+
105
+ def button_press_event(event)
106
+ return false if event.button == 3
107
+ return false if event.window != bin_window
108
+ return false if @context.events.include?(event)
109
+
110
+ if @context.pending_event?
111
+ @context.events << event
112
+ return true
113
+ end
114
+
115
+ return false if event.event_type == Gdk::Event::BUTTON2_PRESS
116
+
117
+ path, _, cell_x, cell_y = get_path_at_pos(event.x, event.y)
118
+ return false if path.nil?
119
+
120
+ # call_parent = (event.state.control_mask? or event.state.shift_mask?) or !selected or event.button != 1
121
+ call_parent = !selection.path_is_selected?(path) or
122
+ event.button != 1
123
+
124
+ if call_parent
125
+ signal_handler_block(@context.button_press_handler) do
126
+ signal_emit('button_press_event', event)
127
+ end
128
+ end
129
+
130
+ if selection.path_is_selected?(path)
131
+ @context.pending_event = true
132
+ @context.pressed_button = event.button
133
+ @context.x = event.x
134
+ @context.y = event.y
135
+ @context.cell_x = cell_x
136
+ @context.cell_y = cell_y
137
+ @context.motion_notify_handler =
138
+ signal_connect('motion_notify_event') do |_widget, evnt, _data|
139
+ motion_notify_event(evnt)
140
+ end
141
+ @context.button_release_handler =
142
+ signal_connect('button_release_event') do |_widget, evnt, _data|
143
+ button_release_event(evnt)
144
+ end
145
+ @context.events << event unless call_parent
146
+ end
147
+
148
+ true
149
+ end
150
+ end
@@ -0,0 +1,194 @@
1
+ # Modifications Copyright (C) 2011 Matijs van Zuijlen
2
+ module Alexandria
3
+ module UI
4
+ class SidePaneManager
5
+ include Logging
6
+ include GetText
7
+ attr_accessor :library_listview
8
+ def initialize(library_listview, parent)
9
+ @library_listview = library_listview
10
+ @parent = parent
11
+ @libraries = Libraries.instance
12
+ @main_app = @parent.main_app
13
+ setup_sidepane
14
+ end
15
+
16
+ def library_already_exists(new_text)
17
+ x = (@libraries.all_libraries + Library.deleted_libraries).find do |library|
18
+ library.name == new_text.strip
19
+ end
20
+ x and x.name != @parent.selected_library.name
21
+ end
22
+
23
+ # if new_text is invalid utf-8, returns true
24
+ # if new_text contains disallowed char (/ or initial .), returns a MatchData object
25
+ # otherwise returns nil
26
+ def contains_illegal_character(new_text)
27
+ new_text.unpack('U*') # attempt to unpack as UTF-8 characters
28
+ match = /(^\.|\/)/.match(new_text)
29
+ # forbid / character (since Library names become dir names)
30
+ # also no initial . since that hides the Library (hidden file)
31
+ # forbidding an initial dot also disallows "." and ".."
32
+ # which are of course pre-existing directories.
33
+ return match
34
+ rescue => ex
35
+ log.warn { "New library name not valid UTF-8: #{ex.message}" }
36
+ return true
37
+ # /([^\w\s'"()&?!:;.\-])/.match(new_text) # anglocentric!
38
+ end
39
+
40
+ def on_edited_library(cell, path_string, new_text)
41
+ log.debug { "edited library name #{new_text}" }
42
+ ## new_text = new_text.reverse # for testing;
43
+ # a great way to generate broken UTF-8
44
+ if cell.text != new_text
45
+ if (match = contains_illegal_character(new_text))
46
+ if match.instance_of? MatchData
47
+ chars = match[1].gsub(/&/, '&amp;')
48
+ ErrorDialog.new(@main_app, _("Invalid library name '%s'") % new_text,
49
+ _('The name provided contains the ' \
50
+ 'disallowed character <b>%s</b> ') % chars)
51
+ else
52
+ ErrorDialog.new(@main_app, _('Invalid library name'),
53
+ _('The name provided contains ' \
54
+ 'invalid characters.'))
55
+ end
56
+
57
+ elsif new_text.strip.empty?
58
+ log.debug { 'Empty text' }
59
+ ErrorDialog.new(@main_app, _('The library name ' \
60
+ 'can not be empty'))
61
+ elsif library_already_exists new_text
62
+ log.debug { 'Already exists' }
63
+ ErrorDialog.new(@main_app,
64
+ _('The library can not be renamed'),
65
+ _('There is already a library named ' \
66
+ "'%s'. Please choose a different " \
67
+ 'name.') % new_text.strip)
68
+ else
69
+ log.debug { "Attempting to apply #{path_string}, #{new_text}" }
70
+ path = Gtk::TreePath.new(path_string)
71
+ iter = @library_listview.model.get_iter(path)
72
+ library_name = new_text.strip
73
+ log.info { "library name is #{library_name}" }
74
+ iter[1] = @parent.selected_library.name = library_name
75
+ @parent.setup_move_actions
76
+ @parent.refresh_libraries
77
+ end
78
+ end
79
+ end
80
+
81
+ def setup_sidepane
82
+ @library_listview.model = Gtk::ListStore.new(Gdk::Pixbuf,
83
+ String,
84
+ TrueClass,
85
+ TrueClass)
86
+ @library_separator_iter = nil
87
+ @libraries.all_regular_libraries.each { |x| @parent.append_library(x) }
88
+ @libraries.all_smart_libraries.each { |x| @parent.append_library(x) }
89
+
90
+ renderer = Gtk::CellRendererPixbuf.new
91
+ column = Gtk::TreeViewColumn.new(_('Library'))
92
+ column.pack_start(renderer, false)
93
+ column.set_cell_data_func(renderer) do |_col, cell, _model, iter|
94
+ # log.debug { "sidepane: cell_data_func #{col}, #{cell}, #{iter}" }
95
+ cell.pixbuf = iter[0]
96
+ end
97
+ renderer = Gtk::CellRendererText.new
98
+ renderer.ellipsize = Pango::ELLIPSIZE_END if Pango.ellipsizable?
99
+ column.pack_start(renderer, true)
100
+ column.set_cell_data_func(renderer) do |_col, cell, _model, iter|
101
+ # log.debug { "sidepane: editable #{cell}, #{iter} #{iter[1]}: #{iter[2]}" }
102
+ cell.text, cell.editable = iter[1], iter[2]
103
+ # log.debug { "exit sidepane: editable #{cell}, #{iter}" }
104
+ end
105
+ renderer.signal_connect('edited', &method(:on_edited_library))
106
+ @library_listview.append_column(column)
107
+
108
+ @library_listview.set_row_separator_func do |_model, iter|
109
+ # log.debug { "library_listview row_separator #{iter}" }
110
+ iter[3]
111
+ end
112
+
113
+ @library_listview.selection.signal_connect('changed') do
114
+ log.debug { 'changed' }
115
+ @parent.refresh_libraries
116
+ @parent.refresh_books
117
+ end
118
+
119
+ @library_listview.enable_model_drag_dest(
120
+ BOOKS_TARGET_TABLE,
121
+ Gdk::DragContext::ACTION_MOVE)
122
+
123
+ @library_listview.signal_connect('drag-motion') do
124
+ |_widget, drag_context, x, y, time, _data|
125
+ log.debug { 'drag-motion' }
126
+
127
+ path, column, _, _ =
128
+ @library_listview.get_path_at_pos(x, y)
129
+
130
+ if path
131
+ # Refuse drags from/to smart libraries.
132
+ if @parent.selected_library.is_a?(SmartLibrary)
133
+ path = nil
134
+ else
135
+ iter = @library_listview.model.get_iter(path)
136
+ if iter[3] # separator?
137
+ path = nil
138
+ else
139
+ library = @libraries.all_libraries.find do |lib|
140
+ lib.name == iter[1]
141
+ end
142
+ path = nil if library.is_a?(SmartLibrary)
143
+ end
144
+ end
145
+ end
146
+
147
+ @library_listview.set_drag_dest_row(
148
+ path,
149
+ Gtk::TreeView::DROP_INTO_OR_AFTER)
150
+
151
+ drag_context.drag_status(
152
+ !path.nil? ? drag_context.suggested_action : 0,
153
+ time)
154
+ end
155
+
156
+ @library_listview.signal_connect('drag-drop') do
157
+ |widget, drag_context, _x, _y, time, _data|
158
+ log.debug { 'drag-drop' }
159
+
160
+ Gtk::Drag.get_data(widget,
161
+ drag_context,
162
+ drag_context.targets.first,
163
+ time)
164
+ true
165
+ end
166
+
167
+ @library_listview.signal_connect('drag-data-received') do
168
+ |_widget, drag_context, x, y, selection_data, _info, _time|
169
+ log.debug { 'drag-data-received' }
170
+
171
+ success = false
172
+ if selection_data.type == Gdk::Selection::TYPE_STRING
173
+ path, _ =
174
+ @library_listview.get_dest_row_at_pos(x, y)
175
+
176
+ if path
177
+ iter = @library_listview.model.get_iter(path)
178
+ library = @libraries.all_libraries.find do |lib|
179
+ lib.name == iter[1]
180
+ end
181
+ @parent.move_selected_books_to_library(library)
182
+ success = true
183
+ end
184
+ end
185
+ begin
186
+ Gtk::Drag.finish(drag_context, success, false, 0) # ,time)
187
+ rescue => ex
188
+ log.error { "Gtk::Drag.finish failed: #{ex}" }
189
+ end
190
+ end
191
+ end
192
+ end
193
+ end
194
+ end
@@ -0,0 +1,107 @@
1
+ # -*- ruby -*-
2
+ #--
3
+ # Copyright (C) 2011 Cathal Mc Ginley
4
+ #
5
+ # This file is part of Alexandria, a GNOME book collection manager.
6
+ #
7
+ # Alexandria is free software; you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation; either version 2 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # Alexandria is distributed in the hope that it will be useful, but
13
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ # General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with Alexandria; see the file COPYING. If not, write to the
19
+ # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
+ # Boston, MA 02110-1301 USA.
21
+ #++
22
+
23
+ require 'gst'
24
+
25
+ module Alexandria
26
+ module UI
27
+ ## Uses Ruby/GStreamer to play Ogg/Vorbis sound effects
28
+ class SoundEffectsPlayer
29
+ def initialize
30
+ @sounds_dir = Alexandria::Config::SOUNDS_DIR
31
+ @ogg_vorbis_pipeline = Gst::Pipeline.new
32
+ set_up_pipeline
33
+ @playing = false
34
+ set_up_glib_loop
35
+ end
36
+
37
+ def play(effect)
38
+ file = File.join(@sounds_dir, "#{effect}.ogg")
39
+ unless @playing
40
+ @filesrc.location = file
41
+ start_playback
42
+ end
43
+ end
44
+
45
+ def set_up_pipeline
46
+ @filesrc = Gst::ElementFactory.make('filesrc')
47
+ demuxer = Gst::ElementFactory.make('oggdemux')
48
+ decoder = Gst::ElementFactory.make('vorbisdec')
49
+ converter = Gst::ElementFactory.make('audioconvert') # #??
50
+ audiosink = Gst::ElementFactory.make('autoaudiosink')
51
+
52
+ @ogg_vorbis_pipeline.add(@filesrc, demuxer, decoder,
53
+ converter, audiosink)
54
+ @filesrc >> demuxer
55
+
56
+ # this next must be a dynamic link, as demuxers potentially
57
+ # have multiple src pads (for audio/video muxed streams)
58
+
59
+ demuxer.signal_connect('pad-added') do |_parser, ogg_src_pad|
60
+ vorbis_sink_pad = decoder.get_pad('sink')
61
+ ogg_src_pad.link(vorbis_sink_pad)
62
+ end
63
+
64
+ decoder >> converter >> audiosink
65
+ end
66
+
67
+ def set_up_glib_loop
68
+ unless @loop
69
+ @loop = GLib::MainLoop.new(nil, false)
70
+
71
+ @bus = @ogg_vorbis_pipeline.bus
72
+ @bus.add_watch do |_bus, message|
73
+ case message.type
74
+ when Gst::Message::EOS
75
+ @playing = false
76
+ @loop.quit
77
+ when Gst::Message::ERROR
78
+ if $DEBUG
79
+ puts 'ERROR loop.quit'
80
+ p message.parse
81
+ end
82
+ @playing = false
83
+ @loop.quit
84
+ end
85
+ true
86
+ end
87
+ end
88
+ end
89
+
90
+ def start_playback
91
+ @playing = true
92
+ @ogg_vorbis_pipeline.play
93
+ begin
94
+ @loop.run
95
+ rescue Interrupt
96
+ ensure
97
+ @ogg_vorbis_pipeline.stop
98
+ @playing = false
99
+ end
100
+ end
101
+
102
+ def stop_playback
103
+ @ogg_vorbis_pipeline.stop
104
+ end
105
+ end
106
+ end
107
+ end