Index: lib/alexandria/ui/callbacks.rb
===================================================================
--- lib/alexandria/ui/callbacks.rb (revision 1067)
+++ lib/alexandria/ui/callbacks.rb (revision 1070)
@@ -19,6 +19,9 @@
module Alexandria
module UI
module Callbacks
+
+ include Logging
+
def on_new widget, event
name = Library.generate_new_name(@libraries.all_libraries)
library = Library.load(name)
@@ -208,6 +211,11 @@
def on_delete widget, event
library = selected_library
books = @library_listview.focus? ? nil : selected_books
+ last_library = (@libraries.all_regular_libraries.length == 1)
+ if last_library
+ log.warn { "Attempted to delete last library, fix GUI" }
+ return
+ end
if library.empty? or ReallyDeleteDialog.new(@main_app,
library,
books).ok?
Index: lib/alexandria/ui/ui_manager.rb
===================================================================
--- lib/alexandria/ui/ui_manager.rb (revision 1067)
+++ lib/alexandria/ui/ui_manager.rb (revision 1070)
@@ -306,6 +306,7 @@
if event_is_right_click event
log.debug { "library right click!" }
+ library_already_selected = true
if path = widget.get_path_at_pos(event.x, event.y)
obj, path = widget.is_a?(Gtk::TreeView) \
? [widget.selection, path.first] : [widget, path]
@@ -313,6 +314,7 @@
unless obj.path_is_selected?(path)
log.debug { "Select #{path}" }
+ library_already_selected = false
widget.unselect_all
obj.select_path(path)
end
@@ -321,10 +323,24 @@
end
menu = determine_library_popup widget, event
- Gtk.idle_add do
- menu.popup(nil, nil, event.button, event.time)
- false
+
+ # Fixes part of bug #25021.
+ #
+ # If the library was not selected when it was right-clicked
+ # we should select the library first (we call on_focus
+ # manually, since the above call to obj.select_path(path) doesn't
+ # seem to suffice).
+ #
+ # Then we wait a while and only *then* pop up the menu.
+
+
+ if library_already_selected
+ Gtk.idle_add do
+ menu.popup(nil, nil, event.button, event.time)
+ false
+ end
end
+
end
end