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
@@ -21,15 +21,15 @@
21
21
 
22
22
  module Alexandria
23
23
  module UI
24
- BOOKS_TARGET_TABLE = [Gtk::TargetEntry.new('ALEXANDRIA_BOOKS', :same_app, 0)].freeze
24
+ BOOKS_TARGET_TABLE = [Gtk::TargetEntry.new("ALEXANDRIA_BOOKS", :same_app, 0)].freeze
25
25
 
26
26
  module DragAndDropable
27
27
  BADGE_MARKUP = '<span weight="heavy" foreground="white">%d</span>'
28
28
 
29
29
  def setup_view_source_dnd(view)
30
30
  # better be Loggable!
31
- log.info { format('setup_view_source_dnd for %s', view) }
32
- view.signal_connect_after('drag-begin') do |_widget, drag_context|
31
+ log.info { format("setup_view_source_dnd for %s", view) }
32
+ view.signal_connect_after("drag-begin") do |_widget, drag_context|
33
33
  n_books = @parent.selected_books.length
34
34
  if n_books > 1
35
35
  # Render generic book icon.
@@ -45,8 +45,8 @@ module Alexandria
45
45
 
46
46
  # Draw a red ellipse where the badge number should be.
47
47
  red_gc = Gdk::GC.new(pixmap)
48
- red_gc.rgb_fg_color = Gdk::Color.parse('red')
49
- red_gc.rgb_bg_color = Gdk::Color.parse('red')
48
+ red_gc.rgb_fg_color = Gdk::Color.parse("red")
49
+ red_gc.rgb_bg_color = Gdk::Color.parse("red")
50
50
  pixmap.draw_arc(red_gc,
51
51
  true,
52
52
  x - 5, y - 2,
@@ -66,11 +66,11 @@ module Alexandria
66
66
  end
67
67
  end
68
68
 
69
- view.signal_connect('drag-data-get') do |_widget, _drag_context, selection_data, _info, _time|
69
+ view.signal_connect("drag-data-get") do |_widget, _drag_context, selection_data, _info, _time|
70
70
  idents = @parent.selected_books.map(&:ident)
71
71
  unless idents.empty?
72
72
  selection_data.set(Gdk::Selection::TYPE_STRING,
73
- idents.join(','))
73
+ idents.join(","))
74
74
  end
75
75
  end
76
76
 
@@ -0,0 +1,25 @@
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 ErrorDialog < AlertDialog
12
+ def initialize(parent, title, message = nil)
13
+ super(parent, title, Gtk::Stock::DIALOG_ERROR,
14
+ [[Gtk::Stock::OK, :ok]], message)
15
+ # FIXME: Should accept just :ok
16
+ self.default_response = Gtk::ResponseType::OK
17
+ end
18
+
19
+ def display
20
+ show_all && run
21
+ destroy
22
+ end
23
+ end
24
+ end
25
+ end
@@ -4,36 +4,16 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require 'alexandria/export_format'
7
+ require "alexandria/export_format"
8
+ require "alexandria/ui/confirm_erase_dialog"
9
+ require "alexandria/ui/error_dialog"
8
10
 
9
11
  module Alexandria
10
12
  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
-
33
13
  class ExportDialog < SimpleDelegator
34
14
  include GetText
35
15
  extend GetText
36
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
16
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
37
17
 
38
18
  FORMATS = Alexandria::ExportFormat.all
39
19
  THEMES = Alexandria::WebTheme.all
@@ -44,11 +24,11 @@ module Alexandria
44
24
  action: :save,
45
25
  buttons: [[Gtk::Stock::HELP, :help],
46
26
  [Gtk::Stock::CANCEL, :cancel],
47
- [_('_Export'), :accept]])
27
+ [_("_Export"), :accept]])
48
28
  super(@export_dialog)
49
29
 
50
30
  self.current_name = library.name
51
- signal_connect('destroy') { hide }
31
+ signal_connect("destroy") { hide }
52
32
 
53
33
  @parent = parent
54
34
  @library = library
@@ -62,12 +42,12 @@ module Alexandria
62
42
  THEMES.each do |theme|
63
43
  @theme_combo.append_text(theme.name)
64
44
  end
65
- @theme_combo.signal_connect('changed') do
45
+ @theme_combo.signal_connect("changed") do
66
46
  file = THEMES[@theme_combo.active].preview_file
67
47
  preview_image.pixbuf = GdkPixbuf::Pixbuf.new(file: file)
68
48
  end
69
49
  @theme_combo.active = 0
70
- theme_label = Gtk::Label.new(_('_Theme:'), use_underline: true)
50
+ theme_label = Gtk::Label.new(_("_Theme:"), use_underline: true)
71
51
  theme_label.xalign = 0
72
52
  theme_label.mnemonic_widget = @theme_combo
73
53
 
@@ -75,23 +55,23 @@ module Alexandria
75
55
  @types_combo.vexpand = false
76
56
  @types_combo.valign = :center
77
57
  FORMATS.each do |format|
78
- text = format.name + ' ('
58
+ text = format.name + " ("
79
59
  text += if format.ext
80
- '*.' + format.ext
60
+ "*." + format.ext
81
61
  else
82
- _('directory')
62
+ _("directory")
83
63
  end
84
- text += ')'
64
+ text += ")"
85
65
  @types_combo.append_text(text)
86
66
  end
87
67
  @types_combo.active = 0
88
- @types_combo.signal_connect('changed') do
68
+ @types_combo.signal_connect("changed") do
89
69
  visible = FORMATS[@types_combo.active].needs_preview?
90
70
  theme_label.visible = @theme_combo.visible = preview_image.visible = visible
91
71
  end
92
72
  @types_combo.show
93
73
 
94
- types_label = Gtk::Label.new(_('Export for_mat:'), use_underline: true)
74
+ types_label = Gtk::Label.new(_("Export for_mat:"), use_underline: true)
95
75
  types_label.xalign = 0
96
76
  types_label.mnemonic_widget = @types_combo
97
77
  types_label.show
@@ -112,13 +92,13 @@ module Alexandria
112
92
  (response != Gtk::ResponseType::DELETE_EVENT)
113
93
 
114
94
  if response == Gtk::ResponseType::HELP
115
- Alexandria::UI.display_help(self, 'exporting')
95
+ Alexandria::UI.display_help(self, "exporting")
116
96
  else
117
97
  begin
118
98
  break if on_export(FORMATS[@types_combo.active],
119
99
  THEMES[@theme_combo.active])
120
- rescue StandardError => e
121
- ErrorDialog.new(@export_dialog, _('Export failed'), e.message).display
100
+ rescue StandardError => ex
101
+ ErrorDialog.new(@export_dialog, _("Export failed"), ex.message).display
122
102
  end
123
103
  end
124
104
  end
@@ -132,7 +112,7 @@ module Alexandria
132
112
 
133
113
  filename = self.filename
134
114
  if format.ext
135
- filename += '.' + format.ext if File.extname(filename).empty?
115
+ filename += "." + format.ext if File.extname(filename).empty?
136
116
  if File.exist?(filename)
137
117
  dialog = ConfirmEraseDialog.new(@export_dialog, filename)
138
118
  return unless dialog.erase?
@@ -144,10 +124,10 @@ module Alexandria
144
124
  if File.exist?(filename)
145
125
  unless File.directory?(filename)
146
126
  msg = _("The target, named '%s', is a regular " \
147
- 'file. A directory is needed for this ' \
148
- 'operation. Please select a directory and ' \
149
- 'try again.') % filename
150
- ErrorDialog.new(@export_dialog, _('Not a directory'), msg).display
127
+ "file. A directory is needed for this " \
128
+ "operation. Please select a directory and " \
129
+ "try again.") % filename
130
+ ErrorDialog.new(@export_dialog, _("Not a directory"), msg).display
151
131
  return
152
132
  end
153
133
  else
@@ -44,7 +44,7 @@ module Alexandria
44
44
  module Icons
45
45
  include Logging
46
46
 
47
- ICONS_DIR = File.join(Alexandria::Config::DATA_DIR, 'icons')
47
+ ICONS_DIR = File.join(Alexandria::Config::DATA_DIR, "icons")
48
48
  def self.init
49
49
  load_icon_images
50
50
  end
@@ -53,11 +53,11 @@ module Alexandria
53
53
  # Alexandria::UI::Icons namespace, e.g., Icons::STAR_SET
54
54
  def self.load_icon_images
55
55
  Dir.entries(ICONS_DIR).each do |file|
56
- next unless file =~ /\.png$/ # skip non '.png' files
56
+ next unless /\.png$/.match?(file) # skip non '.png' files
57
57
 
58
58
  # Don't use upcase and use tr instead
59
59
  # For example in Turkish the upper case of 'i' is still 'i'.
60
- name = File.basename(file, '.png').tr('a-z', 'A-Z')
60
+ name = File.basename(file, ".png").tr("a-z", "A-Z")
61
61
  const_set(name, GdkPixbuf::Pixbuf.new(file: File.join(ICONS_DIR, file)))
62
62
  end
63
63
  end
@@ -79,9 +79,9 @@ module Alexandria
79
79
  def self.blank?(filename)
80
80
  pixbuf = GdkPixbuf::Pixbuf.new(file: filename)
81
81
  (pixbuf.width == 1) && (pixbuf.height == 1)
82
- rescue StandardError => err
83
- puts err.message
84
- puts err.backtrace.join("\n> ")
82
+ rescue StandardError => ex
83
+ puts ex.message
84
+ puts ex.backtrace.join("\n> ")
85
85
  true
86
86
  end
87
87
  end
@@ -19,8 +19,8 @@
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/columns'
23
- require 'alexandria/ui/iconview_tooltips'
22
+ require "alexandria/ui/columns"
23
+ require "alexandria/ui/iconview_tooltips"
24
24
 
25
25
  module Alexandria
26
26
  module UI
@@ -51,14 +51,14 @@ module Alexandria
51
51
  @iconview.column_spacing = 16
52
52
  @iconview.item_width = ICON_WIDTH + 16
53
53
 
54
- @iconview.signal_connect('selection-changed') do
55
- log.debug { 'selection-changed' }
54
+ @iconview.signal_connect("selection-changed") do
55
+ log.debug { "selection-changed" }
56
56
  @parent.on_books_selection_changed
57
57
  end
58
58
 
59
- @iconview.signal_connect('item-activated') do
60
- log.debug { 'item-activated' }
61
- @actiongroup['Properties'].activate
59
+ @iconview.signal_connect("item-activated") do
60
+ log.debug { "item-activated" }
61
+ @actiongroup["Properties"].activate
62
62
  false
63
63
  end
64
64
 
@@ -29,7 +29,7 @@
29
29
  #
30
30
  # Ported to ruby-gtk2 (and modified for IconView) by Cathal Mc Ginley
31
31
 
32
- require 'cgi'
32
+ require "cgi"
33
33
 
34
34
  class IconViewTooltips
35
35
  include Alexandria::Logging
@@ -40,7 +40,7 @@ class IconViewTooltips
40
40
 
41
41
  def set_view(view)
42
42
  view.has_tooltip = true
43
- view.signal_connect('query-tooltip') do |_widget, x, y, _keyboard_mode, tooltip|
43
+ view.signal_connect("query-tooltip") do |_widget, x, y, _keyboard_mode, tooltip|
44
44
  tree_path = view.get_path_at_pos(x, y)
45
45
  if tree_path
46
46
  iter = view.model.get_iter(tree_path)
@@ -56,7 +56,7 @@ class IconViewTooltips
56
56
 
57
57
  def label_for_book(title, authors, publisher, year)
58
58
  # This is much too complex... but it works for now!
59
- html = ''
59
+ html = ""
60
60
  unless title.empty?
61
61
  html += "<b>#{CGI.escapeHTML(title)}</b>"
62
62
  html += "\n" unless authors.empty?
@@ -64,14 +64,14 @@ class IconViewTooltips
64
64
  html += "<i>#{CGI.escapeHTML(authors)}</i>" unless authors.empty?
65
65
  html += "\n" if !title.empty? || !authors.empty?
66
66
 
67
- html += '<small>'
67
+ html += "<small>"
68
68
  html += CGI.escapeHTML(publisher).to_s if publisher && !publisher.empty?
69
69
 
70
70
  if year && !year.empty?
71
- html += ' ' if publisher && !publisher.empty?
71
+ html += " " if publisher && !publisher.empty?
72
72
  html += "(#{year})"
73
73
  end
74
74
 
75
- html + '</small>'
75
+ html + "</small>"
76
76
  end
77
77
  end
@@ -4,6 +4,9 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
+ require "alexandria/ui/error_dialog"
8
+ require "alexandria/ui/skip_entry_dialog"
9
+
7
10
  class Alexandria::ImportFilter
8
11
  def to_filefilter
9
12
  filefilter = Gtk::FileFilter.new
@@ -15,49 +18,28 @@ end
15
18
 
16
19
  module Alexandria
17
20
  module UI
18
- class SkipEntryDialog < AlertDialog
19
- include GetText
20
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
21
-
22
- def initialize(parent, message)
23
- super(parent, _('Error while importing'),
24
- Gtk::Stock::DIALOG_QUESTION,
25
- [[Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL],
26
- [_('_Continue'), Gtk::ResponseType::OK]],
27
- message)
28
- puts "Opened SkipEntryDialog #{inspect}" if $DEBUG
29
- self.default_response = Gtk::ResponseType::CANCEL
30
- end
31
-
32
- def continue?
33
- show_all && (@response = run)
34
- destroy
35
- @response == Gtk::ResponseType::OK
36
- end
37
- end
38
-
39
21
  class ImportDialog < SimpleDelegator
40
22
  include GetText
41
23
  include Logging
42
24
 
43
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
25
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
44
26
 
45
27
  FILTERS = Alexandria::ImportFilter.all
46
28
 
47
29
  def initialize(parent)
48
- title = _('Import a Library')
30
+ title = _("Import a Library")
49
31
  dialog = Gtk::FileChooserDialog.new title: title, parent: parent, action: :open
50
32
  super(dialog)
51
- puts 'ImportDialog opened.' if $DEBUG
33
+ puts "ImportDialog opened." if $DEBUG
52
34
  @destroyed = false
53
35
  @running = false
54
36
  add_button(Gtk::Stock::HELP, Gtk::ResponseType::HELP)
55
37
  add_button(Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL)
56
- import_button = add_button(_('_Import'),
38
+ import_button = add_button(_("_Import"),
57
39
  Gtk::ResponseType::ACCEPT)
58
40
  import_button.sensitive = false
59
41
 
60
- signal_connect('destroy') do
42
+ signal_connect("destroy") do
61
43
  if @running
62
44
  @destroyed = true
63
45
  else
@@ -73,7 +55,7 @@ module Alexandria
73
55
  filters[filefilter] = filter
74
56
  end
75
57
 
76
- signal_connect('selection_changed') do
58
+ signal_connect("selection_changed") do
77
59
  import_button.sensitive = filename && File.file?(filename)
78
60
  end
79
61
 
@@ -106,10 +88,10 @@ module Alexandria
106
88
  response != Gtk::ResponseType::DELETE_EVENT
107
89
 
108
90
  if response == Gtk::ResponseType::HELP
109
- Alexandria::UI.display_help(self, 'import-library')
91
+ Alexandria::UI.display_help(self, "import-library")
110
92
  next
111
93
  end
112
- file = File.basename(filename, '.*')
94
+ file = File.basename(filename, ".*")
113
95
  base = GLib.locale_to_utf8(file)
114
96
  new_library_name = Library.generate_new_name(
115
97
  LibraryCollection.instance.all_libraries,
@@ -161,9 +143,9 @@ module Alexandria
161
143
  puts "Raising ErrorDialog because not_cancelled is #{not_cancelled}" if $DEBUG
162
144
  ErrorDialog.new(self,
163
145
  _("Couldn't import the library"),
164
- _('The format of the file you ' \
165
- 'provided is unknown. Please ' \
166
- 'retry with another file.')).display
146
+ _("The format of the file you " \
147
+ "provided is unknown. Please " \
148
+ "retry with another file.")).display
167
149
  end
168
150
  pbar.hide
169
151
  self.sensitive = true
@@ -1,32 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2004-2006 Laurent Sansonetti
4
- # Copyright (C) 2008 Joseph Method
5
- # Copyright (C) 2011, 2016 Matijs van Zuijlen
3
+ # This file is part of Alexandria.
6
4
  #
7
- # Alexandria is free software; you can redistribute it and/or
8
- # modify it under the terms of the GNU General Public License as
9
- # published by the Free Software Foundation; either version 2 of the
10
- # License, or (at your option) any later version.
11
- #
12
- # Alexandria is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- # General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public
18
- # License along with Alexandria; see the file COPYING. If not,
19
- # write to the Free Software Foundation, Inc., 51 Franklin Street,
20
- # Fifth Floor, Boston, MA 02110-1301 USA.
5
+ # See the file README.md for authorship and licensing information.
6
+
7
+ require "alexandria/ui/error_dialog"
21
8
 
22
9
  class CellRendererToggle < Gtk::CellRendererToggle
23
10
  attr_accessor :text
24
11
  type_register
25
12
  install_property(GLib::Param::String.new(
26
- 'text',
27
- 'text',
28
- 'Some damn value',
29
- '',
13
+ "text",
14
+ "text",
15
+ "Some damn value",
16
+ "",
30
17
  GLib::Param::READABLE | GLib::Param::WRITABLE))
31
18
  end
32
19
 
@@ -60,28 +47,28 @@ end
60
47
 
61
48
  class Alexandria::Library
62
49
  def action_name
63
- 'MoveIn' + name.gsub(/\s/, '')
50
+ "MoveIn" + name.gsub(/\s/, "")
64
51
  end
65
52
  end
66
53
 
67
54
  class Alexandria::BookProviders::AbstractProvider
68
55
  def action_name
69
- 'At' + name
56
+ "At" + name
70
57
  end
71
58
  end
72
59
 
73
60
  module Alexandria
74
61
  module UI
75
62
  def self.display_help(parent, section = nil)
76
- section_index = ''
63
+ section_index = ""
77
64
  section_index = "##{section}" if section
78
65
  exec("gnome-help ghelp:alexandria#{section_index}") if fork.nil?
79
66
  rescue StandardError
80
- log.error(self) { 'Unable to load help browser' }
81
- ErrorDialog.new(parent, _('Unable to launch the help browser'),
82
- _('Could not display help for Alexandria. ' \
83
- 'There was an error launching the system ' \
84
- 'help browser.')).display
67
+ log.error(self) { "Unable to load help browser" }
68
+ ErrorDialog.new(parent, _("Unable to launch the help browser"),
69
+ _("Could not display help for Alexandria. " \
70
+ "There was an error launching the system " \
71
+ "help browser.")).display
85
72
  end
86
73
  end
87
74
  end