alexandria-book-collection-manager 0.7.1 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +9 -0
- data/.gitignore +5 -2
- data/.hound.yml +2 -0
- data/.rubocop.yml +113 -45
- data/.rubocop_todo.yml +82 -170
- data/.simplecov +5 -1
- data/.travis.yml +45 -0
- data/.yardopts +1 -1
- data/CHANGELOG.md +60 -0
- data/ChangeLog.0 +33 -35
- data/Gemfile +6 -5
- data/INSTALL.md +164 -0
- data/README.md +52 -42
- data/Rakefile +95 -109
- data/TODO.md +9 -1
- data/alexandria-book-collection-manager.gemspec +52 -45
- data/bin/alexandria +31 -53
- data/doc/AUTHORS +61 -0
- data/doc/BUGS +31 -0
- data/doc/FAQ +365 -0
- data/doc/HACKING +19 -0
- data/doc/NEWS +341 -0
- data/doc/alexandria.1 +120 -0
- data/doc/cuecat_support.rdoc +67 -0
- data/doc/dependency_decisions.yml +80 -0
- data/lib/alexandria.rb +29 -37
- data/lib/alexandria/about.rb +52 -51
- data/lib/alexandria/book_providers.rb +94 -101
- data/lib/alexandria/book_providers/adlibris.rb +45 -85
- data/lib/alexandria/book_providers/amazon_aws.rb +105 -113
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +293 -324
- data/lib/alexandria/book_providers/barnes_and_noble.rb +54 -53
- data/lib/alexandria/book_providers/douban.rb +29 -51
- data/lib/alexandria/book_providers/proxis.rb +42 -59
- data/lib/alexandria/book_providers/pseudomarc.rb +79 -99
- data/lib/alexandria/book_providers/siciliano.rb +68 -70
- data/lib/alexandria/book_providers/thalia.rb +46 -45
- data/lib/alexandria/book_providers/web.rb +17 -33
- data/lib/alexandria/book_providers/worldcat.rb +74 -102
- data/lib/alexandria/book_providers/z3950.rb +170 -174
- data/lib/alexandria/config.rb +5 -3
- data/lib/alexandria/console.rb +10 -21
- data/lib/alexandria/default_preferences.rb +37 -0
- data/lib/alexandria/execution_queue.rb +17 -15
- data/lib/alexandria/export_format.rb +47 -0
- data/lib/alexandria/export_library.rb +188 -302
- data/lib/alexandria/import_library.rb +114 -155
- data/lib/alexandria/import_library_csv.rb +46 -96
- data/lib/alexandria/library_collection.rb +79 -0
- data/lib/alexandria/library_sort_order.rb +45 -0
- data/lib/alexandria/library_store.rb +233 -0
- data/lib/alexandria/logging.rb +15 -19
- data/lib/alexandria/models/book.rb +15 -20
- data/lib/alexandria/models/library.rb +81 -363
- data/lib/alexandria/net.rb +7 -6
- data/lib/alexandria/preferences.rb +73 -91
- data/lib/alexandria/scanners.rb +4 -2
- data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +24 -20
- data/lib/alexandria/scanners/keyboard.rb +10 -8
- data/lib/alexandria/smart_library.rb +135 -171
- data/lib/alexandria/ui.rb +17 -15
- data/lib/alexandria/ui/about_dialog.rb +49 -0
- data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +129 -152
- data/lib/alexandria/ui/alert_dialog.rb +64 -0
- data/lib/alexandria/ui/bad_isbns_dialog.rb +41 -0
- data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +18 -15
- data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +44 -61
- data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +84 -89
- data/lib/alexandria/ui/builder_base.rb +9 -27
- data/lib/alexandria/ui/callbacks.rb +188 -186
- data/lib/alexandria/ui/columns.rb +2 -0
- data/lib/alexandria/ui/completion_models.rb +12 -23
- 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 +10 -8
- data/lib/alexandria/ui/error_dialog.rb +25 -0
- data/lib/alexandria/ui/export_dialog.rb +139 -0
- data/lib/alexandria/ui/icons.rb +49 -65
- data/lib/alexandria/ui/iconview.rb +15 -13
- data/lib/alexandria/ui/iconview_tooltips.rb +43 -58
- data/lib/alexandria/ui/import_dialog.rb +157 -0
- data/lib/alexandria/ui/init.rb +23 -33
- data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +36 -0
- data/lib/alexandria/ui/libraries_combo.rb +18 -14
- data/lib/alexandria/ui/listview.rb +77 -88
- data/lib/alexandria/ui/main_app.rb +26 -26
- data/lib/alexandria/ui/misc_dialogs.rb +10 -0
- data/lib/alexandria/ui/multi_drag_treeview.rb +30 -41
- data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +168 -215
- data/lib/alexandria/ui/new_book_dialog_manual.rb +139 -0
- data/lib/alexandria/ui/new_provider_dialog.rb +100 -0
- data/lib/alexandria/ui/new_smart_library_dialog.rb +74 -0
- data/lib/alexandria/ui/preferences_dialog.rb +313 -0
- data/lib/alexandria/ui/provider_preferences_base_dialog.rb +95 -0
- data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
- data/lib/alexandria/ui/really_delete_dialog.rb +53 -0
- data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +62 -72
- data/lib/alexandria/ui/skip_entry_dialog.rb +33 -0
- data/lib/alexandria/ui/smart_library_properties_dialog.rb +60 -0
- data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog_base.rb → smart_library_properties_dialog_base.rb} +96 -172
- data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
- data/lib/alexandria/ui/sound.rb +13 -13
- data/lib/alexandria/ui/ui_manager.rb +262 -283
- data/lib/alexandria/undo_manager.rb +3 -0
- data/lib/alexandria/version.rb +6 -19
- data/lib/alexandria/web_themes.rb +24 -21
- data/po/Makefile +2 -2
- data/po/cs.po +993 -880
- data/po/cy.po +957 -874
- data/po/de.po +990 -869
- data/po/el.po +989 -869
- data/po/es.po +985 -865
- data/po/fr.po +986 -870
- data/po/ga.po +907 -823
- data/po/gl.po +981 -865
- data/po/it.po +986 -868
- data/po/ja.po +969 -853
- data/po/mk.po +983 -863
- data/po/nb.po +979 -863
- data/po/nl.po +983 -864
- data/po/pl.po +1020 -969
- data/po/pt.po +988 -861
- data/po/pt_BR.po +984 -868
- data/po/ru.po +992 -873
- data/po/sk.po +987 -869
- data/po/sv.po +977 -861
- data/po/uk.po +975 -865
- data/po/zh_TW.po +976 -860
- data/schemas/alexandria.schemas +25 -3
- data/share/alexandria/glade/acquire_dialog__builder.glade +15 -12
- data/share/alexandria/glade/book_properties_dialog__builder.glade +171 -299
- data/share/alexandria/glade/main_app__builder.glade +24 -33
- data/share/alexandria/glade/new_book_dialog__builder.glade +27 -59
- data/share/alexandria/glade/preferences_dialog__builder.glade +250 -290
- data/share/gnome/help/alexandria/C/introduction.xml +0 -8
- data/share/gnome/help/alexandria/C/searching.xml +1 -1
- data/share/gnome/help/alexandria/C/smart-libraries.xml +2 -2
- data/share/gnome/help/alexandria/C/working-with-libraries.xml +1 -1
- data/share/gnome/help/alexandria/fr/alexandria.xml +1 -1
- data/share/gnome/help/alexandria/ja/introduction.xml +0 -8
- data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
- data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
- data/spec/alexandria/book_providers_spec.rb +77 -210
- data/spec/alexandria/book_spec.rb +16 -12
- data/spec/alexandria/console_spec.rb +27 -0
- data/spec/alexandria/export_library_spec.rb +130 -0
- data/spec/alexandria/library_spec.rb +130 -172
- data/spec/alexandria/library_store_spec.rb +37 -0
- data/spec/alexandria/preferences_spec.rb +46 -17
- data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
- data/spec/alexandria/smart_library_spec.rb +32 -25
- 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/icons_spec.rb +26 -0
- data/spec/alexandria/ui/iconview_spec.rb +9 -21
- data/spec/alexandria/ui/import_dialog_spec.rb +41 -0
- data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/main_app_spec.rb +8 -33
- data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +15 -0
- data/spec/alexandria/ui/new_book_dialog_spec.rb +22 -0
- data/spec/alexandria/ui/new_provider_dialog_spec.rb +30 -0
- data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +39 -0
- data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +34 -0
- data/spec/alexandria/ui/really_delete_dialog_spec.rb +16 -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 +32 -0
- data/spec/alexandria/ui/sound_spec.rb +4 -2
- data/spec/alexandria/ui/ui_manager_spec.rb +45 -20
- data/spec/end_to_end/basic_run_spec.rb +57 -0
- data/spec/spec_helper.rb +66 -33
- data/tasks/setup.rb +5 -3
- data/tasks/spec.rake +18 -3
- data/util/rake/fileinstall.rb +38 -40
- data/util/rake/gettextgenerate.rb +15 -70
- data/util/rake/omfgenerate.rb +10 -10
- metadata +176 -60
- data/INSTALL.rdoc +0 -148
- data/dogtail/basic_run_test.py +0 -9
- data/lib/alexandria/book_providers/bol_it.rb +0 -160
- data/lib/alexandria/book_providers/deastore.rb +0 -273
- data/lib/alexandria/book_providers/ibs_it.rb +0 -147
- data/lib/alexandria/book_providers/mcu.rb +0 -169
- data/lib/alexandria/book_providers/renaud.rb +0 -140
- data/lib/alexandria/book_providers/webster_it.rb +0 -167
- data/lib/alexandria/ui/dialogs/about_dialog.rb +0 -59
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +0 -70
- data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +0 -43
- data/lib/alexandria/ui/dialogs/export_dialog.rb +0 -171
- data/lib/alexandria/ui/dialogs/import_dialog.rb +0 -196
- data/lib/alexandria/ui/dialogs/misc_dialogs.rb +0 -85
- data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +0 -154
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +0 -74
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +0 -578
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +0 -57
- data/spec/alexandria/scanners/cuecat_spec.rb +0 -65
- data/spec/alexandria/ui/dialogs_spec.rb +0 -94
- data/spec/alexandria/ui/sidepane_spec.rb +0 -27
- data/spec/alexandria/ui/ui_utilities_spec.rb +0 -60
- data/spec/alexandria/utilities_spec.rb +0 -50
- data/tasks/dogtail.rake +0 -4
@@ -0,0 +1,95 @@
|
|
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
|
+
|
10
|
+
def mandatory?
|
11
|
+
@mandatory
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module Alexandria
|
16
|
+
module UI
|
17
|
+
class ProviderPreferencesBaseDialog
|
18
|
+
attr_reader :dialog
|
19
|
+
|
20
|
+
def initialize(title:, parent:, flags:, buttons:)
|
21
|
+
@dialog = Gtk::Dialog.new(title: title, parent: parent, flags: flags,
|
22
|
+
buttons: buttons)
|
23
|
+
|
24
|
+
@dialog.resizable = false
|
25
|
+
@dialog.child.border_width = 12
|
26
|
+
|
27
|
+
@controls = []
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def fill_table(table, provider)
|
33
|
+
i = table.n_rows
|
34
|
+
table.resize(table.n_rows + provider.prefs.length,
|
35
|
+
table.n_columns)
|
36
|
+
table.border_width = 12
|
37
|
+
table.row_spacings = 6
|
38
|
+
table.column_spacings = 12
|
39
|
+
|
40
|
+
@controls.clear
|
41
|
+
|
42
|
+
provider.prefs.read.each do |variable|
|
43
|
+
if variable.name == "piggyback"
|
44
|
+
next
|
45
|
+
# ULTRA-HACK!! for bug #13302
|
46
|
+
# not displaying the visual choice, as its usually unnecessary
|
47
|
+
# Either way, this is confusing to the user: FIX
|
48
|
+
# - Cathal Mc Ginley 2008-02-18
|
49
|
+
end
|
50
|
+
|
51
|
+
if variable.name == "enabled"
|
52
|
+
# also don't display Enabled/Disabled
|
53
|
+
next
|
54
|
+
end
|
55
|
+
|
56
|
+
label = Gtk::Label.new("_" + variable.description + ":")
|
57
|
+
label.use_underline = true
|
58
|
+
label.xalign = 0
|
59
|
+
table.attach_defaults(label, 0, 1, i, i + 1)
|
60
|
+
|
61
|
+
if variable.possible_values.nil?
|
62
|
+
entry = Gtk::Entry.new
|
63
|
+
entry.text = variable.value.to_s
|
64
|
+
entry.mandatory = variable.mandatory?
|
65
|
+
else
|
66
|
+
entry = Gtk::ComboBoxText.new
|
67
|
+
variable.possible_values.each do |value|
|
68
|
+
entry.append_text(value.to_s)
|
69
|
+
end
|
70
|
+
index = variable.possible_values.index(variable.value)
|
71
|
+
entry.active = index
|
72
|
+
end
|
73
|
+
label.mnemonic_widget = entry
|
74
|
+
|
75
|
+
@controls << [variable, entry]
|
76
|
+
|
77
|
+
table.attach_defaults(entry, 1, 2, i, i + 1)
|
78
|
+
i += 1
|
79
|
+
end
|
80
|
+
table
|
81
|
+
end
|
82
|
+
|
83
|
+
def sync_variables
|
84
|
+
@controls.each do |variable, entry|
|
85
|
+
variable.new_value = case entry
|
86
|
+
when Gtk::ComboBox
|
87
|
+
variable.possible_values[entry.active]
|
88
|
+
when Gtk::Entry
|
89
|
+
entry.text
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
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
|
+
dialog.child.pack_start(table)
|
24
|
+
|
25
|
+
dialog.signal_connect("destroy") { sync_variables }
|
26
|
+
end
|
27
|
+
|
28
|
+
def acquire
|
29
|
+
dialog.show_all
|
30
|
+
dialog.run
|
31
|
+
dialog.destroy
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,53 @@
|
|
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 ReallyDeleteDialog < AlertDialog
|
12
|
+
include GetText
|
13
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
14
|
+
|
15
|
+
def initialize(parent, library, books = nil)
|
16
|
+
# Deleting a library.
|
17
|
+
if books.nil?
|
18
|
+
message = _("Are you sure you want to delete '%s'?") % library.name
|
19
|
+
description = if library.is_a?(SmartLibrary) || library.empty?
|
20
|
+
nil
|
21
|
+
else
|
22
|
+
n_("If you continue, %d book will be deleted.",
|
23
|
+
"If you continue, %d books will be deleted.",
|
24
|
+
library.size) % library.size
|
25
|
+
end
|
26
|
+
# Deleting books.
|
27
|
+
else
|
28
|
+
message = if books.length == 1
|
29
|
+
format(_("Are you sure you want to delete '%s' " \
|
30
|
+
"from '%s'?"), books.first.title, library.name)
|
31
|
+
else
|
32
|
+
_("Are you sure you want to delete the " \
|
33
|
+
"selected books from '%s'?") % library.name
|
34
|
+
end
|
35
|
+
description = nil
|
36
|
+
end
|
37
|
+
|
38
|
+
super(parent, message, Gtk::Stock::DIALOG_QUESTION,
|
39
|
+
[[Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL],
|
40
|
+
[Gtk::Stock::DELETE, Gtk::ResponseType::OK]],
|
41
|
+
description)
|
42
|
+
|
43
|
+
dialog.default_response = Gtk::ResponseType::CANCEL
|
44
|
+
end
|
45
|
+
|
46
|
+
def ok?
|
47
|
+
show_all && (@response = run)
|
48
|
+
destroy
|
49
|
+
@response == Gtk::ResponseType::OK
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,32 +1,22 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# Alexandria is free software; you can redistribute it and/or
|
6
|
-
# modify it under the terms of the GNU General Public License as
|
7
|
-
# published by the Free Software Foundation; either version 2 of the
|
8
|
-
# License, or (at your option) any later version.
|
9
|
-
#
|
10
|
-
# Alexandria is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
# General Public License for more details.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is part of Alexandria.
|
14
4
|
#
|
15
|
-
#
|
16
|
-
|
17
|
-
|
18
|
-
# 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"
|
19
8
|
|
20
9
|
module Alexandria
|
21
10
|
module UI
|
22
|
-
class
|
11
|
+
class SidepaneManager
|
23
12
|
include Logging
|
24
13
|
include GetText
|
25
14
|
attr_accessor :library_listview
|
15
|
+
|
26
16
|
def initialize(library_listview, parent)
|
27
17
|
@library_listview = library_listview
|
28
18
|
@parent = parent
|
29
|
-
@libraries =
|
19
|
+
@libraries = LibraryCollection.instance
|
30
20
|
@main_app = @parent.main_app
|
31
21
|
setup_sidepane
|
32
22
|
end
|
@@ -42,57 +32,54 @@ module Alexandria
|
|
42
32
|
# if new_text contains disallowed char (/ or initial .), returns a MatchData object
|
43
33
|
# otherwise returns nil
|
44
34
|
def contains_illegal_character(new_text)
|
45
|
-
new_text.unpack(
|
46
|
-
match = /(^\.|\/)/.match(new_text)
|
35
|
+
new_text.unpack("U*") # attempt to unpack as UTF-8 characters
|
47
36
|
# forbid / character (since Library names become dir names)
|
48
37
|
# also no initial . since that hides the Library (hidden file)
|
49
38
|
# forbidding an initial dot also disallows "." and ".."
|
50
39
|
# which are of course pre-existing directories.
|
51
|
-
|
52
|
-
rescue => ex
|
40
|
+
%r{(^\.|/)}.match(new_text)
|
41
|
+
rescue StandardError => ex
|
53
42
|
log.warn { "New library name not valid UTF-8: #{ex.message}" }
|
54
|
-
|
43
|
+
true
|
55
44
|
# /([^\w\s'"()&?!:;.\-])/.match(new_text) # anglocentric!
|
56
45
|
end
|
57
46
|
|
58
47
|
def on_edited_library(cell, path_string, new_text)
|
59
48
|
log.debug { "edited library name #{new_text}" }
|
60
|
-
|
61
|
-
|
62
|
-
if
|
63
|
-
if
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
'disallowed character <b>%s</b> ') % chars)
|
69
|
-
else
|
70
|
-
ErrorDialog.new(@main_app, _('Invalid library name'),
|
71
|
-
_('The name provided contains ' \
|
72
|
-
'invalid characters.'))
|
73
|
-
end
|
74
|
-
|
75
|
-
elsif new_text.strip.empty?
|
76
|
-
log.debug { 'Empty text' }
|
77
|
-
ErrorDialog.new(@main_app, _('The library name ' \
|
78
|
-
'can not be empty'))
|
79
|
-
elsif library_already_exists new_text
|
80
|
-
log.debug { 'Already exists' }
|
81
|
-
ErrorDialog.new(@main_app,
|
82
|
-
_('The library can not be renamed'),
|
83
|
-
_('There is already a library named ' \
|
84
|
-
"'%s'. Please choose a different " \
|
85
|
-
'name.') % new_text.strip)
|
49
|
+
return if cell.text == new_text
|
50
|
+
|
51
|
+
if (match = contains_illegal_character(new_text))
|
52
|
+
if match.instance_of? MatchData
|
53
|
+
chars = match[1].gsub(/&/, "&")
|
54
|
+
ErrorDialog.new(@main_app, _("Invalid library name '%s'") % new_text,
|
55
|
+
_("The name provided contains the " \
|
56
|
+
"disallowed character <b>%s</b>") % chars).display
|
86
57
|
else
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
library_name = new_text.strip
|
91
|
-
log.info { "library name is #{library_name}" }
|
92
|
-
iter[1] = @parent.selected_library.name = library_name
|
93
|
-
@parent.setup_move_actions
|
94
|
-
@parent.refresh_libraries
|
58
|
+
ErrorDialog.new(@main_app, _("Invalid library name"),
|
59
|
+
_("The name provided contains " \
|
60
|
+
"invalid characters.")).display
|
95
61
|
end
|
62
|
+
|
63
|
+
elsif new_text.strip.empty?
|
64
|
+
log.debug { "Empty text" }
|
65
|
+
ErrorDialog.new(@main_app, _("The library name " \
|
66
|
+
"can not be empty")).display
|
67
|
+
elsif library_already_exists new_text
|
68
|
+
log.debug { "Already exists" }
|
69
|
+
ErrorDialog.new(@main_app,
|
70
|
+
_("The library can not be renamed"),
|
71
|
+
_("There is already a library named " \
|
72
|
+
"'%s'. Please choose a different " \
|
73
|
+
"name.") % new_text.strip).display
|
74
|
+
else
|
75
|
+
log.debug { "Attempting to apply #{path_string}, #{new_text}" }
|
76
|
+
path = Gtk::TreePath.new(path_string)
|
77
|
+
iter = @library_listview.model.get_iter(path)
|
78
|
+
library_name = new_text.strip
|
79
|
+
log.info { "library name is #{library_name}" }
|
80
|
+
iter[1] = @parent.selected_library.name = library_name
|
81
|
+
@parent.setup_move_actions
|
82
|
+
@parent.refresh_libraries
|
96
83
|
end
|
97
84
|
end
|
98
85
|
|
@@ -106,14 +93,14 @@ module Alexandria
|
|
106
93
|
@libraries.all_smart_libraries.each { |x| @parent.append_library(x) }
|
107
94
|
|
108
95
|
renderer = Gtk::CellRendererPixbuf.new
|
109
|
-
column = Gtk::TreeViewColumn.new(_(
|
96
|
+
column = Gtk::TreeViewColumn.new(_("Library"))
|
110
97
|
column.pack_start(renderer, false)
|
111
98
|
column.set_cell_data_func(renderer) do |_col, cell, _model, iter|
|
112
99
|
# log.debug { "sidepane: cell_data_func #{col}, #{cell}, #{iter}" }
|
113
100
|
cell.pixbuf = iter[0]
|
114
101
|
end
|
115
102
|
renderer = Gtk::CellRendererText.new
|
116
|
-
renderer.ellipsize =
|
103
|
+
renderer.ellipsize = :end
|
117
104
|
column.pack_start(renderer, true)
|
118
105
|
column.set_cell_data_func(renderer) do |_col, cell, _model, iter|
|
119
106
|
# log.debug { "sidepane: editable #{cell}, #{iter} #{iter[1]}: #{iter[2]}" }
|
@@ -121,7 +108,7 @@ module Alexandria
|
|
121
108
|
cell.editable = iter[2]
|
122
109
|
# log.debug { "exit sidepane: editable #{cell}, #{iter}" }
|
123
110
|
end
|
124
|
-
renderer.signal_connect(
|
111
|
+
renderer.signal_connect("edited", &method(:on_edited_library))
|
125
112
|
@library_listview.append_column(column)
|
126
113
|
|
127
114
|
@library_listview.set_row_separator_func do |model, iter|
|
@@ -129,16 +116,17 @@ module Alexandria
|
|
129
116
|
model.get_value(iter, 3)
|
130
117
|
end
|
131
118
|
|
132
|
-
@library_listview.selection.signal_connect(
|
133
|
-
log.debug {
|
119
|
+
@library_listview.selection.signal_connect("changed") do
|
120
|
+
log.debug { "changed" }
|
134
121
|
@parent.refresh_libraries
|
135
122
|
@parent.refresh_books
|
136
123
|
end
|
137
124
|
|
138
125
|
@library_listview.enable_model_drag_dest(BOOKS_TARGET_TABLE, :move)
|
139
126
|
|
140
|
-
@library_listview
|
141
|
-
|
127
|
+
@library_listview
|
128
|
+
.signal_connect("drag-motion") do |_widget, drag_context, x, y, time, _data|
|
129
|
+
log.debug { "drag-motion" }
|
142
130
|
|
143
131
|
path, column, =
|
144
132
|
@library_listview.get_path_at_pos(x, y)
|
@@ -163,12 +151,13 @@ module Alexandria
|
|
163
151
|
@library_listview.set_drag_dest_row(path, :into_or_after)
|
164
152
|
|
165
153
|
Gdk.drag_status(drag_context,
|
166
|
-
|
154
|
+
path ? drag_context.suggested_action : 0,
|
167
155
|
time)
|
168
156
|
end
|
169
157
|
|
170
|
-
@library_listview
|
171
|
-
|
158
|
+
@library_listview
|
159
|
+
.signal_connect("drag-drop") do |widget, drag_context, _x, _y, time, _data|
|
160
|
+
log.debug { "drag-drop" }
|
172
161
|
|
173
162
|
widget.drag_get_data(drag_context,
|
174
163
|
drag_context.targets.first,
|
@@ -176,13 +165,14 @@ module Alexandria
|
|
176
165
|
true
|
177
166
|
end
|
178
167
|
|
179
|
-
@library_listview
|
180
|
-
|
168
|
+
@library_listview
|
169
|
+
.signal_connect("drag-data-received") do |_, drag_context, x, y, data, _, _|
|
170
|
+
log.debug { "drag-data-received" }
|
181
171
|
|
182
172
|
success = false
|
183
173
|
# FIXME: Ruby-GNOME2 should make comparison work without needing to
|
184
174
|
# call #name.
|
185
|
-
if
|
175
|
+
if data.data_type.name == Gdk::Selection::TYPE_STRING.name
|
186
176
|
success, path =
|
187
177
|
@library_listview.get_dest_row_at_pos(x, y)
|
188
178
|
|
@@ -197,7 +187,7 @@ module Alexandria
|
|
197
187
|
end
|
198
188
|
begin
|
199
189
|
drag_context.finish(success: success, delete: false)
|
200
|
-
rescue => ex
|
190
|
+
rescue StandardError => ex
|
201
191
|
log.error { "drag_context.finish failed: #{ex}" }
|
202
192
|
raise
|
203
193
|
end
|
@@ -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 SkipEntryDialog < AlertDialog
|
12
|
+
include GetText
|
13
|
+
include Logging
|
14
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
15
|
+
|
16
|
+
def initialize(parent, message)
|
17
|
+
super(parent, _("Error while importing"),
|
18
|
+
Gtk::Stock::DIALOG_QUESTION,
|
19
|
+
[[Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL],
|
20
|
+
[_("_Continue"), Gtk::ResponseType::OK]],
|
21
|
+
message)
|
22
|
+
log.debug { "Opened SkipEntryDialog #{inspect}" }
|
23
|
+
dialog.default_response = Gtk::ResponseType::CANCEL
|
24
|
+
end
|
25
|
+
|
26
|
+
def continue?
|
27
|
+
show_all && (@response = run)
|
28
|
+
destroy
|
29
|
+
@response == Gtk::ResponseType::OK
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,60 @@
|
|
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
|
+
class SmartLibraryPropertiesDialog < SmartLibraryPropertiesDialogBase
|
10
|
+
include GetText
|
11
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
12
|
+
|
13
|
+
def initialize(parent, smart_library)
|
14
|
+
super(parent)
|
15
|
+
|
16
|
+
@smart_library = smart_library
|
17
|
+
|
18
|
+
dialog.add_buttons([Gtk::Stock::CANCEL, :cancel],
|
19
|
+
[Gtk::Stock::SAVE, :ok])
|
20
|
+
|
21
|
+
dialog.title = _("Properties for '%s'") % @smart_library.name
|
22
|
+
# FIXME: Should accept just :cancel
|
23
|
+
dialog.default_response = Gtk::ResponseType::CANCEL
|
24
|
+
@smart_library.rules.each { |x| insert_new_rule(x) }
|
25
|
+
update_rules_header_box(@smart_library.predicate_operator_rule)
|
26
|
+
end
|
27
|
+
|
28
|
+
def acquire
|
29
|
+
dialog.show_all
|
30
|
+
|
31
|
+
while (response = dialog.run) != Gtk::ResponseType::CANCEL
|
32
|
+
case response
|
33
|
+
when Gtk::ResponseType::HELP
|
34
|
+
handle_help_response
|
35
|
+
when Gtk::ResponseType::OK
|
36
|
+
break if handle_ok_response
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
dialog.destroy
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def handle_ok_response
|
46
|
+
user_confirms_possible_weirdnesses_before_saving? or return
|
47
|
+
|
48
|
+
@smart_library.rules = smart_library_rules
|
49
|
+
@smart_library.predicate_operator_rule =
|
50
|
+
predicate_operator_rule
|
51
|
+
@smart_library.save
|
52
|
+
true
|
53
|
+
end
|
54
|
+
|
55
|
+
def handle_help_response
|
56
|
+
Alexandria::UI.display_help(self, "edit-smart-library")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|