From 8ae01291578ab7cba89eb1d7e4e0d5fe90214fff Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Wed, 2 Feb 2011 19:56:04 +0000 Subject: [PATCH] Allow remove_gramplet to remove a detached gramplet svn: r16544 --- src/gui/grampsbar.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/gui/grampsbar.py b/src/gui/grampsbar.py index 991993cb8..e826cec82 100644 --- a/src/gui/grampsbar.py +++ b/src/gui/grampsbar.py @@ -184,7 +184,6 @@ class GrampsBar(gtk.Notebook): else: gramplet_list = [self.get_nth_page(page_num) for page_num in range(self.get_n_pages())] - gramplet_list.extend(self.detached_gramplets) for page_num, gramplet in enumerate(gramplet_list): opts = get_gramplet_options_by_name(gramplet.gname) @@ -237,6 +236,7 @@ class GrampsBar(gtk.Notebook): """ Called when the view is closed. """ + map(self.__dock_gramplet, self.detached_gramplets) if not self.empty: for page_num in range(self.get_n_pages()): gramplet = self.get_nth_page(page_num) @@ -265,6 +265,12 @@ class GrampsBar(gtk.Notebook): """ Remove a gramplet by name. """ + for gramplet in self.detached_gramplets: + if gramplet.gname == gname: + self.__dock_gramplet(gramplet) + self.remove_page(self.page_num(gramplet)) + return + for page_num in range(self.get_n_pages()): gramplet = self.get_nth_page(page_num) if gramplet.gname == gname: @@ -275,7 +281,7 @@ class GrampsBar(gtk.Notebook): """ Return True if the GrampsBar contains the gramplet, else False. """ - return True if gname in self.all_gramplets() else False + return gname in self.all_gramplets() def all_gramplets(self): """ @@ -405,8 +411,16 @@ class GrampsBar(gtk.Notebook): gramplet.page = self.page_num(gramplet) self.detached_gramplets.append(gramplet) win = DetachedWindow(grampsbar, gramplet, x_pos, y_pos) + gramplet.detached_window = win return win.get_notebook() + def __dock_gramplet(self, gramplet): + """ + Dock a detached gramplet. + """ + gramplet.detached_window.close() + gramplet.detached_window = None + def __button_press(self, widget, event): """ Called when a button is pressed in the tabs section of the GrampsBar. @@ -526,6 +540,7 @@ class DetachedWindow(ManagedWindow.ManagedWindow): size = self.window.get_size() self.gramplet.detached_width = size[0] self.gramplet.detached_height = size[1] + self.gramplet.detached_window = None self.gramplet.reparent(self.grampsbar) ManagedWindow.ManagedWindow.close(self, *args)