From b84af7731ff92ab82e1226478ae158b675ccb687 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 15 Jan 2006 01:26:47 +0000 Subject: [PATCH] * src/DisplayTabs.py: fix double click * src/EditFamily.py: fix double click * src/GrampsWidgets.py: add SimpleButton * src/ToolTips.py: Family tool tip svn: r5754 --- gramps2/ChangeLog | 6 ++++ gramps2/src/DisplayTabs.py | 58 +++++++++++++++++++++++------------- gramps2/src/EditFamily.py | 4 +-- gramps2/src/GrampsWidgets.py | 9 ++++++ gramps2/src/ToolTips.py | 35 +++++++++++++++++++++- 5 files changed, 89 insertions(+), 23 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index ece9fa918..25931c7f9 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2006-01-14 Don Allingham + * src/DisplayTabs.py: fix double click + * src/EditFamily.py: fix double click + * src/GrampsWidgets.py: add SimpleButton + * src/ToolTips.py: Family tool tip + 2006-01-14 Richard Taylor * src/ObjectSelector/_Constants.py: enums * src/ObjectSelector/_Factories.py: multi object type factories diff --git a/gramps2/src/DisplayTabs.py b/gramps2/src/DisplayTabs.py index 544f4f078..9edab7215 100644 --- a/gramps2/src/DisplayTabs.py +++ b/gramps2/src/DisplayTabs.py @@ -19,6 +19,8 @@ # import gtk +import gobject + import DateHandler import NameDisplay import RelLib @@ -26,6 +28,8 @@ import Utils import ToolTips import GrampsLocale +from GrampsWidgets import SimpleButton + _GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ] #------------------------------------------------------------------------- @@ -77,18 +81,10 @@ class EmbeddedList(gtk.HBox): self.del_btn.set_sensitive(False) def create_buttons(self): - self.add_btn = gtk.Button() - self.add_btn.set_relief(gtk.RELIEF_NONE) - self.add_btn.add(gtk.image_new_from_stock(gtk.STOCK_ADD, - gtk.ICON_SIZE_BUTTON)) - self.edit_btn = gtk.Button() - self.edit_btn.set_relief(gtk.RELIEF_NONE) - self.edit_btn.add(gtk.image_new_from_stock(gtk.STOCK_EDIT, - gtk.ICON_SIZE_BUTTON)) - self.del_btn = gtk.Button() - self.del_btn.set_relief(gtk.RELIEF_NONE) - self.del_btn.add(gtk.image_new_from_stock(gtk.STOCK_REMOVE, - gtk.ICON_SIZE_BUTTON)) + self.add_btn = SimpleButton(gtk.STOCK_ADD, self.add_button_clicked) + self.edit_btn = SimpleButton(gtk.STOCK_EDIT, self.edit_button_clicked) + self.del_btn = SimpleButton(gtk.STOCK_REMOVE, self.del_button_clicked) + vbox = gtk.VBox() vbox.set_spacing(6) vbox.pack_start(self.add_btn,False) @@ -97,9 +93,11 @@ class EmbeddedList(gtk.HBox): vbox.show_all() self.pack_start(vbox,False) - self.add_btn.connect('clicked',self.add_button_clicked) - self.del_btn.connect('clicked',self.del_button_clicked) - self.edit_btn.connect('clicked',self.edit_button_clicked) + self.tree.connect('button_press_event',self.double_click) + + def double_click(self, obj, event): + if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1: + self.edit_button_clicked(obj) def add_button_clicked(self,obj): pass @@ -152,10 +150,12 @@ class EmbeddedList(gtk.HBox): #------------------------------------------------------------------------- class EventEmbedList(EmbeddedList): + _HANDLE_COL = 6 + column_names = [ - (_('Description'),0), - (_('ID'),1), - (_('Type'),2), + (_('Type'),0), + (_('Description'),1), + (_('ID'),2), (_('Date'),3), (_('Place'),4), (_('Cause'),5), @@ -185,6 +185,22 @@ class EventEmbedList(EmbeddedList): def get_tab_widget(self): return self.label + def add_button_clicked(self,obj): + pass + + def del_button_clicked(self,obj): + ref = self.get_selected() + if ref: + ref_list = self.obj.get_event_ref_list() + ref_list.remove(ref) + self.rebuild() + + def edit_button_clicked(self,obj): + ref = self.get_selected() + if ref: + print ref + + #------------------------------------------------------------------------- # # NoteTab @@ -363,17 +379,19 @@ class ChildModel(gtk.ListStore): class EventRefModel(gtk.ListStore): def __init__(self,event_list,db): - gtk.ListStore.__init__(self,str,str,str,str,str,str) + gtk.ListStore.__init__(self,str,str,str,str,str,str, + gobject.TYPE_PYOBJECT) self.db = db for event_ref in event_list: event = db.get_event_from_handle(event_ref.ref) self.append(row=[ + self.column_type(event), event.get_description(), event.get_gramps_id(), - self.column_type(event), self.column_date(event_ref), self.column_place(event_ref), event.get_cause(), + event_ref ]) def column_type(self,event): diff --git a/gramps2/src/EditFamily.py b/gramps2/src/EditFamily.py index 69f5cc49d..28f8926a0 100644 --- a/gramps2/src/EditFamily.py +++ b/gramps2/src/EditFamily.py @@ -240,8 +240,8 @@ class EditFamily(DisplayState.ManagedWindow): self.child_list = ChildEmbedList(self.dbstate,self.uistate, self.track, self.family) - self.event_list = DisplayTabs.EventEmbedList(self.dbstate, self.uistate, - self.track, self.family) + self.event_list = DisplayTabs.EventEmbedList(self.dbstate,self.uistate, + self.track,self.family) self.attr_list = AttrEmbedList(self.dbstate, self.uistate, self.track, self.family.get_attribute_list()) self.note_tab = DisplayTabs.NoteTab(self.family.get_note_object()) diff --git a/gramps2/src/GrampsWidgets.py b/gramps2/src/GrampsWidgets.py index 5513a6c57..f804f1eec 100644 --- a/gramps2/src/GrampsWidgets.py +++ b/gramps2/src/GrampsWidgets.py @@ -75,6 +75,15 @@ class IconButton(gtk.EventBox): self.add(image) self.show() self.connect('button-press-event',func,handle) + +class SimpleButton(gtk.Button): + + def __init__(self,image,func): + gtk.Button.__init__(self) + self.set_relief(gtk.RELIEF_NONE) + self.add(gtk.image_new_from_stock(image,gtk.ICON_SIZE_BUTTON)) + self.connect('clicked',func) + self.show() class LinkBox(gtk.HBox): diff --git a/gramps2/src/ToolTips.py b/gramps2/src/ToolTips.py index 048e44f2b..0d8f2a632 100644 --- a/gramps2/src/ToolTips.py +++ b/gramps2/src/ToolTips.py @@ -208,9 +208,42 @@ class PersonTip: __call__ = get_tip +class FamilyTip: + def __init__(self,db,obj): + self._db = db + self._obj = obj + + def get_tip(self): + global escape + + fhandle = self._obj.get_father_handle() + mhandle = self._obj.get_mother_handle() + + s = "%s" % _("Family") + + if fhandle: + father = self._db.get_person_from_handle(fhandle) + s +="\n %s: %s" % ( + _("Father"),escape(father.get_primary_name().get_name())) + + if mhandle: + mother = self._db.get_person_from_handle(mhandle) + s +="\n %s: %s" % ( + _("Mother"),escape(mother.get_primary_name().get_name())) + + for chandle in self._obj.get_child_handle_list(): + child = self._db.get_person_from_handle(chandle) + s +="\n %s: %s" % ( + _("Child"),escape(child.get_primary_name().get_name())) + + return s + + __call__ = get_tip + CLASS_MAP = { RelLib.Repository : RepositoryTip, - RelLib.Person : PersonTip + RelLib.Person : PersonTip, + RelLib.Family : FamilyTip }