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
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
4
|
# Copyright (C) 2016 Matijs van Zuijlen
|
3
5
|
#
|
@@ -22,7 +24,7 @@ module Alexandria
|
|
22
24
|
module ComboBoxOverrides
|
23
25
|
include GetText
|
24
26
|
extend GetText
|
25
|
-
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset:
|
27
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
26
28
|
|
27
29
|
def populate_with_libraries(libraries, selected_library)
|
28
30
|
libraries_names = libraries.map(&:name)
|
@@ -31,28 +33,22 @@ module Alexandria
|
|
31
33
|
libraries_names.unshift selected_library.name
|
32
34
|
end
|
33
35
|
clear
|
34
|
-
set_row_separator_func do |model, iter|
|
35
|
-
# TODO: Replace with iter[1] if possible
|
36
|
-
model.get_value(iter, 1) == '-'
|
37
|
-
end
|
38
36
|
self.model = Gtk::ListStore.new(GdkPixbuf::Pixbuf, String, TrueClass)
|
39
37
|
libraries_names.each do |library_name|
|
40
|
-
|
41
|
-
iter[0] = Alexandria::UI::Icons::LIBRARY_SMALL
|
42
|
-
iter[1] = library_name
|
43
|
-
iter[2] = false
|
38
|
+
append_entry(Alexandria::UI::Icons::LIBRARY_SMALL, library_name, false)
|
44
39
|
end
|
45
|
-
|
46
|
-
|
47
|
-
iter[0] = Alexandria::UI::Icons::LIBRARY_SMALL
|
48
|
-
iter[1] = _('New Library')
|
49
|
-
iter[2] = true
|
40
|
+
append_entry(nil, "-", nil)
|
41
|
+
append_entry(Alexandria::UI::Icons::LIBRARY_SMALL, _("New Library"), true)
|
50
42
|
renderer = Gtk::CellRendererPixbuf.new
|
51
43
|
pack_start(renderer, false)
|
52
44
|
set_attributes(renderer, pixbuf: 0)
|
53
45
|
renderer = Gtk::CellRendererText.new
|
54
46
|
pack_start(renderer, true)
|
55
47
|
set_attributes(renderer, text: 1)
|
48
|
+
set_row_separator_func do |model, iter|
|
49
|
+
# TODO: Replace with iter[1] if possible
|
50
|
+
model.get_value(iter, 1) == "-"
|
51
|
+
end
|
56
52
|
self.active = 0
|
57
53
|
# self.sensitive = libraries.length > 1
|
58
54
|
# This prohibits us from adding a "New Library" from this combo
|
@@ -74,8 +70,16 @@ module Alexandria
|
|
74
70
|
end
|
75
71
|
end
|
76
72
|
raise unless library
|
73
|
+
|
77
74
|
[library, is_new]
|
78
75
|
end
|
76
|
+
|
77
|
+
def append_entry(icon, label, is_new)
|
78
|
+
iter = model.append
|
79
|
+
iter[0] = icon
|
80
|
+
iter[1] = label
|
81
|
+
iter[2] = is_new
|
82
|
+
end
|
79
83
|
end
|
80
84
|
end
|
81
85
|
|
@@ -1,35 +1,21 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (C) 2011, 2016 Matijs van Zuijlen
|
5
|
-
#
|
6
|
-
# Alexandria is free software; you can redistribute it and/or
|
7
|
-
# modify it under the terms of the GNU General Public License aso
|
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.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is part of Alexandria.
|
15
4
|
#
|
16
|
-
#
|
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
|
-
require
|
7
|
+
require "alexandria/ui/columns"
|
22
8
|
|
23
9
|
module Alexandria
|
24
10
|
module UI
|
25
11
|
include Logging
|
26
12
|
include GetText
|
27
|
-
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset:
|
13
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
28
14
|
class ListViewManager
|
29
15
|
include Logging
|
30
16
|
include GetText
|
31
17
|
include DragAndDropable
|
32
|
-
BOOKS_TARGET_TABLE = [[
|
18
|
+
BOOKS_TARGET_TABLE = [["ALEXANDRIA_BOOKS", :same_app, 0]].freeze
|
33
19
|
|
34
20
|
def initialize(_listview, parent)
|
35
21
|
@parent = parent
|
@@ -43,18 +29,18 @@ module Alexandria
|
|
43
29
|
end
|
44
30
|
|
45
31
|
def setup_title_column
|
46
|
-
title = _(
|
47
|
-
log.debug {
|
32
|
+
title = _("Title")
|
33
|
+
log.debug { format("Create listview column for %s", title) }
|
48
34
|
column = Gtk::TreeViewColumn.new(title)
|
49
35
|
|
50
36
|
renderer = Gtk::CellRendererPixbuf.new
|
51
37
|
column.pack_start(renderer, false)
|
52
|
-
column.add_attribute(renderer,
|
38
|
+
column.add_attribute(renderer, "pixbuf", Columns::COVER_LIST)
|
53
39
|
|
54
40
|
renderer = Gtk::CellRendererText.new
|
55
|
-
renderer.ellipsize =
|
41
|
+
renderer.ellipsize = :end
|
56
42
|
column.pack_start(renderer, true)
|
57
|
-
column.add_attribute(renderer,
|
43
|
+
column.add_attribute(renderer, "text", Columns::TITLE)
|
58
44
|
|
59
45
|
column.sort_column_id = Columns::TITLE
|
60
46
|
column.resizable = true
|
@@ -62,21 +48,21 @@ module Alexandria
|
|
62
48
|
end
|
63
49
|
|
64
50
|
TEXT_COLUMNS = [
|
65
|
-
[_(
|
66
|
-
[_(
|
67
|
-
[_(
|
68
|
-
[_(
|
69
|
-
[_(
|
70
|
-
[_(
|
51
|
+
[_("Authors"), Columns::AUTHORS],
|
52
|
+
[_("ISBN"), Columns::ISBN],
|
53
|
+
[_("Publisher"), Columns::PUBLISHER],
|
54
|
+
[_("Publish Year"), Columns::PUBLISH_DATE],
|
55
|
+
[_("Binding"), Columns::EDITION],
|
56
|
+
[_("Loaned To"), Columns::LOANED_TO]
|
71
57
|
].freeze
|
72
58
|
CHECK_COLUMNS = [
|
73
|
-
[_(
|
74
|
-
[_(
|
75
|
-
[_(
|
59
|
+
[_("Read"), Columns::REDD],
|
60
|
+
[_("Own"), Columns::OWN],
|
61
|
+
[_("Want"), Columns::WANT]
|
76
62
|
].freeze
|
77
63
|
|
78
64
|
def setup_books_listview
|
79
|
-
log.debug {
|
65
|
+
log.debug { "setup_books_listview" }
|
80
66
|
@listview.model = @listview_model
|
81
67
|
setup_title_column
|
82
68
|
TEXT_COLUMNS.each do |title, iterid|
|
@@ -87,8 +73,8 @@ module Alexandria
|
|
87
73
|
end
|
88
74
|
setup_rating_column
|
89
75
|
@listview.selection.mode = :multiple
|
90
|
-
@listview.selection.signal_connect(
|
91
|
-
log.debug {
|
76
|
+
@listview.selection.signal_connect("changed") do
|
77
|
+
log.debug { "changed" }
|
92
78
|
@parent.on_books_selection_changed
|
93
79
|
end
|
94
80
|
setup_tags_column
|
@@ -97,11 +83,10 @@ module Alexandria
|
|
97
83
|
end
|
98
84
|
|
99
85
|
def setup_tags_column
|
100
|
-
|
101
|
-
|
102
|
-
log.debug { 'Create listview column for tags...' }
|
86
|
+
title = _("Tags")
|
87
|
+
log.debug { "Create listview column for tags" }
|
103
88
|
renderer = Gtk::CellRendererText.new
|
104
|
-
renderer.ellipsize =
|
89
|
+
renderer.ellipsize = :end
|
105
90
|
column = Gtk::TreeViewColumn.new(title, renderer,
|
106
91
|
text: Columns::TAGS)
|
107
92
|
column.sort_column_id = Columns::TAGS
|
@@ -110,16 +95,16 @@ module Alexandria
|
|
110
95
|
end
|
111
96
|
|
112
97
|
def setup_row_activation
|
113
|
-
@listview.signal_connect(
|
114
|
-
log.debug {
|
115
|
-
@actiongroup[
|
98
|
+
@listview.signal_connect("row-activated") do
|
99
|
+
log.debug { "row-activated" }
|
100
|
+
@actiongroup["Properties"].activate
|
116
101
|
false
|
117
102
|
end
|
118
103
|
end
|
119
104
|
|
120
105
|
def setup_rating_column
|
121
|
-
title = _(
|
122
|
-
log.debug {
|
106
|
+
title = _("Rating")
|
107
|
+
log.debug { format("Create listview column for %s", title) }
|
123
108
|
column = Gtk::TreeViewColumn.new(title)
|
124
109
|
column.sizing = :fixed
|
125
110
|
width = (Icons::STAR_SET.width + 1) * Book::MAX_RATING_STARS
|
@@ -130,8 +115,7 @@ module Alexandria
|
|
130
115
|
column.pack_start(renderer, false)
|
131
116
|
column.set_cell_data_func(renderer) do |_tree_column, cell, _tree_model, iter|
|
132
117
|
rating = (iter[Columns::RATING] - Book::MAX_RATING_STARS).abs
|
133
|
-
cell.pixbuf = rating >= i.succ ?
|
134
|
-
Icons::STAR_SET : Icons::STAR_UNSET
|
118
|
+
cell.pixbuf = rating >= i.succ ? Icons::STAR_SET : Icons::STAR_UNSET
|
135
119
|
end
|
136
120
|
end
|
137
121
|
column.sort_column_id = Columns::RATING
|
@@ -142,50 +126,48 @@ module Alexandria
|
|
142
126
|
def setup_check_column(title, iterid)
|
143
127
|
renderer = CellRendererToggle.new
|
144
128
|
renderer.activatable = true
|
145
|
-
renderer.signal_connect(
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
when Columns::WANT then book.want = toggle_state
|
168
|
-
end
|
169
|
-
iter[iterid] = toggle_state
|
170
|
-
lib = @parent.selected_library
|
171
|
-
lib.save(book)
|
129
|
+
renderer.signal_connect("toggled") do |_rndrr, path|
|
130
|
+
tree_path = Gtk::TreePath.new(path)
|
131
|
+
child_path = @listview_model.convert_path_to_child_path(tree_path)
|
132
|
+
if child_path
|
133
|
+
unfiltered_path = @filtered_model.convert_path_to_child_path(child_path)
|
134
|
+
# FIX this sometimes returns a nil path for iconview...
|
135
|
+
if unfiltered_path
|
136
|
+
iter = @model.get_iter(unfiltered_path)
|
137
|
+
if iter
|
138
|
+
book = @parent.book_from_iter(@parent.selected_library, iter)
|
139
|
+
toggle_state = case iterid
|
140
|
+
when Columns::REDD then book.redd
|
141
|
+
when Columns::OWN then book.own
|
142
|
+
when Columns::WANT then book.want
|
143
|
+
end
|
144
|
+
# invert toggle_state
|
145
|
+
unless iterid == Columns::WANT && book.own
|
146
|
+
toggle_state = !toggle_state
|
147
|
+
case iterid
|
148
|
+
when Columns::REDD then book.redd = toggle_state
|
149
|
+
when Columns::OWN then book.own = toggle_state
|
150
|
+
when Columns::WANT then book.want = toggle_state
|
172
151
|
end
|
152
|
+
iter[iterid] = toggle_state
|
153
|
+
lib = @parent.selected_library
|
154
|
+
lib.save(book)
|
173
155
|
end
|
174
156
|
end
|
175
|
-
|
176
157
|
end
|
177
|
-
|
178
|
-
log.error { "toggle failed for path #{path} #{e}\n" + e.backtrace.join("\n") }
|
158
|
+
|
179
159
|
end
|
160
|
+
rescue StandardError => ex
|
161
|
+
log.error { "toggle failed for path #{path} #{ex}\n" + e.backtrace.join("\n") }
|
180
162
|
end
|
181
163
|
column = Gtk::TreeViewColumn.new(title, renderer, text: iterid)
|
182
164
|
column.sort_column_id = iterid
|
183
165
|
column.resizable = true
|
184
|
-
log.debug {
|
166
|
+
log.debug { format("Create listview column for %s", title) }
|
185
167
|
|
186
|
-
column.add_attribute(renderer,
|
168
|
+
column.add_attribute(renderer, "active", iterid)
|
187
169
|
if iterid == Columns::WANT
|
188
|
-
column.add_attribute(renderer,
|
170
|
+
column.add_attribute(renderer, "inconsistent", Columns::OWN)
|
189
171
|
end
|
190
172
|
|
191
173
|
log.debug { "append_column #{column}" }
|
@@ -193,9 +175,9 @@ module Alexandria
|
|
193
175
|
end
|
194
176
|
|
195
177
|
def setup_text_column(title, iterid)
|
196
|
-
log.debug {
|
178
|
+
log.debug { format("Create listview column for %s", title) }
|
197
179
|
renderer = Gtk::CellRendererText.new
|
198
|
-
renderer.ellipsize =
|
180
|
+
renderer.ellipsize = :end
|
199
181
|
column = Gtk::TreeViewColumn.new(title, renderer,
|
200
182
|
text: iterid)
|
201
183
|
column.sort_column_id = iterid
|
@@ -204,7 +186,7 @@ module Alexandria
|
|
204
186
|
end
|
205
187
|
|
206
188
|
def setup_listview_columns_visibility
|
207
|
-
log.debug {
|
189
|
+
log.debug { "setup_listview_columns_visibility" }
|
208
190
|
# Show or hide list view columns according to the preferences.
|
209
191
|
cols_visibility = [
|
210
192
|
@prefs.col_authors_visible,
|
@@ -223,7 +205,10 @@ module Alexandria
|
|
223
205
|
cols.each_index do |i|
|
224
206
|
cols[i].visible = cols_visibility[i]
|
225
207
|
end
|
226
|
-
log.debug
|
208
|
+
log.debug do
|
209
|
+
"Columns visibility: " +
|
210
|
+
cols.map { |col| "#{col.title} #{col.visible?}" }.join(", ")
|
211
|
+
end
|
227
212
|
end
|
228
213
|
|
229
214
|
# Sets the width of each column based on any respective
|
@@ -231,19 +216,23 @@ module Alexandria
|
|
231
216
|
def setup_listview_columns_width
|
232
217
|
log.debug { "setup_listview_columns_width #{@prefs.cols_width}" }
|
233
218
|
if @prefs.cols_width
|
234
|
-
cols_width = YAML.
|
219
|
+
cols_width = YAML.safe_load(@prefs.cols_width)
|
235
220
|
log.debug { "cols_width: #{cols_width.inspect}" }
|
236
221
|
@listview.columns.each do |c|
|
237
222
|
if cols_width.key?(c.title)
|
238
223
|
log.debug { "#{c.title} : #{cols_width[c.title]}" }
|
239
224
|
width = cols_width[c.title]
|
240
225
|
next if width.zero?
|
226
|
+
|
241
227
|
c.sizing = :fixed
|
242
228
|
c.fixed_width = width
|
243
229
|
end
|
244
230
|
end
|
245
231
|
end
|
246
|
-
log.debug
|
232
|
+
log.debug do
|
233
|
+
"Columns width: " +
|
234
|
+
@listview.columns.map { |col| "#{col.title} #{col.width}" }.join(", ")
|
235
|
+
end
|
247
236
|
end
|
248
237
|
end
|
249
238
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
4
|
# Copyright (C) 2007 Cathal Mc Ginley
|
3
5
|
# Copyright (C) 2011 Matijs van Zuijlen
|
@@ -17,43 +19,41 @@
|
|
17
19
|
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
18
20
|
# Fifth Floor, Boston, MA 02110-1301 USA.
|
19
21
|
|
20
|
-
require
|
21
|
-
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
35
|
-
require
|
36
|
-
require
|
37
|
-
require
|
38
|
-
require
|
39
|
-
require
|
40
|
-
require 'alexandria/ui/iconview'
|
41
|
-
require 'alexandria/ui/sidepane'
|
22
|
+
require "alexandria/ui/alert_dialog"
|
23
|
+
require "alexandria/ui/about_dialog"
|
24
|
+
require "alexandria/ui/book_properties_dialog_base"
|
25
|
+
require "alexandria/ui/book_properties_dialog"
|
26
|
+
require "alexandria/ui/new_book_dialog_manual"
|
27
|
+
require "alexandria/ui/new_book_dialog"
|
28
|
+
require "alexandria/ui/preferences_dialog"
|
29
|
+
require "alexandria/ui/export_dialog"
|
30
|
+
require "alexandria/ui/import_dialog"
|
31
|
+
require "alexandria/ui/acquire_dialog"
|
32
|
+
require "alexandria/ui/smart_library_properties_dialog_base"
|
33
|
+
require "alexandria/ui/smart_library_properties_dialog"
|
34
|
+
require "alexandria/ui/new_smart_library_dialog"
|
35
|
+
require "alexandria/ui/bad_isbns_dialog"
|
36
|
+
require "alexandria/ui/dndable"
|
37
|
+
require "alexandria/ui/init"
|
38
|
+
require "alexandria/ui/ui_manager"
|
39
|
+
require "alexandria/ui/listview"
|
40
|
+
require "alexandria/ui/iconview"
|
41
|
+
require "alexandria/ui/sidepane_manager"
|
42
42
|
|
43
43
|
module Alexandria
|
44
44
|
module UI
|
45
45
|
include Logging
|
46
46
|
include GetText
|
47
|
-
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset:
|
47
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
48
48
|
|
49
49
|
class MainApp
|
50
50
|
include Logging
|
51
51
|
include GetText
|
52
52
|
include Singleton
|
53
|
-
attr_accessor :main_app, :libraries, :actiongroup, :appbar, :prefs
|
54
|
-
|
53
|
+
attr_accessor :main_app, :libraries, :actiongroup, :appbar, :prefs, :ui_manager
|
54
|
+
|
55
55
|
def initialize
|
56
|
-
log.info {
|
56
|
+
log.info { "Starting MainApp" }
|
57
57
|
@ui_manager = UIManager.new self
|
58
58
|
@actiongroup = @ui_manager.actiongroup
|
59
59
|
@appbar = @ui_manager.appbar
|
@@ -1,47 +1,36 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
# Alexandria is free software; you can redistribute it and/or
|
5
|
-
# modify it under the terms of the GNU General Public License as
|
6
|
-
# published by the Free Software Foundation; either version 2 of the
|
7
|
-
# License, or (at your option) any later version.
|
8
|
-
#
|
9
|
-
# Alexandria is distributed in the hope that it will be useful,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
# General Public License for more details.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is part of Alexandria.
|
13
4
|
#
|
14
|
-
#
|
15
|
-
# License along with Alexandria; see the file COPYING. If not,
|
16
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
17
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
5
|
+
# See the file README.md for authorship and licensing information.
|
18
6
|
|
19
7
|
module Alexandria
|
20
8
|
module EventOverrides
|
21
|
-
def ==(
|
22
|
-
|
9
|
+
def ==(other)
|
10
|
+
other.is_a?(self.class) &&
|
11
|
+
(time == other.time) && (x == other.x) && (y == other.y) &&
|
12
|
+
(button == other.button)
|
23
13
|
end
|
24
14
|
end
|
25
15
|
|
26
16
|
module TreeViewOverrides
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
17
|
+
Context = Struct.new(:pressed_button,
|
18
|
+
:x,
|
19
|
+
:y,
|
20
|
+
:cell_x,
|
21
|
+
:cell_y,
|
22
|
+
:button_press_handler,
|
23
|
+
:motion_notify_handler,
|
24
|
+
:button_release_handler,
|
25
|
+
:drag_data_get_handler,
|
26
|
+
:events,
|
27
|
+
:source_start_button_mask,
|
28
|
+
:source_targets,
|
29
|
+
:source_actions,
|
30
|
+
:pending_event,
|
31
|
+
:drag_context)
|
32
|
+
|
33
|
+
class Context
|
45
34
|
def initialize(*ary)
|
46
35
|
super
|
47
36
|
self.events ||= []
|
@@ -61,7 +50,7 @@ module Alexandria
|
|
61
50
|
@context.source_actions = actions
|
62
51
|
|
63
52
|
@context.button_press_handler =
|
64
|
-
signal_connect(
|
53
|
+
signal_connect("button_press_event") do |_widget, event, _data|
|
65
54
|
button_press_event(event)
|
66
55
|
end
|
67
56
|
end
|
@@ -74,6 +63,7 @@ module Alexandria
|
|
74
63
|
|
75
64
|
def stop_drag_check
|
76
65
|
raise if @context.nil?
|
66
|
+
|
77
67
|
@context.events.clear
|
78
68
|
@context.pending_event = false
|
79
69
|
signal_handler_disconnect(@context.motion_notify_handler)
|
@@ -114,13 +104,12 @@ module Alexandria
|
|
114
104
|
path, _, cell_x, cell_y = get_path_at_pos(event.x, event.y)
|
115
105
|
return false if path.nil?
|
116
106
|
|
117
|
-
# call_parent = (event.state.control_mask? or event.state.shift_mask?) or !selected or event.button != 1
|
118
107
|
(call_parent = !selection.path_is_selected?(path)) ||
|
119
108
|
(event.button != 1)
|
120
109
|
|
121
110
|
if call_parent
|
122
111
|
signal_handler_block(@context.button_press_handler) do
|
123
|
-
signal_emit(
|
112
|
+
signal_emit("button_press_event", event)
|
124
113
|
end
|
125
114
|
end
|
126
115
|
|
@@ -132,11 +121,11 @@ module Alexandria
|
|
132
121
|
@context.cell_x = cell_x
|
133
122
|
@context.cell_y = cell_y
|
134
123
|
@context.motion_notify_handler =
|
135
|
-
signal_connect(
|
124
|
+
signal_connect("motion_notify_event") do |_widget, evnt, _data|
|
136
125
|
motion_notify_event(evnt)
|
137
126
|
end
|
138
127
|
@context.button_release_handler =
|
139
|
-
signal_connect(
|
128
|
+
signal_connect("button_release_event") do |_widget, evnt, _data|
|
140
129
|
button_release_event(evnt)
|
141
130
|
end
|
142
131
|
@context.events << event unless call_parent
|