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
@@ -4,21 +4,23 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
+ require "alexandria/ui/alert_dialog"
8
+
7
9
  module Alexandria
8
10
  module UI
9
11
  class KeepBadISBNDialog < AlertDialog
10
12
  include GetText
11
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
13
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
12
14
 
13
15
  def initialize(parent, book)
14
16
  title = _("Invalid ISBN '%s'") % book.isbn
15
17
  message = _("The book titled '%s' has an invalid ISBN, but still " \
16
- 'exists in the providers libraries. Do you want to ' \
17
- 'keep the book but change the ISBN or cancel the addition?') % book.title
18
+ "exists in the providers libraries. Do you want to " \
19
+ "keep the book but change the ISBN or cancel the addition?") % book.title
18
20
  super(parent, title,
19
21
  Gtk::Stock::DIALOG_QUESTION,
20
22
  [[Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL],
21
- [_('_Keep'), Gtk::ResponseType::OK]], message)
23
+ [_("_Keep"), Gtk::ResponseType::OK]], message)
22
24
  self.default_response = Gtk::ResponseType::OK
23
25
  end
24
26
 
@@ -24,7 +24,7 @@ module Alexandria
24
24
  module ComboBoxOverrides
25
25
  include GetText
26
26
  extend GetText
27
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
27
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
28
28
 
29
29
  def populate_with_libraries(libraries, selected_library)
30
30
  libraries_names = libraries.map(&:name)
@@ -33,10 +33,6 @@ module Alexandria
33
33
  libraries_names.unshift selected_library.name
34
34
  end
35
35
  clear
36
- set_row_separator_func do |model, iter|
37
- # TODO: Replace with iter[1] if possible
38
- model.get_value(iter, 1) == '-'
39
- end
40
36
  self.model = Gtk::ListStore.new(GdkPixbuf::Pixbuf, String, TrueClass)
41
37
  libraries_names.each do |library_name|
42
38
  iter = model.append
@@ -44,10 +40,10 @@ module Alexandria
44
40
  iter[1] = library_name
45
41
  iter[2] = false
46
42
  end
47
- model.append[1] = '-'
43
+ model.append[1] = "-"
48
44
  iter = model.append
49
45
  iter[0] = Alexandria::UI::Icons::LIBRARY_SMALL
50
- iter[1] = _('New Library')
46
+ iter[1] = _("New Library")
51
47
  iter[2] = true
52
48
  renderer = Gtk::CellRendererPixbuf.new
53
49
  pack_start(renderer, false)
@@ -55,6 +51,10 @@ module Alexandria
55
51
  renderer = Gtk::CellRendererText.new
56
52
  pack_start(renderer, true)
57
53
  set_attributes(renderer, text: 1)
54
+ set_row_separator_func do |model, iter|
55
+ # TODO: Replace with iter[1] if possible
56
+ model.get_value(iter, 1) == "-"
57
+ end
58
58
  self.active = 0
59
59
  # self.sensitive = libraries.length > 1
60
60
  # This prohibits us from adding a "New Library" from this combo
@@ -4,18 +4,18 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require 'alexandria/ui/columns'
7
+ require "alexandria/ui/columns"
8
8
 
9
9
  module Alexandria
10
10
  module UI
11
11
  include Logging
12
12
  include GetText
13
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
13
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
14
14
  class ListViewManager
15
15
  include Logging
16
16
  include GetText
17
17
  include DragAndDropable
18
- BOOKS_TARGET_TABLE = [['ALEXANDRIA_BOOKS', :same_app, 0]].freeze
18
+ BOOKS_TARGET_TABLE = [["ALEXANDRIA_BOOKS", :same_app, 0]].freeze
19
19
 
20
20
  def initialize(_listview, parent)
21
21
  @parent = parent
@@ -29,18 +29,18 @@ module Alexandria
29
29
  end
30
30
 
31
31
  def setup_title_column
32
- title = _('Title')
33
- log.debug { format('Create listview column for %s', title) }
32
+ title = _("Title")
33
+ log.debug { format("Create listview column for %s", title) }
34
34
  column = Gtk::TreeViewColumn.new(title)
35
35
 
36
36
  renderer = Gtk::CellRendererPixbuf.new
37
37
  column.pack_start(renderer, false)
38
- column.add_attribute(renderer, 'pixbuf', Columns::COVER_LIST)
38
+ column.add_attribute(renderer, "pixbuf", Columns::COVER_LIST)
39
39
 
40
40
  renderer = Gtk::CellRendererText.new
41
41
  renderer.ellipsize = :end
42
42
  column.pack_start(renderer, true)
43
- column.add_attribute(renderer, 'text', Columns::TITLE)
43
+ column.add_attribute(renderer, "text", Columns::TITLE)
44
44
 
45
45
  column.sort_column_id = Columns::TITLE
46
46
  column.resizable = true
@@ -48,21 +48,21 @@ module Alexandria
48
48
  end
49
49
 
50
50
  TEXT_COLUMNS = [
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]
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]
57
57
  ].freeze
58
58
  CHECK_COLUMNS = [
59
- [_('Read'), Columns::REDD],
60
- [_('Own'), Columns::OWN],
61
- [_('Want'), Columns::WANT]
59
+ [_("Read"), Columns::REDD],
60
+ [_("Own"), Columns::OWN],
61
+ [_("Want"), Columns::WANT]
62
62
  ].freeze
63
63
 
64
64
  def setup_books_listview
65
- log.debug { 'setup_books_listview' }
65
+ log.debug { "setup_books_listview" }
66
66
  @listview.model = @listview_model
67
67
  setup_title_column
68
68
  TEXT_COLUMNS.each do |title, iterid|
@@ -73,8 +73,8 @@ module Alexandria
73
73
  end
74
74
  setup_rating_column
75
75
  @listview.selection.mode = :multiple
76
- @listview.selection.signal_connect('changed') do
77
- log.debug { 'changed' }
76
+ @listview.selection.signal_connect("changed") do
77
+ log.debug { "changed" }
78
78
  @parent.on_books_selection_changed
79
79
  end
80
80
  setup_tags_column
@@ -84,8 +84,8 @@ module Alexandria
84
84
 
85
85
  def setup_tags_column
86
86
  # adding tags column...
87
- title = _('Tags')
88
- log.debug { 'Create listview column for tags...' }
87
+ title = _("Tags")
88
+ log.debug { "Create listview column for tags..." }
89
89
  renderer = Gtk::CellRendererText.new
90
90
  renderer.ellipsize = :end
91
91
  column = Gtk::TreeViewColumn.new(title, renderer,
@@ -96,16 +96,16 @@ module Alexandria
96
96
  end
97
97
 
98
98
  def setup_row_activation
99
- @listview.signal_connect('row-activated') do
100
- log.debug { 'row-activated' }
101
- @actiongroup['Properties'].activate
99
+ @listview.signal_connect("row-activated") do
100
+ log.debug { "row-activated" }
101
+ @actiongroup["Properties"].activate
102
102
  false
103
103
  end
104
104
  end
105
105
 
106
106
  def setup_rating_column
107
- title = _('Rating')
108
- log.debug { format('Create listview column for %s...', title) }
107
+ title = _("Rating")
108
+ log.debug { format("Create listview column for %s...", title) }
109
109
  column = Gtk::TreeViewColumn.new(title)
110
110
  column.sizing = :fixed
111
111
  width = (Icons::STAR_SET.width + 1) * Book::MAX_RATING_STARS
@@ -127,7 +127,7 @@ module Alexandria
127
127
  def setup_check_column(title, iterid)
128
128
  renderer = CellRendererToggle.new
129
129
  renderer.activatable = true
130
- renderer.signal_connect('toggled') do |_rndrr, path|
130
+ renderer.signal_connect("toggled") do |_rndrr, path|
131
131
  begin
132
132
  tree_path = Gtk::TreePath.new(path)
133
133
  child_path = @listview_model.convert_path_to_child_path(tree_path)
@@ -159,24 +159,24 @@ module Alexandria
159
159
  end
160
160
 
161
161
  end
162
- rescue StandardError => e
163
- log.error { "toggle failed for path #{path} #{e}\n" + e.backtrace.join("\n") }
162
+ rescue StandardError => ex
163
+ log.error { "toggle failed for path #{path} #{ex}\n" + e.backtrace.join("\n") }
164
164
  end
165
165
  end
166
166
  column = Gtk::TreeViewColumn.new(title, renderer, text: iterid)
167
167
  column.sort_column_id = iterid
168
168
  column.resizable = true
169
- log.debug { format('Create listview column for %s...', title) }
169
+ log.debug { format("Create listview column for %s...", title) }
170
170
 
171
- column.add_attribute(renderer, 'active', iterid)
172
- column.add_attribute(renderer, 'inconsistent', Columns::OWN) if iterid == Columns::WANT
171
+ column.add_attribute(renderer, "active", iterid)
172
+ column.add_attribute(renderer, "inconsistent", Columns::OWN) if iterid == Columns::WANT
173
173
 
174
174
  log.debug { "append_column #{column}" }
175
175
  @listview.append_column(column)
176
176
  end
177
177
 
178
178
  def setup_text_column(title, iterid)
179
- log.debug { format('Create listview column for %s...', title) }
179
+ log.debug { format("Create listview column for %s...", title) }
180
180
  renderer = Gtk::CellRendererText.new
181
181
  renderer.ellipsize = :end
182
182
  column = Gtk::TreeViewColumn.new(title, renderer,
@@ -187,7 +187,7 @@ module Alexandria
187
187
  end
188
188
 
189
189
  def setup_listview_columns_visibility
190
- log.debug { 'setup_listview_columns_visibility' }
190
+ log.debug { "setup_listview_columns_visibility" }
191
191
  # Show or hide list view columns according to the preferences.
192
192
  cols_visibility = [
193
193
  @prefs.col_authors_visible,
@@ -204,9 +204,9 @@ module Alexandria
204
204
  ]
205
205
  cols = @listview.columns[1..-1] # skip "Title"
206
206
  cols.each_index do |i|
207
- cols[i].visible = cols_visibility[i]
207
+ cols[i].visible = !!cols_visibility[i]
208
208
  end
209
- log.debug { 'Columns visibility: ' + cols.map { |col| "#{col.title} #{col.visible?}" }.join(', ') }
209
+ log.debug { "Columns visibility: " + cols.map { |col| "#{col.title} #{col.visible?}" }.join(", ") }
210
210
  end
211
211
 
212
212
  # Sets the width of each column based on any respective
@@ -227,10 +227,10 @@ module Alexandria
227
227
  end
228
228
  end
229
229
  end
230
- log.debug {
231
- 'Columns width: ' +
232
- @listview.columns.map { |col| "#{col.title} #{col.width}" }.join(', ')
233
- }
230
+ log.debug do
231
+ "Columns width: " +
232
+ @listview.columns.map { |col| "#{col.title} #{col.width}" }.join(", ")
233
+ end
234
234
  end
235
235
  end
236
236
  end
@@ -19,34 +19,32 @@
19
19
  # write to the Free Software Foundation, Inc., 51 Franklin Street,
20
20
  # Fifth Floor, Boston, MA 02110-1301 USA.
21
21
 
22
- require 'alexandria/ui/dialogs/alert_dialog'
23
- # misc_dialogs depends on alert_dialog
24
- require 'alexandria/ui/dialogs/misc_dialogs'
25
- require 'alexandria/ui/dialogs/about_dialog'
26
- require 'alexandria/ui/dialogs/book_properties_dialog_base'
27
- require 'alexandria/ui/dialogs/book_properties_dialog'
28
- require 'alexandria/ui/dialogs/new_book_dialog_manual'
29
- require 'alexandria/ui/dialogs/new_book_dialog'
30
- require 'alexandria/ui/dialogs/preferences_dialog'
31
- require 'alexandria/ui/dialogs/export_dialog'
32
- require 'alexandria/ui/dialogs/import_dialog'
33
- require 'alexandria/ui/dialogs/acquire_dialog'
34
- require 'alexandria/ui/dialogs/smart_library_properties_dialog_base'
35
- require 'alexandria/ui/dialogs/smart_library_properties_dialog'
36
- require 'alexandria/ui/dialogs/new_smart_library_dialog'
37
- require 'alexandria/ui/dialogs/bad_isbns_dialog'
38
- require 'alexandria/ui/dndable'
39
- require 'alexandria/ui/init'
40
- require 'alexandria/ui/ui_manager'
41
- require 'alexandria/ui/listview'
42
- require 'alexandria/ui/iconview'
43
- 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"
44
42
 
45
43
  module Alexandria
46
44
  module UI
47
45
  include Logging
48
46
  include GetText
49
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
47
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
50
48
 
51
49
  class MainApp
52
50
  include Logging
@@ -55,7 +53,7 @@ module Alexandria
55
53
  attr_accessor :main_app, :libraries, :actiongroup, :appbar, :prefs
56
54
  attr_accessor :ui_manager
57
55
  def initialize
58
- log.info { 'Starting MainApp' }
56
+ log.info { "Starting MainApp" }
59
57
  @ui_manager = UIManager.new self
60
58
  @actiongroup = @ui_manager.actiongroup
61
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
@@ -50,7 +50,7 @@ module Alexandria
50
50
  @context.source_actions = actions
51
51
 
52
52
  @context.button_press_handler =
53
- signal_connect('button_press_event') do |_widget, event, _data|
53
+ signal_connect("button_press_event") do |_widget, event, _data|
54
54
  button_press_event(event)
55
55
  end
56
56
  end
@@ -110,7 +110,7 @@ module Alexandria
110
110
 
111
111
  if call_parent
112
112
  signal_handler_block(@context.button_press_handler) do
113
- signal_emit('button_press_event', event)
113
+ signal_emit("button_press_event", event)
114
114
  end
115
115
  end
116
116
 
@@ -122,11 +122,11 @@ module Alexandria
122
122
  @context.cell_x = cell_x
123
123
  @context.cell_y = cell_y
124
124
  @context.motion_notify_handler =
125
- signal_connect('motion_notify_event') do |_widget, evnt, _data|
125
+ signal_connect("motion_notify_event") do |_widget, evnt, _data|
126
126
  motion_notify_event(evnt)
127
127
  end
128
128
  @context.button_release_handler =
129
- signal_connect('button_release_event') do |_widget, evnt, _data|
129
+ signal_connect("button_release_event") do |_widget, evnt, _data|
130
130
  button_release_event(evnt)
131
131
  end
132
132
  @context.events << event unless call_parent
@@ -4,9 +4,10 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require 'gdk_pixbuf2'
8
- require 'alexandria/ui/builder_base'
9
- require 'alexandria/ui/dialogs/keep_bad_isbn_dialog'
7
+ require "gdk_pixbuf2"
8
+ require "alexandria/ui/builder_base"
9
+ require "alexandria/ui/error_dialog"
10
+ require "alexandria/ui/keep_bad_isbn_dialog"
10
11
 
11
12
  module Alexandria
12
13
  class DuplicateBookException < NameError
@@ -17,12 +18,12 @@ module Alexandria
17
18
  include Logging
18
19
  include GetText
19
20
  extend GetText
20
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
21
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
21
22
  @@last_criterion_was_not_isbn = false
22
23
 
23
24
  def initialize(parent, selected_library = nil, &block)
24
- super('new_book_dialog__builder.glade', widget_names)
25
- log.info { 'New Book Dialog' }
25
+ super("new_book_dialog__builder.glade", widget_names)
26
+ log.info { "New Book Dialog" }
26
27
  @new_book_dialog.transient_for = @parent = parent
27
28
  @block = block
28
29
  @destroyed = false
@@ -48,12 +49,12 @@ module Alexandria
48
49
  @treeview_results.model = Gtk::ListStore.new(String, String,
49
50
  GdkPixbuf::Pixbuf)
50
51
  @treeview_results.selection.mode = :multiple
51
- @treeview_results.selection.signal_connect('changed') do
52
+ @treeview_results.selection.signal_connect("changed") do
52
53
  @button_add.sensitive = true
53
54
  end
54
55
 
55
56
  renderer = Gtk::CellRendererPixbuf.new
56
- col = Gtk::TreeViewColumn.new('', renderer)
57
+ col = Gtk::TreeViewColumn.new("", renderer)
57
58
  col.set_cell_data_func(renderer) do |_column, cell, _model, iter|
58
59
  pixbuf = iter[2]
59
60
  max_height = 25
@@ -67,7 +68,7 @@ module Alexandria
67
68
  end
68
69
  @treeview_results.append_column(col)
69
70
 
70
- col = Gtk::TreeViewColumn.new('', Gtk::CellRendererText.new,
71
+ col = Gtk::TreeViewColumn.new("", Gtk::CellRendererText.new,
71
72
  text: 0)
72
73
  @treeview_results.append_column(col)
73
74
 
@@ -86,14 +87,14 @@ module Alexandria
86
87
  @find_thread = nil
87
88
  @image_thread = nil
88
89
 
89
- @new_book_dialog.signal_connect('destroy') {
90
+ @new_book_dialog.signal_connect("destroy") do
90
91
  @new_book_dialog.destroy
91
92
  @destroyed = true
92
- }
93
+ end
93
94
  end
94
95
 
95
96
  def on_criterion_toggled(item)
96
- log.debug { 'on_criterion_toggled' }
97
+ log.debug { "on_criterion_toggled" }
97
98
  return unless item.active?
98
99
 
99
100
  # There used to be a strange effect here (pre SVN r1022).
@@ -145,12 +146,12 @@ module Alexandria
145
146
  def image_error_dialog(error)
146
147
  ErrorDialog.new(
147
148
  @parent,
148
- _('A problem occurred while downloading images'),
149
+ _("A problem occurred while downloading images"),
149
150
  error)
150
151
  end
151
152
 
152
153
  def get_images_async
153
- log.info { 'get_images_async' }
154
+ log.info { "get_images_async" }
154
155
  @images = {}
155
156
  @image_error = nil
156
157
  @image_thread = Thread.new do
@@ -160,7 +161,7 @@ module Alexandria
160
161
  uri = result[1]
161
162
  if uri
162
163
  if URI.parse(uri).scheme.nil?
163
- File.open(uri, 'r') do |io|
164
+ File.open(uri, "r") do |io|
164
165
  @images[i] = io.read
165
166
  end
166
167
  else
@@ -168,8 +169,8 @@ module Alexandria
168
169
  end
169
170
  end
170
171
  end
171
- rescue StandardError => e
172
- @image_error = e.message
172
+ rescue StandardError => ex
173
+ @image_error = ex.message
173
174
  end
174
175
  end
175
176
 
@@ -186,15 +187,15 @@ module Alexandria
186
187
  if pixbuf.width > 1
187
188
  iter = @treeview_results.model.get_iter(key.to_s)
188
189
  unless @treeview_results.model.iter_is_valid?(iter)
189
- raise format('Iter is invalid! %s', iter)
190
+ raise format("Iter is invalid! %s", iter)
190
191
  end
191
192
 
192
193
  iter[2] = pixbuf # I bet you this is it!
193
194
  end
194
195
 
195
196
  @images.delete(key)
196
- rescue StandardError => e
197
- image_error_dialog(e.message).display
197
+ rescue StandardError => ex
198
+ image_error_dialog(ex.message).display
198
199
  end
199
200
  end
200
201
  end
@@ -211,7 +212,7 @@ module Alexandria
211
212
  end
212
213
 
213
214
  def on_find
214
- log.info { 'on_find' }
215
+ log.info { "on_find" }
215
216
  mode = case @combo_search.active
216
217
  when 0
217
218
  BookProviders::SEARCH_BY_TITLE
@@ -223,11 +224,11 @@ module Alexandria
223
224
 
224
225
  criterion = @entry_search.text.strip
225
226
  @treeview_results.model.clear
226
- log.info {
227
- format('TreeStore Model: %s columns; ref_counts: %s',
227
+ log.info do
228
+ format("TreeStore Model: %s columns; ref_counts: %s",
228
229
  @treeview_results.model.n_columns,
229
230
  @treeview_results.model.ref_count)
230
- }
231
+ end
231
232
 
232
233
  @find_error = nil
233
234
  @results = nil
@@ -244,8 +245,8 @@ module Alexandria
244
245
  @results = Alexandria::BookProviders.search(criterion, mode)
245
246
 
246
247
  log.info { "got #{@results.length} results" }
247
- rescue StandardError => e
248
- @find_error = e.message
248
+ rescue StandardError => ex
249
+ @find_error = ex.message
249
250
  ensure
250
251
  Alexandria::BookProviders.instance.delete_observer(self)
251
252
  # notify_end_add_by_isbn
@@ -261,7 +262,7 @@ module Alexandria
261
262
  # Err... continue == false if @find_error
262
263
  continue = if @find_error
263
264
  ErrorDialog.new(@new_book_dialog,
264
- _('Unable to find matches for your search'),
265
+ _("Unable to find matches for your search"),
265
266
  @find_error).display
266
267
  false
267
268
  elsif @results
@@ -302,13 +303,13 @@ module Alexandria
302
303
 
303
304
  def copy_results_to_treeview_model(results, model)
304
305
  results.each do |book, _cover_url|
305
- s = format(_('%s, by %s'), book.title, book.authors.join(', '))
306
- similar_books = results.find { |book2, _cover2|
306
+ s = format(_("%s, by %s"), book.title, book.authors.join(", "))
307
+ similar_books = results.find do |book2, _cover2|
307
308
  (book.title == book2.title) &&
308
309
  (book.authors == book2.authors)
309
- }
310
+ end
310
311
  s += " (#{book.edition}, #{book.publisher})" if similar_books.length > 1
311
- log.info { format('Copying %s into tree view.', book.title) }
312
+ log.info { format("Copying %s into tree view.", book.title) }
312
313
  iter = model.append
313
314
  iter[0] = s
314
315
  iter[1] = book.ident
@@ -318,11 +319,11 @@ module Alexandria
318
319
 
319
320
  def decode_cuecat?(entry) # srsly?
320
321
  if entry.text =~ /^\..*?\..*?\.(.*?)\.$/
321
- tmp = Regexp.last_match[1].tr('a-zA-Z0-9+-', ' -_')
322
- tmp = ((32 + tmp.length * 3 / 4).to_i.chr << tmp).unpack('u')[0]
322
+ tmp = Regexp.last_match[1].tr("a-zA-Z0-9+-", " -_")
323
+ tmp = ((32 + tmp.length * 3 / 4).to_i.chr << tmp).unpack1("u")
323
324
  tmp.chomp!("\000")
324
325
  entry.text = tmp.gsub!(/./) { |c| (c[0] ^ 67).chr }
325
- entry.text = 'Bad scan result' if entry.text.count('^ -~') > 0
326
+ entry.text = "Bad scan result" if entry.text.count("^ -~") > 0
326
327
  end
327
328
  end
328
329
 
@@ -337,8 +338,8 @@ module Alexandria
337
338
  Library.canonicalise_isbn(@entry_isbn.text)
338
339
  rescue StandardError
339
340
  raise _("Couldn't validate the EAN/ISBN you " \
340
- 'provided. Make sure it is written ' \
341
- 'correctly, and try again.')
341
+ "provided. Make sure it is written " \
342
+ "correctly, and try again.")
342
343
  end
343
344
  assert_not_exist(library, @entry_isbn.text)
344
345
  @button_add.sensitive = false
@@ -357,14 +358,14 @@ module Alexandria
357
358
 
358
359
  puts "adding book #{book} to library"
359
360
  add_book_to_library(library, book, cover_url)
360
- @entry_isbn.text = ''
361
+ @entry_isbn.text = ""
361
362
 
362
363
  post_addition([book], library, is_new)
363
364
  else
364
365
  post_addition([], library, is_new)
365
366
  end
366
- rescue Alexandria::BookProviders::NoResultsError => e
367
- @find_error = e.message
367
+ rescue Alexandria::BookProviders::NoResultsError => ex
368
+ @find_error = ex.message
368
369
  @button_add.sensitive = true
369
370
  notify_end_add_by_isbn
370
371
  ensure
@@ -385,7 +386,7 @@ module Alexandria
385
386
 
386
387
  isbn = book.isbn
387
388
  if isbn.nil? || isbn.empty?
388
- puts 'noisbn'
389
+ puts "noisbn"
389
390
  book.isbn = book.saved_ident = nil
390
391
  books_to_add << [book, cover]
391
392
  next
@@ -431,7 +432,7 @@ module Alexandria
431
432
  @entry_search.grab_focus
432
433
  else
433
434
  @button_add.sensitive = true #
434
- @entry_isbn.text = '' # blank ISBN field
435
+ @entry_isbn.text = "" # blank ISBN field
435
436
  @entry_isbn.grab_focus
436
437
  end
437
438
 
@@ -464,9 +465,9 @@ module Alexandria
464
465
 
465
466
  # Do not destroy if there is no addition.
466
467
  # return unless book_was_added
467
- rescue StandardError => e
468
+ rescue StandardError => ex
468
469
  # FIXME: Message containing <> should be displayed correctly.
469
- ErrorDialog.new(@new_book_dialog, _("Couldn't add the book"), e.message).display
470
+ ErrorDialog.new(@new_book_dialog, _("Couldn't add the book"), ex.message).display
470
471
  end
471
472
  # books_to_add
472
473
  end
@@ -558,7 +559,7 @@ module Alexandria
558
559
  end
559
560
 
560
561
  def on_help
561
- Alexandria::UI.display_help(@preferences_dialog, 'add-book-by-isbn')
562
+ Alexandria::UI.display_help(@preferences_dialog, "add-book-by-isbn")
562
563
  end
563
564
 
564
565
  private
@@ -570,7 +571,7 @@ module Alexandria
570
571
 
571
572
  if (book = library.find { |bk| bk.isbn == isbn13 })
572
573
  raise DuplicateBookException, format(_("'%s' already exists in '%s' (titled '%s')."),
573
- isbn, library.name, book.title.sub('&', '&amp;'))
574
+ isbn, library.name, book.title.sub("&", "&amp;"))
574
575
  end
575
576
  end
576
577
  end