Gramplets only update when active, detached, or forced

svn: r14138
This commit is contained in:
Doug Blank 2010-01-26 12:00:01 +00:00
parent f5fe747716
commit cf4748ecaf
2 changed files with 30 additions and 8 deletions

View File

@ -32,6 +32,8 @@ class Gramplet(object):
Internal constructor for non-graphical gramplets. Internal constructor for non-graphical gramplets.
""" """
self._idle_id = 0 self._idle_id = 0
self.active = True
self.dirty = False
self._pause = False self._pause = False
self._generator = None self._generator = None
self._need_to_update = False self._need_to_update = False
@ -140,8 +142,6 @@ class Gramplet(object):
""" """
Private code that updates the GUI when active_person is changed. 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) self.active_changed(handle)
def db_changed(self): def db_changed(self):
@ -264,8 +264,16 @@ class Gramplet(object):
The main interface for running the main method. The main interface for running the main method.
""" """
import gobject import gobject
if (self.gui.state in ["closed", "minimized"] and if ((not self.active or
not self.gui.force_update): return 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: if self._idle_id != 0:
self.interrupt() self.interrupt()
self._generator = self.main() self._generator = self.main()
@ -337,8 +345,6 @@ class Gramplet(object):
Internal method for handling items that should happen when the Internal method for handling items that should happen when the
database changes. This will push a message to the GUI status bar. 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.dbstate.db = db
self.gui.dbstate.db = db self.gui.dbstate.db = db
self.db_changed() self.db_changed()

View File

@ -1197,8 +1197,24 @@ class GrampletView(PageView):
""" """
return 'gramps-gramplet' return 'gramps-gramplet'
def build_tree(self): def set_inactive(self):
return 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): def ui_definition(self):
return """ return """