diff --git a/src/gen/plug/_gramplet.py b/src/gen/plug/_gramplet.py
index fa5a10d1b..bfef9bc7e 100644
--- a/src/gen/plug/_gramplet.py
+++ b/src/gen/plug/_gramplet.py
@@ -44,6 +44,7 @@ class Gramplet(object):
self.track = []
self.active = False
self.dirty = True
+ self.has_data = True
self._pause = False
self._generator = None
self._need_to_update = False
@@ -280,9 +281,11 @@ class Gramplet(object):
not self.dbstate.open) and
not self.gui.force_update):
self.dirty = True
- #print " %s is not active" % self.gui.title
+ if self.dbstate.open:
+ #print " %s is not active" % self.gui.gname
+ self.update_has_data()
return
- #print " %s is UPDATING" % self.gui.title
+ #print " %s is UPDATING" % self.gui.gname
self.dirty = False
self.uistate.push_message(self.dbstate,
_("Gramplet %s is running") % self.gui.title)
@@ -432,3 +435,17 @@ class Gramplet(object):
show_all() in some places.
"""
return []
+
+ def set_has_data(self, value):
+ """
+ Set the status as to whether this gramplet has data.
+ """
+ if value != self.has_data:
+ self.has_data = value
+ self.gui.set_has_data(value)
+
+ def update_has_data(self):
+ """
+ By default, assume that the gramplet has data.
+ """
+ self.set_has_data(True)
diff --git a/src/gui/grampsbar.py b/src/gui/grampsbar.py
index 99434a76e..6135b1272 100644
--- a/src/gui/grampsbar.py
+++ b/src/gui/grampsbar.py
@@ -320,7 +320,12 @@ class GrampsBar(gtk.Notebook):
Create a tab label consisting of a label and a close button.
"""
hbox = gtk.HBox(False, 4)
- label = gtk.Label(gramplet.title)
+ label = gtk.Label()
+ if gramplet.pui.has_data:
+ label.set_text("%s" % gramplet.title)
+ else:
+ label.set_text(gramplet.title)
+ label.set_use_markup(True)
label.set_tooltip_text(gramplet.tname)
closebtn = gtk.Button()
image = gtk.Image()
@@ -378,6 +383,7 @@ class GrampsBar(gtk.Notebook):
self.remove_page(0)
else:
return
+ gramplet.pane = self
label = self.__create_tab_label(gramplet)
self.set_tab_label(gramplet, label)
self.set_tab_reorderable(gramplet, True)
diff --git a/src/gui/widgets/grampletpane.py b/src/gui/widgets/grampletpane.py
index 9611539a2..594567920 100644
--- a/src/gui/widgets/grampletpane.py
+++ b/src/gui/widgets/grampletpane.py
@@ -684,6 +684,16 @@ class GuiGramplet(object):
warn( "Unknown link type " + link_type, RuntimeWarning, 2)
return False # did not handle event
+ def set_has_data(self, value):
+ if isinstance(self.pane, gtk.Notebook):
+ if self.pane.get_tab_label(self):
+ label = self.pane.get_tab_label(self).get_children()[0]
+ if value:
+ label.set_text("%s" % self.title)
+ label.set_use_markup(True)
+ else:
+ label.set_text(self.title)
+
class GridGramplet(GuiGramplet):
"""
Class that handles the plugin interfaces for the GrampletView.
diff --git a/src/plugins/gramplet/Attributes.py b/src/plugins/gramplet/Attributes.py
index 4cf9e1ce7..716d9deb2 100644
--- a/src/plugins/gramplet/Attributes.py
+++ b/src/plugins/gramplet/Attributes.py
@@ -54,6 +54,7 @@ class Attributes(Gramplet):
"""
for attr in obj.get_attribute_list():
self.model.add((attr.get_type(), attr.get_value()))
+ self.set_has_data(self.model.count > 0)
def display_report(self, treeview):
"""
@@ -67,6 +68,16 @@ class Attributes(Gramplet):
'attribute_match',
key)
+ def get_has_data(self, obj):
+ """
+ Return True if the gramplet has data, else return False.
+ """
+ if obj is None:
+ return False
+ if obj.get_attribute_list():
+ return True
+ return False
+
class PersonAttributes(Attributes):
"""
Displays the attributes of a person.
@@ -78,6 +89,11 @@ class PersonAttributes(Attributes):
def active_changed(self, handle):
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Person')
+ active = self.dbstate.db.get_person_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Person')
active = self.dbstate.db.get_person_from_handle(active_handle)
@@ -85,6 +101,8 @@ class PersonAttributes(Attributes):
self.model.clear()
if active:
self.display_attributes(active)
+ else:
+ self.set_has_data(False)
class EventAttributes(Attributes):
"""
@@ -95,6 +113,11 @@ class EventAttributes(Attributes):
self.connect_signal('Event', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Event')
+ active = self.dbstate.db.get_event_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Event')
active = self.dbstate.db.get_event_from_handle(active_handle)
@@ -102,6 +125,8 @@ class EventAttributes(Attributes):
self.model.clear()
if active:
self.display_attributes(active)
+ else:
+ self.set_has_data(False)
class FamilyAttributes(Attributes):
"""
@@ -112,6 +137,11 @@ class FamilyAttributes(Attributes):
self.connect_signal('Family', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Family')
+ active = self.dbstate.db.get_family_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Family')
active = self.dbstate.db.get_family_from_handle(active_handle)
@@ -119,6 +149,8 @@ class FamilyAttributes(Attributes):
self.model.clear()
if active:
self.display_attributes(active)
+ else:
+ self.set_has_data(False)
class MediaAttributes(Attributes):
"""
@@ -129,6 +161,11 @@ class MediaAttributes(Attributes):
self.connect_signal('Media', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Media')
+ active = self.dbstate.db.get_object_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Media')
active = self.dbstate.db.get_object_from_handle(active_handle)
@@ -136,4 +173,6 @@ class MediaAttributes(Attributes):
self.model.clear()
if active:
self.display_attributes(active)
+ else:
+ self.set_has_data(False)
diff --git a/src/plugins/gramplet/Backlinks.py b/src/plugins/gramplet/Backlinks.py
index d5d58ea12..f57a10f7d 100644
--- a/src/plugins/gramplet/Backlinks.py
+++ b/src/plugins/gramplet/Backlinks.py
@@ -50,10 +50,20 @@ class Backlinks(Gramplet):
Display the back references for an object.
"""
for classname, handle in \
- self.dbstate.db.find_backlink_handles(active_handle,
- include_classes=None):
+ self.dbstate.db.find_backlink_handles(active_handle):
name = navigation_label(self.dbstate.db, classname, handle)[0]
self.model.add((classname, name))
+ self.set_has_data(self.model.count > 0)
+
+ def get_has_data(self, active_handle):
+ """
+ Return True if the gramplet has data, else return False.
+ """
+ if active_handle is None:
+ return False
+ for handle in self.dbstate.db.find_backlink_handles(active_handle):
+ return True
+ return False
class PersonBacklinks(Backlinks):
"""
@@ -66,11 +76,17 @@ class PersonBacklinks(Backlinks):
def active_changed(self, handle):
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Person')
+ self.set_has_data(self.get_has_data(active_handle))
+
def main(self):
active_handle = self.get_active('Person')
self.model.clear()
if active_handle:
self.display_backlinks(active_handle)
+ else:
+ self.set_has_data(False)
class EventBacklinks(Backlinks):
"""
@@ -81,11 +97,17 @@ class EventBacklinks(Backlinks):
self.connect_signal('Event', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Event')
+ self.set_has_data(self.get_has_data(active_handle))
+
def main(self):
active_handle = self.get_active('Event')
self.model.clear()
if active_handle:
self.display_backlinks(active_handle)
+ else:
+ self.set_has_data(False)
class FamilyBacklinks(Backlinks):
"""
@@ -96,11 +118,17 @@ class FamilyBacklinks(Backlinks):
self.connect_signal('Family', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Family')
+ self.set_has_data(self.get_has_data(active_handle))
+
def main(self):
active_handle = self.get_active('Family')
self.model.clear()
if active_handle:
self.display_backlinks(active_handle)
+ else:
+ self.set_has_data(False)
class PlaceBacklinks(Backlinks):
"""
@@ -111,11 +139,17 @@ class PlaceBacklinks(Backlinks):
self.connect_signal('Place', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Place')
+ self.set_has_data(self.get_has_data(active_handle))
+
def main(self):
active_handle = self.get_active('Place')
self.model.clear()
if active_handle:
self.display_backlinks(active_handle)
+ else:
+ self.set_has_data(False)
class SourceBacklinks(Backlinks):
"""
@@ -126,11 +160,17 @@ class SourceBacklinks(Backlinks):
self.connect_signal('Source', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Source')
+ self.set_has_data(self.get_has_data(active_handle))
+
def main(self):
active_handle = self.get_active('Source')
self.model.clear()
if active_handle:
self.display_backlinks(active_handle)
+ else:
+ self.set_has_data(False)
class RepositoryBacklinks(Backlinks):
"""
@@ -141,11 +181,17 @@ class RepositoryBacklinks(Backlinks):
self.connect_signal('Repository', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Repository')
+ self.set_has_data(self.get_has_data(active_handle))
+
def main(self):
active_handle = self.get_active('Repository')
self.model.clear()
if active_handle:
self.display_backlinks(active_handle)
+ else:
+ self.set_has_data(False)
class MediaBacklinks(Backlinks):
"""
@@ -156,11 +202,17 @@ class MediaBacklinks(Backlinks):
self.connect_signal('Media', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Media')
+ self.set_has_data(self.get_has_data(active_handle))
+
def main(self):
active_handle = self.get_active('Media')
self.model.clear()
if active_handle:
self.display_backlinks(active_handle)
+ else:
+ self.set_has_data(False)
class NoteBacklinks(Backlinks):
"""
@@ -171,9 +223,15 @@ class NoteBacklinks(Backlinks):
self.connect_signal('Note', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Note')
+ self.set_has_data(self.get_has_data(active_handle))
+
def main(self):
active_handle = self.get_active('Note')
self.model.clear()
if active_handle:
self.display_backlinks(active_handle)
+ else:
+ self.set_has_data(False)
diff --git a/src/plugins/gramplet/Children.py b/src/plugins/gramplet/Children.py
index 34e7a0fff..27b3bd147 100644
--- a/src/plugins/gramplet/Children.py
+++ b/src/plugins/gramplet/Children.py
@@ -102,6 +102,25 @@ class PersonChildren(Children):
self.model.clear()
if active_handle:
self.display_person(active_handle)
+ else:
+ self.set_has_data(False)
+
+ def update_has_data(self):
+ active_handle = self.get_active('Person')
+ active = self.dbstate.db.get_person_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
+ def get_has_data(self, active_person):
+ """
+ Return True if the gramplet has data, else return False.
+ """
+ if active_person is None:
+ return False
+ for family_handle in active_person.get_family_handle_list():
+ family = self.dbstate.db.get_family_from_handle(family_handle)
+ if family.get_child_ref_list():
+ return True
+ return False
def display_person(self, active_handle):
"""
@@ -111,6 +130,7 @@ class PersonChildren(Children):
for family_handle in active_person.get_family_handle_list():
family = self.dbstate.db.get_family_from_handle(family_handle)
self.display_family(family, active_handle)
+ self.set_has_data(self.model.count > 0)
def display_family(self, family, active_handle):
"""
@@ -176,6 +196,23 @@ class FamilyChildren(Children):
if active_handle:
family = self.dbstate.db.get_family_from_handle(active_handle)
self.display_family(family)
+ else:
+ self.set_has_data(False)
+
+ def update_has_data(self):
+ active_handle = self.get_active('Family')
+ active = self.dbstate.db.get_family_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
+ def get_has_data(self, active_family):
+ """
+ Return True if the gramplet has data, else return False.
+ """
+ if active_family is None:
+ return False
+ if active_family.get_child_ref_list():
+ return True
+ return False
def display_family(self, family):
"""
@@ -184,6 +221,7 @@ class FamilyChildren(Children):
for child_ref in family.get_child_ref_list():
child = self.dbstate.db.get_person_from_handle(child_ref.ref)
self.add_child(child)
+ self.set_has_data(self.model.count > 0)
def add_child(self, child):
"""
diff --git a/src/plugins/gramplet/Exif.py b/src/plugins/gramplet/Exif.py
index 28868fe53..5fbd4d249 100644
--- a/src/plugins/gramplet/Exif.py
+++ b/src/plugins/gramplet/Exif.py
@@ -88,6 +88,42 @@ class Exif(Gramplet):
self.model.clear()
if media:
self.display_exif_tags(media)
+ else:
+ self.set_has_data(False)
+
+ def update_has_data(self):
+ active_handle = self.get_active('Media')
+ active = self.dbstate.db.get_object_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
+ def get_has_data(self, media):
+ """
+ Return True if the gramplet has data, else return False.
+ """
+ if media is None:
+ return False
+
+ full_path = Utils.media_path_full(self.dbstate.db, media.get_path())
+
+ if LesserVersion: # prior to v0.2.0
+ try:
+ metadata = pyexiv2.Image(full_path)
+ except IOError:
+ return False
+ metadata.readMetadata()
+ if metadata.exifKeys():
+ return True
+
+ else: # v0.2.0 and above
+ metadata = pyexiv2.ImageMetadata(full_path)
+ try:
+ metadata.read()
+ except IOError:
+ return False
+ if metadata.exif_keys:
+ return True
+
+ return False
def display_exif_tags(self, media):
"""
@@ -115,3 +151,5 @@ class Exif(Gramplet):
for key in metadata.exif_keys:
tag = metadata[key]
self.model.add((tag.label, tag.human_value))
+
+ self.set_has_data(self.model.count > 0)
diff --git a/src/plugins/gramplet/Gallery.py b/src/plugins/gramplet/Gallery.py
index 75e24124e..df54d27e2 100644
--- a/src/plugins/gramplet/Gallery.py
+++ b/src/plugins/gramplet/Gallery.py
@@ -54,17 +54,35 @@ class Gallery(Gramplet):
Load the primary image into the main form if it exists.
"""
media_list = obj.get_media_list()
+ count = 0
for media_ref in media_list:
- object_handle = media_ref.get_reference_handle()
- obj = self.dbstate.db.get_object_from_handle(object_handle)
- full_path = Utils.media_path_full(self.dbstate.db, obj.get_path())
- mime_type = obj.get_mime_type()
+ media_handle = media_ref.get_reference_handle()
+ media = self.dbstate.db.get_object_from_handle(media_handle)
+ full_path = Utils.media_path_full(self.dbstate.db, media.get_path())
+ mime_type = media.get_mime_type()
if mime_type and mime_type.startswith("image"):
photo = Photo(180.0)
photo.set_image(full_path, media_ref.get_rectangle())
self.image_list.append(photo)
self.top.pack_start(photo, expand=False, fill=False)
self.top.show_all()
+ count += 1
+ self.set_has_data(count > 0)
+
+ def get_has_data(self, obj):
+ """
+ Return True if the gramplet has data, else return False.
+ """
+ if obj is None:
+ return False
+ media_list = obj.get_media_list()
+ for media_ref in media_list:
+ media_handle = media_ref.get_reference_handle()
+ media = self.dbstate.db.get_object_from_handle(media_handle)
+ mime_type = media.get_mime_type()
+ if mime_type and mime_type.startswith("image"):
+ return True
+ return False
class PersonGallery(Gallery):
"""
@@ -77,6 +95,11 @@ class PersonGallery(Gallery):
def active_changed(self, handle):
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Person')
+ active = self.dbstate.db.get_person_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Person')
active = self.dbstate.db.get_person_from_handle(active_handle)
@@ -84,6 +107,8 @@ class PersonGallery(Gallery):
self.clear_images()
if active:
self.load_images(active)
+ else:
+ self.set_has_data(False)
class EventGallery(Gallery):
"""
@@ -94,6 +119,11 @@ class EventGallery(Gallery):
self.connect_signal('Event', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Event')
+ active = self.dbstate.db.get_event_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Event')
active = self.dbstate.db.get_event_from_handle(active_handle)
@@ -101,6 +131,8 @@ class EventGallery(Gallery):
self.clear_images()
if active:
self.load_images(active)
+ else:
+ self.set_has_data(False)
class PlaceGallery(Gallery):
"""
@@ -111,6 +143,11 @@ class PlaceGallery(Gallery):
self.connect_signal('Place', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Place')
+ active = self.dbstate.db.get_place_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Place')
active = self.dbstate.db.get_place_from_handle(active_handle)
@@ -118,6 +155,8 @@ class PlaceGallery(Gallery):
self.clear_images()
if active:
self.load_images(active)
+ else:
+ self.set_has_data(False)
class SourceGallery(Gallery):
"""
@@ -128,6 +167,11 @@ class SourceGallery(Gallery):
self.connect_signal('Source', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Source')
+ active = self.dbstate.db.get_source_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Source')
active = self.dbstate.db.get_source_from_handle(active_handle)
@@ -135,4 +179,6 @@ class SourceGallery(Gallery):
self.clear_images()
if active:
self.load_images(active)
+ else:
+ self.set_has_data(False)
diff --git a/src/plugins/gramplet/MediaPreview.py b/src/plugins/gramplet/MediaPreview.py
index 676fc0779..64c078c5b 100644
--- a/src/plugins/gramplet/MediaPreview.py
+++ b/src/plugins/gramplet/MediaPreview.py
@@ -55,14 +55,21 @@ class MediaPreview(Gramplet):
self.connect_signal('Media', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Media')
+ active_media = self.dbstate.db.get_object_from_handle(active_handle)
+ self.set_has_data(active_media is not None)
+
def main(self):
active_handle = self.get_active('Media')
media = self.dbstate.db.get_object_from_handle(active_handle)
self.top.hide()
if media:
self.load_image(media)
+ self.set_has_data(True)
else:
self.thumbnail.clear()
+ self.set_has_data(False)
self.top.show()
def load_image(self, media):
diff --git a/src/plugins/gramplet/Notes.py b/src/plugins/gramplet/Notes.py
index 784b45fd7..73d6b40b2 100644
--- a/src/plugins/gramplet/Notes.py
+++ b/src/plugins/gramplet/Notes.py
@@ -74,10 +74,13 @@ class Notes(Gramplet):
self.note_list = obj.get_note_list()
self.page.set_text('')
if len(self.note_list) > 0:
+ self.set_has_data(True)
if len(self.note_list) > 1:
self.right.set_sensitive(True)
self.current = 0
self.display_note()
+ else:
+ self.set_has_data(False)
def display_note(self):
"""
@@ -111,6 +114,16 @@ class Notes(Gramplet):
self.right.set_sensitive(False)
self.display_note()
+ def get_has_data(self, obj):
+ """
+ Return True if the gramplet has data, else return False.
+ """
+ if obj is None:
+ return False
+ if obj.get_note_list():
+ return True
+ return False
+
class PersonNotes(Notes):
"""
Displays the notes for a person.
@@ -122,11 +135,18 @@ class PersonNotes(Notes):
def active_changed(self, handle):
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Person')
+ active = self.dbstate.db.get_person_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Person')
active = self.dbstate.db.get_person_from_handle(active_handle)
if active:
self.get_notes(active)
+ else:
+ self.set_has_data(False)
class EventNotes(Notes):
"""
@@ -137,11 +157,18 @@ class EventNotes(Notes):
self.connect_signal('Event', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Event')
+ active = self.dbstate.db.get_event_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Event')
active = self.dbstate.db.get_event_from_handle(active_handle)
if active:
self.get_notes(active)
+ else:
+ self.set_has_data(False)
class FamilyNotes(Notes):
"""
@@ -152,11 +179,18 @@ class FamilyNotes(Notes):
self.connect_signal('Family', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Family')
+ active = self.dbstate.db.get_family_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Family')
active = self.dbstate.db.get_family_from_handle(active_handle)
if active:
self.get_notes(active)
+ else:
+ self.set_has_data(False)
class PlaceNotes(Notes):
"""
@@ -167,11 +201,18 @@ class PlaceNotes(Notes):
self.connect_signal('Place', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Place')
+ active = self.dbstate.db.get_place_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Place')
active = self.dbstate.db.get_place_from_handle(active_handle)
if active:
self.get_notes(active)
+ else:
+ self.set_has_data(False)
class SourceNotes(Notes):
"""
@@ -182,11 +223,18 @@ class SourceNotes(Notes):
self.connect_signal('Source', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Source')
+ active = self.dbstate.db.get_source_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Source')
active = self.dbstate.db.get_source_from_handle(active_handle)
if active:
self.get_notes(active)
+ else:
+ self.set_has_data(False)
class RepositoryNotes(Notes):
"""
@@ -197,11 +245,18 @@ class RepositoryNotes(Notes):
self.connect_signal('Repository', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Repository')
+ active = self.dbstate.db.get_repository_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Repository')
active = self.dbstate.db.get_repository_from_handle(active_handle)
if active:
self.get_notes(active)
+ else:
+ self.set_has_data(False)
class MediaNotes(Notes):
"""
@@ -212,9 +267,16 @@ class MediaNotes(Notes):
self.connect_signal('Media', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Media')
+ active = self.dbstate.db.get_object_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Media')
active = self.dbstate.db.get_object_from_handle(active_handle)
if active:
self.get_notes(active)
+ else:
+ self.set_has_data(False)
diff --git a/src/plugins/gramplet/PersonDetails.py b/src/plugins/gramplet/PersonDetails.py
index 507655b67..8751dc641 100644
--- a/src/plugins/gramplet/PersonDetails.py
+++ b/src/plugins/gramplet/PersonDetails.py
@@ -90,14 +90,21 @@ class PersonDetails(Gramplet):
def active_changed(self, handle):
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Person')
+ active_person = self.dbstate.db.get_person_from_handle(active_handle)
+ self.set_has_data(active_person is not None)
+
def main(self): # return false finishes
active_handle = self.get_active('Person')
active_person = self.dbstate.db.get_person_from_handle(active_handle)
self.top.hide()
if active_person:
self.display_person(active_person)
+ self.set_has_data(True)
else:
self.display_empty()
+ self.set_has_data(False)
self.top.show()
def display_person(self, active_person):
diff --git a/src/plugins/gramplet/PersonResidence.py b/src/plugins/gramplet/PersonResidence.py
index 228a06743..3db32548d 100644
--- a/src/plugins/gramplet/PersonResidence.py
+++ b/src/plugins/gramplet/PersonResidence.py
@@ -58,6 +58,23 @@ class PersonResidence(Gramplet):
def active_changed(self, handle):
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Person')
+ active = self.dbstate.db.get_person_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
+ def get_has_data(self, active_person):
+ """
+ Return True if the gramplet has data, else return False.
+ """
+ if active_person:
+ for event_ref in active_person.get_event_ref_list():
+ if int(event_ref.get_role()) == EventRoleType.PRIMARY:
+ event = self.dbstate.db.get_event_from_handle(event_ref.ref)
+ if int(event.get_type()) == EventType.RESIDENCE:
+ return True
+ return False
+
def main(self): # return false finishes
active_handle = self.get_active('Person')
active_person = self.dbstate.db.get_person_from_handle(active_handle)
@@ -65,16 +82,21 @@ class PersonResidence(Gramplet):
self.model.clear()
if active_person:
self.display_person(active_person)
+ else:
+ self.set_has_data(False)
def display_person(self, active_person):
"""
Display the residence events of the active person.
"""
+ count = 0
for event_ref in active_person.get_event_ref_list():
if int(event_ref.get_role()) == EventRoleType.PRIMARY:
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
if int(event.get_type()) == EventType.RESIDENCE:
self.add_residence(event)
+ count += 1
+ self.set_has_data(count > 0)
def add_residence(self, event):
"""
diff --git a/src/plugins/gramplet/PlaceDetails.py b/src/plugins/gramplet/PlaceDetails.py
index 6f0a0bdff..63d706068 100644
--- a/src/plugins/gramplet/PlaceDetails.py
+++ b/src/plugins/gramplet/PlaceDetails.py
@@ -79,14 +79,21 @@ class PlaceDetails(Gramplet):
self.connect_signal('Place', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Person')
+ active_person = self.dbstate.db.get_person_from_handle(active_handle)
+ self.set_has_data(active_person is not None)
+
def main(self):
active_handle = self.get_active('Place')
place = self.dbstate.db.get_place_from_handle(active_handle)
self.top.hide()
if place:
self.display_place(place)
+ self.set_has_data(True)
else:
self.display_empty()
+ self.set_has_data(False)
self.top.show()
def display_place(self, place):
diff --git a/src/plugins/gramplet/RepositoryDetails.py b/src/plugins/gramplet/RepositoryDetails.py
index cd40516b6..a29d74791 100644
--- a/src/plugins/gramplet/RepositoryDetails.py
+++ b/src/plugins/gramplet/RepositoryDetails.py
@@ -76,14 +76,21 @@ class RepositoryDetails(Gramplet):
self.connect_signal('Repository', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Person')
+ active_person = self.dbstate.db.get_person_from_handle(active_handle)
+ self.set_has_data(active_person is not None)
+
def main(self):
active_handle = self.get_active('Repository')
repo = self.dbstate.db.get_repository_from_handle(active_handle)
self.top.hide()
if repo:
self.display_repo(repo)
+ self.set_has_data(True)
else:
self.display_empty()
+ self.set_has_data(False)
self.top.show()
def display_repo(self, repo):
diff --git a/src/plugins/gramplet/Sources.py b/src/plugins/gramplet/Sources.py
index 87889ac88..4f21cfd68 100644
--- a/src/plugins/gramplet/Sources.py
+++ b/src/plugins/gramplet/Sources.py
@@ -56,6 +56,7 @@ class Sources(Gramplet):
"""
for source_ref in obj.get_source_references():
self.add_source_ref(source_ref)
+ self.set_has_data(self.model.count > 0)
def add_source_ref(self, source_ref):
"""
@@ -80,6 +81,16 @@ class Sources(Gramplet):
except Errors.WindowActiveError:
pass
+ def get_has_data(self, obj):
+ """
+ Return True if the gramplet has data, else return False.
+ """
+ if obj is None:
+ return False
+ if obj.get_source_references():
+ return True
+ return False
+
class PersonSources(Sources):
"""
Displays the sources for a person.
@@ -91,6 +102,11 @@ class PersonSources(Sources):
def active_changed(self, handle):
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Person')
+ active = self.dbstate.db.get_person_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Person')
active = self.dbstate.db.get_person_from_handle(active_handle)
@@ -98,6 +114,8 @@ class PersonSources(Sources):
self.model.clear()
if active:
self.display_sources(active)
+ else:
+ self.set_has_data(False)
class EventSources(Sources):
"""
@@ -108,6 +126,11 @@ class EventSources(Sources):
self.connect_signal('Event', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Event')
+ active = self.dbstate.db.get_event_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Event')
active = self.dbstate.db.get_event_from_handle(active_handle)
@@ -115,6 +138,8 @@ class EventSources(Sources):
self.model.clear()
if active:
self.display_sources(active)
+ else:
+ self.set_has_data(False)
class FamilySources(Sources):
"""
@@ -125,6 +150,11 @@ class FamilySources(Sources):
self.connect_signal('Family', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Family')
+ active = self.dbstate.db.get_family_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Family')
active = self.dbstate.db.get_family_from_handle(active_handle)
@@ -132,6 +162,8 @@ class FamilySources(Sources):
self.model.clear()
if active:
self.display_sources(active)
+ else:
+ self.set_has_data(False)
class PlaceSources(Sources):
"""
@@ -142,6 +174,11 @@ class PlaceSources(Sources):
self.connect_signal('Place', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Place')
+ active = self.dbstate.db.get_place_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Place')
active = self.dbstate.db.get_place_from_handle(active_handle)
@@ -149,6 +186,8 @@ class PlaceSources(Sources):
self.model.clear()
if active:
self.display_sources(active)
+ else:
+ self.set_has_data(False)
class MediaSources(Sources):
"""
@@ -159,6 +198,11 @@ class MediaSources(Sources):
self.connect_signal('Media', self.update)
self.update()
+ def update_has_data(self):
+ active_handle = self.get_active('Media')
+ active = self.dbstate.db.get_object_from_handle(active_handle)
+ self.set_has_data(self.get_has_data(active))
+
def main(self):
active_handle = self.get_active('Media')
active = self.dbstate.db.get_object_from_handle(active_handle)
@@ -166,4 +210,6 @@ class MediaSources(Sources):
self.model.clear()
if active:
self.display_sources(active)
+ else:
+ self.set_has_data(False)