From 854bc784fecd5a8218318aed231892f86f65ee4d Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 15 Nov 2002 03:49:39 +0000 Subject: [PATCH] EditPerson fixes, list model enhancements svn: r1189 --- gramps2/src/EditPerson.py | 65 ++++++------- gramps2/src/FamilyView.py | 4 +- gramps2/src/ListModel.py | 12 +++ gramps2/src/QuickAdd.py | 5 +- gramps2/src/SelectChild.py | 15 +-- gramps2/src/edit_person.glade | 77 +--------------- gramps2/src/filters/AltFam.py | 8 +- gramps2/src/gramps.glade | 2 +- gramps2/src/gramps_main.py | 156 +++----------------------------- gramps2/src/plugins/EventCmp.py | 2 +- gramps2/src/revision.glade | 4 +- 11 files changed, 76 insertions(+), 274 deletions(-) diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index 606aeda6c..ec983e2f8 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -36,6 +36,8 @@ import gtk import gnome.ui import gtk.glade +from gtk.gdk import ACTION_COPY, BUTTON1_MASK, INTERP_BILINEAR, pixbuf_new_from_file + #------------------------------------------------------------------------- # # gramps modules @@ -153,7 +155,7 @@ class EditPerson: self.event_src_field = self.get_widget("event_srcinfo") self.event_conf_field = self.get_widget("event_conf") self.attr_conf_field = self.get_widget("attr_conf") - self.addr_conf_field = self.get_widget("attr_conf") + self.addr_conf_field = self.get_widget("addr_conf") self.name_conf_field = self.get_widget("name_conf") self.attr_src_field = self.get_widget("attr_srcinfo") self.name_src_field = self.get_widget("name_srcinfo") @@ -260,20 +262,6 @@ class EditPerson: self.event_list = self.get_widget("eventList") - if GrampsCfg.display_attr: - self.get_widget("user_label").set_text(GrampsCfg.attr_name) - val = "" - for attr in self.person.getAttributeList(): - if attr.getType() == const.save_pattr(GrampsCfg.attr_name): - val = attr.getValue() - break - self.get_widget("user_data").set_text(val) - self.get_widget("user_colon").show() - else: - self.get_widget("user_label").hide() - self.get_widget("user_colon").hide() - self.get_widget("user_data").hide() - self.lds_baptism = LdsOrd(self.person.getLdsBaptism()) self.lds_endowment = LdsOrd(self.person.getLdsEndowment()) self.lds_sealing = LdsOrd(self.person.getLdsSeal()) @@ -304,34 +292,33 @@ class EditPerson: self.notes_buffer = self.notes_field.get_buffer() self.notes_buffer.set_text(person.getNote()) - self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,gtk.gdk.ACTION_COPY) - self.event_list.drag_source_set(gtk.gdk.BUTTON1_MASK, pycode_tgts, gtk.gdk.ACTION_COPY) + self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY) + self.event_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY) self.event_list.connect('drag_data_get', self.ev_drag_data_get) self.event_list.connect('drag_data_received', self.ev_drag_data_received) -# self.web_list.drag_dest_set(gtk.DEST_DEFAULT_ALL, -# pycode_tgts,ACTION_COPY) -# self.web_list.drag_source_set(BUTTON1_MASK, pycode_tgts, gtk.gdk.ACTION_COPY) -# self.web_list.connect('drag_data_get', self.url_drag_data_get) -# self.web_list.connect('drag_data_received', -# self.url_drag_data_received) + self.web_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY) + self.web_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY) + self.web_list.connect('drag_data_get', self.url_drag_data_get) + self.web_list.connect('drag_data_received', + self.url_drag_data_received) -# self.attr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts, -# gtk.gdk.ACTION_COPY) -# self.attr_list.drag_source_set(gtk.gdk.BUTTON1_MASK, pycode_tgts, -# gtk.gdk.ACTION_COPY) -# self.attr_list.connect('drag_data_get', self.at_drag_data_get) -# self.attr_list.connect('drag_data_received', -# self.at_drag_data_received) + self.attr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts, + ACTION_COPY) + self.attr_list.drag_source_set(BUTTON1_MASK, pycode_tgts, + ACTION_COPY) + self.attr_list.connect('drag_data_get', self.at_drag_data_get) + self.attr_list.connect('drag_data_received', + self.at_drag_data_received) -# self.addr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL, -# pycode_tgts,ACTION_COPY) -# self.addr_list.drag_source_set(gtk.gdk.BUTTON1_MASK, pycode_tgts, -# gtk.gdk.ACTION_COPY) -# self.addr_list.connect('drag_data_get', self.ad_drag_data_get) -# self.addr_list.connect('drag_data_received', -# self.ad_drag_data_received) + self.addr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL, + pycode_tgts,ACTION_COPY) + self.addr_list.drag_source_set(BUTTON1_MASK, pycode_tgts, + ACTION_COPY) + self.addr_list.connect('drag_data_get', self.ad_drag_data_get) + self.addr_list.connect('drag_data_received', + self.ad_drag_data_received) self.redraw_event_list() self.redraw_attr_list() @@ -1088,12 +1075,12 @@ class EditPerson: self.get_widget("personPix").hide() else: try: - i = gtk.gdk.pixbuf_new_from_file(photo) + i = pixbuf_new_from_file(photo) ratio = float(max(i.get_height(),i.get_width())) scale = float(const.picWidth)/ratio x = int(scale*(i.get_width())) y = int(scale*(i.get_height())) - i = i.scale_simple(x,y,gtk.gdk.INTERP_BILINEAR) + i = i.scale_simple(x,y,INTERP_BILINEAR) self.get_widget("personPix").set_from_pixbuf(i) self.get_widget("personPix").show() except: diff --git a/gramps2/src/FamilyView.py b/gramps2/src/FamilyView.py index 92eea7009..e07fcc1c7 100644 --- a/gramps2/src/FamilyView.py +++ b/gramps2/src/FamilyView.py @@ -162,8 +162,8 @@ class FamilyView: return try: SelectChild.SelectChild(self.parent.db, self.family, - self.person, - self.load_family) + self.person, self.load_family, + self.parent.update_person_list) except: DisplayTrace.DisplayTrace() diff --git a/gramps2/src/ListModel.py b/gramps2/src/ListModel.py index bcda3ae7c..b7b29cb93 100644 --- a/gramps2/src/ListModel.py +++ b/gramps2/src/ListModel.py @@ -67,6 +67,9 @@ class ListModel: def clear(self): self.model.clear() + def remove(self,iter): + self.model.remove(iter) + def get_object(self,iter): return self.model.get_value(iter,self.data_index) @@ -77,6 +80,15 @@ class ListModel: self.model.set_value(iter,col,object) col = col + 1 self.model.set_value(iter,col,info) + + def add_and_select(self,data,info=None): + iter = self.model.append() + col = 0 + for object in data: + self.model.set_value(iter,col,object) + col = col + 1 + self.model.set_value(iter,col,info) + self.selection.select_iter(iter) def button_press(self,obj,event): if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: diff --git a/gramps2/src/QuickAdd.py b/gramps2/src/QuickAdd.py index 9a5fa18e5..685b39360 100644 --- a/gramps2/src/QuickAdd.py +++ b/gramps2/src/QuickAdd.py @@ -48,13 +48,12 @@ class QuickAdd: name = person.getPrimaryName() name.setSurname(surname) name.setFirstName(given) - self.db.addPerson(person) + if self.xml.get_widget("male").get_active(): person.setGender(RelLib.Person.male) - self.father = person else: person.setGender(RelLib.Person.female) - self.mother = person + self.db.addPerson(person) Utils.modified() Utils.destroy_passed_object(self.window) self.callback(person) diff --git a/gramps2/src/SelectChild.py b/gramps2/src/SelectChild.py index 057a0634e..03ba2f6c5 100644 --- a/gramps2/src/SelectChild.py +++ b/gramps2/src/SelectChild.py @@ -60,11 +60,12 @@ import ListModel #------------------------------------------------------------------------- class SelectChild: - def __init__(self,db,family,person,redraw): + def __init__(self,db,family,person,redraw,add_person): self.db = db self.person = person self.family = family self.redraw = redraw + self.add_person = add_person self.xml = gtk.glade.XML(const.gladeFile,"selectChild") self.xml.signal_autoconnect({ @@ -108,9 +109,10 @@ class SelectChild: self.frel.set_text(_("Birth")) - self.refmodel = ListModel.ListModel(self.add_child,[(_('Name'),150,3),(_('ID'),50,1), - (_('Birth Date'),100,4), - ('',0,0),('',0,0)]) + titles = [(_('Name'),3,150),(_('ID'),1,50), (_('Birth Date'),4,100), + ('',-1,0),('',-1,0)] + + self.refmodel = ListModel.ListModel(self.add_child,titles) self.redraw_child_list(2) self.top.show() @@ -233,6 +235,7 @@ class SelectChild: depending on the gender of the person.""" id = person.getId() dinfo = self.db.getPersonDisplay(id) + print dinfo rdata = [dinfo[0],dinfo[1],dinfo[3],dinfo[5],dinfo[6]] - self.refmodel.add(rdata) - + self.refmodel.add_and_select(rdata) + self.add_person(person) diff --git a/gramps2/src/edit_person.glade b/gramps2/src/edit_person.glade index 613d4e96a..f06bf7a7c 100644 --- a/gramps2/src/edit_person.glade +++ b/gramps2/src/edit_person.glade @@ -1243,37 +1243,12 @@ True - 2 + 1 3 False 0 0 - - - True - - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 2 - 3 - 1 - 2 - 5 - 5 - - - - True @@ -1300,32 +1275,6 @@ - - - True - - False - False - GTK_JUSTIFY_CENTER - False - False - 1 - 0.5 - 5 - 0 - - - 0 - 1 - 1 - 2 - 5 - 5 - fill - - - - True @@ -1350,30 +1299,6 @@ - - - True - : - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 1 - 2 - fill - - - - True diff --git a/gramps2/src/filters/AltFam.py b/gramps2/src/filters/AltFam.py index 026f1f35c..676dacc1e 100644 --- a/gramps2/src/filters/AltFam.py +++ b/gramps2/src/filters/AltFam.py @@ -22,14 +22,16 @@ import Filter from RelLib import Person -import intl -_ = intl.gettext +from intl import gettext as _ class HaveAltFamilies(Filter.Filter): "People who were adopted" def match(self,person): - return len(person.getParentList()) > 1 + for vals in person.getParentList(): + if vals[1] == "Adopted" or vals[2] == "Adopted": + return 1 + return 0 Filter.register_filter(HaveAltFamilies, diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index 282debb81..5a11f323a 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -1140,7 +1140,6 @@ True False True - @@ -6074,6 +6073,7 @@ GTK_WIN_POS_NONE False 300 + 200 True False True diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index b5dc2bfae..ffd0e5381 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -97,14 +97,8 @@ class Gramps: self.program = gnome.program_init("gramps",const.version) self.DataFilter = Filter.Filter("") - self.active_child = None - self.active_family = None - self.active_father = None - self.active_mother = None - self.active_parents = None self.parents_index = 0 self.active_person = None - self.active_spouse = None self.bookmarks = None self.c_details = 6 self.id2col = {} @@ -290,9 +284,6 @@ class Gramps: "on_alpha_switch_page" : self.change_alpha_page, "delete_event" : self.delete_event, "destroy_passed_object" : Utils.destroy_passed_object, - "on_family_up_clicked" : self.family_up_clicked, - "on_family_down_clicked" : self.family_down_clicked, - "on_spouse_list_changed" : self.spouse_list_changed, "on_about_activate" : self.on_about_activate, "on_add_bookmark_activate" : self.on_add_bookmark_activate, "on_add_place_clicked" : self.place_view.on_add_place_clicked, @@ -324,7 +315,6 @@ class Gramps: "on_open_activate" : self.on_open_activate, "on_pedigree1_activate" : self.on_pedigree1_activate, "on_person_list1_activate" : self.on_person_list1_activate, - "on_person_list_button_press" : self.alpha_event, "on_main_key_release_event" : self.on_main_key_release_event, "on_add_media_clicked" : self.media_view.create_add_dialog, "on_media_activate" : self.on_media_activate, @@ -337,7 +327,6 @@ class Gramps: "on_places_activate" : self.on_places_activate, "on_preferences_activate" : self.on_preferences_activate, "on_reload_plugins_activate" : Plugins.reload_plugins, - "on_remove_child_clicked" : self.on_remove_child_clicked, "on_reports_clicked" : self.on_reports_clicked, "on_revert_activate" : self.on_revert_activate, "on_save_activate" : self.on_save_activate, @@ -345,7 +334,6 @@ class Gramps: "on_show_plugin_status" : self.on_show_plugin_status, "on_source_list_button_press" : self.source_view.button_press, "on_sources_activate" : self.on_sources_activate, - "on_swap_clicked" : self.on_swap_clicked, "on_tools_clicked" : self.on_tools_clicked, "on_gramps_home_page_activate" : self.on_gramps_home_page_activate, "on_gramps_report_bug_activate" : self.on_gramps_report_bug_activate, @@ -575,31 +563,6 @@ class Gramps: if url: url = "gnome-help:"+url gnome.help.goto(url) - - def on_remove_child_clicked(self,obj): - if not self.active_family or not self.active_child or not self.active_person: - return - - self.active_family.removeChild(self.active_child) - self.active_child.removeAltFamily(self.active_child) - - if len(self.active_family.getChildList()) == 0: - if self.active_family.getFather() == None: - self.delete_family_from(self.active_family.getMother()) - elif self.active_family.getMother() == None: - self.delete_family_from(self.active_family.getFather()) - - Utils.modified() - self.family_view.load_family() - - def delete_family_from(self,person): - person.removeFamily(self.active_family) - self.db.deleteFamily(self.active_family) - flist = self.active_person.getFamilyList() - if len(flist) > 0: - self.active_family = flist[0][0] - else: - self.active_family = None def add_new_cancel(self,obj): Utils.destroy_passed_object(self.addornew) @@ -641,11 +604,6 @@ class Gramps: self.topWindow.set_title("GRAMPS") self.active_person = None - self.active_father = None - self.active_family = None - self.active_mother = None - self.active_child = None - self.active_spouse = None self.id2col = {} Utils.clearModified() @@ -939,9 +897,8 @@ class Gramps: self.redisplay_person_list(p1) self.update_display(0) - def alpha_event(self,obj,event): - if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: - self.load_person(self.active_person) + def alpha_event(self,obj): + self.load_person(self.active_person) def goto_active_person(self): if not self.active_person: @@ -964,23 +921,10 @@ class Gramps: self.statusbar.set_status("") else: pname = GrampsCfg.nameof(self.active_person) - if GrampsCfg.status_bar == 1: - name = "[%s] %s" % (self.active_person.getId(),pname) - elif GrampsCfg.status_bar == 2: - name = pname - for attr in self.active_person.getAttributeList(): - if attr.getType() == GrampsCfg.attr_name: - name = "[%s] %s" % (attr.getValue(),pname) - break - else: - name = pname + name = "[%s] %s" % (self.active_person.getId(),pname) self.statusbar.set_status(name) return 0 - def on_child_list_select_row(self,obj,row,b,c): - id = obj.get_row_data(row) - self.active_child = id - def on_child_list_row_move(self,clist,fm,to): """Validate whether or not this child can be moved within the clist. This routine is called in the middle of the clist's callbacks, so @@ -1083,11 +1027,6 @@ class Gramps: file = self.db.getSavePath() self.db.new() self.active_person = None - self.active_father = None - self.active_family = None - self.active_mother = None - self.active_child = None - self.active_spouse = None self.id2col = {} self.read_file(file) Utils.clearModified() @@ -1181,14 +1120,6 @@ class Gramps: self.merge_button.set_sensitive(0) self.media_view.load_media() - def on_swap_clicked(self,obj): - if not self.active_person: - return - - if self.active_spouse: - self.change_active_person(self.active_spouse) - self.family_view.load_family() - def on_apply_filter_clicked(self,obj): invert_filter = self.filter_inv.get_active() qualifer = self.filter_text.get_text() @@ -1244,7 +1175,7 @@ class Gramps: self.redisplay_person_list(person) self.update_display(0) - def redisplay_person_list(self,person): + def add_to_person_list(self,person,change): key = person.getId() val = self.db.getPersonDisplay(person.getId()) pg = val[0] @@ -1257,12 +1188,19 @@ class Gramps: iter = model.model.append() page = self.model2page[model] self.id2col[key] = (model,iter,page) - + model.model.set(iter, 0, val[0], 1, val[1], 2, val[2], 3, val[3], 4, val[4], 5, val[5], 6, val[6], 7, val[7]) - self.change_active_person(person) - self.goto_active_person() + if change: + self.change_active_person(person) + self.goto_active_person() + + def redisplay_person_list(self,person): + self.add_to_person_list(person,1) + + def update_person_list(self,person): + self.add_to_person_list(person,0) def load_person(self,person): if person: @@ -1271,30 +1209,6 @@ class Gramps: except: DisplayTrace.DisplayTrace() - def build_spouse_dropdown(self): - list = [] - mymap = {} - mynmap = {} - sel = None - for f in self.active_person.getFamilyList(): - if self.active_person == f.getFather(): - sname = self.parent_name(f.getMother()) - else: - sname = self.parent_name(f.getFather()) - c = self.list_item(sname,f.getId()) - list.append(c) - if f == self.active_family or sel == None: - sel = c - mynmap[f.getId()] = sname - mymap[f.getId()] = c - self.spouse_combo.disable_activate() - self.spouse_combo.list.clear_items(0,-1) - self.spouse_combo.list.append_items(list) - - for v in mymap.keys(): - self.spouse_combo.set_item_string(mymap[v],mynmap[v]) - self.spouse_combo.list.select_child(sel) - def list_item(self,label,filter): l = gtk.Label(label) l.set_alignment(0,0.5) @@ -1470,48 +1384,6 @@ class Gramps: self.db.setDefaultPerson(self.active_person) Utils.modified() - def family_up_clicked(self,obj): - if self.active_parents == None: - return - flist = self.active_person.getParentList() - if self.parents_index == 0: - self.parents_index = len(flist)-1 - else: - self.parents_index = self.parents_index - 1 - self.active_parents = flist[self.parents_index][0] - self.change_parents(self.active_parents) - - def family_down_clicked(self,obj): - if self.active_parents == None: - return - flist = self.active_person.getParentList() - if self.parents_index == len(flist)-1: - self.parents_index = 0 - else: - self.parents_index = self.parents_index + 1 - self.active_parents = flist[self.parents_index][0] - self.change_parents(self.active_parents) - - def spouse_list_changed(self,obj): - if self.active_family == None: - return - select = self.spouse_combo.list.get_selection() - if len(select) == 0: - self.active_family = None - else: - self.active_family = self.db.getFamily(select[0].get_data('d')) - - if self.active_family == self.active_person.getFamilyList()[0]: - self.pref_spouse.set_sensitive(0) - msg = _("Preferred Relationship") - else: - msg = _("Relationship") - self.pref_spouse.set_sensitive(1) - - self.gtop.get_widget('rel_frame').set_label(msg) - - self.display_marriage(self.active_family) - def export_callback(self,obj,plugin_function): """Call the export plugin, with the active person and database""" if self.active_person: diff --git a/gramps2/src/plugins/EventCmp.py b/gramps2/src/plugins/EventCmp.py index f163e1e6d..2c2a112be 100644 --- a/gramps2/src/plugins/EventCmp.py +++ b/gramps2/src/plugins/EventCmp.py @@ -204,7 +204,7 @@ class DisplayChart: titles = [] index = 0 for v in self.event_titles: - titles.append((v,150,index)) + titles.append((v,index,150)) index = index + 1 self.list = ListModel.ListModel(self.eventlist,titles) diff --git a/gramps2/src/revision.glade b/gramps2/src/revision.glade index 29a131361..7993fbf3b 100644 --- a/gramps2/src/revision.glade +++ b/gramps2/src/revision.glade @@ -326,6 +326,8 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False + 350 + 150 True False True @@ -383,7 +385,7 @@ 0 - 0 + 5 False False