From 56fa449de888f8e6abf604f8718b3bba3d374705 Mon Sep 17 00:00:00 2001 From: prculley Date: Wed, 11 Jan 2017 11:40:57 -0600 Subject: [PATCH] upgrade Update Addons to ManagedWindow This change was initiated to correct status bar and popup dialogs that were coming up in the wrong place under Windows. Upgrade to Managedwindow allows for size/position config, correct popup of subordinate dialogs, and better window management in relation to other dialogs. The Glade change allows the transient parent function to work. Note that UpdateAddons remains a modal dialog. --- gramps/gui/configure.py | 2 +- gramps/gui/glade/updateaddons.glade | 3 +-- gramps/gui/plug/_windows.py | 30 ++++++++++++++--------------- gramps/gui/viewmanager.py | 2 +- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/gramps/gui/configure.py b/gramps/gui/configure.py index da941f4bc..e8a744f31 100644 --- a/gramps/gui/configure.py +++ b/gramps/gui/configure.py @@ -1421,7 +1421,7 @@ class GrampsPreferences(ConfigureDialog): return if len(addon_update_list) > 0: - PluginWindows.UpdateAddons(addon_update_list, self.window) + PluginWindows.UpdateAddons(self.uistate, self.track, addon_update_list) else: check_types = config.get('behavior.check-for-addon-update-types') OkDialog( diff --git a/gramps/gui/glade/updateaddons.glade b/gramps/gui/glade/updateaddons.glade index 76d20fd44..f8d366ae8 100644 --- a/gramps/gui/glade/updateaddons.glade +++ b/gramps/gui/glade/updateaddons.glade @@ -1,11 +1,10 @@ - + False 5 - center 700 500 True diff --git a/gramps/gui/plug/_windows.py b/gramps/gui/plug/_windows.py index cfb48979a..bda6bdd90 100644 --- a/gramps/gui/plug/_windows.py +++ b/gramps/gui/plug/_windows.py @@ -1072,16 +1072,16 @@ class ToolManagedWindow(tool.Tool, ToolManagedWindowBase): # UpdateAddons # #------------------------------------------------------------------------- -class UpdateAddons: +class UpdateAddons(ManagedWindow): - def __init__(self, addon_update_list, parent_window): + def __init__(self, uistate, track, addon_update_list): self.title = _('Available Gramps Updates for Addons') + ManagedWindow.__init__(self, uistate, track, self, modal=True) glade = Glade("updateaddons.glade") - self.window = glade.toplevel + self.set_window(glade.toplevel, None, None) self.window.set_title(self.title) - self.window.set_size_request(750, 400) - self.window.set_transient_for(parent_window) + self.setup_configs("interface.updateaddons", 750, 400) apply_button = glade.get_object('apply') cancel_button = glade.get_object('cancel') @@ -1135,13 +1135,11 @@ class UpdateAddons: pos = iter if pos: self.list.selection.select_iter(pos) - self.window.run() - def close(self, widget): - """ - Close the dialog. - """ - self.window.destroy() + self.show() + + def build_menu_names(self, obj): + return (self.title, " ") def select_all_clicked(self, widget): """ @@ -1176,7 +1174,7 @@ class UpdateAddons: length, 1, # total, increment-by can_cancel=True) pm = ProgressMonitor(GtkProgressDialog, - ("Title", self.window, Gtk.DialogFlags.MODAL)) + ("Title", self.parent_window, Gtk.DialogFlags.MODAL)) pm.add_op(longop) count = 0 if not config.get('behavior.do-not-show-previously-seen-addon-updates'): @@ -1210,7 +1208,7 @@ class UpdateAddons: OkDialog(_("Installation Errors"), _("The following addons had errors: ") + ", ".join(errors), - parent=self.window) + parent=self.parent_window) if count: OkDialog(_("Done downloading and installing addons"), # translators: leave all/any {...} untranslated @@ -1218,12 +1216,12 @@ class UpdateAddons: "{number_of} addons were installed.", count).format(number_of=count), _("If you have installed a 'Gramps View', you will need to restart Gramps.")), - parent=self.window) + parent=self.parent_window) else: OkDialog(_("Done downloading and installing addons"), _("No addons were installed."), - parent=self.window) - self.window.destroy() + parent=self.parent_window) + self.close() #------------------------------------------------------------------------- # diff --git a/gramps/gui/viewmanager.py b/gramps/gui/viewmanager.py index 50e94a2c1..af6d57942 100644 --- a/gramps/gui/viewmanager.py +++ b/gramps/gui/viewmanager.py @@ -344,7 +344,7 @@ class ViewManager(CLIManager): """ Called when add-on updates are available. """ - PluginWindows.UpdateAddons(addon_update_list, self.window) + PluginWindows.UpdateAddons(self.uistate, [], addon_update_list) self.do_reg_plugins(self.dbstate, self.uistate) def _errordialog(self, title, errormessage):