alexandria-book-collection-manager 0.7.2 → 0.7.7
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 +5 -1
- data/.hound.yml +2 -0
- data/.rubocop.yml +87 -37
- data/.rubocop_todo.yml +62 -191
- data/.simplecov +5 -2
- data/CHANGELOG.md +63 -0
- data/Gemfile +4 -3
- data/INSTALL.md +26 -14
- data/README.md +52 -42
- data/Rakefile +93 -109
- data/TODO.md +9 -1
- data/alexandria-book-collection-manager.gemspec +50 -43
- data/bin/alexandria +30 -53
- data/doc/FAQ +2 -6
- data/doc/dependency_decisions.yml +27 -8
- data/lib/alexandria.rb +27 -37
- data/lib/alexandria/about.rb +50 -50
- data/lib/alexandria/book_providers.rb +90 -97
- data/lib/alexandria/book_providers/adlibris.rb +41 -76
- data/lib/alexandria/book_providers/amazon_aws.rb +96 -100
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +295 -322
- data/lib/alexandria/book_providers/barnes_and_noble.rb +48 -45
- data/lib/alexandria/book_providers/douban.rb +26 -42
- data/lib/alexandria/book_providers/proxis.rb +44 -55
- data/lib/alexandria/book_providers/pseudomarc.rb +77 -85
- data/lib/alexandria/book_providers/siciliano.rb +64 -65
- data/lib/alexandria/book_providers/thalia.rb +42 -41
- data/lib/alexandria/book_providers/web.rb +15 -33
- data/lib/alexandria/book_providers/worldcat.rb +70 -97
- data/lib/alexandria/book_providers/z3950.rb +160 -173
- data/lib/alexandria/config.rb +1 -1
- data/lib/alexandria/console.rb +8 -21
- data/lib/alexandria/default_preferences.rb +37 -0
- data/lib/alexandria/execution_queue.rb +15 -13
- data/lib/alexandria/export_format.rb +47 -0
- data/lib/alexandria/export_library.rb +193 -300
- data/lib/alexandria/import_library.rb +108 -141
- data/lib/alexandria/import_library_csv.rb +43 -46
- 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 +11 -13
- data/lib/alexandria/models/book.rb +13 -20
- data/lib/alexandria/models/library.rb +81 -353
- data/lib/alexandria/net.rb +5 -6
- data/lib/alexandria/preferences.rb +73 -87
- data/lib/alexandria/scanners.rb +2 -2
- data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +20 -18
- data/lib/alexandria/scanners/keyboard.rb +8 -8
- data/lib/alexandria/smart_library.rb +133 -170
- data/lib/alexandria/ui.rb +15 -15
- data/lib/alexandria/ui/about_dialog.rb +49 -0
- data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +119 -136
- 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} +16 -15
- data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +39 -52
- data/lib/alexandria/ui/book_properties_dialog_base.rb +318 -0
- data/lib/alexandria/ui/builder_base.rb +7 -27
- data/lib/alexandria/ui/calendar_popup.rb +58 -0
- data/lib/alexandria/ui/callbacks.rb +189 -183
- data/lib/alexandria/ui/completion_models.rb +10 -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 +7 -7
- data/lib/alexandria/ui/error_dialog.rb +25 -0
- data/lib/alexandria/ui/export_dialog.rb +142 -0
- data/lib/alexandria/ui/icons.rb +47 -63
- 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 +21 -33
- data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +36 -0
- data/lib/alexandria/ui/libraries_combo.rb +16 -14
- data/lib/alexandria/ui/listview.rb +73 -87
- 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 +28 -41
- data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +156 -194
- 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} +56 -68
- 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 +236 -251
- data/lib/alexandria/undo_manager.rb +1 -0
- data/lib/alexandria/version.rb +4 -19
- data/lib/alexandria/web_themes.rb +22 -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 +1017 -974
- 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 +75 -171
- data/spec/alexandria/book_spec.rb +12 -10
- data/spec/alexandria/console_spec.rb +27 -0
- data/spec/alexandria/export_library_spec.rb +130 -0
- data/spec/alexandria/library_spec.rb +128 -172
- data/spec/alexandria/library_store_spec.rb +37 -0
- 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 +30 -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 +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 +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 +49 -0
- data/spec/alexandria/ui/sound_spec.rb +2 -2
- data/spec/alexandria/ui/ui_manager_spec.rb +43 -20
- data/spec/end_to_end/basic_run_spec.rb +52 -0
- data/spec/spec_helper.rb +65 -33
- data/tasks/setup.rb +2 -2
- data/tasks/spec.rake +16 -3
- data/util/rake/fileinstall.rb +39 -35
- data/util/rake/gettextgenerate.rb +7 -7
- data/util/rake/omfgenerate.rb +7 -7
- metadata +178 -45
- data/dogtail/basic_run_test.py +0 -9
- data/lib/alexandria/book_providers/deastore.rb +0 -265
- data/lib/alexandria/book_providers/mcu.rb +0 -182
- data/lib/alexandria/book_providers/renaud.rb +0 -149
- data/lib/alexandria/ui/dialogs/about_dialog.rb +0 -61
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +0 -72
- data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +0 -51
- data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +0 -426
- 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 -87
- 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 -568
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +0 -59
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +0 -420
- data/spec/alexandria/scanners/cuecat_spec.rb +0 -67
- data/spec/alexandria/ui/dialogs_spec.rb +0 -96
- 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,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (C) 2007 Joseph Method
|
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.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU General Public
|
16
|
-
# License along with Alexandria; see the file COPYING. If not,
|
17
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
18
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
19
|
-
|
20
|
-
module Alexandria
|
21
|
-
module UI
|
22
|
-
# Generalized Dialog for lists of bad isbns. Used for on_import. Can also
|
23
|
-
# be used for on_load library conversions.
|
24
|
-
class BadIsbnsDialog < Gtk::MessageDialog
|
25
|
-
def initialize(parent, message = nil, list = nil)
|
26
|
-
message ||= _("There's a problem")
|
27
|
-
|
28
|
-
super(parent,
|
29
|
-
Gtk::Dialog::MODAL,
|
30
|
-
Gtk::MessageDialog::WARNING,
|
31
|
-
Gtk::MessageDialog::BUTTONS_CLOSE,
|
32
|
-
message)
|
33
|
-
|
34
|
-
isbn_container = Gtk::Box.new :horizontal
|
35
|
-
the_vbox = children.first
|
36
|
-
the_vbox.pack_start(isbn_container)
|
37
|
-
the_vbox.reorder_child(isbn_container, 3)
|
38
|
-
scrolley = Gtk::ScrolledWindow.new
|
39
|
-
isbn_container.pack_start(scrolley)
|
40
|
-
textview = Gtk::TextView.new(Gtk::TextBuffer.new)
|
41
|
-
textview.editable = false
|
42
|
-
textview.cursor_visible = false
|
43
|
-
scrolley.add(textview)
|
44
|
-
list.each do |li|
|
45
|
-
textview.buffer.insert_at_cursor("#{li}\n")
|
46
|
-
end
|
47
|
-
show_all
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,426 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (C) 2004-2006 Laurent Sansonetti
|
4
|
-
# Copyright (C) 2011, 2014, 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 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.
|
20
|
-
|
21
|
-
# require 'alexandria/ui/glade_base'
|
22
|
-
|
23
|
-
module Alexandria
|
24
|
-
module UI
|
25
|
-
class BookPropertiesDialogBase < BuilderBase
|
26
|
-
include GetText
|
27
|
-
extend GetText
|
28
|
-
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
|
29
|
-
|
30
|
-
COVER_MAXWIDTH = 140 # pixels
|
31
|
-
|
32
|
-
COVER_ABSOLUTE_MAXHEIGHT = 250 # pixels, above this we scale down...
|
33
|
-
|
34
|
-
def initialize(parent, cover_file)
|
35
|
-
super('book_properties_dialog__builder.glade', widget_names)
|
36
|
-
@setup_finished = false
|
37
|
-
@book_properties_dialog.transient_for = parent
|
38
|
-
@parent = parent
|
39
|
-
@cover_file = cover_file
|
40
|
-
@original_cover_file = nil
|
41
|
-
@delete_cover_file = false # fixing bug #16707
|
42
|
-
|
43
|
-
@entry_title.complete_titles
|
44
|
-
@entry_title.grab_focus
|
45
|
-
@entry_publisher.complete_publishers
|
46
|
-
@entry_edition.complete_editions
|
47
|
-
@entry_loaned_to.complete_borrowers
|
48
|
-
|
49
|
-
@entry_tags.complete_tags
|
50
|
-
|
51
|
-
@treeview_authors.model = Gtk::ListStore.new(String, TrueClass)
|
52
|
-
@treeview_authors.selection.mode = :single
|
53
|
-
renderer = Gtk::CellRendererText.new
|
54
|
-
renderer.signal_connect('edited') do |_cell, path_string, new_text|
|
55
|
-
path = Gtk::TreePath.new(path_string)
|
56
|
-
iter = @treeview_authors.model.get_iter(path)
|
57
|
-
iter[0] = new_text
|
58
|
-
end
|
59
|
-
renderer.signal_connect('editing_started') do |_cell, entry, _path_string|
|
60
|
-
entry.complete_authors
|
61
|
-
end
|
62
|
-
col = Gtk::TreeViewColumn.new('', renderer,
|
63
|
-
text: 0,
|
64
|
-
editable: 1)
|
65
|
-
@treeview_authors.append_column(col)
|
66
|
-
|
67
|
-
setup_calendar_widgets
|
68
|
-
GLib::Timeout.add(150) do
|
69
|
-
@setup_finished = true
|
70
|
-
|
71
|
-
false
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def setup_calendar_widgets
|
76
|
-
@popup_displayed = false
|
77
|
-
@calendar_popup = Gtk::Window.new # Gtk::Window::POPUP)
|
78
|
-
# @calendar_popup.modal = true
|
79
|
-
@calendar_popup.decorated = false
|
80
|
-
@calendar_popup.skip_taskbar_hint = true
|
81
|
-
@calendar_popup.skip_pager_hint = true
|
82
|
-
@calendar_popup.events = [:focus_change_mask]
|
83
|
-
|
84
|
-
@calendar_popup.set_transient_for(@book_properties_dialog)
|
85
|
-
@calendar_popup.set_type_hint :dialog
|
86
|
-
@calendar_popup.name = 'calendar-popup'
|
87
|
-
@calendar_popup.resizable = false
|
88
|
-
# @calendar_popup.border_width = 4
|
89
|
-
# @calendar_popup.app_paintable = true
|
90
|
-
|
91
|
-
@calendar_popup.signal_connect('focus-out-event') do |_popup, _event|
|
92
|
-
hide_calendar_popup
|
93
|
-
false
|
94
|
-
end
|
95
|
-
|
96
|
-
@calendar = Gtk::Calendar.new
|
97
|
-
@calendar_popup.add(@calendar)
|
98
|
-
|
99
|
-
@calendar.signal_connect('day-selected') do
|
100
|
-
date_arr = @calendar.date
|
101
|
-
year = date_arr[0]
|
102
|
-
month = date_arr[1] # + 1 # gtk : months 0-indexed, Time.gm : 1-index
|
103
|
-
day = date_arr[2]
|
104
|
-
if @calendar_popup_for_entry
|
105
|
-
time = Time.gm(year, month, day)
|
106
|
-
@calendar_popup_for_entry.text = format_date(time)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
@calendar.signal_connect('day-selected-double-click') do
|
111
|
-
date_arr = @calendar.date
|
112
|
-
year = date_arr[0]
|
113
|
-
month = date_arr[1] # + 1 # gtk : months 0-indexed, Time.gm : 1-index
|
114
|
-
day = date_arr[2]
|
115
|
-
if @calendar_popup_for_entry
|
116
|
-
time = Time.gm(year, month, day)
|
117
|
-
@calendar_popup_for_entry.text = format_date(time)
|
118
|
-
end
|
119
|
-
hide_calendar_popup
|
120
|
-
end
|
121
|
-
|
122
|
-
@redd_date.signal_connect('icon-press') do |entry, primary, _icon|
|
123
|
-
if primary.nick == 'primary'
|
124
|
-
display_calendar_popup(entry)
|
125
|
-
elsif primary.nick == 'secondary'
|
126
|
-
clear_date_entry(entry)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
@date_loaned_since.signal_connect('icon-press') do |entry, primary, _icon|
|
131
|
-
if primary.nick == 'primary'
|
132
|
-
display_calendar_popup(entry)
|
133
|
-
elsif primary.nick == 'secondary'
|
134
|
-
clear_date_entry(entry)
|
135
|
-
@label_loaning_duration.label = ''
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def clear_date_entry(entry)
|
141
|
-
entry.text = ''
|
142
|
-
end
|
143
|
-
|
144
|
-
def hide_calendar_popup
|
145
|
-
@calendar_popup_for_entry = nil
|
146
|
-
|
147
|
-
@calendar_popup.hide_all
|
148
|
-
@book_properties_dialog.modal = true
|
149
|
-
|
150
|
-
GLib::Timeout.add(150) do
|
151
|
-
# If we set @popup_displayed=false immediately, then a click
|
152
|
-
# event on the primary icon of the Entry simultaneous with
|
153
|
-
# the focus-out-event of the Calendar causes the Calendar to
|
154
|
-
# pop up again milliseconds after being closed.
|
155
|
-
#
|
156
|
-
# This is never what the user intends.
|
157
|
-
#
|
158
|
-
# So we add a small delay before the primary icon's event
|
159
|
-
# handler is told to pop up the calendar in response to
|
160
|
-
# clicks.
|
161
|
-
|
162
|
-
@popup_displayed = false
|
163
|
-
false
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
def display_calendar_popup(entry)
|
168
|
-
if @popup_displayed
|
169
|
-
hide_calendar_popup
|
170
|
-
else
|
171
|
-
@calendar_popup_for_entry = entry
|
172
|
-
unless entry.text.strip.empty?
|
173
|
-
time = parse_date(entry.text)
|
174
|
-
unless time.nil?
|
175
|
-
@calendar.year = time.year
|
176
|
-
@calendar.month = time.month - 1
|
177
|
-
@calendar.day = time.day
|
178
|
-
end
|
179
|
-
end
|
180
|
-
@book_properties_dialog.modal = false
|
181
|
-
@calendar_popup.move(*get_entry_popup_coords(entry))
|
182
|
-
@calendar_popup.show_all
|
183
|
-
@popup_displayed = true
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
def get_entry_popup_coords(entry)
|
188
|
-
gdk_win = entry.parent_window
|
189
|
-
x, y = gdk_win.origin
|
190
|
-
alloc = entry.allocation
|
191
|
-
x += alloc.x
|
192
|
-
y += alloc.y
|
193
|
-
y += alloc.height
|
194
|
-
# x = [0, x].max
|
195
|
-
# y = [0, y].max
|
196
|
-
[x, y]
|
197
|
-
end
|
198
|
-
|
199
|
-
def widget_names
|
200
|
-
[:book_properties_dialog, :dialog_vbox1, :button_box,
|
201
|
-
:notebook1, :hbox1, :table1, :label1, :label7, :entry_title,
|
202
|
-
:entry_publisher, :label5, :entry_isbn, :hbox3,
|
203
|
-
:scrolledwindow2, :treeview_authors, :vbox2, :button3,
|
204
|
-
:image2, :button4, :image3, :label3, :label9, :entry_edition,
|
205
|
-
:label16, :entry_publish_date, :label17, :entry_tags,
|
206
|
-
:vseparator1, :vbox1, :label12, :button_cover, :image_cover,
|
207
|
-
:vbox4, :vbox5, :checkbutton_own, :vbox6, :checkbutton_redd,
|
208
|
-
:redd_date, :checkbutton_want, :eventbox8, :hbox2,
|
209
|
-
:eventbox6, :image5, :eventbox1, :image_rating1, :eventbox5,
|
210
|
-
:image_rating2, :eventbox4, :image_rating3, :eventbox3,
|
211
|
-
:image_rating4, :eventbox2, :image_rating5, :eventbox7,
|
212
|
-
:image4, :label11, :label9, :vbox3, :checkbutton_loaned,
|
213
|
-
:table2, :entry_loaned_to, :label_loaning_duration, :label15,
|
214
|
-
:label14, :date_loaned_since, :label13, :scrolledwindow1,
|
215
|
-
:textview_notes, :label10]
|
216
|
-
end
|
217
|
-
|
218
|
-
def on_title_changed
|
219
|
-
title = @entry_title.text.strip
|
220
|
-
@book_properties_dialog.title = if title.empty?
|
221
|
-
_('Properties')
|
222
|
-
else
|
223
|
-
_("Properties for '%s'") % title
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
def on_add_author
|
228
|
-
iter = @treeview_authors.model.append
|
229
|
-
iter[0] = _('Author')
|
230
|
-
iter[1] = true
|
231
|
-
@treeview_authors.set_cursor(iter.path,
|
232
|
-
@treeview_authors.get_column(0),
|
233
|
-
true)
|
234
|
-
end
|
235
|
-
|
236
|
-
def on_remove_author
|
237
|
-
iter = @treeview_authors.selection.selected
|
238
|
-
@treeview_authors.model.remove(iter) if iter
|
239
|
-
end
|
240
|
-
|
241
|
-
def on_image_rating1_press
|
242
|
-
self.rating = 1
|
243
|
-
end
|
244
|
-
|
245
|
-
def on_image_rating2_press
|
246
|
-
self.rating = 2
|
247
|
-
end
|
248
|
-
|
249
|
-
def on_image_rating3_press
|
250
|
-
self.rating = 3
|
251
|
-
end
|
252
|
-
|
253
|
-
def on_image_rating4_press
|
254
|
-
self.rating = 4
|
255
|
-
end
|
256
|
-
|
257
|
-
def on_image_rating5_press
|
258
|
-
self.rating = 5
|
259
|
-
end
|
260
|
-
|
261
|
-
def on_image_no_rating_press
|
262
|
-
self.rating = 0
|
263
|
-
end
|
264
|
-
|
265
|
-
def own_toggled
|
266
|
-
@checkbutton_want.inconsistent = if @checkbutton_own.active?
|
267
|
-
true
|
268
|
-
else
|
269
|
-
false
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
def want_toggled; end
|
274
|
-
|
275
|
-
@@latest_filechooser_directory = ENV['HOME']
|
276
|
-
def on_change_cover
|
277
|
-
backend = `uname`.chomp == 'FreeBSD' ? 'neant' : 'gnome-vfs'
|
278
|
-
dialog = Gtk::FileChooserDialog.new(_('Select a cover image'),
|
279
|
-
@book_properties_dialog,
|
280
|
-
Gtk::FileChooser::ACTION_OPEN,
|
281
|
-
backend,
|
282
|
-
[_('No Cover'), :reject],
|
283
|
-
[Gtk::Stock::CANCEL, :cancel],
|
284
|
-
[Gtk::Stock::OPEN, :accept])
|
285
|
-
dialog.current_folder = @@latest_filechooser_directory
|
286
|
-
response = dialog.run
|
287
|
-
if response == :accept
|
288
|
-
begin
|
289
|
-
@delete_cover_file = false
|
290
|
-
cover = GdkPixbuf::Pixbuf.new(file: dialog.filename)
|
291
|
-
# At this stage the file format is recognized.
|
292
|
-
|
293
|
-
if File.exist?(@cover_file)
|
294
|
-
unless @original_cover_file
|
295
|
-
# make a back up, but only of the original
|
296
|
-
@original_cover_file = "#{@cover_file}~"
|
297
|
-
FileUtils.cp(@cover_file, @original_cover_file)
|
298
|
-
end
|
299
|
-
end
|
300
|
-
if cover.height > COVER_ABSOLUTE_MAXHEIGHT
|
301
|
-
FileUtils.cp(dialog.filename, "#{@cover_file}.orig")
|
302
|
-
new_width = cover.width / (cover.height / COVER_ABSOLUTE_MAXHEIGHT.to_f)
|
303
|
-
puts "Scaling large cover image to #{new_width.to_i} x #{COVER_ABSOLUTE_MAXHEIGHT}"
|
304
|
-
cover = cover.scale(new_width.to_i, COVER_ABSOLUTE_MAXHEIGHT)
|
305
|
-
cover.save(@cover_file, 'jpeg')
|
306
|
-
else
|
307
|
-
FileUtils.cp(dialog.filename, @cover_file)
|
308
|
-
end
|
309
|
-
|
310
|
-
self.cover = cover
|
311
|
-
@@latest_filechooser_directory = dialog.current_folder
|
312
|
-
rescue RuntimeError => e
|
313
|
-
ErrorDialog.new(@book_properties_dialog, e.message)
|
314
|
-
end
|
315
|
-
elsif response == :reject
|
316
|
-
## FileUtils.rm_f(@cover_file) # fixing bug #16707
|
317
|
-
@delete_cover_file = true
|
318
|
-
|
319
|
-
self.cover = Icons::BOOK_ICON
|
320
|
-
end
|
321
|
-
dialog.destroy
|
322
|
-
end
|
323
|
-
|
324
|
-
def on_destroy; end # no action by default
|
325
|
-
|
326
|
-
def on_loaned
|
327
|
-
loaned = @checkbutton_loaned.active?
|
328
|
-
@entry_loaned_to.sensitive = loaned
|
329
|
-
@date_loaned_since.sensitive = loaned
|
330
|
-
@label_loaning_duration.visible = loaned
|
331
|
-
end
|
332
|
-
|
333
|
-
def on_loaned_date_changed
|
334
|
-
date_regexes = [/[0123]?[0-9]\/[0123]?[0-9]\/[0-9]{4}/,
|
335
|
-
/[0-9]{4}-[0123]?[0-9]-[0123]?[0-9]/]
|
336
|
-
matches_regex = false
|
337
|
-
date_regexes.each do |regex|
|
338
|
-
matches_regex = regex.match(@date_loaned_since.text)
|
339
|
-
break if matches_regex
|
340
|
-
end
|
341
|
-
return unless matches_regex
|
342
|
-
t = parse_date(@date_loaned_since.text)
|
343
|
-
if t.nil?
|
344
|
-
@label_loaning_duration.label = ''
|
345
|
-
return
|
346
|
-
end
|
347
|
-
loaned_time = Time.at(t)
|
348
|
-
n_days = ((Time.now - loaned_time) / (3600 * 24)).to_i
|
349
|
-
if n_days > 365_250 # 1,000 years
|
350
|
-
@label_loaning_duration.label = ''
|
351
|
-
return
|
352
|
-
end
|
353
|
-
@label_loaning_duration.label = if n_days > 0
|
354
|
-
n_('%d day', '%d days', n_days) % n_days
|
355
|
-
else
|
356
|
-
''
|
357
|
-
end
|
358
|
-
end
|
359
|
-
|
360
|
-
def redd_toggled
|
361
|
-
redd_yes = @checkbutton_redd.active?
|
362
|
-
@redd_date.sensitive = redd_yes
|
363
|
-
if @setup_finished
|
364
|
-
# don't do this when popping up the dialog for the first time
|
365
|
-
display_calendar_popup(@redd_date) if redd_yes && @redd_date.text.strip.empty?
|
366
|
-
end
|
367
|
-
end
|
368
|
-
|
369
|
-
private
|
370
|
-
|
371
|
-
def rating=(rating)
|
372
|
-
images = [
|
373
|
-
@image_rating1,
|
374
|
-
@image_rating2,
|
375
|
-
@image_rating3,
|
376
|
-
@image_rating4,
|
377
|
-
@image_rating5
|
378
|
-
]
|
379
|
-
raise 'out of range' if rating < 0 || rating > images.length
|
380
|
-
images[0..rating - 1].each { |x| x.pixbuf = Icons::STAR_SET }
|
381
|
-
images[rating..-1].each { |x| x.pixbuf = Icons::STAR_UNSET }
|
382
|
-
@current_rating = rating
|
383
|
-
end
|
384
|
-
|
385
|
-
def cover=(pixbuf)
|
386
|
-
if pixbuf.width > COVER_MAXWIDTH
|
387
|
-
new_height = pixbuf.height / (pixbuf.width / COVER_MAXWIDTH.to_f)
|
388
|
-
# We don't want to modify in place the given pixbuf,
|
389
|
-
# that's why we make a copy.
|
390
|
-
pixbuf = pixbuf.scale(COVER_MAXWIDTH, new_height)
|
391
|
-
end
|
392
|
-
@image_cover.pixbuf = pixbuf
|
393
|
-
end
|
394
|
-
|
395
|
-
def loaned_since=(time)
|
396
|
-
if time.nil?
|
397
|
-
@date_loaned_since.text = ''
|
398
|
-
@label_loaning_duration.label = ''
|
399
|
-
else
|
400
|
-
@date_loaned_since.text = format_date(time)
|
401
|
-
on_loaned_date_changed
|
402
|
-
end
|
403
|
-
# XXX 'date_changed' signal not automatically called after #time=.
|
404
|
-
end
|
405
|
-
|
406
|
-
def redd_when=(time)
|
407
|
-
@redd_date.text = format_date(time)
|
408
|
-
end
|
409
|
-
|
410
|
-
def parse_date(datestring)
|
411
|
-
date_format = '%d/%m/%Y' # or '%m/%d/%Y' for USA and Canada ; or '%Y-%m-%d' for most of Asia
|
412
|
-
## http://en.wikipedia.org/wiki/Calendar_date#Middle_endian_forms.2C_starting_with_the_month
|
413
|
-
begin
|
414
|
-
d = Date.strptime(datestring, date_format)
|
415
|
-
Time.gm(d.year, d.month, d.day)
|
416
|
-
rescue
|
417
|
-
nil
|
418
|
-
end
|
419
|
-
end
|
420
|
-
|
421
|
-
def format_date(datetime)
|
422
|
-
datetime.strftime('%d/%m/%Y')
|
423
|
-
end
|
424
|
-
end
|
425
|
-
end
|
426
|
-
end
|