* src/FamilyView.py: Handle reordering of spouses by drag
and drop * src/RelLib.py: Allow the family list to be set externally * src/gramps.glade: enable reordering flag for spouse list svn: r3736
This commit is contained in:
parent
003912f326
commit
a6a6c78782
@ -1,4 +1,8 @@
|
|||||||
2004-11-18 Don Allingham <dallingham@users.sourceforge.net>
|
2004-11-18 Don Allingham <dallingham@users.sourceforge.net>
|
||||||
|
* src/FamilyView.py: Handle reordering of spouses by drag
|
||||||
|
and drop
|
||||||
|
* src/RelLib.py: Allow the family list to be set externally
|
||||||
|
* src/gramps.glade: enable reordering flag for spouse list
|
||||||
* src/DisplayModels.py: Added ChildModel to handle the
|
* src/DisplayModels.py: Added ChildModel to handle the
|
||||||
child list in the Family View
|
child list in the Family View
|
||||||
* src/gramps_main.py: add column editor for Family View
|
* src/gramps_main.py: add column editor for Family View
|
||||||
|
@ -57,6 +57,8 @@ _DIED = _('d.')
|
|||||||
|
|
||||||
pycode_tgts = [('child', 0, 0)]
|
pycode_tgts = [('child', 0, 0)]
|
||||||
|
|
||||||
|
spcode_tgts = [('spouse', 0, 0)]
|
||||||
|
|
||||||
column_names = [
|
column_names = [
|
||||||
(_('#'),0) ,
|
(_('#'),0) ,
|
||||||
(_('ID'),1) ,
|
(_('ID'),1) ,
|
||||||
@ -82,6 +84,7 @@ class FamilyView:
|
|||||||
self.top = parent.gtop
|
self.top = parent.gtop
|
||||||
self.family = None
|
self.family = None
|
||||||
self.cadded = [ 0, 0 ]
|
self.cadded = [ 0, 0 ]
|
||||||
|
self.in_drag = False
|
||||||
self.init_interface()
|
self.init_interface()
|
||||||
|
|
||||||
def set_widgets(self,val):
|
def set_widgets(self,val):
|
||||||
@ -124,6 +127,7 @@ class FamilyView:
|
|||||||
self.ap_parents_clicked)
|
self.ap_parents_clicked)
|
||||||
self.top.get_widget('sp_parents_btn2').connect('clicked',
|
self.top.get_widget('sp_parents_btn2').connect('clicked',
|
||||||
self.sp_parents_clicked)
|
self.sp_parents_clicked)
|
||||||
|
|
||||||
self.parent.views.get_nth_page(2).show_all()
|
self.parent.views.get_nth_page(2).show_all()
|
||||||
if self.parent.views.get_current_page() == 1:
|
if self.parent.views.get_current_page() == 1:
|
||||||
self.parent.views.set_current_page(2)
|
self.parent.views.set_current_page(2)
|
||||||
@ -169,6 +173,15 @@ class FamilyView:
|
|||||||
self.parent.views.set_current_page(1)
|
self.parent.views.set_current_page(1)
|
||||||
self.parent.views.get_nth_page(2).hide()
|
self.parent.views.get_nth_page(2).hide()
|
||||||
|
|
||||||
|
self.spouse_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
|
||||||
|
spcode_tgts,ACTION_COPY)
|
||||||
|
self.spouse_list.drag_source_set(BUTTON1_MASK,
|
||||||
|
spcode_tgts, ACTION_COPY)
|
||||||
|
self.spouse_list.connect('drag_data_get',
|
||||||
|
self.sp_drag_data_get)
|
||||||
|
self.spouse_list.connect('drag_data_received',
|
||||||
|
self.sp_drag_data_received)
|
||||||
|
|
||||||
def init_interface(self):
|
def init_interface(self):
|
||||||
fv = GrampsGconfKeys.get_family_view()
|
fv = GrampsGconfKeys.get_family_view()
|
||||||
self.dd = DateHandler.create_display()
|
self.dd = DateHandler.create_display()
|
||||||
@ -202,7 +215,7 @@ class FamilyView:
|
|||||||
self.sp_parents.connect('button-press-event',self.sp_par_button_press)
|
self.sp_parents.connect('button-press-event',self.sp_par_button_press)
|
||||||
self.sp_parents.connect('key-press-event',self.sp_par_key_press)
|
self.sp_parents.connect('key-press-event',self.sp_par_key_press)
|
||||||
|
|
||||||
self.spouse_model = gtk.ListStore(TYPE_STRING)
|
self.spouse_model = gtk.ListStore(TYPE_STRING,TYPE_STRING)
|
||||||
self.spouse_list.set_model(self.spouse_model)
|
self.spouse_list.set_model(self.spouse_model)
|
||||||
self.spouse_selection = self.spouse_list.get_selection()
|
self.spouse_selection = self.spouse_list.get_selection()
|
||||||
if not already_init:
|
if not already_init:
|
||||||
@ -530,6 +543,8 @@ class FamilyView:
|
|||||||
SelectChild.EditRel(self.parent.db,person,self.family,self.load_family)
|
SelectChild.EditRel(self.parent.db,person,self.family,self.load_family)
|
||||||
|
|
||||||
def spouse_changed(self,obj):
|
def spouse_changed(self,obj):
|
||||||
|
if self.in_drag:
|
||||||
|
return
|
||||||
model, node = obj.get_selected()
|
model, node = obj.get_selected()
|
||||||
if not node:
|
if not node:
|
||||||
self.display_marriage(None)
|
self.display_marriage(None)
|
||||||
@ -539,7 +554,6 @@ class FamilyView:
|
|||||||
fam = self.parent.db.get_family_from_handle(family_handle)
|
fam = self.parent.db.get_family_from_handle(family_handle)
|
||||||
self.display_marriage(fam)
|
self.display_marriage(fam)
|
||||||
|
|
||||||
|
|
||||||
def build_spouse_menu(self,event):
|
def build_spouse_menu(self,event):
|
||||||
|
|
||||||
menu = gtk.Menu()
|
menu = gtk.Menu()
|
||||||
@ -660,7 +674,7 @@ class FamilyView:
|
|||||||
self.parent.people_view.redisplay_person_list(epo.person)
|
self.parent.people_view.redisplay_person_list(epo.person)
|
||||||
|
|
||||||
self.parent.active_person = ap
|
self.parent.active_person = ap
|
||||||
self.load_family(self.family)
|
self.load_family()
|
||||||
|
|
||||||
def new_spouse_after_edit(self,epo,val):
|
def new_spouse_after_edit(self,epo,val):
|
||||||
|
|
||||||
@ -891,7 +905,6 @@ class FamilyView:
|
|||||||
|
|
||||||
def load_family(self,family=None):
|
def load_family(self,family=None):
|
||||||
|
|
||||||
self.build_columns()
|
|
||||||
if self.parent.active_person:
|
if self.parent.active_person:
|
||||||
handle = self.parent.active_person.get_handle()
|
handle = self.parent.active_person.get_handle()
|
||||||
self.person = self.parent.db.get_person_from_handle(handle)
|
self.person = self.parent.db.get_person_from_handle(handle)
|
||||||
@ -961,8 +974,10 @@ class FamilyView:
|
|||||||
const.family_relations[fm.get_relationship()][0],
|
const.family_relations[fm.get_relationship()][0],
|
||||||
mdate)
|
mdate)
|
||||||
self.spouse_model.set(node,0,v)
|
self.spouse_model.set(node,0,v)
|
||||||
|
self.spouse_model.set(node,1,f)
|
||||||
else:
|
else:
|
||||||
self.spouse_model.set(node,0,"%s\n" % _("<double click to add spouse>"))
|
self.spouse_model.set(node,0,"%s\n" % _("<double click to add spouse>"))
|
||||||
|
self.spouse_model.set(node,1,f)
|
||||||
|
|
||||||
if family and family.get_handle() in flist:
|
if family and family.get_handle() in flist:
|
||||||
self.display_marriage(family)
|
self.display_marriage(family)
|
||||||
@ -1348,7 +1363,43 @@ class FamilyView:
|
|||||||
trans = self.parent.db.transaction_begin()
|
trans = self.parent.db.transaction_begin()
|
||||||
self.parent.db.commit_family(self.family,trans)
|
self.parent.db.commit_family(self.family,trans)
|
||||||
self.parent.db.transaction_commit(trans,_('Reorder children'))
|
self.parent.db.transaction_commit(trans,_('Reorder children'))
|
||||||
self.display_marriage(self.family)
|
self.load_family(self.family)
|
||||||
|
|
||||||
|
def sp_drag_data_received(self,widget,context,x,y,sel_data,info,time):
|
||||||
|
self.in_drag = True
|
||||||
|
path = self.spouse_list.get_path_at_pos(x,y)
|
||||||
|
if path == None:
|
||||||
|
row = len(self.person.get_family_handle_list())
|
||||||
|
else:
|
||||||
|
row = path[0][0] -1
|
||||||
|
|
||||||
|
if sel_data and sel_data.data:
|
||||||
|
exec 'data = %s' % sel_data.data
|
||||||
|
exec 'mytype = "%s"' % data[0]
|
||||||
|
exec 'person = "%s"' % data[1]
|
||||||
|
|
||||||
|
if mytype != 'spouse':
|
||||||
|
return
|
||||||
|
|
||||||
|
s,i = self.spouse_selection.get_selected()
|
||||||
|
if not i:
|
||||||
|
return
|
||||||
|
|
||||||
|
spath = s.get_path(i)
|
||||||
|
src = spath[0]
|
||||||
|
family_list = self.person.get_family_handle_list()
|
||||||
|
|
||||||
|
obj = family_list[src]
|
||||||
|
family_list.remove(obj)
|
||||||
|
family_list.insert(row,obj)
|
||||||
|
|
||||||
|
self.person.set_family_handle_list(family_list)
|
||||||
|
trans = self.parent.db.transaction_begin()
|
||||||
|
self.parent.db.commit_person(self.person,trans)
|
||||||
|
self.parent.db.transaction_commit(trans,_('Reorder spouses'))
|
||||||
|
self.load_family()
|
||||||
|
#self.display_marriage(self.family)
|
||||||
|
self.in_drag = False
|
||||||
|
|
||||||
def drag_data_get(self,widget, context, sel_data, info, time):
|
def drag_data_get(self,widget, context, sel_data, info, time):
|
||||||
store,node = self.child_selection.get_selected()
|
store,node = self.child_selection.get_selected()
|
||||||
@ -1359,6 +1410,15 @@ class FamilyView:
|
|||||||
data = str(('child',handle));
|
data = str(('child',handle));
|
||||||
sel_data.set(sel_data.target, bits_per, data)
|
sel_data.set(sel_data.target, bits_per, data)
|
||||||
|
|
||||||
|
def sp_drag_data_get(self,widget, context, sel_data, info, time):
|
||||||
|
store,node = self.spouse_selection.get_selected()
|
||||||
|
if not node:
|
||||||
|
return
|
||||||
|
handle = self.spouse_model.get_value(node,1)
|
||||||
|
bits_per = 8; # we're going to pass a string
|
||||||
|
data = str(('spouse',handle));
|
||||||
|
sel_data.set(sel_data.target, bits_per, data)
|
||||||
|
|
||||||
def north_american(self,val):
|
def north_american(self,val):
|
||||||
if self.person.get_gender() == RelLib.Person.male:
|
if self.person.get_gender() == RelLib.Person.male:
|
||||||
pname = self.person.get_primary_name()
|
pname = self.person.get_primary_name()
|
||||||
|
@ -430,6 +430,11 @@ class Person(PrimaryObject,SourceNote):
|
|||||||
person is a parent or spouse"""
|
person is a parent or spouse"""
|
||||||
return self.family_list
|
return self.family_list
|
||||||
|
|
||||||
|
def set_family_handle_list(self,flist) :
|
||||||
|
"""returns the list of Family instances in which the
|
||||||
|
person is a parent or spouse"""
|
||||||
|
self.family_list = flist
|
||||||
|
|
||||||
def clear_family_handle_list(self) :
|
def clear_family_handle_list(self) :
|
||||||
"""
|
"""
|
||||||
Removes all familyts from the family list.
|
Removes all familyts from the family list.
|
||||||
|
@ -731,10 +731,6 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkSeparatorToolItem" id="separatortoolitem1">
|
<widget class="GtkSeparatorToolItem" id="separatortoolitem1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -2010,7 +2006,7 @@
|
|||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="headers_visible">False</property>
|
<property name="headers_visible">False</property>
|
||||||
<property name="rules_hint">True</property>
|
<property name="rules_hint">True</property>
|
||||||
<property name="reorderable">False</property>
|
<property name="reorderable">True</property>
|
||||||
<property name="enable_search">True</property>
|
<property name="enable_search">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
@ -2199,7 +2195,7 @@
|
|||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="headers_visible">False</property>
|
<property name="headers_visible">False</property>
|
||||||
<property name="rules_hint">True</property>
|
<property name="rules_hint">True</property>
|
||||||
<property name="reorderable">False</property>
|
<property name="reorderable">True</property>
|
||||||
<property name="enable_search">True</property>
|
<property name="enable_search">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
|
Loading…
Reference in New Issue
Block a user