alexandria-book-collection-manager 0.7.3 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/ruby.yml +77 -0
- data/.gitignore +4 -1
- data/.rubocop.yml +86 -36
- data/.rubocop_todo.yml +58 -161
- data/.simplecov +5 -2
- data/CHANGELOG.md +56 -2
- data/Gemfile +4 -3
- data/INSTALL.md +23 -11
- data/README.md +52 -41
- data/Rakefile +78 -75
- data/alexandria-book-collection-manager.gemspec +50 -44
- data/bin/alexandria +12 -22
- data/doc/FAQ +1 -2
- data/doc/dependency_decisions.yml +27 -8
- data/lib/alexandria.rb +25 -23
- data/lib/alexandria/about.rb +50 -50
- data/lib/alexandria/book_providers.rb +86 -91
- data/lib/alexandria/book_providers/adlibris.rb +37 -74
- data/lib/alexandria/book_providers/amazon_aws.rb +94 -100
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +289 -324
- data/lib/alexandria/book_providers/barnes_and_noble.rb +42 -42
- data/lib/alexandria/book_providers/douban.rb +25 -41
- data/lib/alexandria/book_providers/proxis.rb +34 -29
- data/lib/alexandria/book_providers/pseudomarc.rb +77 -85
- data/lib/alexandria/book_providers/siciliano.rb +60 -64
- data/lib/alexandria/book_providers/thalia_provider.rb +161 -0
- data/lib/alexandria/book_providers/web.rb +5 -5
- data/lib/alexandria/book_providers/worldcat.rb +66 -95
- data/lib/alexandria/book_providers/z3950.rb +153 -169
- data/lib/alexandria/config.rb +1 -1
- data/lib/alexandria/console.rb +3 -3
- data/lib/alexandria/default_preferences.rb +37 -0
- data/lib/alexandria/execution_queue.rb +13 -12
- data/lib/alexandria/export_format.rb +8 -8
- data/lib/alexandria/export_library.rb +128 -127
- data/lib/alexandria/import_library.rb +102 -126
- data/lib/alexandria/import_library_csv.rb +41 -41
- data/lib/alexandria/library_collection.rb +6 -5
- data/lib/alexandria/library_sort_order.rb +4 -2
- data/lib/alexandria/library_store.rb +39 -28
- data/lib/alexandria/logging.rb +10 -14
- data/lib/alexandria/models/book.rb +5 -4
- data/lib/alexandria/models/library.rb +63 -53
- data/lib/alexandria/net.rb +5 -6
- data/lib/alexandria/preferences.rb +66 -63
- data/lib/alexandria/scanners.rb +2 -2
- data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +17 -17
- data/lib/alexandria/scanners/keyboard.rb +8 -8
- data/lib/alexandria/smart_library.rb +110 -112
- data/lib/alexandria/ui.rb +15 -15
- data/lib/alexandria/ui/{dialogs/about_dialog.rb → about_dialog.rb} +2 -2
- data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +108 -109
- data/lib/alexandria/ui/alert_dialog.rb +66 -0
- data/lib/alexandria/ui/{dialogs/bad_isbns_dialog.rb → bad_isbns_dialog.rb} +13 -9
- data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +16 -15
- data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +25 -38
- data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +64 -157
- data/lib/alexandria/ui/builder_base.rb +1 -1
- data/lib/alexandria/ui/calendar_popup.rb +58 -0
- data/lib/alexandria/ui/callbacks.rb +187 -155
- data/lib/alexandria/ui/completion_models.rb +8 -22
- 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} +37 -58
- data/lib/alexandria/ui/icons.rb +38 -43
- data/lib/alexandria/ui/iconview.rb +12 -10
- data/lib/alexandria/ui/iconview_tooltips.rb +41 -54
- data/lib/alexandria/ui/import_dialog.rb +157 -0
- data/lib/alexandria/ui/init.rb +30 -41
- data/lib/alexandria/ui/{dialogs/keep_bad_isbn_dialog.rb → keep_bad_isbn_dialog.rb} +9 -6
- data/lib/alexandria/ui/libraries_combo.rb +15 -14
- data/lib/alexandria/ui/listview.rb +69 -67
- data/lib/alexandria/ui/main_app.rb +24 -26
- data/lib/alexandria/ui/misc_dialogs.rb +10 -0
- data/lib/alexandria/ui/multi_drag_treeview.rb +8 -9
- data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +113 -114
- data/lib/alexandria/ui/{dialogs/new_book_dialog_manual.rb → new_book_dialog_manual.rb} +22 -19
- 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/{dialogs/misc_dialogs.rb → really_delete_dialog.rb} +7 -28
- data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +53 -48
- 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/smart_library_properties_dialog_base.rb +242 -0
- data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
- data/lib/alexandria/ui/sound.rb +11 -13
- data/lib/alexandria/ui/ui_manager.rb +216 -200
- data/lib/alexandria/version.rb +4 -19
- data/lib/alexandria/web_themes.rb +21 -21
- data/po/Makefile +2 -2
- data/po/cs.po +992 -875
- data/po/cy.po +961 -874
- data/po/de.po +990 -865
- data/po/el.po +989 -865
- data/po/es.po +985 -861
- data/po/fr.po +987 -867
- data/po/ga.po +908 -820
- data/po/gl.po +980 -860
- data/po/it.po +986 -864
- data/po/ja.po +969 -849
- data/po/mk.po +984 -860
- data/po/nb.po +979 -859
- data/po/nl.po +983 -860
- data/po/pl.po +1018 -971
- data/po/pt.po +988 -857
- data/po/pt_BR.po +983 -863
- data/po/ru.po +994 -871
- data/po/sk.po +989 -867
- data/po/sv.po +976 -856
- data/po/uk.po +972 -858
- data/po/zh_TW.po +974 -854
- data/schemas/alexandria.schemas +24 -2
- data/share/alexandria/glade/acquire_dialog__builder.glade +1 -1
- data/share/alexandria/glade/book_properties_dialog__builder.glade +1 -1
- data/share/alexandria/glade/main_app__builder.glade +6 -21
- data/share/alexandria/glade/new_book_dialog__builder.glade +1 -1
- data/share/alexandria/glade/preferences_dialog__builder.glade +1 -1
- data/share/gnome/help/alexandria/C/introduction.xml +0 -4
- 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 -4
- data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
- data/spec/alexandria/book_providers/thalia_provider_spec.rb +119 -0
- data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
- data/spec/alexandria/book_providers_spec.rb +62 -156
- data/spec/alexandria/book_spec.rb +12 -10
- data/spec/alexandria/console_spec.rb +6 -11
- data/spec/alexandria/export_library_spec.rb +47 -58
- data/spec/alexandria/library_spec.rb +121 -109
- data/spec/alexandria/library_store_spec.rb +8 -8
- data/spec/alexandria/preferences_spec.rb +44 -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 +59 -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 +36 -0
- data/spec/alexandria/ui/icons_spec.rb +26 -0
- data/spec/alexandria/ui/iconview_spec.rb +7 -21
- data/spec/alexandria/ui/import_dialog_spec.rb +46 -0
- data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/main_app_spec.rb +7 -34
- data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +51 -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 +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 +49 -0
- data/spec/alexandria/ui/sound_spec.rb +2 -2
- data/spec/alexandria/ui/ui_manager_spec.rb +44 -20
- data/spec/end_to_end/basic_run_spec.rb +21 -38
- data/spec/fixtures/cover.jpg +0 -0
- data/spec/spec_helper.rb +54 -10
- data/tasks/setup.rb +2 -2
- data/tasks/spec.rake +11 -11
- data/util/rake/fileinstall.rb +38 -35
- data/util/rake/gettextgenerate.rb +7 -7
- data/util/rake/omfgenerate.rb +7 -7
- metadata +158 -45
- data/dogtail/basic_run_test.py +0 -9
- data/lib/alexandria/book_providers/renaud.rb +0 -155
- data/lib/alexandria/book_providers/thalia.rb +0 -198
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +0 -63
- data/lib/alexandria/ui/dialogs/import_dialog.rb +0 -176
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +0 -62
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +0 -563
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +0 -61
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +0 -423
- 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
- data/spec/alexandria/ui/ui_utilities_spec.rb +0 -62
- data/spec/alexandria/utilities_spec.rb +0 -52
- data/tasks/dogtail.rake +0 -6
@@ -1,22 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
# Copyright (C) 2011, 2016 Matijs van Zuijlen
|
3
|
+
# This file is part of Alexandria.
|
5
4
|
#
|
6
|
-
#
|
7
|
-
# modify it under the terms of the GNU General Public License as
|
8
|
-
# published by the Free Software Foundation; either version 2 of the
|
9
|
-
# License, or (at your option) any later version.
|
10
|
-
#
|
11
|
-
# Alexandria is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
-
# General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public
|
17
|
-
# License along with Alexandria; see the file COPYING. If not,
|
18
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
19
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
5
|
+
# See the file README.md for authorship and licensing information.
|
20
6
|
|
21
7
|
module Alexandria
|
22
8
|
module EntryOverrides
|
@@ -44,21 +30,21 @@ module Alexandria
|
|
44
30
|
complete(Alexandria::UI::CompletionModels::TAG)
|
45
31
|
# min = self.completion.minimum_key_length
|
46
32
|
min = 2
|
47
|
-
completion.signal_connect(
|
33
|
+
completion.signal_connect("match-selected") do |c, model, iter|
|
48
34
|
cur_text = c.entry.text
|
49
35
|
# TODO: Replace with iter[0] if possible
|
50
36
|
new_tag = model.get_value(iter, 0)
|
51
|
-
cur_text_split = cur_text.split(
|
37
|
+
cur_text_split = cur_text.split(",")
|
52
38
|
cur_text_split.delete_at(-1)
|
53
39
|
cur_text_split << new_tag
|
54
|
-
c.entry.text = cur_text_split.join(
|
40
|
+
c.entry.text = cur_text_split.join(",")
|
55
41
|
true
|
56
42
|
end
|
57
43
|
completion.set_match_func do |_comp, key, iter|
|
58
|
-
cur_tag = key.split(
|
44
|
+
cur_tag = key.split(",").last.strip
|
59
45
|
if cur_tag.size >= min
|
60
46
|
begin
|
61
|
-
if iter[0]
|
47
|
+
if /^#{cur_tag}/.match?(iter[0])
|
62
48
|
true
|
63
49
|
else
|
64
50
|
false
|
@@ -178,7 +164,7 @@ module Alexandria
|
|
178
164
|
editions << book.edition
|
179
165
|
borrowers << book.loaned_to
|
180
166
|
# TODO: Ensure #tags is always an array
|
181
|
-
(book.tags
|
167
|
+
tags.concat(book.tags) if book.tags
|
182
168
|
end
|
183
169
|
end
|
184
170
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is part of Alexandria.
|
4
|
+
#
|
5
|
+
# See the file README.md for authorship and licensing information.
|
6
|
+
|
7
|
+
require "alexandria/ui/alert_dialog"
|
8
|
+
|
9
|
+
module Alexandria
|
10
|
+
module UI
|
11
|
+
class ConfirmEraseDialog < AlertDialog
|
12
|
+
include GetText
|
13
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
14
|
+
|
15
|
+
def initialize(parent, filename)
|
16
|
+
super(parent, _("File already exists"),
|
17
|
+
Gtk::Stock::DIALOG_QUESTION,
|
18
|
+
[[Gtk::Stock::CANCEL, :cancel],
|
19
|
+
[_("_Replace"), :ok]],
|
20
|
+
_("A file named '%s' already exists. Do you want " \
|
21
|
+
"to replace it with the one you are generating?") % filename)
|
22
|
+
# FIXME: Should accept just :cancel
|
23
|
+
dialog.default_response = Gtk::ResponseType::CANCEL
|
24
|
+
end
|
25
|
+
|
26
|
+
def erase?
|
27
|
+
show_all && (@response = run)
|
28
|
+
destroy
|
29
|
+
@response == Gtk::ResponseType::OK
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is part of Alexandria.
|
4
|
+
#
|
5
|
+
# See the file README.md for authorship and licensing information.
|
6
|
+
|
7
|
+
require "alexandria/ui/alert_dialog"
|
8
|
+
|
9
|
+
module Alexandria
|
10
|
+
module UI
|
11
|
+
class ConflictWhileCopyingDialog < AlertDialog
|
12
|
+
include GetText
|
13
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
14
|
+
|
15
|
+
def initialize(parent, library, book)
|
16
|
+
super(parent,
|
17
|
+
format(_("The book '%s' already exists in '%s'. Would you like " \
|
18
|
+
"to replace it?"), book.title, library.name),
|
19
|
+
Gtk::Stock::DIALOG_QUESTION,
|
20
|
+
[[_("_Skip"), Gtk::ResponseType::CANCEL],
|
21
|
+
[_("_Replace"), Gtk::ResponseType::OK]],
|
22
|
+
_("If you replace the existing book, its contents will " \
|
23
|
+
"be overwritten."))
|
24
|
+
dialog.default_response = Gtk::ResponseType::CANCEL
|
25
|
+
end
|
26
|
+
|
27
|
+
def replace?
|
28
|
+
show_all && (@response = run)
|
29
|
+
destroy
|
30
|
+
@response == Gtk::ResponseType::OK
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -21,15 +21,15 @@
|
|
21
21
|
|
22
22
|
module Alexandria
|
23
23
|
module UI
|
24
|
-
BOOKS_TARGET_TABLE = [Gtk::TargetEntry.new(
|
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(
|
32
|
-
view.signal_connect_after(
|
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(
|
49
|
-
red_gc.rgb_bg_color = Gdk::Color.parse(
|
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(
|
69
|
+
view.signal_connect("drag-data-get") do |_, _, selection_data, _, _|
|
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
|
+
dialog.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,51 +4,31 @@
|
|
4
4
|
#
|
5
5
|
# See the file README.md for authorship and licensing information.
|
6
6
|
|
7
|
-
require
|
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
|
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
|
-
class ExportDialog < SimpleDelegator
|
13
|
+
class ExportDialog
|
34
14
|
include GetText
|
35
15
|
extend GetText
|
36
|
-
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset:
|
16
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
37
17
|
|
38
18
|
FORMATS = Alexandria::ExportFormat.all
|
39
19
|
THEMES = Alexandria::WebTheme.all
|
40
20
|
|
41
|
-
|
42
|
-
@export_dialog = Gtk::FileChooserDialog.new(title: _("Export '%s'") % library.name,
|
43
|
-
parent: parent,
|
44
|
-
action: :save,
|
45
|
-
buttons: [[Gtk::Stock::HELP, :help],
|
46
|
-
[Gtk::Stock::CANCEL, :cancel],
|
47
|
-
[_('_Export'), :accept]])
|
48
|
-
super(@export_dialog)
|
21
|
+
attr_reader :dialog
|
49
22
|
|
50
|
-
|
51
|
-
|
23
|
+
def initialize(parent, library, sort_order)
|
24
|
+
@dialog = Gtk::FileChooserDialog.new(title: _("Export '%s'") % library.name,
|
25
|
+
parent: parent,
|
26
|
+
action: :save,
|
27
|
+
buttons: [[Gtk::Stock::HELP, :help],
|
28
|
+
[Gtk::Stock::CANCEL, :cancel],
|
29
|
+
[_("_Export"), :accept]])
|
30
|
+
@dialog.current_name = library.name
|
31
|
+
@dialog.signal_connect("destroy") { @dialog.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(
|
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(_(
|
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
|
-
|
60
|
+
"*." + format.ext
|
81
61
|
else
|
82
|
-
_(
|
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(
|
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(_(
|
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
|
@@ -104,37 +84,36 @@ module Alexandria
|
|
104
84
|
grid.attach theme_label, 0, 1, 1, 1
|
105
85
|
grid.attach @theme_combo, 1, 1, 1, 1
|
106
86
|
grid.attach preview_image, 2, 0, 1, 3
|
107
|
-
set_extra_widget grid
|
87
|
+
@dialog.set_extra_widget grid
|
108
88
|
end
|
109
89
|
|
110
90
|
def perform
|
111
|
-
while ((response = run) != Gtk::ResponseType::CANCEL) &&
|
91
|
+
while ((response = dialog.run) != Gtk::ResponseType::CANCEL) &&
|
112
92
|
(response != Gtk::ResponseType::DELETE_EVENT)
|
113
93
|
|
114
94
|
if response == Gtk::ResponseType::HELP
|
115
|
-
Alexandria::UI.display_help(self,
|
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 =>
|
121
|
-
ErrorDialog.new(@
|
100
|
+
rescue StandardError => ex
|
101
|
+
ErrorDialog.new(@dialog, _("Export failed"), ex.message).display
|
102
|
+
break
|
122
103
|
end
|
123
104
|
end
|
124
105
|
end
|
125
|
-
destroy
|
106
|
+
dialog.destroy
|
126
107
|
end
|
127
108
|
|
128
109
|
private
|
129
110
|
|
130
111
|
def on_export(format, theme)
|
131
|
-
|
132
|
-
|
133
|
-
filename = self.filename
|
112
|
+
filename = dialog.filename
|
134
113
|
if format.ext
|
135
|
-
filename +=
|
114
|
+
filename += "." + format.ext if File.extname(filename).empty?
|
136
115
|
if File.exist?(filename)
|
137
|
-
dialog = ConfirmEraseDialog.new(@
|
116
|
+
dialog = ConfirmEraseDialog.new(@dialog, filename)
|
138
117
|
return unless dialog.erase?
|
139
118
|
|
140
119
|
FileUtils.rm(filename)
|
@@ -144,10 +123,10 @@ module Alexandria
|
|
144
123
|
if File.exist?(filename)
|
145
124
|
unless File.directory?(filename)
|
146
125
|
msg = _("The target, named '%s', is a regular " \
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
ErrorDialog.new(@
|
126
|
+
"file. A directory is needed for this " \
|
127
|
+
"operation. Please select a directory and " \
|
128
|
+
"try again.") % filename
|
129
|
+
ErrorDialog.new(@dialog, _("Not a directory"), msg).display
|
151
130
|
return
|
152
131
|
end
|
153
132
|
else
|
data/lib/alexandria/ui/icons.rb
CHANGED
@@ -4,47 +4,12 @@
|
|
4
4
|
#
|
5
5
|
# See the file README.md for authorship and licensing information.
|
6
6
|
|
7
|
-
class GdkPixbuf::Pixbuf
|
8
|
-
def tag(tag_pixbuf)
|
9
|
-
# Computes some tweaks.
|
10
|
-
tweak_x = tag_pixbuf.width / 3
|
11
|
-
tweak_y = tag_pixbuf.height / 3
|
12
|
-
|
13
|
-
# Creates the destination pixbuf.
|
14
|
-
new_pixbuf = GdkPixbuf::Pixbuf.new(colorspace: :rgb,
|
15
|
-
has_alpha: true,
|
16
|
-
bits_per_sample: 8,
|
17
|
-
width: width + tweak_x,
|
18
|
-
height: height + tweak_y)
|
19
|
-
|
20
|
-
# Fills with blank.
|
21
|
-
new_pixbuf.fill!(0)
|
22
|
-
|
23
|
-
# Copies the current pixbuf there (south-west).
|
24
|
-
copy_area(0, 0,
|
25
|
-
width, height,
|
26
|
-
new_pixbuf,
|
27
|
-
0, tweak_y)
|
28
|
-
|
29
|
-
# Copies the tag pixbuf there (north-est).
|
30
|
-
tag_pixbuf_x = width - (tweak_x * 2)
|
31
|
-
new_pixbuf.composite!(tag_pixbuf,
|
32
|
-
dest_x: 0, dest_y: 0,
|
33
|
-
dest_width: tag_pixbuf.width + tag_pixbuf_x,
|
34
|
-
dest_height: tag_pixbuf.height,
|
35
|
-
offset_x: tag_pixbuf_x, offset_y: 0,
|
36
|
-
scale_x: 1, scale_y: 1,
|
37
|
-
interpolation_type: :hyper, overall_alpha: 255)
|
38
|
-
new_pixbuf
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
7
|
module Alexandria
|
43
8
|
module UI
|
44
9
|
module Icons
|
45
10
|
include Logging
|
46
11
|
|
47
|
-
ICONS_DIR = File.join(Alexandria::Config::DATA_DIR,
|
12
|
+
ICONS_DIR = File.join(Alexandria::Config::DATA_DIR, "icons")
|
48
13
|
def self.init
|
49
14
|
load_icon_images
|
50
15
|
end
|
@@ -53,11 +18,11 @@ module Alexandria
|
|
53
18
|
# Alexandria::UI::Icons namespace, e.g., Icons::STAR_SET
|
54
19
|
def self.load_icon_images
|
55
20
|
Dir.entries(ICONS_DIR).each do |file|
|
56
|
-
next unless file
|
21
|
+
next unless file.end_with?(".png") # skip non '.png' files
|
57
22
|
|
58
23
|
# Don't use upcase and use tr instead
|
59
24
|
# For example in Turkish the upper case of 'i' is still 'i'.
|
60
|
-
name = File.basename(file,
|
25
|
+
name = File.basename(file, ".png").tr("a-z", "A-Z")
|
61
26
|
const_set(name, GdkPixbuf::Pixbuf.new(file: File.join(ICONS_DIR, file)))
|
62
27
|
end
|
63
28
|
end
|
@@ -70,19 +35,49 @@ module Alexandria
|
|
70
35
|
return GdkPixbuf::Pixbuf.new(file: filename) if File.exist?(filename)
|
71
36
|
rescue GdkPixbuf::PixbufError
|
72
37
|
log.error do
|
73
|
-
"Failed to load GdkPixbuf::Pixbuf,
|
38
|
+
"Failed to load GdkPixbuf::Pixbuf," \
|
39
|
+
" please ensure that #{filename} is a valid image file"
|
74
40
|
end
|
75
41
|
end
|
76
42
|
BOOK_ICON
|
77
43
|
end
|
78
44
|
|
45
|
+
def self.tag_icon(icon_pixbuf, tag_pixbuf)
|
46
|
+
# Computes some tweaks.
|
47
|
+
tweak_x = tag_pixbuf.width / 3
|
48
|
+
tweak_y = tag_pixbuf.height / 3
|
49
|
+
|
50
|
+
# Creates the destination pixbuf.
|
51
|
+
new_pixbuf = GdkPixbuf::Pixbuf.new(colorspace: :rgb,
|
52
|
+
has_alpha: true,
|
53
|
+
bits_per_sample: 8,
|
54
|
+
width: icon_pixbuf.width + tweak_x,
|
55
|
+
height: icon_pixbuf.height + tweak_y)
|
56
|
+
|
57
|
+
# Fills with blank.
|
58
|
+
new_pixbuf.fill!(0)
|
59
|
+
|
60
|
+
# Copies the current pixbuf there (south-west).
|
61
|
+
icon_pixbuf.copy_area(0, 0,
|
62
|
+
icon_pixbuf.width, icon_pixbuf.height,
|
63
|
+
new_pixbuf,
|
64
|
+
0, tweak_y)
|
65
|
+
|
66
|
+
# Copies the tag pixbuf there (north-est).
|
67
|
+
tag_pixbuf_x = icon_pixbuf.width - (tweak_x * 2)
|
68
|
+
new_pixbuf.composite!(tag_pixbuf,
|
69
|
+
dest_x: 0, dest_y: 0,
|
70
|
+
dest_width: tag_pixbuf.width + tag_pixbuf_x,
|
71
|
+
dest_height: tag_pixbuf.height,
|
72
|
+
offset_x: tag_pixbuf_x, offset_y: 0,
|
73
|
+
scale_x: 1, scale_y: 1,
|
74
|
+
interpolation_type: :hyper, overall_alpha: 255)
|
75
|
+
new_pixbuf
|
76
|
+
end
|
77
|
+
|
79
78
|
def self.blank?(filename)
|
80
79
|
pixbuf = GdkPixbuf::Pixbuf.new(file: filename)
|
81
80
|
(pixbuf.width == 1) && (pixbuf.height == 1)
|
82
|
-
rescue StandardError => err
|
83
|
-
puts err.message
|
84
|
-
puts err.backtrace.join("\n> ")
|
85
|
-
true
|
86
81
|
end
|
87
82
|
end
|
88
83
|
end
|