alexandria-book-collection-manager 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +28 -25
  3. data/.rubocop_todo.yml +87 -67
  4. data/CHANGELOG.md +12 -1
  5. data/Gemfile +4 -3
  6. data/README.md +16 -6
  7. data/Rakefile +71 -72
  8. data/alexandria-book-collection-manager.gemspec +44 -44
  9. data/bin/alexandria +12 -12
  10. data/lib/alexandria.rb +22 -22
  11. data/lib/alexandria/about.rb +50 -50
  12. data/lib/alexandria/book_providers.rb +50 -50
  13. data/lib/alexandria/book_providers/adlibris.rb +28 -44
  14. data/lib/alexandria/book_providers/amazon_aws.rb +64 -64
  15. data/lib/alexandria/book_providers/amazon_ecs_util.rb +52 -78
  16. data/lib/alexandria/book_providers/barnes_and_noble.rb +34 -34
  17. data/lib/alexandria/book_providers/douban.rb +21 -37
  18. data/lib/alexandria/book_providers/proxis.rb +24 -24
  19. data/lib/alexandria/book_providers/pseudomarc.rb +19 -19
  20. data/lib/alexandria/book_providers/renaud.rb +44 -57
  21. data/lib/alexandria/book_providers/siciliano.rb +39 -39
  22. data/lib/alexandria/book_providers/thalia.rb +33 -33
  23. data/lib/alexandria/book_providers/web.rb +5 -5
  24. data/lib/alexandria/book_providers/worldcat.rb +44 -69
  25. data/lib/alexandria/book_providers/z3950.rb +94 -109
  26. data/lib/alexandria/config.rb +1 -1
  27. data/lib/alexandria/console.rb +3 -3
  28. data/lib/alexandria/export_format.rb +8 -8
  29. data/lib/alexandria/export_library.rb +112 -113
  30. data/lib/alexandria/import_library.rb +45 -45
  31. data/lib/alexandria/import_library_csv.rb +30 -30
  32. data/lib/alexandria/library_collection.rb +4 -4
  33. data/lib/alexandria/library_sort_order.rb +1 -1
  34. data/lib/alexandria/library_store.rb +14 -14
  35. data/lib/alexandria/logging.rb +5 -5
  36. data/lib/alexandria/models/book.rb +1 -1
  37. data/lib/alexandria/models/library.rb +36 -36
  38. data/lib/alexandria/net.rb +5 -5
  39. data/lib/alexandria/preferences.rb +32 -32
  40. data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +13 -13
  41. data/lib/alexandria/scanners/keyboard.rb +5 -5
  42. data/lib/alexandria/smart_library.rb +53 -53
  43. data/lib/alexandria/ui.rb +15 -15
  44. data/lib/alexandria/ui/{dialogs/about_dialog.rb → about_dialog.rb} +1 -1
  45. data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +66 -65
  46. data/lib/alexandria/ui/{dialogs/alert_dialog.rb → alert_dialog.rb} +1 -16
  47. data/lib/alexandria/ui/{dialogs/bad_isbns_dialog.rb → bad_isbns_dialog.rb} +0 -0
  48. data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +7 -7
  49. data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +25 -37
  50. data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +38 -37
  51. data/lib/alexandria/ui/builder_base.rb +1 -1
  52. data/lib/alexandria/ui/callbacks.rb +95 -91
  53. data/lib/alexandria/ui/completion_models.rb +7 -21
  54. data/lib/alexandria/ui/confirm_erase_dialog.rb +33 -0
  55. data/lib/alexandria/ui/conflict_while_copying_dialog.rb +34 -0
  56. data/lib/alexandria/ui/dndable.rb +7 -7
  57. data/lib/alexandria/ui/error_dialog.rb +25 -0
  58. data/lib/alexandria/ui/{dialogs/export_dialog.rb → export_dialog.rb} +22 -42
  59. data/lib/alexandria/ui/icons.rb +6 -6
  60. data/lib/alexandria/ui/iconview.rb +7 -7
  61. data/lib/alexandria/ui/iconview_tooltips.rb +6 -6
  62. data/lib/alexandria/ui/{dialogs/import_dialog.rb → import_dialog.rb} +14 -32
  63. data/lib/alexandria/ui/init.rb +16 -29
  64. data/lib/alexandria/ui/{dialogs/keep_bad_isbn_dialog.rb → keep_bad_isbn_dialog.rb} +6 -4
  65. data/lib/alexandria/ui/libraries_combo.rb +7 -7
  66. data/lib/alexandria/ui/listview.rb +40 -40
  67. data/lib/alexandria/ui/main_app.rb +22 -24
  68. data/lib/alexandria/ui/misc_dialogs.rb +10 -0
  69. data/lib/alexandria/ui/multi_drag_treeview.rb +4 -4
  70. data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +46 -45
  71. data/lib/alexandria/ui/{dialogs/new_book_dialog_manual.rb → new_book_dialog_manual.rb} +20 -19
  72. data/lib/alexandria/ui/new_provider_dialog.rb +99 -0
  73. data/lib/alexandria/ui/{dialogs/new_smart_library_dialog.rb → new_smart_library_dialog.rb} +4 -4
  74. data/lib/alexandria/ui/{dialogs/preferences_dialog.rb → preferences_dialog.rb} +44 -235
  75. data/lib/alexandria/ui/provider_preferences_base_dialog.rb +90 -0
  76. data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
  77. data/lib/alexandria/ui/{dialogs/misc_dialogs.rb → really_delete_dialog.rb} +6 -27
  78. data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +27 -25
  79. data/lib/alexandria/ui/skip_entry_dialog.rb +32 -0
  80. data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog.rb → smart_library_properties_dialog.rb} +2 -2
  81. data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog_base.rb → smart_library_properties_dialog_base.rb} +30 -30
  82. data/lib/alexandria/ui/sound.rb +8 -8
  83. data/lib/alexandria/ui/ui_manager.rb +136 -135
  84. data/lib/alexandria/version.rb +4 -19
  85. data/lib/alexandria/web_themes.rb +8 -8
  86. data/po/cs.po +97 -97
  87. data/po/cy.po +97 -97
  88. data/po/de.po +97 -97
  89. data/po/el.po +97 -97
  90. data/po/es.po +97 -97
  91. data/po/fr.po +97 -97
  92. data/po/ga.po +97 -97
  93. data/po/gl.po +97 -97
  94. data/po/it.po +97 -97
  95. data/po/ja.po +97 -97
  96. data/po/mk.po +97 -97
  97. data/po/nb.po +97 -97
  98. data/po/nl.po +97 -97
  99. data/po/pl.po +97 -97
  100. data/po/pt.po +97 -97
  101. data/po/pt_BR.po +97 -97
  102. data/po/ru.po +97 -97
  103. data/po/sk.po +97 -97
  104. data/po/sv.po +97 -97
  105. data/po/uk.po +97 -97
  106. data/po/zh_TW.po +97 -97
  107. data/schemas/alexandria.schemas +24 -2
  108. data/spec/alexandria/book_providers_spec.rb +65 -82
  109. data/spec/alexandria/book_spec.rb +12 -10
  110. data/spec/alexandria/console_spec.rb +9 -9
  111. data/spec/alexandria/export_library_spec.rb +31 -31
  112. data/spec/alexandria/library_spec.rb +86 -86
  113. data/spec/alexandria/library_store_spec.rb +8 -8
  114. data/spec/alexandria/preferences_spec.rb +18 -17
  115. data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
  116. data/spec/alexandria/smart_library_spec.rb +15 -15
  117. data/spec/alexandria/ui/about_dialog_spec.rb +14 -0
  118. data/spec/alexandria/ui/acquire_dialog_spec.rb +14 -0
  119. data/spec/alexandria/ui/alert_dialog_spec.rb +16 -0
  120. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +14 -0
  121. data/spec/alexandria/ui/book_properties_dialog_spec.rb +17 -0
  122. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +14 -0
  123. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +16 -0
  124. data/spec/alexandria/ui/error_dialog_spec.rb +14 -0
  125. data/spec/alexandria/ui/export_dialog_spec.rb +15 -0
  126. data/spec/alexandria/ui/iconview_spec.rb +7 -21
  127. data/spec/alexandria/ui/import_dialog_spec.rb +14 -0
  128. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
  129. data/spec/alexandria/ui/main_app_spec.rb +6 -6
  130. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +15 -0
  131. data/spec/alexandria/ui/{dialogs/new_book_dialog_spec.rb → new_book_dialog_spec.rb} +4 -4
  132. data/spec/alexandria/ui/new_provider_dialog_spec.rb +14 -0
  133. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +14 -0
  134. data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
  135. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +19 -0
  136. data/spec/alexandria/ui/really_delete_dialog_spec.rb +15 -0
  137. data/spec/alexandria/ui/sidepane_manager_spec.rb +15 -0
  138. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +14 -0
  139. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +18 -0
  140. data/spec/alexandria/ui/sound_spec.rb +2 -2
  141. data/spec/alexandria/ui/ui_manager_spec.rb +6 -20
  142. data/spec/alexandria/ui/ui_utilities_spec.rb +9 -9
  143. data/spec/alexandria/utilities_spec.rb +6 -6
  144. data/spec/end_to_end/basic_run_spec.rb +24 -36
  145. data/spec/spec_helper.rb +9 -9
  146. data/tasks/dogtail.rake +1 -1
  147. data/tasks/setup.rb +2 -2
  148. data/tasks/spec.rake +11 -11
  149. data/util/rake/fileinstall.rb +25 -25
  150. data/util/rake/gettextgenerate.rb +7 -7
  151. data/util/rake/omfgenerate.rb +7 -7
  152. metadata +59 -33
  153. data/spec/alexandria/scanners/cuecat_spec.rb +0 -67
  154. data/spec/alexandria/ui/dialogs_spec.rb +0 -162
  155. data/spec/alexandria/ui/sidepane_spec.rb +0 -29
@@ -22,7 +22,7 @@
22
22
  # Boston, MA 02110-1301 USA.
23
23
  #++
24
24
 
25
- require 'gst'
25
+ require "gst"
26
26
 
27
27
  module Alexandria
28
28
  module UI
@@ -48,11 +48,11 @@ module Alexandria
48
48
  end
49
49
 
50
50
  def set_up_pipeline
51
- @filesrc = Gst::ElementFactory.make('filesrc')
52
- demuxer = Gst::ElementFactory.make('oggdemux')
53
- decoder = Gst::ElementFactory.make('vorbisdec')
54
- converter = Gst::ElementFactory.make('audioconvert') # #??
55
- audiosink = Gst::ElementFactory.make('autoaudiosink')
51
+ @filesrc = Gst::ElementFactory.make("filesrc")
52
+ demuxer = Gst::ElementFactory.make("oggdemux")
53
+ decoder = Gst::ElementFactory.make("vorbisdec")
54
+ converter = Gst::ElementFactory.make("audioconvert") # #??
55
+ audiosink = Gst::ElementFactory.make("autoaudiosink")
56
56
 
57
57
  @ogg_vorbis_pipeline.add(@filesrc, demuxer, decoder,
58
58
  converter, audiosink)
@@ -61,7 +61,7 @@ module Alexandria
61
61
  # this next must be a dynamic link, as demuxers potentially
62
62
  # have multiple src pads (for audio/video muxed streams)
63
63
 
64
- demuxer.signal_connect('pad-added') do |_parser, ogg_src_pad|
64
+ demuxer.signal_connect("pad-added") do |_parser, ogg_src_pad|
65
65
  vorbis_sink_pad = decoder.sinkpads.first
66
66
  ogg_src_pad.link(vorbis_sink_pad)
67
67
  end
@@ -77,7 +77,7 @@ module Alexandria
77
77
  stop_playback
78
78
  when Gst::MessageType::ERROR
79
79
  if $DEBUG
80
- puts 'ERROR loop.quit'
80
+ puts "ERROR loop.quit"
81
81
  p message.parse
82
82
  end
83
83
  stop_playback
@@ -4,9 +4,10 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require 'alexandria/ui/callbacks'
8
- require 'alexandria/ui/columns'
9
- require 'alexandria/library_sort_order'
7
+ require "alexandria/ui/callbacks"
8
+ require "alexandria/ui/columns"
9
+ require "alexandria/ui/conflict_while_copying_dialog"
10
+ require "alexandria/library_sort_order"
10
11
 
11
12
  module Alexandria
12
13
  module UI
@@ -16,10 +17,10 @@ module Alexandria
16
17
  attr_reader :model
17
18
  include Logging
18
19
  include GetText
19
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
20
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
20
21
 
21
22
  def initialize(parent)
22
- super('main_app__builder.glade', widget_names)
23
+ super("main_app__builder.glade", widget_names)
23
24
  @parent = parent
24
25
 
25
26
  @library_separator_iter = nil
@@ -47,7 +48,7 @@ module Alexandria
47
48
  log.debug { "UI Manager initialized: #{@iconview.model.inspect}" }
48
49
  @clicking_on_sidepane = true
49
50
 
50
- @library_listview.signal_connect('cursor-changed') do
51
+ @library_listview.signal_connect("cursor-changed") do
51
52
  @clicking_on_sidepane = true
52
53
  end
53
54
  end
@@ -63,14 +64,14 @@ module Alexandria
63
64
  end
64
65
 
65
66
  def create_uimanager
66
- log.debug { 'Adding actiongroup to uimanager' }
67
+ log.debug { "Adding actiongroup to uimanager" }
67
68
  @uimanager = Gtk::UIManager.new
68
69
  @uimanager.insert_action_group(@actiongroup, 0)
69
70
  end
70
71
 
71
72
  def setup_dependents
72
- @listview_model = Gtk::TreeModelSort.new(model: @filtered_model)
73
- @iconview_model = Gtk::TreeModelSort.new(model: @filtered_model)
73
+ @listview_model = Gtk::TreeModelSort.new(@filtered_model)
74
+ @iconview_model = Gtk::TreeModelSort.new(@filtered_model)
74
75
  @listview_manager = ListViewManager.new @listview, self
75
76
  @iconview_manager = IconViewManager.new @iconview, self
76
77
  @sidepane_manager = SidePaneManager.new @library_listview, self
@@ -89,10 +90,10 @@ module Alexandria
89
90
  end
90
91
 
91
92
  def setup_toolbar
92
- log.debug { 'setup_toolbar' }
93
+ log.debug { "setup_toolbar" }
93
94
  setup_book_providers
94
95
  add_main_toolbar_items
95
- @toolbar = @uimanager.get_widget('/MainToolbar')
96
+ @toolbar = @uimanager.get_widget("/MainToolbar")
96
97
  @toolbar.show_arrow = true
97
98
  @toolbar.insert(Gtk::SeparatorToolItem.new, -1)
98
99
  setup_toolbar_combobox
@@ -100,18 +101,18 @@ module Alexandria
100
101
  @toolbar.insert(Gtk::SeparatorToolItem.new, -1)
101
102
  setup_toolbar_viewas
102
103
  @toolbar.show_all
103
- @actiongroup['Undo'].sensitive = @actiongroup['Redo'].sensitive = false
104
+ @actiongroup["Undo"].sensitive = @actiongroup["Redo"].sensitive = false
104
105
  UndoManager.instance.add_observer(self)
105
106
  @vbox1.add(@toolbar, position: 1, expand: false, fill: false)
106
107
  end
107
108
 
108
109
  def add_main_toolbar_items
109
110
  mid = @uimanager.new_merge_id
110
- @uimanager.add_ui(mid, 'ui/', 'MainToolbar', 'MainToolbar',
111
+ @uimanager.add_ui(mid, "ui/", "MainToolbar", "MainToolbar",
111
112
  :toolbar, false)
112
- @uimanager.add_ui(mid, 'ui/MainToolbar/', 'New', 'New',
113
+ @uimanager.add_ui(mid, "ui/MainToolbar/", "New", "New",
113
114
  :toolitem, false)
114
- @uimanager.add_ui(mid, 'ui/MainToolbar/', 'AddBook', 'AddBook',
115
+ @uimanager.add_ui(mid, "ui/MainToolbar/", "AddBook", "AddBook",
115
116
  :toolitem, false)
116
117
  # @uimanager.add_ui(mid, "ui/MainToolbar/", "sep", "sep",
117
118
  # :separator, false)
@@ -121,11 +122,11 @@ module Alexandria
121
122
 
122
123
  def setup_toolbar_filter_entry
123
124
  @filter_entry = Gtk::Entry.new
124
- @filter_entry.signal_connect('changed', &method(:on_toolbar_filter_entry_changed))
125
+ @filter_entry.signal_connect("changed", &method(:on_toolbar_filter_entry_changed))
125
126
  @toolitem = Gtk::ToolItem.new
126
127
  @toolitem.expand = true
127
128
  @toolitem.border_width = 5
128
- @filter_entry.set_tooltip_text _('Type here the search criterion')
129
+ @filter_entry.set_tooltip_text _("Type here the search criterion")
129
130
  @toolitem << @filter_entry
130
131
  @toolbar.insert(@toolitem, -1)
131
132
  end
@@ -134,20 +135,20 @@ module Alexandria
134
135
  cb = Gtk::ComboBoxText.new
135
136
  cb.set_row_separator_func do |model, iter|
136
137
  # TODO: Replace with iter[0] if possible
137
- model.get_value(iter, 0) == '-'
138
+ model.get_value(iter, 0) == "-"
138
139
  end
139
- [_('Match everything'),
140
- '-',
141
- _('Title contains'),
142
- _('Authors contain'),
143
- _('ISBN contains'),
144
- _('Publisher contains'),
145
- _('Notes contain'),
146
- _('Tags contain')].each do |item|
140
+ [_("Match everything"),
141
+ "-",
142
+ _("Title contains"),
143
+ _("Authors contain"),
144
+ _("ISBN contains"),
145
+ _("Publisher contains"),
146
+ _("Notes contain"),
147
+ _("Tags contain")].each do |item|
147
148
  cb.append_text(item)
148
149
  end
149
150
  cb.active = 0
150
- cb.signal_connect('changed', &method(:on_criterion_combobox_changed))
151
+ cb.signal_connect("changed", &method(:on_criterion_combobox_changed))
151
152
 
152
153
  # Put the combo box in a event box because it is not currently
153
154
  # possible assign a tooltip to a combo box.
@@ -157,16 +158,16 @@ module Alexandria
157
158
  @toolitem.border_width = 5
158
159
  @toolitem << eb
159
160
  @toolbar.insert(@toolitem, -1)
160
- eb.set_tooltip_text _('Change the search type')
161
+ eb.set_tooltip_text _("Change the search type")
161
162
  end
162
163
 
163
164
  def setup_toolbar_viewas
164
165
  @toolbar_view_as = Gtk::ComboBoxText.new
165
- @toolbar_view_as.append_text(_('View as Icons'))
166
- @toolbar_view_as.append_text(_('View as List'))
166
+ @toolbar_view_as.append_text(_("View as Icons"))
167
+ @toolbar_view_as.append_text(_("View as List"))
167
168
  @toolbar_view_as.active = 0
168
169
  @toolbar_view_as_signal_hid = \
169
- @toolbar_view_as.signal_connect('changed', &method(:on_toolbar_view_as_changed))
170
+ @toolbar_view_as.signal_connect("changed", &method(:on_toolbar_view_as_changed))
170
171
 
171
172
  # Put the combo box in a event box because it is not currently
172
173
  # possible assign a tooltip to a combo box.
@@ -176,17 +177,17 @@ module Alexandria
176
177
  @toolitem.border_width = 5
177
178
  @toolitem << eb
178
179
  @toolbar.insert(@toolitem, -1)
179
- eb.set_tooltip_text _('Choose how to show books')
180
+ eb.set_tooltip_text _("Choose how to show books")
180
181
  end
181
182
 
182
183
  def setup_book_providers
183
- log.debug { 'setup_book_providers' }
184
+ log.debug { "setup_book_providers" }
184
185
  mid = @uimanager.new_merge_id
185
186
  BookProviders.each do |provider|
186
187
  name = provider.action_name
187
- ['ui/MainMenubar/ViewMenu/OnlineInformation/',
188
- 'ui/BookPopup/OnlineInformation/',
189
- 'ui/NoBookPopup/OnlineInformation/'].each do |path|
188
+ ["ui/MainMenubar/ViewMenu/OnlineInformation/",
189
+ "ui/BookPopup/OnlineInformation/",
190
+ "ui/NoBookPopup/OnlineInformation/"].each do |path|
190
191
  log.debug { "Adding #{name} to #{path}" }
191
192
  @uimanager.add_ui(mid, path, name, name,
192
193
  :menuitem, false)
@@ -195,40 +196,40 @@ module Alexandria
195
196
  end
196
197
 
197
198
  def add_menus_and_popups_from_xml
198
- log.debug { 'add_menus_and_popups_from_xml' }
199
- ['menus.xml', 'popups.xml'].each do |ui_file|
199
+ log.debug { "add_menus_and_popups_from_xml" }
200
+ ["menus.xml", "popups.xml"].each do |ui_file|
200
201
  @uimanager.add_ui(File.join(Alexandria::Config::DATA_DIR,
201
- 'ui', ui_file))
202
+ "ui", ui_file))
202
203
  end
203
204
  end
204
205
 
205
206
  def setup_accel_group
206
- log.debug { 'setup_accel_group' }
207
+ log.debug { "setup_accel_group" }
207
208
  @main_app.add_accel_group(@uimanager.accel_group)
208
209
  end
209
210
 
210
211
  def setup_menus
211
- @menubar = @uimanager.get_widget('/MainMenubar')
212
+ @menubar = @uimanager.get_widget("/MainMenubar")
212
213
  @vbox1.add(@menubar, position: 0, expand: false, fill: false)
213
214
  end
214
215
 
215
216
  def setup_popups
216
- log.debug { 'setup_popups' }
217
- @library_popup = @uimanager.get_widget('/LibraryPopup')
218
- @smart_library_popup = @uimanager.get_widget('/SmartLibraryPopup')
219
- @nolibrary_popup = @uimanager.get_widget('/NoLibraryPopup')
220
- @book_popup = @uimanager.get_widget('/BookPopup')
221
- @nobook_popup = @uimanager.get_widget('/NoBookPopup')
217
+ log.debug { "setup_popups" }
218
+ @library_popup = @uimanager.get_widget("/LibraryPopup")
219
+ @smart_library_popup = @uimanager.get_widget("/SmartLibraryPopup")
220
+ @nolibrary_popup = @uimanager.get_widget("/NoLibraryPopup")
221
+ @book_popup = @uimanager.get_widget("/BookPopup")
222
+ @nobook_popup = @uimanager.get_widget("/NoBookPopup")
222
223
  end
223
224
 
224
225
  def setup_window_events
225
- log.debug { 'setup_window_events' }
226
- @main_app.signal_connect('window-state-event', &method(:on_window_state_event))
227
- @main_app.signal_connect('destroy', &method(:on_window_destroy))
226
+ log.debug { "setup_window_events" }
227
+ @main_app.signal_connect("window-state-event", &method(:on_window_state_event))
228
+ @main_app.signal_connect("destroy", &method(:on_window_destroy))
228
229
  end
229
230
 
230
231
  def setup_active_model
231
- log.debug { 'setting up active model' }
232
+ log.debug { "setting up active model" }
232
233
  # The active model.
233
234
 
234
235
  list = [
@@ -263,13 +264,13 @@ module Alexandria
263
264
  true
264
265
  else
265
266
  data = case @filter_books_mode
266
- when 0 then
267
- (iter[Columns::TITLE] || '') +
268
- (iter[Columns::AUTHORS] || '') +
269
- (iter[Columns::ISBN] || '') +
270
- (iter[Columns::PUBLISHER] || '') +
271
- (iter[Columns::NOTES] || '') +
272
- (iter[Columns::TAGS] || '')
267
+ when 0
268
+ (iter[Columns::TITLE] || "") +
269
+ (iter[Columns::AUTHORS] || "") +
270
+ (iter[Columns::ISBN] || "") +
271
+ (iter[Columns::PUBLISHER] || "") +
272
+ (iter[Columns::NOTES] || "") +
273
+ (iter[Columns::TAGS] || "")
273
274
  when 2 then iter[Columns::TITLE]
274
275
  when 3 then iter[Columns::AUTHORS]
275
276
  when 4 then iter[Columns::ISBN]
@@ -283,15 +284,15 @@ module Alexandria
283
284
 
284
285
  # Give filter entry the initial keyboard focus.
285
286
  @filter_entry.grab_focus
286
- log.debug { 'done setting up active model' }
287
+ log.debug { "done setting up active model" }
287
288
  end
288
289
 
289
290
  def on_library_button_press_event(widget, event)
290
- log.debug { 'library_button_press_event' }
291
+ log.debug { "library_button_press_event" }
291
292
 
292
293
  # right click
293
294
  if event_is_right_click event
294
- log.debug { 'library right click!' }
295
+ log.debug { "library right click!" }
295
296
  library_already_selected = true
296
297
  if (path = widget.get_path_at_pos(event.x, event.y))
297
298
  @clicking_on_sidepane = true
@@ -367,7 +368,7 @@ module Alexandria
367
368
  end
368
369
 
369
370
  def on_books_button_press_event(widget, event)
370
- log.debug { 'books_button_press_event' }
371
+ log.debug { "books_button_press_event" }
371
372
  if event_is_right_click event
372
373
  widget.grab_focus
373
374
 
@@ -405,9 +406,9 @@ module Alexandria
405
406
  library.length), library.name, library.length)
406
407
  else
407
408
  format(n_("Library '%s' selected, %d book, " \
408
- '%d unrated',
409
+ "%d unrated",
409
410
  "Library '%s' selected, %d books, " \
410
- '%d unrated',
411
+ "%d unrated",
411
412
  library.length), library.name, library.length, n_unrated)
412
413
  end
413
414
  end
@@ -420,7 +421,7 @@ module Alexandria
420
421
  when 1
421
422
  _("'%s' selected") % books.first.title
422
423
  else
423
- n_('%d book selected', '%d books selected',
424
+ n_("%d book selected", "%d books selected",
424
425
  books.length) % books.length
425
426
  end
426
427
  end
@@ -440,28 +441,28 @@ module Alexandria
440
441
 
441
442
  log.debug { "Currently focused widget: #{@main_app.focus.inspect}" }
442
443
  log.debug { "#{@library_listview} : #{@library_popup} : #{@listview}" }
443
- log.debug {
444
+ log.debug do
444
445
  "@library_listview: #{@library_listview.has_focus?} " \
445
446
  "or @library_popup:#{@library_popup.has_focus?}"
446
- }
447
- log.debug { '@library_listview does *NOT* have focus' }
447
+ end
448
+ log.debug { "@library_listview does *NOT* have focus" }
448
449
  log.debug { "Books are empty: #{books.empty?}" }
449
- @actiongroup['Properties'].sensitive = \
450
- @actiongroup['OnlineInformation'].sensitive = \
450
+ @actiongroup["Properties"].sensitive = \
451
+ @actiongroup["OnlineInformation"].sensitive = \
451
452
  books.length == 1
452
- @actiongroup['SelectAll'].sensitive = \
453
+ @actiongroup["SelectAll"].sensitive = \
453
454
  books.length < library.length
454
455
 
455
- @actiongroup['Delete'].sensitive = \
456
- @actiongroup['DeselectAll'].sensitive = \
457
- @actiongroup['Move'].sensitive =
458
- @actiongroup['SetRating'].sensitive = !books.empty?
456
+ @actiongroup["Delete"].sensitive = \
457
+ @actiongroup["DeselectAll"].sensitive = \
458
+ @actiongroup["Move"].sensitive =
459
+ @actiongroup["SetRating"].sensitive = !books.empty?
459
460
 
460
461
  log.debug { "on_books_selection_changed Delete: #{@actiongroup['Delete'].sensitive?}" }
461
462
 
462
463
  if library.is_a?(SmartLibrary)
463
- @actiongroup['Delete'].sensitive =
464
- @actiongroup['Move'].sensitive = false
464
+ @actiongroup["Delete"].sensitive =
465
+ @actiongroup["Move"].sensitive = false
465
466
  end
466
467
 
467
468
  # Sensitize providers URL
@@ -479,27 +480,27 @@ module Alexandria
479
480
  @actiongroup[provider.action_name].sensitive = !has_no_url
480
481
  no_urls = false unless has_no_url
481
482
  end
482
- @actiongroup['OnlineInformation'].sensitive = false if no_urls
483
+ @actiongroup["OnlineInformation"].sensitive = false if no_urls
483
484
  end
484
485
  end
485
486
  @clicking_on_sidepane = false
486
487
  end
487
488
 
488
489
  def on_switch_page(_notebook, _page, page_num)
489
- log.debug { 'on_switch_page' }
490
- @actiongroup['ArrangeIcons'].sensitive = page_num.zero?
490
+ log.debug { "on_switch_page" }
491
+ @actiongroup["ArrangeIcons"].sensitive = page_num.zero?
491
492
  on_books_selection_changed
492
493
  end
493
494
 
494
495
  def on_focus(widget, _event_focus)
495
496
  if @clicking_on_sidepane || (widget == @library_listview)
496
- log.debug { 'on_focus: @library_listview' }
497
+ log.debug { "on_focus: @library_listview" }
497
498
  GLib::Idle.add do
498
499
  %w(OnlineInformation SelectAll DeselectAll).each do |action|
499
500
  @actiongroup[action].sensitive = false
500
501
  end
501
- @actiongroup['Properties'].sensitive = selected_library.is_a?(SmartLibrary)
502
- @actiongroup['Delete'].sensitive = determine_delete_option
502
+ @actiongroup["Properties"].sensitive = selected_library.is_a?(SmartLibrary)
503
+ @actiongroup["Delete"].sensitive = determine_delete_option
503
504
  false
504
505
  end
505
506
  else
@@ -513,8 +514,8 @@ module Alexandria
513
514
  end
514
515
 
515
516
  def on_close_sidepane
516
- log.debug { 'on_close_sidepane' }
517
- @actiongroup['Sidepane'].active = false
517
+ log.debug { "on_close_sidepane" }
518
+ @actiongroup["Sidepane"].active = false
518
519
  end
519
520
 
520
521
  def select_a_book(book)
@@ -533,9 +534,9 @@ module Alexandria
533
534
  selection.select_path(path)
534
535
  end
535
536
  begin
536
- log.debug { 'select_a_book: listview' }
537
+ log.debug { "select_a_book: listview" }
537
538
  select_this_book.call(book, @listview)
538
- log.debug { 'select_a_book: listview' }
539
+ log.debug { "select_a_book: listview" }
539
540
  select_this_book.call(book, @iconview)
540
541
  rescue StandardError => ex
541
542
  trace = ex.backtrace.join("\n> ")
@@ -548,12 +549,12 @@ module Alexandria
548
549
  log.debug { "on_update #{ary}" }
549
550
  caller = ary.first
550
551
  if caller.is_a?(UndoManager)
551
- @actiongroup['Undo'].sensitive = caller.can_undo?
552
- @actiongroup['Redo'].sensitive = caller.can_redo?
552
+ @actiongroup["Undo"].sensitive = caller.can_undo?
553
+ @actiongroup["Redo"].sensitive = caller.can_redo?
553
554
  elsif caller.is_a?(Library)
554
555
  handle_update_caller_library ary unless caller.updating?
555
556
  else
556
- raise 'unrecognized update event'
557
+ raise "unrecognized update event"
557
558
  end
558
559
  end
559
560
 
@@ -583,14 +584,14 @@ module Alexandria
583
584
 
584
585
  def open_web_browser(url)
585
586
  if url.nil?
586
- log.warn('Attempt to open browser with nil url')
587
+ log.warn("Attempt to open browser with nil url")
587
588
  return
588
589
  end
589
590
  Gtk.show_uri url
590
591
  end
591
592
 
592
593
  def detach_old_libraries
593
- log.debug { 'Un-observing old libraries' }
594
+ log.debug { "Un-observing old libraries" }
594
595
  @libraries.all_regular_libraries.each do |library|
595
596
  if library.is_a?(Library)
596
597
  library.delete_observer(self)
@@ -600,7 +601,7 @@ module Alexandria
600
601
  end
601
602
 
602
603
  def load_libraries
603
- log.info { 'Loading libraries...' }
604
+ log.info { "Loading libraries..." }
604
605
  @completion_models = CompletionModels.instance
605
606
  if @libraries
606
607
  detach_old_libraries
@@ -618,17 +619,17 @@ module Alexandria
618
619
 
619
620
  def handle_ruined_books
620
621
  new_message = _(
621
- 'The data files for the following books are malformed or empty. Do you wish to' \
622
+ "The data files for the following books are malformed or empty. Do you wish to" \
622
623
  " attempt to download new information for them from the online book providers?\n")
623
624
 
624
- @libraries.ruined_books.each { |bi|
625
+ @libraries.ruined_books.each do |bi|
625
626
  new_message += "\n#{bi[1] || bi[1].inspect}"
626
- }
627
+ end
627
628
  recovery_dialog = Gtk::MessageDialog.new(@main_app, Gtk::Dialog::MODAL,
628
629
  Gtk::MessageDialog::WARNING,
629
630
  Gtk::MessageDialog::BUTTONS_OK_CANCEL,
630
631
  new_message).show
631
- recovery_dialog.signal_connect('response') do |_dialog, response_type|
632
+ recovery_dialog.signal_connect("response") do |_dialog, response_type|
632
633
  recovery_dialog.destroy
633
634
  if response_type == Gtk::ResponseType::OK
634
635
  # progress indicator...
@@ -688,7 +689,7 @@ module Alexandria
688
689
  ## Hide the progress bar.
689
690
  @appbar.children.first.visible = false
690
691
  ## Refresh the status bar.
691
- set_status_label('')
692
+ set_status_label("")
692
693
  # on_books_selection_changed
693
694
  false
694
695
  end
@@ -713,22 +714,22 @@ module Alexandria
713
714
  iter[Columns::TITLE] = book.title
714
715
  title = book.title.sub(REDUCE_TITLE_REGEX, '\1...')
715
716
  iter[Columns::TITLE_REDUCED] = title
716
- iter[Columns::AUTHORS] = book.authors.join(', ')
717
+ iter[Columns::AUTHORS] = book.authors.join(", ")
717
718
  iter[Columns::ISBN] = book.isbn.to_s
718
719
  iter[Columns::PUBLISHER] = book.publisher
719
720
  iter[Columns::PUBLISH_DATE] = book.publishing_year.to_s
720
721
  iter[Columns::EDITION] = book.edition
721
- iter[Columns::NOTES] = (book.notes || '')
722
- iter[Columns::LOANED_TO] = (book.loaned_to || '')
722
+ iter[Columns::NOTES] = (book.notes || "")
723
+ iter[Columns::LOANED_TO] = (book.loaned_to || "")
723
724
  rating = (book.rating || Book::DEFAULT_RATING)
724
725
  iter[Columns::RATING] = Book::MAX_RATING_STARS - rating # ascending order is the default
725
726
  iter[Columns::OWN] = book.own?
726
727
  iter[Columns::REDD] = book.redd?
727
728
  iter[Columns::WANT] = book.want?
728
729
  iter[Columns::TAGS] = if book.tags
729
- book.tags.join(',')
730
+ book.tags.join(",")
730
731
  else
731
- ''
732
+ ""
732
733
  end
733
734
 
734
735
  icon = Icons.cover(selected_library, book)
@@ -742,7 +743,7 @@ module Alexandria
742
743
  end
743
744
  icon = icon.tag(Icons::FAVORITE_TAG) if rating == Book::MAX_RATING_STARS
744
745
  iter[Columns::COVER_ICON] = icon
745
- log.debug { 'Full iter: ' + (0..15).map { |num| iter[num].inspect }.join(', ') }
746
+ log.debug { "Full iter: " + (0..15).map { |num| iter[num].inspect }.join(", ") }
746
747
  end
747
748
 
748
749
  def append_book(book, _tail = nil)
@@ -752,7 +753,7 @@ module Alexandria
752
753
  if iter
753
754
  fill_iter_with_book(iter, book)
754
755
  else
755
- log.debug { '@model.append' }
756
+ log.debug { "@model.append" }
756
757
  iter = @model.append
757
758
  fill_iter_with_book(iter, book)
758
759
  log.debug { "no iter for book #{book}" }
@@ -789,13 +790,13 @@ module Alexandria
789
790
  @library_listview.set_cursor(iter.path,
790
791
  @library_listview.get_column(0),
791
792
  true)
792
- @actiongroup['Sidepane'].active = true
793
+ @actiongroup["Sidepane"].active = true
793
794
  end
794
795
  iter
795
796
  end
796
797
 
797
798
  def append_library_separator
798
- log.debug { 'append_library_separator' }
799
+ log.debug { "append_library_separator" }
799
800
  iter = @library_listview.model.append
800
801
  iter[0] = nil
801
802
  iter[1] = nil
@@ -805,7 +806,7 @@ module Alexandria
805
806
  end
806
807
 
807
808
  def refresh_books
808
- log.debug { 'refresh_books' }
809
+ log.debug { "refresh_books" }
809
810
  @library_listview.set_sensitive(false)
810
811
  library = selected_library
811
812
  @iconview.freeze
@@ -851,7 +852,7 @@ module Alexandria
851
852
  end
852
853
 
853
854
  def selected_library
854
- log.debug { 'selected_library' }
855
+ log.debug { "selected_library" }
855
856
  if (iter = @library_listview.selection.selected)
856
857
  target_name = iter[1]
857
858
  @libraries.all_libraries.find { |it| it.name == target_name }
@@ -923,11 +924,11 @@ module Alexandria
923
924
  end
924
925
 
925
926
  def refresh_libraries
926
- log.debug { 'refresh_libraries' }
927
+ log.debug { "refresh_libraries" }
927
928
  library = selected_library
928
929
 
929
930
  # Change the application's title.
930
- @main_app.title = library.name + ' - ' + TITLE
931
+ @main_app.title = library.name + " - " + TITLE
931
932
 
932
933
  # Disable the selected library in the move libraries actions.
933
934
  @libraries.all_regular_libraries.each do |i_library|
@@ -941,11 +942,11 @@ module Alexandria
941
942
  smart = library.is_a?(SmartLibrary)
942
943
  log.debug { "sensitize_library: smartlibrary = #{smart}" }
943
944
  GLib::Idle.add do
944
- @actiongroup['AddBook'].sensitive = !smart
945
- @actiongroup['AddBookManual'].sensitive = !smart
946
- @actiongroup['Properties'].sensitive = smart
945
+ @actiongroup["AddBook"].sensitive = !smart
946
+ @actiongroup["AddBookManual"].sensitive = !smart
947
+ @actiongroup["Properties"].sensitive = smart
947
948
  can_delete = smart || (@libraries.all_regular_libraries.length > 1)
948
- @actiongroup['Delete'].sensitive = can_delete
949
+ @actiongroup["Delete"].sensitive = can_delete
949
950
  log.debug { "sensitize_library delete: #{@actiongroup['Delete'].sensitive?}" }
950
951
  false
951
952
  end
@@ -954,14 +955,14 @@ module Alexandria
954
955
  def get_view_actiongroup
955
956
  case @prefs.view_as
956
957
  when 0
957
- @actiongroup['AsIcons']
958
+ @actiongroup["AsIcons"]
958
959
  when 1
959
- @actiongroup['AsList']
960
+ @actiongroup["AsList"]
960
961
  end
961
962
  end
962
963
 
963
964
  def restore_preferences
964
- log.debug { 'Restoring preferences...' }
965
+ log.debug { "Restoring preferences..." }
965
966
  if @prefs.maximized
966
967
  @main_app.maximize
967
968
  else
@@ -970,9 +971,9 @@ module Alexandria
970
971
  @maximized = false
971
972
  end
972
973
  @paned.position = @prefs.sidepane_position
973
- @actiongroup['Sidepane'].active = @prefs.sidepane_visible
974
- @actiongroup['Toolbar'].active = @prefs.toolbar_visible
975
- @actiongroup['Statusbar'].active = @prefs.statusbar_visible
974
+ @actiongroup["Sidepane"].active = @prefs.sidepane_visible
975
+ @actiongroup["Toolbar"].active = @prefs.toolbar_visible
976
+ @actiongroup["Statusbar"].active = @prefs.statusbar_visible
976
977
  @appbar.visible = @prefs.statusbar_visible
977
978
  action = get_view_actiongroup
978
979
  action.activate
@@ -996,29 +997,29 @@ module Alexandria
996
997
  end
997
998
 
998
999
  def save_preferences
999
- log.debug { 'save_preferences' }
1000
+ log.debug { "save_preferences" }
1000
1001
  @prefs.position = @main_app.position
1001
1002
  @prefs.size = @main_app.allocation.to_a[2..3]
1002
1003
  @prefs.maximized = @maximized
1003
1004
  @prefs.sidepane_position = @paned.position
1004
- @prefs.sidepane_visible = @actiongroup['Sidepane'].active?
1005
- @prefs.toolbar_visible = @actiongroup['Toolbar'].active?
1006
- @prefs.statusbar_visible = @actiongroup['Statusbar'].active?
1005
+ @prefs.sidepane_visible = @actiongroup["Sidepane"].active?
1006
+ @prefs.toolbar_visible = @actiongroup["Toolbar"].active?
1007
+ @prefs.statusbar_visible = @actiongroup["Statusbar"].active?
1007
1008
  @prefs.view_as = @notebook.page
1008
1009
  @prefs.selected_library = selected_library.name
1009
1010
  cols_width = {}
1010
1011
  @listview.columns.each do |c|
1011
1012
  cols_width[c.title] = c.width
1012
1013
  end
1013
- @prefs.cols_width = '{' + cols_width.to_a.map do |t, v|
1014
+ @prefs.cols_width = "{" + cols_width.to_a.map do |t, v|
1014
1015
  '"' + t + '": ' + v.to_s
1015
- end.join(', ') + '}'
1016
+ end.join(", ") + "}"
1016
1017
  log.debug { "cols_width: #{@prefs.cols_width} " }
1017
1018
  @prefs.save!
1018
1019
  end
1019
1020
 
1020
1021
  def undoable_move(source, dest, books)
1021
- log.debug { 'undoable_move' }
1022
+ log.debug { "undoable_move" }
1022
1023
  Library.move(source, dest, *books)
1023
1024
  UndoManager.instance.push { undoable_move(dest, source, books) }
1024
1025
  end
@@ -1035,7 +1036,7 @@ module Alexandria
1035
1036
 
1036
1037
  def setup_move_actions
1037
1038
  @actiongroup.actions.each do |action|
1038
- next unless /^MoveIn/ =~ action.name
1039
+ next unless /^MoveIn/.match?(action.name)
1039
1040
 
1040
1041
  @actiongroup.remove_action(action)
1041
1042
  end
@@ -1052,8 +1053,8 @@ module Alexandria
1052
1053
  @move_mid = @uimanager.new_merge_id
1053
1054
  @libraries.all_regular_libraries.each do |library|
1054
1055
  name = library.action_name
1055
- ['ui/MainMenubar/EditMenu/Move/',
1056
- 'ui/BookPopup/Move/'].each do |path|
1056
+ ["ui/MainMenubar/EditMenu/Move/",
1057
+ "ui/BookPopup/Move/"].each do |path|
1057
1058
  @uimanager.add_ui(@move_mid, path, name, name,
1058
1059
  :menuitem, false)
1059
1060
  end
@@ -1072,10 +1073,10 @@ module Alexandria
1072
1073
  # Gets the sort order of the current library, for use by export
1073
1074
  def library_sort_order
1074
1075
  # added by Cathal Mc Ginley, 23 Oct 2007
1075
- log.debug {
1076
+ log.debug do
1076
1077
  "library_sort_order #{@notebook.page}: " \
1077
1078
  "#{@iconview.model.inspect} #{@listview.model.inspect}"
1078
- }
1079
+ end
1079
1080
  result, sort_column, sort_order = current_view.model.sort_column_id
1080
1081
  if result
1081
1082
  column_ids_to_attributes = { 2 => :title,
@@ -1161,8 +1162,8 @@ module Alexandria
1161
1162
 
1162
1163
  def setup_window_icons
1163
1164
  @main_app.icon = Icons::ALEXANDRIA_SMALL
1164
- Gtk::Window.set_default_icon_name('alexandria')
1165
- @main_app.icon_name = 'alexandria'
1165
+ Gtk::Window.set_default_icon_name("alexandria")
1166
+ @main_app.icon_name = "alexandria"
1166
1167
  end
1167
1168
 
1168
1169
  ICONS_SORTS = [