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.
- checksums.yaml +4 -4
- data/.rubocop.yml +28 -25
- data/.rubocop_todo.yml +87 -67
- data/CHANGELOG.md +12 -1
- data/Gemfile +4 -3
- data/README.md +16 -6
- data/Rakefile +71 -72
- data/alexandria-book-collection-manager.gemspec +44 -44
- data/bin/alexandria +12 -12
- data/lib/alexandria.rb +22 -22
- data/lib/alexandria/about.rb +50 -50
- data/lib/alexandria/book_providers.rb +50 -50
- data/lib/alexandria/book_providers/adlibris.rb +28 -44
- data/lib/alexandria/book_providers/amazon_aws.rb +64 -64
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +52 -78
- data/lib/alexandria/book_providers/barnes_and_noble.rb +34 -34
- data/lib/alexandria/book_providers/douban.rb +21 -37
- data/lib/alexandria/book_providers/proxis.rb +24 -24
- data/lib/alexandria/book_providers/pseudomarc.rb +19 -19
- data/lib/alexandria/book_providers/renaud.rb +44 -57
- data/lib/alexandria/book_providers/siciliano.rb +39 -39
- data/lib/alexandria/book_providers/thalia.rb +33 -33
- data/lib/alexandria/book_providers/web.rb +5 -5
- data/lib/alexandria/book_providers/worldcat.rb +44 -69
- data/lib/alexandria/book_providers/z3950.rb +94 -109
- data/lib/alexandria/config.rb +1 -1
- data/lib/alexandria/console.rb +3 -3
- data/lib/alexandria/export_format.rb +8 -8
- data/lib/alexandria/export_library.rb +112 -113
- data/lib/alexandria/import_library.rb +45 -45
- data/lib/alexandria/import_library_csv.rb +30 -30
- data/lib/alexandria/library_collection.rb +4 -4
- data/lib/alexandria/library_sort_order.rb +1 -1
- data/lib/alexandria/library_store.rb +14 -14
- data/lib/alexandria/logging.rb +5 -5
- data/lib/alexandria/models/book.rb +1 -1
- data/lib/alexandria/models/library.rb +36 -36
- data/lib/alexandria/net.rb +5 -5
- data/lib/alexandria/preferences.rb +32 -32
- data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +13 -13
- data/lib/alexandria/scanners/keyboard.rb +5 -5
- data/lib/alexandria/smart_library.rb +53 -53
- data/lib/alexandria/ui.rb +15 -15
- data/lib/alexandria/ui/{dialogs/about_dialog.rb → about_dialog.rb} +1 -1
- data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +66 -65
- data/lib/alexandria/ui/{dialogs/alert_dialog.rb → alert_dialog.rb} +1 -16
- data/lib/alexandria/ui/{dialogs/bad_isbns_dialog.rb → bad_isbns_dialog.rb} +0 -0
- data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +7 -7
- data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +25 -37
- data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +38 -37
- data/lib/alexandria/ui/builder_base.rb +1 -1
- data/lib/alexandria/ui/callbacks.rb +95 -91
- data/lib/alexandria/ui/completion_models.rb +7 -21
- data/lib/alexandria/ui/confirm_erase_dialog.rb +33 -0
- data/lib/alexandria/ui/conflict_while_copying_dialog.rb +34 -0
- data/lib/alexandria/ui/dndable.rb +7 -7
- data/lib/alexandria/ui/error_dialog.rb +25 -0
- data/lib/alexandria/ui/{dialogs/export_dialog.rb → export_dialog.rb} +22 -42
- data/lib/alexandria/ui/icons.rb +6 -6
- data/lib/alexandria/ui/iconview.rb +7 -7
- data/lib/alexandria/ui/iconview_tooltips.rb +6 -6
- data/lib/alexandria/ui/{dialogs/import_dialog.rb → import_dialog.rb} +14 -32
- data/lib/alexandria/ui/init.rb +16 -29
- data/lib/alexandria/ui/{dialogs/keep_bad_isbn_dialog.rb → keep_bad_isbn_dialog.rb} +6 -4
- data/lib/alexandria/ui/libraries_combo.rb +7 -7
- data/lib/alexandria/ui/listview.rb +40 -40
- data/lib/alexandria/ui/main_app.rb +22 -24
- data/lib/alexandria/ui/misc_dialogs.rb +10 -0
- data/lib/alexandria/ui/multi_drag_treeview.rb +4 -4
- data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +46 -45
- data/lib/alexandria/ui/{dialogs/new_book_dialog_manual.rb → new_book_dialog_manual.rb} +20 -19
- data/lib/alexandria/ui/new_provider_dialog.rb +99 -0
- data/lib/alexandria/ui/{dialogs/new_smart_library_dialog.rb → new_smart_library_dialog.rb} +4 -4
- data/lib/alexandria/ui/{dialogs/preferences_dialog.rb → preferences_dialog.rb} +44 -235
- data/lib/alexandria/ui/provider_preferences_base_dialog.rb +90 -0
- data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
- data/lib/alexandria/ui/{dialogs/misc_dialogs.rb → really_delete_dialog.rb} +6 -27
- data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +27 -25
- data/lib/alexandria/ui/skip_entry_dialog.rb +32 -0
- data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog.rb → smart_library_properties_dialog.rb} +2 -2
- data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog_base.rb → smart_library_properties_dialog_base.rb} +30 -30
- data/lib/alexandria/ui/sound.rb +8 -8
- data/lib/alexandria/ui/ui_manager.rb +136 -135
- data/lib/alexandria/version.rb +4 -19
- data/lib/alexandria/web_themes.rb +8 -8
- data/po/cs.po +97 -97
- data/po/cy.po +97 -97
- data/po/de.po +97 -97
- data/po/el.po +97 -97
- data/po/es.po +97 -97
- data/po/fr.po +97 -97
- data/po/ga.po +97 -97
- data/po/gl.po +97 -97
- data/po/it.po +97 -97
- data/po/ja.po +97 -97
- data/po/mk.po +97 -97
- data/po/nb.po +97 -97
- data/po/nl.po +97 -97
- data/po/pl.po +97 -97
- data/po/pt.po +97 -97
- data/po/pt_BR.po +97 -97
- data/po/ru.po +97 -97
- data/po/sk.po +97 -97
- data/po/sv.po +97 -97
- data/po/uk.po +97 -97
- data/po/zh_TW.po +97 -97
- data/schemas/alexandria.schemas +24 -2
- data/spec/alexandria/book_providers_spec.rb +65 -82
- data/spec/alexandria/book_spec.rb +12 -10
- data/spec/alexandria/console_spec.rb +9 -9
- data/spec/alexandria/export_library_spec.rb +31 -31
- data/spec/alexandria/library_spec.rb +86 -86
- data/spec/alexandria/library_store_spec.rb +8 -8
- data/spec/alexandria/preferences_spec.rb +18 -17
- data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
- data/spec/alexandria/smart_library_spec.rb +15 -15
- data/spec/alexandria/ui/about_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/acquire_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/alert_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/book_properties_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/error_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/export_dialog_spec.rb +15 -0
- data/spec/alexandria/ui/iconview_spec.rb +7 -21
- data/spec/alexandria/ui/import_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/main_app_spec.rb +6 -6
- data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +15 -0
- data/spec/alexandria/ui/{dialogs/new_book_dialog_spec.rb → new_book_dialog_spec.rb} +4 -4
- data/spec/alexandria/ui/new_provider_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +19 -0
- data/spec/alexandria/ui/really_delete_dialog_spec.rb +15 -0
- data/spec/alexandria/ui/sidepane_manager_spec.rb +15 -0
- data/spec/alexandria/ui/skip_entry_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +18 -0
- data/spec/alexandria/ui/sound_spec.rb +2 -2
- data/spec/alexandria/ui/ui_manager_spec.rb +6 -20
- data/spec/alexandria/ui/ui_utilities_spec.rb +9 -9
- data/spec/alexandria/utilities_spec.rb +6 -6
- data/spec/end_to_end/basic_run_spec.rb +24 -36
- data/spec/spec_helper.rb +9 -9
- data/tasks/dogtail.rake +1 -1
- data/tasks/setup.rb +2 -2
- data/tasks/spec.rake +11 -11
- data/util/rake/fileinstall.rb +25 -25
- data/util/rake/gettextgenerate.rb +7 -7
- data/util/rake/omfgenerate.rb +7 -7
- metadata +59 -33
- data/spec/alexandria/scanners/cuecat_spec.rb +0 -67
- data/spec/alexandria/ui/dialogs_spec.rb +0 -162
- data/spec/alexandria/ui/sidepane_spec.rb +0 -29
@@ -0,0 +1,90 @@
|
|
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
|
+
class Gtk::Entry
|
8
|
+
attr_writer :mandatory
|
9
|
+
def mandatory?
|
10
|
+
@mandatory
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Alexandria
|
15
|
+
module UI
|
16
|
+
class ProviderPreferencesBaseDialog < SimpleDelegator
|
17
|
+
def initialize(title:, parent:, flags:, buttons:)
|
18
|
+
dialog = Gtk::Dialog.new(title: title, parent: parent, flags: flags, buttons: buttons)
|
19
|
+
super(dialog)
|
20
|
+
|
21
|
+
self.resizable = false
|
22
|
+
child.border_width = 12
|
23
|
+
|
24
|
+
@controls = []
|
25
|
+
end
|
26
|
+
|
27
|
+
def fill_table(table, provider)
|
28
|
+
i = table.n_rows
|
29
|
+
table.resize(table.n_rows + provider.prefs.length,
|
30
|
+
table.n_columns)
|
31
|
+
table.border_width = 12
|
32
|
+
table.row_spacings = 6
|
33
|
+
table.column_spacings = 12
|
34
|
+
|
35
|
+
@controls.clear
|
36
|
+
|
37
|
+
provider.prefs.read.each do |variable|
|
38
|
+
if variable.name == "piggyback"
|
39
|
+
next
|
40
|
+
# ULTRA-HACK!! for bug #13302
|
41
|
+
# not displaying the visual choice, as its usually unnecessary
|
42
|
+
# Either way, this is confusing to the user: FIX
|
43
|
+
# - Cathal Mc Ginley 2008-02-18
|
44
|
+
end
|
45
|
+
|
46
|
+
if variable.name == "enabled"
|
47
|
+
# also don't display Enabled/Disabled
|
48
|
+
next
|
49
|
+
end
|
50
|
+
|
51
|
+
label = Gtk::Label.new("_" + variable.description + ":")
|
52
|
+
label.use_underline = true
|
53
|
+
label.xalign = 0
|
54
|
+
table.attach_defaults(label, 0, 1, i, i + 1)
|
55
|
+
|
56
|
+
if variable.possible_values.nil?
|
57
|
+
entry = Gtk::Entry.new
|
58
|
+
entry.text = variable.value.to_s
|
59
|
+
entry.mandatory = variable.mandatory?
|
60
|
+
else
|
61
|
+
entry = Gtk::ComboBoxText.new
|
62
|
+
variable.possible_values.each do |value|
|
63
|
+
entry.append_text(value.to_s)
|
64
|
+
end
|
65
|
+
index = variable.possible_values.index(variable.value)
|
66
|
+
entry.active = index
|
67
|
+
end
|
68
|
+
label.mnemonic_widget = entry
|
69
|
+
|
70
|
+
@controls << [variable, entry]
|
71
|
+
|
72
|
+
table.attach_defaults(entry, 1, 2, i, i + 1)
|
73
|
+
i += 1
|
74
|
+
end
|
75
|
+
table
|
76
|
+
end
|
77
|
+
|
78
|
+
def sync_variables
|
79
|
+
@controls.each do |variable, entry|
|
80
|
+
variable.new_value = case entry
|
81
|
+
when Gtk::ComboBox
|
82
|
+
variable.possible_values[entry.active]
|
83
|
+
when Gtk::Entry
|
84
|
+
entry.text
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,35 @@
|
|
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/provider_preferences_base_dialog"
|
8
|
+
|
9
|
+
module Alexandria
|
10
|
+
module UI
|
11
|
+
class ProviderPreferencesDialog < ProviderPreferencesBaseDialog
|
12
|
+
include GetText
|
13
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
14
|
+
|
15
|
+
def initialize(parent, provider)
|
16
|
+
super(title: _("Preferences for %s") % provider.fullname,
|
17
|
+
parent: parent,
|
18
|
+
flags: :modal,
|
19
|
+
buttons: [[Gtk::Stock::CLOSE, :close]])
|
20
|
+
|
21
|
+
table = Gtk::Table.new(0, 0)
|
22
|
+
fill_table(table, provider)
|
23
|
+
child.pack_start(table)
|
24
|
+
|
25
|
+
signal_connect("destroy") { sync_variables }
|
26
|
+
end
|
27
|
+
|
28
|
+
def acquire
|
29
|
+
show_all
|
30
|
+
run
|
31
|
+
destroy
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -4,34 +4,13 @@
|
|
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
|
-
class ConflictWhileCopyingDialog < AlertDialog
|
10
|
-
include GetText
|
11
|
-
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
|
12
|
-
|
13
|
-
def initialize(parent, library, book)
|
14
|
-
super(parent,
|
15
|
-
format(_("The book '%s' already exists in '%s'. Would you like " \
|
16
|
-
'to replace it?'), book.title, library.name),
|
17
|
-
Gtk::Stock::DIALOG_QUESTION,
|
18
|
-
[[_('_Skip'), Gtk::ResponseType::CANCEL],
|
19
|
-
[_('_Replace'), Gtk::ResponseType::OK]],
|
20
|
-
_('If you replace the existing book, its contents will ' \
|
21
|
-
'be overwritten.'))
|
22
|
-
self.default_response = Gtk::ResponseType::CANCEL
|
23
|
-
end
|
24
|
-
|
25
|
-
def replace?
|
26
|
-
show_all && (@response = run)
|
27
|
-
destroy
|
28
|
-
@response == Gtk::ResponseType::OK
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
11
|
class ReallyDeleteDialog < AlertDialog
|
33
12
|
include GetText
|
34
|
-
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset:
|
13
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
35
14
|
|
36
15
|
def initialize(parent, library, books = nil)
|
37
16
|
# Deleting a library.
|
@@ -40,8 +19,8 @@ module Alexandria
|
|
40
19
|
description = if library.is_a?(SmartLibrary) || library.empty?
|
41
20
|
nil
|
42
21
|
else
|
43
|
-
n_(
|
44
|
-
|
22
|
+
n_("If you continue, %d book will be deleted.",
|
23
|
+
"If you continue, %d books will be deleted.",
|
45
24
|
library.size) % library.size
|
46
25
|
end
|
47
26
|
# Deleting books.
|
@@ -50,7 +29,7 @@ module Alexandria
|
|
50
29
|
format(_("Are you sure you want to delete '%s' " \
|
51
30
|
"from '%s'?"), books.first.title, library.name)
|
52
31
|
else
|
53
|
-
_(
|
32
|
+
_("Are you sure you want to delete the " \
|
54
33
|
"selected books from '%s'?") % library.name
|
55
34
|
end
|
56
35
|
description = nil
|
@@ -4,6 +4,8 @@
|
|
4
4
|
#
|
5
5
|
# See the file README.md for authorship and licensing information.
|
6
6
|
|
7
|
+
require "alexandria/ui/error_dialog"
|
8
|
+
|
7
9
|
module Alexandria
|
8
10
|
module UI
|
9
11
|
class SidePaneManager
|
@@ -29,8 +31,8 @@ module Alexandria
|
|
29
31
|
# if new_text contains disallowed char (/ or initial .), returns a MatchData object
|
30
32
|
# otherwise returns nil
|
31
33
|
def contains_illegal_character(new_text)
|
32
|
-
new_text.unpack(
|
33
|
-
match =
|
34
|
+
new_text.unpack("U*") # attempt to unpack as UTF-8 characters
|
35
|
+
match = %r{(^\.|/)}.match(new_text)
|
34
36
|
# forbid / character (since Library names become dir names)
|
35
37
|
# also no initial . since that hides the Library (hidden file)
|
36
38
|
# forbidding an initial dot also disallows "." and ".."
|
@@ -49,27 +51,27 @@ module Alexandria
|
|
49
51
|
if cell.text != new_text
|
50
52
|
if (match = contains_illegal_character(new_text))
|
51
53
|
if match.instance_of? MatchData
|
52
|
-
chars = match[1].gsub(/&/,
|
54
|
+
chars = match[1].gsub(/&/, "&")
|
53
55
|
ErrorDialog.new(@main_app, _("Invalid library name '%s'") % new_text,
|
54
|
-
_(
|
55
|
-
|
56
|
+
_("The name provided contains the " \
|
57
|
+
"disallowed character <b>%s</b> ") % chars).display
|
56
58
|
else
|
57
|
-
ErrorDialog.new(@main_app, _(
|
58
|
-
_(
|
59
|
-
|
59
|
+
ErrorDialog.new(@main_app, _("Invalid library name"),
|
60
|
+
_("The name provided contains " \
|
61
|
+
"invalid characters.")).display
|
60
62
|
end
|
61
63
|
|
62
64
|
elsif new_text.strip.empty?
|
63
|
-
log.debug {
|
64
|
-
ErrorDialog.new(@main_app, _(
|
65
|
-
|
65
|
+
log.debug { "Empty text" }
|
66
|
+
ErrorDialog.new(@main_app, _("The library name " \
|
67
|
+
"can not be empty")).display
|
66
68
|
elsif library_already_exists new_text
|
67
|
-
log.debug {
|
69
|
+
log.debug { "Already exists" }
|
68
70
|
ErrorDialog.new(@main_app,
|
69
|
-
_(
|
70
|
-
_(
|
71
|
+
_("The library can not be renamed"),
|
72
|
+
_("There is already a library named " \
|
71
73
|
"'%s'. Please choose a different " \
|
72
|
-
|
74
|
+
"name.") % new_text.strip).display
|
73
75
|
else
|
74
76
|
log.debug { "Attempting to apply #{path_string}, #{new_text}" }
|
75
77
|
path = Gtk::TreePath.new(path_string)
|
@@ -93,7 +95,7 @@ module Alexandria
|
|
93
95
|
@libraries.all_smart_libraries.each { |x| @parent.append_library(x) }
|
94
96
|
|
95
97
|
renderer = Gtk::CellRendererPixbuf.new
|
96
|
-
column = Gtk::TreeViewColumn.new(_(
|
98
|
+
column = Gtk::TreeViewColumn.new(_("Library"))
|
97
99
|
column.pack_start(renderer, false)
|
98
100
|
column.set_cell_data_func(renderer) do |_col, cell, _model, iter|
|
99
101
|
# log.debug { "sidepane: cell_data_func #{col}, #{cell}, #{iter}" }
|
@@ -108,7 +110,7 @@ module Alexandria
|
|
108
110
|
cell.editable = iter[2]
|
109
111
|
# log.debug { "exit sidepane: editable #{cell}, #{iter}" }
|
110
112
|
end
|
111
|
-
renderer.signal_connect(
|
113
|
+
renderer.signal_connect("edited", &method(:on_edited_library))
|
112
114
|
@library_listview.append_column(column)
|
113
115
|
|
114
116
|
@library_listview.set_row_separator_func do |model, iter|
|
@@ -116,16 +118,16 @@ module Alexandria
|
|
116
118
|
model.get_value(iter, 3)
|
117
119
|
end
|
118
120
|
|
119
|
-
@library_listview.selection.signal_connect(
|
120
|
-
log.debug {
|
121
|
+
@library_listview.selection.signal_connect("changed") do
|
122
|
+
log.debug { "changed" }
|
121
123
|
@parent.refresh_libraries
|
122
124
|
@parent.refresh_books
|
123
125
|
end
|
124
126
|
|
125
127
|
@library_listview.enable_model_drag_dest(BOOKS_TARGET_TABLE, :move)
|
126
128
|
|
127
|
-
@library_listview.signal_connect(
|
128
|
-
log.debug {
|
129
|
+
@library_listview.signal_connect("drag-motion") do |_widget, drag_context, x, y, time, _data|
|
130
|
+
log.debug { "drag-motion" }
|
129
131
|
|
130
132
|
path, column, =
|
131
133
|
@library_listview.get_path_at_pos(x, y)
|
@@ -154,8 +156,8 @@ module Alexandria
|
|
154
156
|
time)
|
155
157
|
end
|
156
158
|
|
157
|
-
@library_listview.signal_connect(
|
158
|
-
log.debug {
|
159
|
+
@library_listview.signal_connect("drag-drop") do |widget, drag_context, _x, _y, time, _data|
|
160
|
+
log.debug { "drag-drop" }
|
159
161
|
|
160
162
|
widget.drag_get_data(drag_context,
|
161
163
|
drag_context.targets.first,
|
@@ -163,8 +165,8 @@ module Alexandria
|
|
163
165
|
true
|
164
166
|
end
|
165
167
|
|
166
|
-
@library_listview.signal_connect(
|
167
|
-
log.debug {
|
168
|
+
@library_listview.signal_connect("drag-data-received") do |_, drag_context, x, y, data, _, _|
|
169
|
+
log.debug { "drag-data-received" }
|
168
170
|
|
169
171
|
success = false
|
170
172
|
# FIXME: Ruby-GNOME2 should make comparison work without needing to
|
@@ -0,0 +1,32 @@
|
|
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 SkipEntryDialog < AlertDialog
|
12
|
+
include GetText
|
13
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
14
|
+
|
15
|
+
def initialize(parent, message)
|
16
|
+
super(parent, _("Error while importing"),
|
17
|
+
Gtk::Stock::DIALOG_QUESTION,
|
18
|
+
[[Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL],
|
19
|
+
[_("_Continue"), Gtk::ResponseType::OK]],
|
20
|
+
message)
|
21
|
+
puts "Opened SkipEntryDialog #{inspect}" if $DEBUG
|
22
|
+
self.default_response = Gtk::ResponseType::CANCEL
|
23
|
+
end
|
24
|
+
|
25
|
+
def continue?
|
26
|
+
show_all && (@response = run)
|
27
|
+
destroy
|
28
|
+
@response == Gtk::ResponseType::OK
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -21,7 +21,7 @@ module Alexandria
|
|
21
21
|
module UI
|
22
22
|
class SmartLibraryPropertiesDialog < SmartLibraryPropertiesDialogBase
|
23
23
|
include GetText
|
24
|
-
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset:
|
24
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
25
25
|
|
26
26
|
def initialize(parent, smart_library)
|
27
27
|
super(parent)
|
@@ -41,7 +41,7 @@ module Alexandria
|
|
41
41
|
|
42
42
|
while (response = run) != Gtk::ResponseType::CANCEL
|
43
43
|
if response == Gtk::ResponseType::HELP
|
44
|
-
Alexandria::UI.display_help(self,
|
44
|
+
Alexandria::UI.display_help(self, "edit-smart-library")
|
45
45
|
elsif response == Gtk::ResponseType::OK
|
46
46
|
if user_confirms_possible_weirdnesses_before_saving?
|
47
47
|
smart_library.rules = smart_library_rules
|
@@ -23,12 +23,12 @@ module Alexandria
|
|
23
23
|
class SmartLibraryPropertiesDialogBase < SimpleDelegator
|
24
24
|
include Logging
|
25
25
|
include GetText
|
26
|
-
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset:
|
26
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
27
27
|
|
28
28
|
attr_reader :predicate_operator_rule
|
29
29
|
|
30
30
|
def initialize(parent)
|
31
|
-
@dialog = Gtk::Dialog.new(title:
|
31
|
+
@dialog = Gtk::Dialog.new(title: "",
|
32
32
|
parent: parent,
|
33
33
|
flags: :modal,
|
34
34
|
buttons: [[Gtk::Stock::HELP, :help]])
|
@@ -75,7 +75,7 @@ module Alexandria
|
|
75
75
|
def has_weirdnesses?
|
76
76
|
fill_smart_library_rules_values
|
77
77
|
smart_library_rules.each do |rule|
|
78
|
-
return true if rule.value ==
|
78
|
+
return true if rule.value == ""
|
79
79
|
end
|
80
80
|
false
|
81
81
|
end
|
@@ -85,14 +85,14 @@ module Alexandria
|
|
85
85
|
|
86
86
|
dialog = AlertDialog.new(
|
87
87
|
@dialog,
|
88
|
-
_(
|
88
|
+
_("Empty or conflictive condition"),
|
89
89
|
Gtk::Stock::DIALOG_QUESTION,
|
90
90
|
[[Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL],
|
91
|
-
[_(
|
92
|
-
_(
|
93
|
-
|
94
|
-
|
95
|
-
|
91
|
+
[_("_Save However"), Gtk::ResponseType::YES]],
|
92
|
+
_("This smart library contains one or more conditions " \
|
93
|
+
"which are empty or conflict with each other. This is " \
|
94
|
+
"likely to result in never matching a book. Are you " \
|
95
|
+
"sure you want to save this library?"))
|
96
96
|
dialog.default_response = Gtk::ResponseType::CANCEL
|
97
97
|
dialog.show_all
|
98
98
|
confirmed = dialog.run == Gtk::ResponseType::YES
|
@@ -106,11 +106,11 @@ module Alexandria
|
|
106
106
|
if @rules_box.children.length > 1
|
107
107
|
label1 = Gtk::Label.new
|
108
108
|
label1.set_alignment(0.0, 0.5)
|
109
|
-
label1.text = _(
|
109
|
+
label1.text = _("Match")
|
110
110
|
|
111
111
|
cb = Gtk::ComboBoxText.new
|
112
|
-
[_(
|
113
|
-
cb.signal_connect(
|
112
|
+
[_("all"), _("any")].each { |x| cb.append_text(x) }
|
113
|
+
cb.signal_connect("changed") do
|
114
114
|
@predicate_operator_rule = cb.active.zero? ? SmartLibrary::ALL_RULES : SmartLibrary::ANY_RULE
|
115
115
|
end
|
116
116
|
cb.active =
|
@@ -118,7 +118,7 @@ module Alexandria
|
|
118
118
|
|
119
119
|
label2 = Gtk::Label.new
|
120
120
|
label2.set_alignment(0.0, 0.5)
|
121
|
-
label2.text = _(
|
121
|
+
label2.text = _("of the following rules:")
|
122
122
|
|
123
123
|
@rules_header_box.pack_start(label1, expand: false, fill: false)
|
124
124
|
@rules_header_box.pack_start(cb, expand: false, fill: false)
|
@@ -126,7 +126,7 @@ module Alexandria
|
|
126
126
|
else
|
127
127
|
label = Gtk::Label.new
|
128
128
|
label.set_alignment(0.0, 0.5)
|
129
|
-
label.text = _(
|
129
|
+
label.text = _("Match the following rule:")
|
130
130
|
@rules_header_box << label
|
131
131
|
@predicate_operator_rule = SmartLibrary::ALL_RULES
|
132
132
|
end
|
@@ -146,29 +146,29 @@ module Alexandria
|
|
146
146
|
date_entry = Gtk::Entry.new
|
147
147
|
date_entry.primary_icon_name = Gtk::Stock::EDIT
|
148
148
|
date_entry.primary_icon_activatable = true
|
149
|
-
date_entry.signal_connect(
|
150
|
-
display_calendar_popup(entry) if primary.nick ==
|
149
|
+
date_entry.signal_connect("icon-press") do |entry, primary, _icon|
|
150
|
+
display_calendar_popup(entry) if primary.nick == "primary"
|
151
151
|
end
|
152
152
|
|
153
153
|
# Really hide the time part of the date entry, as the constructor
|
154
154
|
# does not seem to do it...
|
155
155
|
# ##date_entry.children[2..3].each { |x| date_entry.remove(x) }
|
156
156
|
# ##date_entry.spacing = 8
|
157
|
-
entry_label = Gtk::Label.new(
|
157
|
+
entry_label = Gtk::Label.new("")
|
158
158
|
|
159
|
-
add_button = Gtk::Button.new(label:
|
159
|
+
add_button = Gtk::Button.new(label: "")
|
160
160
|
add_button.remove(add_button.children.first)
|
161
161
|
add_button << Gtk::Image.new(stock: Gtk::Stock::ADD,
|
162
162
|
size: Gtk::IconSize::BUTTON)
|
163
163
|
|
164
|
-
add_button.signal_connect(
|
164
|
+
add_button.signal_connect("clicked") { insert_new_rule }
|
165
165
|
|
166
|
-
remove_button = Gtk::Button.new(label:
|
166
|
+
remove_button = Gtk::Button.new(label: "")
|
167
167
|
remove_button.remove(remove_button.children.first)
|
168
168
|
remove_button << Gtk::Image.new(stock: Gtk::Stock::REMOVE,
|
169
169
|
size: Gtk::IconSize::BUTTON)
|
170
170
|
|
171
|
-
remove_button.signal_connect(
|
171
|
+
remove_button.signal_connect("clicked") do |_button|
|
172
172
|
idx = @rules_box.children.index(rule_box)
|
173
173
|
raise if idx.nil?
|
174
174
|
|
@@ -182,7 +182,7 @@ module Alexandria
|
|
182
182
|
operands.each do |operand|
|
183
183
|
left_operand_combo.append_text(operand.name)
|
184
184
|
end
|
185
|
-
operator_combo.signal_connect(
|
185
|
+
operator_combo.signal_connect("changed") do
|
186
186
|
operand = operands[left_operand_combo.active]
|
187
187
|
operations = SmartLibrary::Rule.operations_for_operand(operand)
|
188
188
|
operation = operations[operator_combo.active]
|
@@ -191,7 +191,7 @@ module Alexandria
|
|
191
191
|
right_operand = operation.last
|
192
192
|
unless right_operand.nil?
|
193
193
|
entry = case right_operand.klass.name
|
194
|
-
when
|
194
|
+
when "Time"
|
195
195
|
date_entry
|
196
196
|
else
|
197
197
|
value_entry
|
@@ -215,7 +215,7 @@ module Alexandria
|
|
215
215
|
new_rule.operation = operation.first
|
216
216
|
new_rule.value = nil
|
217
217
|
end
|
218
|
-
left_operand_combo.signal_connect(
|
218
|
+
left_operand_combo.signal_connect("changed") do
|
219
219
|
operand = operands[left_operand_combo.active]
|
220
220
|
operator_combo.freeze_notify do
|
221
221
|
operator_combo.remove_all
|
@@ -312,12 +312,12 @@ module Alexandria
|
|
312
312
|
|
313
313
|
@calendar_popup.set_transient_for(@dialog)
|
314
314
|
@calendar_popup.set_type_hint(:dialog)
|
315
|
-
@calendar_popup.name =
|
315
|
+
@calendar_popup.name = "calendar-popup"
|
316
316
|
@calendar_popup.resizable = false
|
317
317
|
# @calendar_popup.border_width = 4
|
318
318
|
# @calendar_popup.app_paintable = true
|
319
319
|
|
320
|
-
@calendar_popup.signal_connect(
|
320
|
+
@calendar_popup.signal_connect("focus-out-event") do |_popup, _event|
|
321
321
|
hide_calendar_popup
|
322
322
|
false
|
323
323
|
end
|
@@ -325,7 +325,7 @@ module Alexandria
|
|
325
325
|
@calendar = Gtk::Calendar.new
|
326
326
|
@calendar_popup.add(@calendar)
|
327
327
|
|
328
|
-
@calendar.signal_connect(
|
328
|
+
@calendar.signal_connect("day-selected") do
|
329
329
|
date_arr = @calendar.date
|
330
330
|
year = date_arr[0]
|
331
331
|
month = date_arr[1] # + 1 # gtk : months 0-indexed, Time.gm : 1-index
|
@@ -336,7 +336,7 @@ module Alexandria
|
|
336
336
|
end
|
337
337
|
end
|
338
338
|
|
339
|
-
@calendar.signal_connect(
|
339
|
+
@calendar.signal_connect("day-selected-double-click") do
|
340
340
|
date_arr = @calendar.date
|
341
341
|
year = date_arr[0]
|
342
342
|
month = date_arr[1] # + 1 # gtk : months 0-indexed, Time.gm : 1-index
|
@@ -405,7 +405,7 @@ module Alexandria
|
|
405
405
|
end
|
406
406
|
|
407
407
|
def parse_date(datestring)
|
408
|
-
date_format =
|
408
|
+
date_format = "%d/%m/%Y" # or '%m/%d/%Y' for USA and Canada ; or '%Y-%m-%d' for most of Asia
|
409
409
|
## http://en.wikipedia.org/wiki/Calendar_date#Middle_endian_forms.2C_starting_with_the_month
|
410
410
|
begin
|
411
411
|
d = Date.strptime(datestring, date_format)
|
@@ -416,7 +416,7 @@ module Alexandria
|
|
416
416
|
end
|
417
417
|
|
418
418
|
def format_date(datetime)
|
419
|
-
datetime.strftime(
|
419
|
+
datetime.strftime("%d/%m/%Y")
|
420
420
|
end
|
421
421
|
end
|
422
422
|
end
|