* 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
This commit is contained in:
Don Allingham 2006-01-15 01:26:47 +00:00
parent 4e6804cb9e
commit fdaccccc59
5 changed files with 89 additions and 23 deletions

View File

@ -1,3 +1,9 @@
2006-01-14 Don Allingham <don@gramps-project.org>
* 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 <rjt-gramps@thegrindstone.me.uk>
* src/ObjectSelector/_Constants.py: enums
* src/ObjectSelector/_Factories.py: multi object type factories

View File

@ -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):

View File

@ -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())

View File

@ -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):

View File

@ -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 = "<span size=\"larger\" weight=\"bold\">%s</span>" % _("Family")
if fhandle:
father = self._db.get_person_from_handle(fhandle)
s +="\n <span weight=\"bold\">%s:</span> %s" % (
_("Father"),escape(father.get_primary_name().get_name()))
if mhandle:
mother = self._db.get_person_from_handle(mhandle)
s +="\n <span weight=\"bold\">%s:</span> %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 <span weight=\"bold\">%s:</span> %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
}