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
@@ -8,7 +8,7 @@ module Alexandria
8
8
  module UI
9
9
  class BuilderBase
10
10
  def initialize(filename, widget_names)
11
- file = File.join(Alexandria::Config::DATA_DIR, 'glade', filename)
11
+ file = File.join(Alexandria::Config::DATA_DIR, "glade", filename)
12
12
  builder = Gtk::Builder.new
13
13
  # TODO: This emits the warning 'GtkDialog mapped without a transient
14
14
  # parent. This is discouraged.'
@@ -4,6 +4,8 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
+ require "alexandria/ui/really_delete_dialog"
8
+
7
9
  module Alexandria
8
10
  module UI
9
11
  module Callbacks
@@ -28,7 +30,7 @@ module Alexandria
28
30
  end
29
31
 
30
32
  def on_add_book(*)
31
- log.info { 'on_add_book' }
33
+ log.info { "on_add_book" }
32
34
  NewBookDialog.new(@main_app, selected_library) do |_books, library, is_new|
33
35
  if is_new
34
36
  append_library(library, true)
@@ -41,24 +43,24 @@ module Alexandria
41
43
 
42
44
  def on_add_book_manual(*)
43
45
  library = selected_library
44
- NewBookDialogManual.new(@main_app, library) { |_book|
46
+ NewBookDialogManual.new(@main_app, library) do |_book|
45
47
  refresh_books
46
- }
48
+ end
47
49
  end
48
50
 
49
51
  def on_import(*)
50
52
  ImportDialog.new(@main_app).acquire do |library, bad_isbns, failed_isbns|
51
53
  unless bad_isbns.empty?
52
- log.debug { 'bad_isbn' }
53
- message = _('The following lines are not valid ISBNs and were not imported:')
54
+ log.debug { "bad_isbn" }
55
+ message = _("The following lines are not valid ISBNs and were not imported:")
54
56
  bad_isbn_warn = BadIsbnsDialog.new(@main_app, message, bad_isbns)
55
- bad_isbn_warn.signal_connect('response') { bad_isbn_warn.destroy }
57
+ bad_isbn_warn.signal_connect("response") { bad_isbn_warn.destroy }
56
58
  end
57
59
  unless failed_isbns.nil? || failed_isbns.empty?
58
60
  log.debug { "failed lookup of #{failed_isbns.size} ISBNs" }
59
- message = _('Books could not be found for the following ISBNs:')
61
+ message = _("Books could not be found for the following ISBNs:")
60
62
  failed_lookup = BadIsbnsDialog.new(@main_app, message, failed_isbns)
61
- failed_lookup.signal_connect('response') { failed_lookup.destroy }
63
+ failed_lookup.signal_connect("response") { failed_lookup.destroy }
62
64
  end
63
65
  @libraries.add_library(library)
64
66
  append_library(library, true)
@@ -67,29 +69,29 @@ module Alexandria
67
69
  end
68
70
 
69
71
  def on_window_state_event(_window, event)
70
- log.debug { 'window-state-event' }
72
+ log.debug { "window-state-event" }
71
73
  @maximized = event.new_window_state == :maximized if event.is_a?(Gdk::EventWindowState)
72
- log.debug { 'end window-state-event' }
74
+ log.debug { "end window-state-event" }
73
75
  end
74
76
 
75
77
  def on_toolbar_view_as_changed(cb)
76
- log.debug { 'changed' }
78
+ log.debug { "changed" }
77
79
  action = case cb.active
78
80
  when 0
79
- @actiongroup['AsIcons']
81
+ @actiongroup["AsIcons"]
80
82
  when 1
81
- @actiongroup['AsList']
83
+ @actiongroup["AsList"]
82
84
  end
83
85
  action.active = true
84
86
  end
85
87
 
86
88
  def on_window_destroy(_window)
87
- log.debug { 'destroy' }
88
- @actiongroup['Quit'].activate
89
+ log.debug { "destroy" }
90
+ @actiongroup["Quit"].activate
89
91
  end
90
92
 
91
93
  def on_toolbar_filter_entry_changed(_entry)
92
- log.debug { 'changed' }
94
+ log.debug { "changed" }
93
95
  @filter_entry.text.strip!
94
96
  @iconview.freeze
95
97
  @filtered_model.refilter
@@ -97,7 +99,7 @@ module Alexandria
97
99
  end
98
100
 
99
101
  def on_criterion_combobox_changed(cb)
100
- log.debug { 'changed' }
102
+ log.debug { "changed" }
101
103
  @filter_books_mode = cb.active
102
104
  @filter_entry.text.strip!
103
105
  @iconview.freeze
@@ -158,7 +160,7 @@ module Alexandria
158
160
  end
159
161
 
160
162
  def on_select_all(*)
161
- log.debug { 'on_select_all' }
163
+ log.debug { "on_select_all" }
162
164
  case @notebook.page
163
165
  when 0
164
166
  @iconview.select_all
@@ -168,7 +170,7 @@ module Alexandria
168
170
  end
169
171
 
170
172
  def on_deselect_all(*)
171
- log.debug { 'on_deselect_all' }
173
+ log.debug { "on_deselect_all" }
172
174
  case @notebook.page
173
175
  when 0
174
176
  @iconview.unselect_all
@@ -210,7 +212,7 @@ module Alexandria
210
212
  is_smart = library.is_a?(SmartLibrary)
211
213
  last_library = (@libraries.all_regular_libraries.length == 1)
212
214
  if books.nil? && !is_smart && last_library
213
- log.warn { 'Attempted to delete last library, fix GUI' }
215
+ log.warn { "Attempted to delete last library, fix GUI" }
214
216
  return
215
217
  end
216
218
  if library.empty? || ReallyDeleteDialog.new(@main_app,
@@ -221,7 +223,7 @@ module Alexandria
221
223
  end
222
224
 
223
225
  def on_clear_search_results(*)
224
- @filter_entry.text = ''
226
+ @filter_entry.text = ""
225
227
  @iconview.freeze
226
228
  @filtered_model.refilter
227
229
  @iconview.unfreeze
@@ -250,129 +252,130 @@ module Alexandria
250
252
  end
251
253
 
252
254
  def on_view_sidepane(action)
253
- log.debug { 'on_view_sidepane' }
255
+ log.debug { "on_view_sidepane" }
254
256
  @paned.child1.visible = action.active?
255
257
  end
256
258
 
257
259
  def on_view_toolbar(action)
258
- log.debug { 'on_view_toolbar' }
260
+ log.debug { "on_view_toolbar" }
259
261
  @toolbar.visible = action.active?
260
262
  end
261
263
 
262
264
  def on_view_statusbar(action)
263
- log.debug { 'on_view_statusbar' }
265
+ log.debug { "on_view_statusbar" }
264
266
  @appbar.visible = action.active?
265
267
  end
266
268
 
267
269
  def on_reverse_order(action)
268
- log.debug { 'on_reverse_order' }
270
+ log.debug { "on_reverse_order" }
269
271
  Preferences.instance.reverse_icons = action.active?
270
272
  Preferences.instance.save!
271
273
  setup_books_iconview_sorting
272
274
  end
273
275
 
274
276
  def connect_signals
275
- # rubocop:disable LineLength
277
+ # rubocop:disable Metrics/LineLength
276
278
  standard_actions = [
277
- ['LibraryMenu', nil, _('_Library')],
278
- ['New', Gtk::Stock::NEW, _('_New Library'), '<control>L', _('Create a new library'), method(:on_new)],
279
- ['NewSmart', nil, _('New _Smart Library...'), '<control><shift>L', _('Create a new smart library'), method(:on_new_smart)],
280
- ['AddBook', Gtk::Stock::ADD, _('_Add Book...'), '<control>N', _('Add a new book from the Internet'), method(:on_add_book)],
281
- ['AddBookManual', nil, _('Add Book _Manually...'), '<control><shift>N', _('Add a new book manually'), method(:on_add_book_manual)],
282
- ['Import', nil, _('_Import...'), '<control>I', _('Import a library'), method(:on_import)],
283
- ['Export', nil, _('_Export...'), '<control><shift>E', _('Export the selected library'), method(:on_export)],
284
- ['Acquire', nil, _('A_cquire from Scanner...'), '<control><shift>S', _('Acquire books from a scanner'), method(:on_acquire)],
285
- ['Properties', Gtk::Stock::PROPERTIES, _('_Properties'), nil, _('Edit the properties of the selected book'), method(:on_properties)],
286
- ['Quit', Gtk::Stock::QUIT, _('_Quit'), '<control>Q', _('Quit the program'), method(:on_quit)],
287
- ['EditMenu', nil, _('_Edit')],
288
- ['Undo', Gtk::Stock::UNDO, _('_Undo'), '<control>Z', _('Undo the last action'), method(:on_undo)],
289
- ['Redo', Gtk::Stock::REDO, _('_Redo'), '<control><shift>Z', _('Redo the undone action'), method(:on_redo)],
290
- ['SelectAll', nil, _('_Select All'), '<control>A', _('Select all visible books'), method(:on_select_all)],
291
- ['DeselectAll', nil, _('Dese_lect All'), '<control><shift>A', _('Deselect everything'), method(:on_deselect_all)],
292
- ['SetRating', nil, _('My _Rating')],
293
- ['SetRating0', nil, _('None'), nil, nil, proc { on_set_rating[0].call }],
294
- ['SetRating1', nil, _('One Star'), nil, nil, proc { on_set_rating[1].call }],
295
- ['SetRating2', nil, _('Two Stars'), nil, nil, proc { on_set_rating[2].call }],
296
- ['SetRating3', nil, _('Three Stars'), nil, nil, proc { on_set_rating[3].call }],
297
- ['SetRating4', nil, _('Four Stars'), nil, nil, proc { on_set_rating[4].call }],
298
- ['SetRating5', nil, _('Five Stars'), nil, nil, proc { on_set_rating[5].call }],
299
- ['Move', nil, _('_Move')],
300
- ['Rename', nil, _('_Rename'), nil, nil, method(:on_rename)],
301
- ['Delete', Gtk::Stock::DELETE, _('_Delete'), 'Delete', _('Delete the selected books or library'), method(:on_delete)],
302
- ['Search', Gtk::Stock::FIND, _('_Search'), '<control>F', _('Filter books'), method(:on_search)],
303
- ['ClearSearchResult', Gtk::Stock::CLEAR, _('_Clear Results'), '<control><alt>B', _('Clear the search results'), method(:on_clear_search_results)],
304
- ['Preferences', Gtk::Stock::PREFERENCES, _('_Preferences'), '<control>O', _("Change Alexandria's settings"), method(:on_preferences)],
305
- ['ViewMenu', nil, _('_View')],
306
- ['ArrangeIcons', nil, _('Arran_ge Icons')],
307
- ['OnlineInformation', nil, _('Display Online _Information')],
308
-
309
- ['HelpMenu', nil, _('_Help')],
310
- ['SubmitBugReport', Gtk::Stock::EDIT, _('Submit _Bug Report'), nil, _('Submit a bug report to the developers'), method(:on_submit_bug_report)],
311
- ['Help', Gtk::Stock::HELP, _('Contents'), 'F1', _("View Alexandria's manual"), method(:on_help)],
312
- ['About', Gtk::Stock::ABOUT, _('_About'), nil, _('Show information about Alexandria'), method(:on_about)],
279
+ ["LibraryMenu", nil, _("_Library")],
280
+ ["New", Gtk::Stock::NEW, _("_New Library"), "<control>L", _("Create a new library"), method(:on_new)],
281
+ ["NewSmart", nil, _("New _Smart Library..."), "<control><shift>L", _("Create a new smart library"), method(:on_new_smart)],
282
+ ["AddBook", Gtk::Stock::ADD, _("_Add Book..."), "<control>N", _("Add a new book from the Internet"), method(:on_add_book)],
283
+ ["AddBookManual", nil, _("Add Book _Manually..."), "<control><shift>N", _("Add a new book manually"), method(:on_add_book_manual)],
284
+ ["Import", nil, _("_Import..."), "<control>I", _("Import a library"), method(:on_import)],
285
+ ["Export", nil, _("_Export..."), "<control><shift>E", _("Export the selected library"), method(:on_export)],
286
+ ["Acquire", nil, _("A_cquire from Scanner..."), "<control><shift>S", _("Acquire books from a scanner"), method(:on_acquire)],
287
+ ["Properties", Gtk::Stock::PROPERTIES, _("_Properties"), nil, _("Edit the properties of the selected book"), method(:on_properties)],
288
+ ["Quit", Gtk::Stock::QUIT, _("_Quit"), "<control>Q", _("Quit the program"), method(:on_quit)],
289
+ ["EditMenu", nil, _("_Edit")],
290
+ ["Undo", Gtk::Stock::UNDO, _("_Undo"), "<control>Z", _("Undo the last action"), method(:on_undo)],
291
+ ["Redo", Gtk::Stock::REDO, _("_Redo"), "<control><shift>Z", _("Redo the undone action"), method(:on_redo)],
292
+ ["SelectAll", nil, _("_Select All"), "<control>A", _("Select all visible books"), method(:on_select_all)],
293
+ ["DeselectAll", nil, _("Dese_lect All"), "<control><shift>A", _("Deselect everything"), method(:on_deselect_all)],
294
+ ["SetRating", nil, _("My _Rating")],
295
+ ["SetRating0", nil, _("None"), nil, nil, proc { on_set_rating[0].call }],
296
+ ["SetRating1", nil, _("One Star"), nil, nil, proc { on_set_rating[1].call }],
297
+ ["SetRating2", nil, _("Two Stars"), nil, nil, proc { on_set_rating[2].call }],
298
+ ["SetRating3", nil, _("Three Stars"), nil, nil, proc { on_set_rating[3].call }],
299
+ ["SetRating4", nil, _("Four Stars"), nil, nil, proc { on_set_rating[4].call }],
300
+ ["SetRating5", nil, _("Five Stars"), nil, nil, proc { on_set_rating[5].call }],
301
+ ["Move", nil, _("_Move")],
302
+ ["Rename", nil, _("_Rename"), nil, nil, method(:on_rename)],
303
+ ["Delete", Gtk::Stock::DELETE, _("_Delete"), "Delete", _("Delete the selected books or library"), method(:on_delete)],
304
+ ["Search", Gtk::Stock::FIND, _("_Search"), "<control>F", _("Filter books"), method(:on_search)],
305
+ ["ClearSearchResult", Gtk::Stock::CLEAR, _("_Clear Results"), "<control><alt>B", _("Clear the search results"), method(:on_clear_search_results)],
306
+ ["Preferences", Gtk::Stock::PREFERENCES, _("_Preferences"), "<control>O", _("Change Alexandria's settings"), method(:on_preferences)],
307
+ ["ViewMenu", nil, _("_View")],
308
+ ["ArrangeIcons", nil, _("Arran_ge Icons")],
309
+ ["OnlineInformation", nil, _("Display Online _Information")],
310
+
311
+ ["HelpMenu", nil, _("_Help")],
312
+ ["SubmitBugReport", Gtk::Stock::EDIT, _("Submit _Bug Report"), nil, _("Submit a bug report to the developers"), method(:on_submit_bug_report)],
313
+ ["Help", Gtk::Stock::HELP, _("Contents"), "F1", _("View Alexandria's manual"), method(:on_help)],
314
+ ["About", Gtk::Stock::ABOUT, _("_About"), nil, _("Show information about Alexandria"), method(:on_about)],
313
315
  ]
314
- # rubocop:enable LineLength
316
+ # rubocop:enable Metrics/LineLength
315
317
 
316
318
  toggle_actions = [
317
- ['Sidepane', nil, _('Side _Pane'), 'F9', nil, method(:on_view_sidepane), true],
318
- ['Toolbar', nil, _('_Toolbar'), nil, nil, method(:on_view_toolbar), true],
319
- ['Statusbar', nil, _('_Statusbar'), nil, nil, method(:on_view_statusbar), true],
320
- ['ReversedOrder', nil, _('Re_versed Order'), nil, nil, method(:on_reverse_order), false],
319
+ ["Sidepane", nil, _("Side _Pane"), "F9", nil, method(:on_view_sidepane), true],
320
+ ["Toolbar", nil, _("_Toolbar"), nil, nil, method(:on_view_toolbar), true],
321
+ ["Statusbar", nil, _("_Statusbar"), nil, nil, method(:on_view_statusbar), true],
322
+ ["ReversedOrder", nil, _("Re_versed Order"), nil, nil, method(:on_reverse_order), false],
321
323
  ]
322
324
 
323
325
  view_as_actions = [
324
- ['AsIcons', nil, _('View as _Icons'), nil, nil, 0],
325
- ['AsList', nil, _('View as _List'), nil, nil, 1]
326
+ ["AsIcons", nil, _("View as _Icons"), nil, nil, 0],
327
+ ["AsList", nil, _("View as _List"), nil, nil, 1]
326
328
  ]
327
329
 
328
330
  arrange_icons_actions = [
329
- ['ByTitle', nil, _('By _Title'), nil, nil, 0],
330
- ['ByAuthors', nil, _('By _Authors'), nil, nil, 1],
331
- ['ByISBN', nil, _('By _ISBN'), nil, nil, 2],
332
- ['ByPublisher', nil, _('By _Publisher'), nil, nil, 3],
333
- ['ByEdition', nil, _('By _Binding'), nil, nil, 4],
334
- ['ByRating', nil, _('By _Rating'), nil, nil, 5]
331
+ ["ByTitle", nil, _("By _Title"), nil, nil, 0],
332
+ ["ByAuthors", nil, _("By _Authors"), nil, nil, 1],
333
+ ["ByISBN", nil, _("By _ISBN"), nil, nil, 2],
334
+ ["ByPublisher", nil, _("By _Publisher"), nil, nil, 3],
335
+ ["ByEdition", nil, _("By _Binding"), nil, nil, 4],
336
+ ["ByRating", nil, _("By _Rating"), nil, nil, 5]
335
337
  ]
336
338
  providers_actions = BookProviders.map do |provider|
337
339
  [provider.action_name, Gtk::Stock::JUMP_TO,
338
- _('At _%s') % provider.fullname, nil, nil,
340
+ _("At _%s") % provider.fullname, nil, nil,
339
341
  proc { open_web_browser(provider.url(selected_books.first)) }]
340
342
  end
341
343
 
342
- log.debug { 'Adding actions to @actiongroup' }
344
+ log.debug { "Adding actions to @actiongroup" }
343
345
 
344
- @actiongroup = Gtk::ActionGroup.new('actions')
346
+ @actiongroup = Gtk::ActionGroup.new("actions")
345
347
 
346
348
  standard_actions.each do |name, stock_id, label, accelerator, tooltip, callback|
347
349
  action = Gtk::Action.new(name, label: label, tooltip: tooltip, stock_id: stock_id)
348
350
  @actiongroup.add_action_with_accel(action, accelerator)
349
- action.signal_connect('activate', &callback) if callback
351
+ action.signal_connect("activate", &callback) if callback
350
352
  end
351
353
 
352
354
  providers_actions.each do |name, stock_id, label, accelerator, tooltip, callback|
353
355
  action = Gtk::Action.new(name, label: label, tooltip: tooltip, stock_id: stock_id)
354
356
  @actiongroup.add_action_with_accel(action, accelerator)
355
- action.signal_connect('activate', &callback) if callback
357
+ action.signal_connect("activate", &callback) if callback
356
358
  end
357
359
 
358
360
  toggle_actions.each do |name, stock_id, label, accelerator, tooltip, callback, is_active|
359
361
  action = Gtk::ToggleAction.new(name, label: label, tooltip: tooltip, stock_id: stock_id)
360
362
  action.set_active is_active
361
363
  @actiongroup.add_action_with_accel(action, accelerator)
362
- action.signal_connect('toggled', &callback) if callback
364
+ action.signal_connect("toggled", &callback) if callback
363
365
  end
364
366
 
365
- group = nil
366
367
  first_action = nil
367
368
  view_as_actions.each do |name, stock_id, label, accelerator, tooltip, value|
368
369
  action = Gtk::RadioAction.new(name, value, label: label, tooltip: tooltip, stock_id: stock_id)
369
- first_action = action unless group
370
- action.set_group group
371
- group = action.group
370
+ if first_action
371
+ action.join_group first_action
372
+ else
373
+ first_action = action
374
+ end
372
375
  @actiongroup.add_action_with_accel(action, accelerator)
373
376
  end
374
377
 
375
- first_action.signal_connect 'changed' do |_action, current, _user_data|
378
+ first_action.signal_connect "changed" do |_action, current, _user_data|
376
379
  @notebook.page = current.current_value
377
380
  hid = @toolbar_view_as_signal_hid
378
381
  @toolbar_view_as.signal_handler_block(hid) do
@@ -380,17 +383,18 @@ module Alexandria
380
383
  end
381
384
  end
382
385
 
383
- group = nil
384
386
  first_action = nil
385
387
  arrange_icons_actions.each do |name, stock_id, label, accelerator, tooltip, value|
386
388
  action = Gtk::RadioAction.new(name, value, label: label, tooltip: tooltip, stock_id: stock_id)
387
- first_action = action unless group
388
- action.set_group group
389
- group = action.group
389
+ if first_action
390
+ action.join_group first_action
391
+ else
392
+ first_action = action
393
+ end
390
394
  @actiongroup.add_action_with_accel(action, accelerator)
391
395
  end
392
396
 
393
- first_action.signal_connect 'changed' do |_action, current, _user_data|
397
+ first_action.signal_connect "changed" do |_action, current, _user_data|
394
398
  @prefs.arrange_icons_mode = current.current_value
395
399
  setup_books_iconview_sorting
396
400
  end
@@ -1,22 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2005-2006 Laurent Sansonetti
4
- # Copyright (C) 2011, 2016 Matijs van Zuijlen
3
+ # This file is part of Alexandria.
5
4
  #
6
- # Alexandria is free software; you can redistribute it and/or
7
- # modify it under the terms of the GNU General Public License as
8
- # published by the Free Software Foundation; either version 2 of the
9
- # License, or (at your option) any later version.
10
- #
11
- # Alexandria is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- # General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public
17
- # License along with Alexandria; see the file COPYING. If not,
18
- # write to the Free Software Foundation, Inc., 51 Franklin Street,
19
- # Fifth Floor, Boston, MA 02110-1301 USA.
5
+ # See the file README.md for authorship and licensing information.
20
6
 
21
7
  module Alexandria
22
8
  module EntryOverrides
@@ -44,21 +30,21 @@ module Alexandria
44
30
  complete(Alexandria::UI::CompletionModels::TAG)
45
31
  # min = self.completion.minimum_key_length
46
32
  min = 2
47
- completion.signal_connect('match-selected') do |c, model, iter|
33
+ completion.signal_connect("match-selected") do |c, model, iter|
48
34
  cur_text = c.entry.text
49
35
  # TODO: Replace with iter[0] if possible
50
36
  new_tag = model.get_value(iter, 0)
51
- cur_text_split = cur_text.split(',')
37
+ cur_text_split = cur_text.split(",")
52
38
  cur_text_split.delete_at(-1)
53
39
  cur_text_split << new_tag
54
- c.entry.text = cur_text_split.join(',')
40
+ c.entry.text = cur_text_split.join(",")
55
41
  true
56
42
  end
57
43
  completion.set_match_func do |_comp, key, iter|
58
- cur_tag = key.split(',').last.strip
44
+ cur_tag = key.split(",").last.strip
59
45
  if cur_tag.size >= min
60
46
  begin
61
- if iter[0] =~ /^#{cur_tag}/
47
+ if /^#{cur_tag}/.match?(iter[0])
62
48
  true
63
49
  else
64
50
  false
@@ -0,0 +1,33 @@
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
+ require "alexandria/ui/alert_dialog"
8
+
9
+ module Alexandria
10
+ module UI
11
+ class ConfirmEraseDialog < AlertDialog
12
+ include GetText
13
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
14
+
15
+ def initialize(parent, filename)
16
+ super(parent, _("File already exists"),
17
+ Gtk::Stock::DIALOG_QUESTION,
18
+ [[Gtk::Stock::CANCEL, :cancel],
19
+ [_("_Replace"), :ok]],
20
+ _("A file named '%s' already exists. Do you want " \
21
+ "to replace it with the one you are generating?") % filename)
22
+ # FIXME: Should accept just :cancel
23
+ self.default_response = Gtk::ResponseType::CANCEL
24
+ end
25
+
26
+ def erase?
27
+ show_all && (@response = run)
28
+ destroy
29
+ @response == Gtk::ResponseType::OK
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
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
+ require "alexandria/ui/alert_dialog"
8
+
9
+ module Alexandria
10
+ module UI
11
+ class ConflictWhileCopyingDialog < AlertDialog
12
+ include GetText
13
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
14
+
15
+ def initialize(parent, library, book)
16
+ super(parent,
17
+ format(_("The book '%s' already exists in '%s'. Would you like " \
18
+ "to replace it?"), book.title, library.name),
19
+ Gtk::Stock::DIALOG_QUESTION,
20
+ [[_("_Skip"), Gtk::ResponseType::CANCEL],
21
+ [_("_Replace"), Gtk::ResponseType::OK]],
22
+ _("If you replace the existing book, its contents will " \
23
+ "be overwritten."))
24
+ self.default_response = Gtk::ResponseType::CANCEL
25
+ end
26
+
27
+ def replace?
28
+ show_all && (@response = run)
29
+ destroy
30
+ @response == Gtk::ResponseType::OK
31
+ end
32
+ end
33
+ end
34
+ end