alexandria-book-collection-manager 0.7.1 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. checksums.yaml +5 -5
  2. data/.github/dependabot.yml +9 -0
  3. data/.gitignore +5 -2
  4. data/.hound.yml +2 -0
  5. data/.rubocop.yml +113 -45
  6. data/.rubocop_todo.yml +82 -170
  7. data/.simplecov +5 -1
  8. data/.travis.yml +45 -0
  9. data/.yardopts +1 -1
  10. data/CHANGELOG.md +60 -0
  11. data/ChangeLog.0 +33 -35
  12. data/Gemfile +6 -5
  13. data/INSTALL.md +164 -0
  14. data/README.md +52 -42
  15. data/Rakefile +95 -109
  16. data/TODO.md +9 -1
  17. data/alexandria-book-collection-manager.gemspec +52 -45
  18. data/bin/alexandria +31 -53
  19. data/doc/AUTHORS +61 -0
  20. data/doc/BUGS +31 -0
  21. data/doc/FAQ +365 -0
  22. data/doc/HACKING +19 -0
  23. data/doc/NEWS +341 -0
  24. data/doc/alexandria.1 +120 -0
  25. data/doc/cuecat_support.rdoc +67 -0
  26. data/doc/dependency_decisions.yml +80 -0
  27. data/lib/alexandria.rb +29 -37
  28. data/lib/alexandria/about.rb +52 -51
  29. data/lib/alexandria/book_providers.rb +94 -101
  30. data/lib/alexandria/book_providers/adlibris.rb +45 -85
  31. data/lib/alexandria/book_providers/amazon_aws.rb +105 -113
  32. data/lib/alexandria/book_providers/amazon_ecs_util.rb +293 -324
  33. data/lib/alexandria/book_providers/barnes_and_noble.rb +54 -53
  34. data/lib/alexandria/book_providers/douban.rb +29 -51
  35. data/lib/alexandria/book_providers/proxis.rb +42 -59
  36. data/lib/alexandria/book_providers/pseudomarc.rb +79 -99
  37. data/lib/alexandria/book_providers/siciliano.rb +68 -70
  38. data/lib/alexandria/book_providers/thalia.rb +46 -45
  39. data/lib/alexandria/book_providers/web.rb +17 -33
  40. data/lib/alexandria/book_providers/worldcat.rb +74 -102
  41. data/lib/alexandria/book_providers/z3950.rb +170 -174
  42. data/lib/alexandria/config.rb +5 -3
  43. data/lib/alexandria/console.rb +10 -21
  44. data/lib/alexandria/default_preferences.rb +37 -0
  45. data/lib/alexandria/execution_queue.rb +17 -15
  46. data/lib/alexandria/export_format.rb +47 -0
  47. data/lib/alexandria/export_library.rb +188 -302
  48. data/lib/alexandria/import_library.rb +114 -155
  49. data/lib/alexandria/import_library_csv.rb +46 -96
  50. data/lib/alexandria/library_collection.rb +79 -0
  51. data/lib/alexandria/library_sort_order.rb +45 -0
  52. data/lib/alexandria/library_store.rb +233 -0
  53. data/lib/alexandria/logging.rb +15 -19
  54. data/lib/alexandria/models/book.rb +15 -20
  55. data/lib/alexandria/models/library.rb +81 -363
  56. data/lib/alexandria/net.rb +7 -6
  57. data/lib/alexandria/preferences.rb +73 -91
  58. data/lib/alexandria/scanners.rb +4 -2
  59. data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +24 -20
  60. data/lib/alexandria/scanners/keyboard.rb +10 -8
  61. data/lib/alexandria/smart_library.rb +135 -171
  62. data/lib/alexandria/ui.rb +17 -15
  63. data/lib/alexandria/ui/about_dialog.rb +49 -0
  64. data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +129 -152
  65. data/lib/alexandria/ui/alert_dialog.rb +64 -0
  66. data/lib/alexandria/ui/bad_isbns_dialog.rb +41 -0
  67. data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +18 -15
  68. data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +44 -61
  69. data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +84 -89
  70. data/lib/alexandria/ui/builder_base.rb +9 -27
  71. data/lib/alexandria/ui/callbacks.rb +188 -186
  72. data/lib/alexandria/ui/columns.rb +2 -0
  73. data/lib/alexandria/ui/completion_models.rb +12 -23
  74. data/lib/alexandria/ui/confirm_erase_dialog.rb +33 -0
  75. data/lib/alexandria/ui/conflict_while_copying_dialog.rb +34 -0
  76. data/lib/alexandria/ui/dndable.rb +10 -8
  77. data/lib/alexandria/ui/error_dialog.rb +25 -0
  78. data/lib/alexandria/ui/export_dialog.rb +139 -0
  79. data/lib/alexandria/ui/icons.rb +49 -65
  80. data/lib/alexandria/ui/iconview.rb +15 -13
  81. data/lib/alexandria/ui/iconview_tooltips.rb +43 -58
  82. data/lib/alexandria/ui/import_dialog.rb +157 -0
  83. data/lib/alexandria/ui/init.rb +23 -33
  84. data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +36 -0
  85. data/lib/alexandria/ui/libraries_combo.rb +18 -14
  86. data/lib/alexandria/ui/listview.rb +77 -88
  87. data/lib/alexandria/ui/main_app.rb +26 -26
  88. data/lib/alexandria/ui/misc_dialogs.rb +10 -0
  89. data/lib/alexandria/ui/multi_drag_treeview.rb +30 -41
  90. data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +168 -215
  91. data/lib/alexandria/ui/new_book_dialog_manual.rb +139 -0
  92. data/lib/alexandria/ui/new_provider_dialog.rb +100 -0
  93. data/lib/alexandria/ui/new_smart_library_dialog.rb +74 -0
  94. data/lib/alexandria/ui/preferences_dialog.rb +313 -0
  95. data/lib/alexandria/ui/provider_preferences_base_dialog.rb +95 -0
  96. data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
  97. data/lib/alexandria/ui/really_delete_dialog.rb +53 -0
  98. data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +62 -72
  99. data/lib/alexandria/ui/skip_entry_dialog.rb +33 -0
  100. data/lib/alexandria/ui/smart_library_properties_dialog.rb +60 -0
  101. data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog_base.rb → smart_library_properties_dialog_base.rb} +96 -172
  102. data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
  103. data/lib/alexandria/ui/sound.rb +13 -13
  104. data/lib/alexandria/ui/ui_manager.rb +262 -283
  105. data/lib/alexandria/undo_manager.rb +3 -0
  106. data/lib/alexandria/version.rb +6 -19
  107. data/lib/alexandria/web_themes.rb +24 -21
  108. data/po/Makefile +2 -2
  109. data/po/cs.po +993 -880
  110. data/po/cy.po +957 -874
  111. data/po/de.po +990 -869
  112. data/po/el.po +989 -869
  113. data/po/es.po +985 -865
  114. data/po/fr.po +986 -870
  115. data/po/ga.po +907 -823
  116. data/po/gl.po +981 -865
  117. data/po/it.po +986 -868
  118. data/po/ja.po +969 -853
  119. data/po/mk.po +983 -863
  120. data/po/nb.po +979 -863
  121. data/po/nl.po +983 -864
  122. data/po/pl.po +1020 -969
  123. data/po/pt.po +988 -861
  124. data/po/pt_BR.po +984 -868
  125. data/po/ru.po +992 -873
  126. data/po/sk.po +987 -869
  127. data/po/sv.po +977 -861
  128. data/po/uk.po +975 -865
  129. data/po/zh_TW.po +976 -860
  130. data/schemas/alexandria.schemas +25 -3
  131. data/share/alexandria/glade/acquire_dialog__builder.glade +15 -12
  132. data/share/alexandria/glade/book_properties_dialog__builder.glade +171 -299
  133. data/share/alexandria/glade/main_app__builder.glade +24 -33
  134. data/share/alexandria/glade/new_book_dialog__builder.glade +27 -59
  135. data/share/alexandria/glade/preferences_dialog__builder.glade +250 -290
  136. data/share/gnome/help/alexandria/C/introduction.xml +0 -8
  137. data/share/gnome/help/alexandria/C/searching.xml +1 -1
  138. data/share/gnome/help/alexandria/C/smart-libraries.xml +2 -2
  139. data/share/gnome/help/alexandria/C/working-with-libraries.xml +1 -1
  140. data/share/gnome/help/alexandria/fr/alexandria.xml +1 -1
  141. data/share/gnome/help/alexandria/ja/introduction.xml +0 -8
  142. data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
  143. data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
  144. data/spec/alexandria/book_providers_spec.rb +77 -210
  145. data/spec/alexandria/book_spec.rb +16 -12
  146. data/spec/alexandria/console_spec.rb +27 -0
  147. data/spec/alexandria/export_library_spec.rb +130 -0
  148. data/spec/alexandria/library_spec.rb +130 -172
  149. data/spec/alexandria/library_store_spec.rb +37 -0
  150. data/spec/alexandria/preferences_spec.rb +46 -17
  151. data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
  152. data/spec/alexandria/smart_library_spec.rb +32 -25
  153. data/spec/alexandria/ui/about_dialog_spec.rb +14 -0
  154. data/spec/alexandria/ui/acquire_dialog_spec.rb +14 -0
  155. data/spec/alexandria/ui/alert_dialog_spec.rb +16 -0
  156. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +14 -0
  157. data/spec/alexandria/ui/book_properties_dialog_spec.rb +17 -0
  158. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +14 -0
  159. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +16 -0
  160. data/spec/alexandria/ui/error_dialog_spec.rb +14 -0
  161. data/spec/alexandria/ui/export_dialog_spec.rb +15 -0
  162. data/spec/alexandria/ui/icons_spec.rb +26 -0
  163. data/spec/alexandria/ui/iconview_spec.rb +9 -21
  164. data/spec/alexandria/ui/import_dialog_spec.rb +41 -0
  165. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
  166. data/spec/alexandria/ui/main_app_spec.rb +8 -33
  167. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +15 -0
  168. data/spec/alexandria/ui/new_book_dialog_spec.rb +22 -0
  169. data/spec/alexandria/ui/new_provider_dialog_spec.rb +30 -0
  170. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +39 -0
  171. data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
  172. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +34 -0
  173. data/spec/alexandria/ui/really_delete_dialog_spec.rb +16 -0
  174. data/spec/alexandria/ui/sidepane_manager_spec.rb +15 -0
  175. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +14 -0
  176. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +32 -0
  177. data/spec/alexandria/ui/sound_spec.rb +4 -2
  178. data/spec/alexandria/ui/ui_manager_spec.rb +45 -20
  179. data/spec/end_to_end/basic_run_spec.rb +57 -0
  180. data/spec/spec_helper.rb +66 -33
  181. data/tasks/setup.rb +5 -3
  182. data/tasks/spec.rake +18 -3
  183. data/util/rake/fileinstall.rb +38 -40
  184. data/util/rake/gettextgenerate.rb +15 -70
  185. data/util/rake/omfgenerate.rb +10 -10
  186. metadata +176 -60
  187. data/INSTALL.rdoc +0 -148
  188. data/dogtail/basic_run_test.py +0 -9
  189. data/lib/alexandria/book_providers/bol_it.rb +0 -160
  190. data/lib/alexandria/book_providers/deastore.rb +0 -273
  191. data/lib/alexandria/book_providers/ibs_it.rb +0 -147
  192. data/lib/alexandria/book_providers/mcu.rb +0 -169
  193. data/lib/alexandria/book_providers/renaud.rb +0 -140
  194. data/lib/alexandria/book_providers/webster_it.rb +0 -167
  195. data/lib/alexandria/ui/dialogs/about_dialog.rb +0 -59
  196. data/lib/alexandria/ui/dialogs/alert_dialog.rb +0 -70
  197. data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +0 -43
  198. data/lib/alexandria/ui/dialogs/export_dialog.rb +0 -171
  199. data/lib/alexandria/ui/dialogs/import_dialog.rb +0 -196
  200. data/lib/alexandria/ui/dialogs/misc_dialogs.rb +0 -85
  201. data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +0 -154
  202. data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +0 -74
  203. data/lib/alexandria/ui/dialogs/preferences_dialog.rb +0 -578
  204. data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +0 -57
  205. data/spec/alexandria/scanners/cuecat_spec.rb +0 -65
  206. data/spec/alexandria/ui/dialogs_spec.rb +0 -94
  207. data/spec/alexandria/ui/sidepane_spec.rb +0 -27
  208. data/spec/alexandria/ui/ui_utilities_spec.rb +0 -60
  209. data/spec/alexandria/utilities_spec.rb +0 -50
  210. data/tasks/dogtail.rake +0 -4
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
4
  # Copyright (C) 2016 Matijs van Zuijlen
3
5
  #
@@ -22,7 +24,7 @@ module Alexandria
22
24
  module ComboBoxOverrides
23
25
  include GetText
24
26
  extend GetText
25
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
27
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
26
28
 
27
29
  def populate_with_libraries(libraries, selected_library)
28
30
  libraries_names = libraries.map(&:name)
@@ -31,28 +33,22 @@ module Alexandria
31
33
  libraries_names.unshift selected_library.name
32
34
  end
33
35
  clear
34
- set_row_separator_func do |model, iter|
35
- # TODO: Replace with iter[1] if possible
36
- model.get_value(iter, 1) == '-'
37
- end
38
36
  self.model = Gtk::ListStore.new(GdkPixbuf::Pixbuf, String, TrueClass)
39
37
  libraries_names.each do |library_name|
40
- iter = model.append
41
- iter[0] = Alexandria::UI::Icons::LIBRARY_SMALL
42
- iter[1] = library_name
43
- iter[2] = false
38
+ append_entry(Alexandria::UI::Icons::LIBRARY_SMALL, library_name, false)
44
39
  end
45
- model.append[1] = '-'
46
- iter = model.append
47
- iter[0] = Alexandria::UI::Icons::LIBRARY_SMALL
48
- iter[1] = _('New Library')
49
- iter[2] = true
40
+ append_entry(nil, "-", nil)
41
+ append_entry(Alexandria::UI::Icons::LIBRARY_SMALL, _("New Library"), true)
50
42
  renderer = Gtk::CellRendererPixbuf.new
51
43
  pack_start(renderer, false)
52
44
  set_attributes(renderer, pixbuf: 0)
53
45
  renderer = Gtk::CellRendererText.new
54
46
  pack_start(renderer, true)
55
47
  set_attributes(renderer, text: 1)
48
+ set_row_separator_func do |model, iter|
49
+ # TODO: Replace with iter[1] if possible
50
+ model.get_value(iter, 1) == "-"
51
+ end
56
52
  self.active = 0
57
53
  # self.sensitive = libraries.length > 1
58
54
  # This prohibits us from adding a "New Library" from this combo
@@ -74,8 +70,16 @@ module Alexandria
74
70
  end
75
71
  end
76
72
  raise unless library
73
+
77
74
  [library, is_new]
78
75
  end
76
+
77
+ def append_entry(icon, label, is_new)
78
+ iter = model.append
79
+ iter[0] = icon
80
+ iter[1] = label
81
+ iter[2] = is_new
82
+ end
79
83
  end
80
84
  end
81
85
 
@@ -1,35 +1,21 @@
1
- # Copyright (C) 2004-2006 Laurent Sansonetti
2
- # Copyright (C) 2008 Joseph Method
3
- # Copyright (C) 2010 Cathal Mc Ginley
4
- # Copyright (C) 2011, 2016 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.
1
+ # frozen_string_literal: true
2
+
3
+ # This file is part of Alexandria.
15
4
  #
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.
5
+ # See the file README.md for authorship and licensing information.
20
6
 
21
- require 'alexandria/ui/columns'
7
+ require "alexandria/ui/columns"
22
8
 
23
9
  module Alexandria
24
10
  module UI
25
11
  include Logging
26
12
  include GetText
27
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
13
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
28
14
  class ListViewManager
29
15
  include Logging
30
16
  include GetText
31
17
  include DragAndDropable
32
- BOOKS_TARGET_TABLE = [['ALEXANDRIA_BOOKS', :same_app, 0]].freeze
18
+ BOOKS_TARGET_TABLE = [["ALEXANDRIA_BOOKS", :same_app, 0]].freeze
33
19
 
34
20
  def initialize(_listview, parent)
35
21
  @parent = parent
@@ -43,18 +29,18 @@ module Alexandria
43
29
  end
44
30
 
45
31
  def setup_title_column
46
- title = _('Title')
47
- log.debug { 'Create listview column for %s' % title }
32
+ title = _("Title")
33
+ log.debug { format("Create listview column for %s", title) }
48
34
  column = Gtk::TreeViewColumn.new(title)
49
35
 
50
36
  renderer = Gtk::CellRendererPixbuf.new
51
37
  column.pack_start(renderer, false)
52
- column.add_attribute(renderer, 'pixbuf', Columns::COVER_LIST)
38
+ column.add_attribute(renderer, "pixbuf", Columns::COVER_LIST)
53
39
 
54
40
  renderer = Gtk::CellRendererText.new
55
- renderer.ellipsize = Pango::ELLIPSIZE_END
41
+ renderer.ellipsize = :end
56
42
  column.pack_start(renderer, true)
57
- column.add_attribute(renderer, 'text', Columns::TITLE)
43
+ column.add_attribute(renderer, "text", Columns::TITLE)
58
44
 
59
45
  column.sort_column_id = Columns::TITLE
60
46
  column.resizable = true
@@ -62,21 +48,21 @@ module Alexandria
62
48
  end
63
49
 
64
50
  TEXT_COLUMNS = [
65
- [_('Authors'), Columns::AUTHORS],
66
- [_('ISBN'), Columns::ISBN],
67
- [_('Publisher'), Columns::PUBLISHER],
68
- [_('Publish Year'), Columns::PUBLISH_DATE],
69
- [_('Binding'), Columns::EDITION],
70
- [_('Loaned To'), Columns::LOANED_TO]
51
+ [_("Authors"), Columns::AUTHORS],
52
+ [_("ISBN"), Columns::ISBN],
53
+ [_("Publisher"), Columns::PUBLISHER],
54
+ [_("Publish Year"), Columns::PUBLISH_DATE],
55
+ [_("Binding"), Columns::EDITION],
56
+ [_("Loaned To"), Columns::LOANED_TO]
71
57
  ].freeze
72
58
  CHECK_COLUMNS = [
73
- [_('Read'), Columns::REDD],
74
- [_('Own'), Columns::OWN],
75
- [_('Want'), Columns::WANT]
59
+ [_("Read"), Columns::REDD],
60
+ [_("Own"), Columns::OWN],
61
+ [_("Want"), Columns::WANT]
76
62
  ].freeze
77
63
 
78
64
  def setup_books_listview
79
- log.debug { 'setup_books_listview' }
65
+ log.debug { "setup_books_listview" }
80
66
  @listview.model = @listview_model
81
67
  setup_title_column
82
68
  TEXT_COLUMNS.each do |title, iterid|
@@ -87,8 +73,8 @@ module Alexandria
87
73
  end
88
74
  setup_rating_column
89
75
  @listview.selection.mode = :multiple
90
- @listview.selection.signal_connect('changed') do
91
- log.debug { 'changed' }
76
+ @listview.selection.signal_connect("changed") do
77
+ log.debug { "changed" }
92
78
  @parent.on_books_selection_changed
93
79
  end
94
80
  setup_tags_column
@@ -97,11 +83,10 @@ module Alexandria
97
83
  end
98
84
 
99
85
  def setup_tags_column
100
- # adding tags column...
101
- title = _('Tags')
102
- log.debug { 'Create listview column for tags...' }
86
+ title = _("Tags")
87
+ log.debug { "Create listview column for tags" }
103
88
  renderer = Gtk::CellRendererText.new
104
- renderer.ellipsize = Pango::ELLIPSIZE_END
89
+ renderer.ellipsize = :end
105
90
  column = Gtk::TreeViewColumn.new(title, renderer,
106
91
  text: Columns::TAGS)
107
92
  column.sort_column_id = Columns::TAGS
@@ -110,16 +95,16 @@ module Alexandria
110
95
  end
111
96
 
112
97
  def setup_row_activation
113
- @listview.signal_connect('row-activated') do
114
- log.debug { 'row-activated' }
115
- @actiongroup['Properties'].activate
98
+ @listview.signal_connect("row-activated") do
99
+ log.debug { "row-activated" }
100
+ @actiongroup["Properties"].activate
116
101
  false
117
102
  end
118
103
  end
119
104
 
120
105
  def setup_rating_column
121
- title = _('Rating')
122
- log.debug { 'Create listview column for %s...' % title }
106
+ title = _("Rating")
107
+ log.debug { format("Create listview column for %s", title) }
123
108
  column = Gtk::TreeViewColumn.new(title)
124
109
  column.sizing = :fixed
125
110
  width = (Icons::STAR_SET.width + 1) * Book::MAX_RATING_STARS
@@ -130,8 +115,7 @@ module Alexandria
130
115
  column.pack_start(renderer, false)
131
116
  column.set_cell_data_func(renderer) do |_tree_column, cell, _tree_model, iter|
132
117
  rating = (iter[Columns::RATING] - Book::MAX_RATING_STARS).abs
133
- cell.pixbuf = rating >= i.succ ?
134
- Icons::STAR_SET : Icons::STAR_UNSET
118
+ cell.pixbuf = rating >= i.succ ? Icons::STAR_SET : Icons::STAR_UNSET
135
119
  end
136
120
  end
137
121
  column.sort_column_id = Columns::RATING
@@ -142,50 +126,48 @@ module Alexandria
142
126
  def setup_check_column(title, iterid)
143
127
  renderer = CellRendererToggle.new
144
128
  renderer.activatable = true
145
- renderer.signal_connect('toggled') do |_rndrr, path|
146
- begin
147
- tree_path = Gtk::TreePath.new(path)
148
- child_path = @listview_model.convert_path_to_child_path(tree_path)
149
- if child_path
150
- unfiltered_path = @filtered_model.convert_path_to_child_path(child_path)
151
- # FIX this sometimes returns a nil path for iconview...
152
- if unfiltered_path
153
- iter = @model.get_iter(unfiltered_path)
154
- if iter
155
- book = @parent.book_from_iter(@parent.selected_library, iter)
156
- toggle_state = case iterid
157
- when Columns::REDD then book.redd
158
- when Columns::OWN then book.own
159
- when Columns::WANT then book.want
160
- end
161
- # invert toggle_state
162
- unless iterid == Columns::WANT && book.own
163
- toggle_state = !toggle_state
164
- case iterid
165
- when Columns::REDD then book.redd = toggle_state
166
- when Columns::OWN then book.own = toggle_state
167
- when Columns::WANT then book.want = toggle_state
168
- end
169
- iter[iterid] = toggle_state
170
- lib = @parent.selected_library
171
- lib.save(book)
129
+ renderer.signal_connect("toggled") do |_rndrr, path|
130
+ tree_path = Gtk::TreePath.new(path)
131
+ child_path = @listview_model.convert_path_to_child_path(tree_path)
132
+ if child_path
133
+ unfiltered_path = @filtered_model.convert_path_to_child_path(child_path)
134
+ # FIX this sometimes returns a nil path for iconview...
135
+ if unfiltered_path
136
+ iter = @model.get_iter(unfiltered_path)
137
+ if iter
138
+ book = @parent.book_from_iter(@parent.selected_library, iter)
139
+ toggle_state = case iterid
140
+ when Columns::REDD then book.redd
141
+ when Columns::OWN then book.own
142
+ when Columns::WANT then book.want
143
+ end
144
+ # invert toggle_state
145
+ unless iterid == Columns::WANT && book.own
146
+ toggle_state = !toggle_state
147
+ case iterid
148
+ when Columns::REDD then book.redd = toggle_state
149
+ when Columns::OWN then book.own = toggle_state
150
+ when Columns::WANT then book.want = toggle_state
172
151
  end
152
+ iter[iterid] = toggle_state
153
+ lib = @parent.selected_library
154
+ lib.save(book)
173
155
  end
174
156
  end
175
-
176
157
  end
177
- rescue => e
178
- log.error { "toggle failed for path #{path} #{e}\n" + e.backtrace.join("\n") }
158
+
179
159
  end
160
+ rescue StandardError => ex
161
+ log.error { "toggle failed for path #{path} #{ex}\n" + e.backtrace.join("\n") }
180
162
  end
181
163
  column = Gtk::TreeViewColumn.new(title, renderer, text: iterid)
182
164
  column.sort_column_id = iterid
183
165
  column.resizable = true
184
- log.debug { 'Create listview column for %s...' % title }
166
+ log.debug { format("Create listview column for %s", title) }
185
167
 
186
- column.add_attribute(renderer, 'active', iterid)
168
+ column.add_attribute(renderer, "active", iterid)
187
169
  if iterid == Columns::WANT
188
- column.add_attribute(renderer, 'inconsistent', Columns::OWN)
170
+ column.add_attribute(renderer, "inconsistent", Columns::OWN)
189
171
  end
190
172
 
191
173
  log.debug { "append_column #{column}" }
@@ -193,9 +175,9 @@ module Alexandria
193
175
  end
194
176
 
195
177
  def setup_text_column(title, iterid)
196
- log.debug { 'Create listview column for %s...' % title }
178
+ log.debug { format("Create listview column for %s", title) }
197
179
  renderer = Gtk::CellRendererText.new
198
- renderer.ellipsize = Pango::ELLIPSIZE_END
180
+ renderer.ellipsize = :end
199
181
  column = Gtk::TreeViewColumn.new(title, renderer,
200
182
  text: iterid)
201
183
  column.sort_column_id = iterid
@@ -204,7 +186,7 @@ module Alexandria
204
186
  end
205
187
 
206
188
  def setup_listview_columns_visibility
207
- log.debug { 'setup_listview_columns_visibility' }
189
+ log.debug { "setup_listview_columns_visibility" }
208
190
  # Show or hide list view columns according to the preferences.
209
191
  cols_visibility = [
210
192
  @prefs.col_authors_visible,
@@ -223,7 +205,10 @@ module Alexandria
223
205
  cols.each_index do |i|
224
206
  cols[i].visible = cols_visibility[i]
225
207
  end
226
- log.debug { 'Columns visibility: ' + cols.map { |col| "#{col.title} #{col.visible?}" }.join(', ') }
208
+ log.debug do
209
+ "Columns visibility: " +
210
+ cols.map { |col| "#{col.title} #{col.visible?}" }.join(", ")
211
+ end
227
212
  end
228
213
 
229
214
  # Sets the width of each column based on any respective
@@ -231,19 +216,23 @@ module Alexandria
231
216
  def setup_listview_columns_width
232
217
  log.debug { "setup_listview_columns_width #{@prefs.cols_width}" }
233
218
  if @prefs.cols_width
234
- cols_width = YAML.load(@prefs.cols_width)
219
+ cols_width = YAML.safe_load(@prefs.cols_width)
235
220
  log.debug { "cols_width: #{cols_width.inspect}" }
236
221
  @listview.columns.each do |c|
237
222
  if cols_width.key?(c.title)
238
223
  log.debug { "#{c.title} : #{cols_width[c.title]}" }
239
224
  width = cols_width[c.title]
240
225
  next if width.zero?
226
+
241
227
  c.sizing = :fixed
242
228
  c.fixed_width = width
243
229
  end
244
230
  end
245
231
  end
246
- log.debug { 'Columns width: ' + @listview.columns.map { |col| "#{col.title} #{col.width}" }.join(', ') }
232
+ log.debug do
233
+ "Columns width: " +
234
+ @listview.columns.map { |col| "#{col.title} #{col.width}" }.join(", ")
235
+ end
247
236
  end
248
237
  end
249
238
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
4
  # Copyright (C) 2007 Cathal Mc Ginley
3
5
  # Copyright (C) 2011 Matijs van Zuijlen
@@ -17,43 +19,41 @@
17
19
  # write to the Free Software Foundation, Inc., 51 Franklin Street,
18
20
  # Fifth Floor, Boston, MA 02110-1301 USA.
19
21
 
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'
22
+ require "alexandria/ui/alert_dialog"
23
+ require "alexandria/ui/about_dialog"
24
+ require "alexandria/ui/book_properties_dialog_base"
25
+ require "alexandria/ui/book_properties_dialog"
26
+ require "alexandria/ui/new_book_dialog_manual"
27
+ require "alexandria/ui/new_book_dialog"
28
+ require "alexandria/ui/preferences_dialog"
29
+ require "alexandria/ui/export_dialog"
30
+ require "alexandria/ui/import_dialog"
31
+ require "alexandria/ui/acquire_dialog"
32
+ require "alexandria/ui/smart_library_properties_dialog_base"
33
+ require "alexandria/ui/smart_library_properties_dialog"
34
+ require "alexandria/ui/new_smart_library_dialog"
35
+ require "alexandria/ui/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_manager"
42
42
 
43
43
  module Alexandria
44
44
  module UI
45
45
  include Logging
46
46
  include GetText
47
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
47
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
48
48
 
49
49
  class MainApp
50
50
  include Logging
51
51
  include GetText
52
52
  include Singleton
53
- attr_accessor :main_app, :libraries, :actiongroup, :appbar, :prefs
54
- attr_accessor :ui_manager
53
+ attr_accessor :main_app, :libraries, :actiongroup, :appbar, :prefs, :ui_manager
54
+
55
55
  def initialize
56
- log.info { 'Starting MainApp' }
56
+ log.info { "Starting MainApp" }
57
57
  @ui_manager = UIManager.new self
58
58
  @actiongroup = @ui_manager.actiongroup
59
59
  @appbar = @ui_manager.appbar
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is part of Alexandria.
4
+ #
5
+ # See the file README.md for authorship and licensing information.
6
+
7
+ module Alexandria
8
+ module UI
9
+ end
10
+ end
@@ -1,47 +1,36 @@
1
- # Copyright (C) 2004-2006 Laurent Sansonetti
2
- # Copyright (C) 2011, 2016 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.
1
+ # frozen_string_literal: true
2
+
3
+ # This file is part of Alexandria.
13
4
  #
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.
5
+ # See the file README.md for authorship and licensing information.
18
6
 
19
7
  module Alexandria
20
8
  module EventOverrides
21
- def ==(obj)
22
- obj.is_a?(self.class) && (time == obj.time) && (x == obj.x) && (y == obj.y) && (button == obj.button)
9
+ def ==(other)
10
+ other.is_a?(self.class) &&
11
+ (time == other.time) && (x == other.x) && (y == other.y) &&
12
+ (button == other.button)
23
13
  end
24
14
  end
25
15
 
26
16
  module TreeViewOverrides
27
- # include Alexandria::Logging
28
-
29
- class Context < Struct.new(:pressed_button,
30
- :x,
31
- :y,
32
- :cell_x,
33
- :cell_y,
34
- :button_press_handler,
35
- :motion_notify_handler,
36
- :button_release_handler,
37
- :drag_data_get_handler,
38
- :events,
39
- :source_start_button_mask,
40
- :source_targets,
41
- :source_actions,
42
- :pending_event,
43
- :drag_context)
44
-
17
+ Context = Struct.new(:pressed_button,
18
+ :x,
19
+ :y,
20
+ :cell_x,
21
+ :cell_y,
22
+ :button_press_handler,
23
+ :motion_notify_handler,
24
+ :button_release_handler,
25
+ :drag_data_get_handler,
26
+ :events,
27
+ :source_start_button_mask,
28
+ :source_targets,
29
+ :source_actions,
30
+ :pending_event,
31
+ :drag_context)
32
+
33
+ class Context
45
34
  def initialize(*ary)
46
35
  super
47
36
  self.events ||= []
@@ -61,7 +50,7 @@ module Alexandria
61
50
  @context.source_actions = actions
62
51
 
63
52
  @context.button_press_handler =
64
- signal_connect('button_press_event') do |_widget, event, _data|
53
+ signal_connect("button_press_event") do |_widget, event, _data|
65
54
  button_press_event(event)
66
55
  end
67
56
  end
@@ -74,6 +63,7 @@ module Alexandria
74
63
 
75
64
  def stop_drag_check
76
65
  raise if @context.nil?
66
+
77
67
  @context.events.clear
78
68
  @context.pending_event = false
79
69
  signal_handler_disconnect(@context.motion_notify_handler)
@@ -114,13 +104,12 @@ module Alexandria
114
104
  path, _, cell_x, cell_y = get_path_at_pos(event.x, event.y)
115
105
  return false if path.nil?
116
106
 
117
- # call_parent = (event.state.control_mask? or event.state.shift_mask?) or !selected or event.button != 1
118
107
  (call_parent = !selection.path_is_selected?(path)) ||
119
108
  (event.button != 1)
120
109
 
121
110
  if call_parent
122
111
  signal_handler_block(@context.button_press_handler) do
123
- signal_emit('button_press_event', event)
112
+ signal_emit("button_press_event", event)
124
113
  end
125
114
  end
126
115
 
@@ -132,11 +121,11 @@ module Alexandria
132
121
  @context.cell_x = cell_x
133
122
  @context.cell_y = cell_y
134
123
  @context.motion_notify_handler =
135
- signal_connect('motion_notify_event') do |_widget, evnt, _data|
124
+ signal_connect("motion_notify_event") do |_widget, evnt, _data|
136
125
  motion_notify_event(evnt)
137
126
  end
138
127
  @context.button_release_handler =
139
- signal_connect('button_release_event') do |_widget, evnt, _data|
128
+ signal_connect("button_release_event") do |_widget, evnt, _data|
140
129
  button_release_event(evnt)
141
130
  end
142
131
  @context.events << event unless call_parent