From cf4748ecafa145784ae7672a8b42213e85ec211a Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Tue, 26 Jan 2010 12:00:01 +0000 Subject: [PATCH] Gramplets only update when active, detached, or forced svn: r14138 --- src/gen/plug/_gramplet.py | 18 ++++++++++++------ src/plugins/view/grampletview.py | 20 ++++++++++++++++++-- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/gen/plug/_gramplet.py b/src/gen/plug/_gramplet.py index bf8f2e36d..58ddfeca1 100644 --- a/src/gen/plug/_gramplet.py +++ b/src/gen/plug/_gramplet.py @@ -32,6 +32,8 @@ class Gramplet(object): Internal constructor for non-graphical gramplets. """ self._idle_id = 0 + self.active = True + self.dirty = False self._pause = False self._generator = None self._need_to_update = False @@ -140,8 +142,6 @@ class Gramplet(object): """ Private code that updates the GUI when active_person is changed. """ - self.uistate.push_message(self.gui.dbstate, - _("Gramplet %s is running") % self.gui.title) self.active_changed(handle) def db_changed(self): @@ -264,8 +264,16 @@ class Gramplet(object): The main interface for running the main method. """ import gobject - if (self.gui.state in ["closed", "minimized"] and - not self.gui.force_update): return + if ((not self.active or + self.gui.state in ["closed", "minimized"]) and + not self.gui.force_update): + self.dirty = True + #print " %s is not active" % self.gui.title + return + #print " %s is UPDATING" % self.gui.title + self.dirty = False + self.uistate.push_message(self.dbstate, + _("Gramplet %s is running") % self.gui.title) if self._idle_id != 0: self.interrupt() self._generator = self.main() @@ -337,8 +345,6 @@ class Gramplet(object): Internal method for handling items that should happen when the database changes. This will push a message to the GUI status bar. """ - self.uistate.push_message(self.dbstate, - _("Gramplet %s is running") % self.gui.title) self.dbstate.db = db self.gui.dbstate.db = db self.db_changed() diff --git a/src/plugins/view/grampletview.py b/src/plugins/view/grampletview.py index 494630a4c..7959a5ba6 100644 --- a/src/plugins/view/grampletview.py +++ b/src/plugins/view/grampletview.py @@ -1197,8 +1197,24 @@ class GrampletView(PageView): """ return 'gramps-gramplet' - def build_tree(self): - return + def set_inactive(self): + print "gramplet page inactive..." + self.active = False + for title in self.gramplet_map: + if self.gramplet_map[title].pui: + if self.gramplet_map[title].state != "detached": + self.gramplet_map[title].pui.active = False + + def set_active(self): + print "gramplet page active!" + self.active = True + for title in self.gramplet_map: + if self.gramplet_map[title].pui: + self.gramplet_map[title].pui.active = True + if self.gramplet_map[title].pui.dirty: + if self.gramplet_map[title].state == "maximized": + # FIXME: do in background? + self.gramplet_map[title].pui.update() def ui_definition(self): return """