From 2c4f2b8225ad5b35f2411a431e8bb1be386125b6 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 30 Jan 2006 05:01:21 +0000 Subject: [PATCH] * src/DdTargets.py: Add support for EventRef * src/DisplayTabs.py: Drag and drop support in base class * src/EditPerson.py: remove unused functions * src/edit_person.glade: privacy flag change * src/gramps.glade: add tooltip svn: r5857 --- gramps2/ChangeLog | 7 ++ gramps2/src/DdTargets.py | 1 + gramps2/src/DisplayTabs.py | 149 +++++++++++++++++++++------- gramps2/src/EditPerson.py | 180 ++-------------------------------- gramps2/src/edit_person.glade | 53 +++++----- gramps2/src/gramps.glade | 1 + 6 files changed, 162 insertions(+), 229 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 3f7db0d87..b405122a3 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,10 @@ +2006-01-29 Don Allingham + * src/DdTargets.py: Add support for EventRef + * src/DisplayTabs.py: Drag and drop support in base class + * src/EditPerson.py: remove unused functions + * src/edit_person.glade: privacy flag change + * src/gramps.glade: add tooltip + 2006-01-29 Alex Roitman * src/GrampsDb/_WriteXML.py (write_place_obj): Always write ptitle. * src/GrampsDb/_ReadXML.py: Prase file and ptitle tags. diff --git a/gramps2/src/DdTargets.py b/gramps2/src/DdTargets.py index 57889c524..80855c8b7 100644 --- a/gramps2/src/DdTargets.py +++ b/gramps2/src/DdTargets.py @@ -99,6 +99,7 @@ class _DdTargets(object): self.URL = _DdType(self,'url') self.EVENT = _DdType(self,'pevent') + self.EVENTREF = _DdType(self,'peventref') self.ATTRIBUTE = _DdType(self,'pattr') self.ADDRESS = _DdType(self,'paddr') self.SOURCEREF = _DdType(self,'srcref') diff --git a/gramps2/src/DisplayTabs.py b/gramps2/src/DisplayTabs.py index 79314cc46..6fe2b67a6 100644 --- a/gramps2/src/DisplayTabs.py +++ b/gramps2/src/DisplayTabs.py @@ -25,6 +25,8 @@ #------------------------------------------------------------------------- import gtk import gobject +import pango +from gtk.gdk import ACTION_COPY, BUTTON1_MASK #------------------------------------------------------------------------- # @@ -33,6 +35,7 @@ import gobject #------------------------------------------------------------------------- from gettext import gettext as _ +import pickle #------------------------------------------------------------------------- # @@ -46,6 +49,7 @@ import Utils import GrampsMime import const +from DdTargets import DdTargets from GrampsWidgets import SimpleButton #------------------------------------------------------------------------- @@ -123,7 +127,7 @@ class GrampsTab(gtk.HBox): gtk.ICON_SIZE_MENU) self.label = gtk.Label(self.tab_name) hbox.pack_start(self.tab_image) - hbox.set_spacing(3) + hbox.set_spacing(6) hbox.add(self.label) hbox.show_all() return hbox @@ -255,6 +259,7 @@ class EmbeddedList(ButtonTab): """ _HANDLE_COL = -1 + _DND_TYPE = "" def __init__(self, dbstate, uistate, track, name, build_model): """ @@ -272,10 +277,58 @@ class EmbeddedList(ButtonTab): self.columns = [] self.build_columns() + self.set_dnd() + # build the initial data self.rebuild() self.show_all() + def set_dnd(self): + self.tree.drag_dest_set(gtk.DEST_DEFAULT_ALL, + [DdTargets.NAME.target()], + ACTION_COPY) + self.tree.drag_source_set(BUTTON1_MASK, + [DdTargets.NAME.target()], + ACTION_COPY) + self.tree.connect('drag_data_get', self.drag_data_get) + self.tree.connect('drag_data_received', self.drag_data_received) + + def drag_data_get(self,widget, context, sel_data, info, time): + obj = self.get_selected() + if not obj: + return + + bits_per = 8; # we're going to pass a string + pickled = pickle.dumps(obj); + data = str((self._DND_TYPE, id(self), pickled)) + sel_data.set(sel_data.target, bits_per, data) + + def drag_data_received(self,widget,context,x,y,sel_data,info,time): + row = self.tree.get_path_at_pos(x,y) + if row == None: + row = len(self.get_data()) + else: + row = row[0][0] + if sel_data and sel_data.data: + exec 'dnddata = %s' % sel_data.data + mytype = dnddata[0] + selfid = dnddata[1] + obj = pickle.loads(dnddata[2]) + if mytype == self._DND_TYPE: + if id(self) == selfid: + self.move(row,obj) + else: + self.handle_drag(row,obj) + self.rebuild() + + def handle_drag(self, row, obj): + print "drag row=",row + print "drag obj=", obj + + def move(self, row, obj): + print "move row=",row + print "move obj=", obj + def get_icon_name(self): """ Specifies the basic icon used for a generic list. Typically, @@ -295,6 +348,7 @@ class EmbeddedList(ButtonTab): # button press to the double click function. self.tree = gtk.TreeView() + self.tree.set_reorderable(True) self.tree.set_rules_hint(True) self.tree.connect('button_press_event',self.double_click) @@ -383,12 +437,13 @@ class EmbeddedList(ButtonTab): # assign it to the column name. The text value is extracted # from the model column specified in pair[1] name = self._column_names[pair[1]][0] - column = gtk.TreeViewColumn(name, gtk.CellRendererText(), - text=pair[1]) + renderer = gtk.CellRendererText() + renderer.set_property('ellipsize',pango.ELLIPSIZE_END) + column = gtk.TreeViewColumn(name, renderer, text=pair[1]) # insert the colum into the tree column.set_resizable(True) - column.set_min_width(75) + column.set_min_width(self._column_names[pair[1]][2]) column.set_sort_column_id(self._column_names[pair[1]][1]) self.columns.append(column) self.tree.append_column(column) @@ -411,14 +466,15 @@ class EmbeddedList(ButtonTab): class EventEmbedList(EmbeddedList): _HANDLE_COL = 6 + _DND_TYPE = DdTargets.EVENTREF.drag_type _column_names = [ - (_('Type'),0), - (_('Description'),1), - (_('ID'),2), - (_('Date'),3), - (_('Place'),4), - (_('Cause'),5), + (_('Type'),0,100), + (_('Description'),1,200), + (_('ID'),2, 60), + (_('Date'),3, 150), + (_('Place'),4, 140), + (_('Role'),5, 80), ] def __init__(self,dbstate,uistate,track,obj): @@ -463,8 +519,20 @@ class EventEmbedList(EmbeddedList): self.rebuild() def event_added(self,value): + value[0].ref = value[1].handle + self.obj.add_event_ref(value[0]) self.changed = True self.rebuild() + +class PersonEventEmbedList(EventEmbedList): + + def __init__(self,dbstate,uistate,track,obj): + EventEmbedList.__init__(self, dbstate, uistate, track, obj) + + def get_data(self): + return [ obj for obj in [ self.obj.get_birth_ref(), \ + self.obj.get_death_ref()] + self.obj.get_event_ref_list() \ + if obj ] #------------------------------------------------------------------------- # @@ -476,9 +544,9 @@ class SourceBackRefList(EmbeddedList): _HANDLE_COL = 3 _column_names = [ - (_('Type'),0), - (_('ID'),1), - (_('Name'),2), + (_('Type'),0, 100), + (_('ID'), 1, 75), + (_('Name'),2, 250), ] def __init__(self,dbstate,uistate,track,obj): @@ -541,8 +609,8 @@ class SourceBackRefList(EmbeddedList): class DataEmbedList(EmbeddedList): _column_names = [ - (_('Key'),0), - (_('Value'),1), + (_('Key'),0,150), + (_('Value'),1,250), ] def __init__(self,dbstate,uistate,track,obj): @@ -580,10 +648,11 @@ class DataEmbedList(EmbeddedList): class AttrEmbedList(EmbeddedList): _HANDLE_COL = 2 + _DND_TYPE = DdTargets.ATTRIBUTE.drag_type _column_names = [ - (_('Type'),0), - (_('Value'),1), + (_('Type'),0,250), + (_('Value'),1,200), ] def __init__(self,dbstate,uistate,track,data): @@ -605,11 +674,12 @@ class AttrEmbedList(EmbeddedList): class WebEmbedList(EmbeddedList): _HANDLE_COL = -1 + _DND_TYPE = DdTargets.URL.drag_type _column_names = [ - (_('Type'),0), - (_('Path'),1), - (_('Description'),2), + (_('Type') ,0, 100), + (_('Path') ,1, 200), + (_('Description'),2, 150), ] def __init__(self,dbstate,uistate,track,data): @@ -631,10 +701,11 @@ class WebEmbedList(EmbeddedList): class NameEmbedList(EmbeddedList): _HANDLE_COL = -1 + _DND_TYPE = DdTargets.NAME.drag_type _column_names = [ - (_('Name'),0), - (_('Type'),1), + (_('Name'),0, 250), + (_('Type'),1, 100), ] def __init__(self,dbstate,uistate,track,data): @@ -656,13 +727,14 @@ class NameEmbedList(EmbeddedList): class AddrEmbedList(EmbeddedList): _HANDLE_COL = -1 + _DND_TYPE = DdTargets.ADDRESS.drag_type _column_names = [ - (_('Date'),0), - (_('Street'),1), - (_('State'),2), - (_('City'),3), - (_('Country'),4), + (_('Date'), 0, 150), + (_('Street'), 1, 225), + (_('State'), 2, 100), + (_('City'), 3, 100), + (_('Country'), 4, 75), ] def __init__(self,dbstate,uistate,track,data): @@ -820,12 +892,13 @@ class GalleryTab(ButtonTab): class SourceEmbedList(EmbeddedList): _HANDLE_COL = 4 - + _DND_TYPE = DdTargets.SOURCEREF.drag_type + _column_names = [ - (_('ID'),0), - (_('Title'),1), - (_('Author'),2), - (_('Page'),3), + (_('ID'), 0, 75), + (_('Title'), 1, 200), + (_('Author'), 2, 125), + (_('Page'), 3, 100), ] def __init__(self,dbstate,uistate,track,obj): @@ -865,7 +938,8 @@ class SourceEmbedList(EmbeddedList): class ChildModel(gtk.ListStore): _HANDLE_COL = -8 - + _DND_TYPE = DdTargets.PERSON_LINK.drag_type + def __init__(self, family, db): self.family = family gtk.ListStore.__init__(self,int,str,str,str,str,str, @@ -991,7 +1065,7 @@ class EventRefModel(gtk.ListStore): event.get_gramps_id(), self.column_date(event_ref), self.column_place(event_ref), - event.get_cause(), + self.column_role(event_ref), event_ref ]) @@ -1005,6 +1079,13 @@ class EventRefModel(gtk.ListStore): else: return Utils.family_events[t] + def column_role(self,event_ref): + t,v = event_ref.get_role() + if t == RelLib.EventRef.CUSTOM: + return v + else: + return Utils.event_roles[t] + def column_date(self,event_ref): event = self.db.get_event_from_handle(event_ref.ref) return DateHandler.get_date(event) diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index e4e48f81a..9ad931cc2 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -77,8 +77,6 @@ from DdTargets import DdTargets # #------------------------------------------------------------------------- -_PICTURE_WIDTH = 200.0 - _temple_names = const.lds_temple_codes.keys() _temple_names.sort() _temple_names = [""] + _temple_names @@ -175,8 +173,6 @@ class EditPerson(DisplayState.ManagedWindow): self.prefix.set_editable(mod) self.given = self.top.get_widget("given_name") self.given.set_editable(mod) -# self.nick = self.top.get_widget("nickname") -# self.nick.set_editable(mod) self.title = self.top.get_widget("title") self.title.set_editable(mod) self.surname = self.top.get_widget("surname") @@ -249,8 +245,8 @@ class EditPerson(DisplayState.ManagedWindow): self.gladeif.connect("button15", "clicked", self.on_cancel_edit) self.gladeif.connect("ok", "clicked", self.on_apply_person_clicked) self.gladeif.connect("button134", "clicked", self.on_help_clicked) -# self.gladeif.connect("notebook", "switch_page", self.on_switch_page) - self.gladeif.connect("given_name", "focus_out_event", self.on_given_focus_out_event) + self.gladeif.connect("given_name", "focus_out_event", + self.on_given_focus_out_event) self.gladeif.connect("button177", "clicked", self.on_edit_name_clicked) self.private.set_active(self.person.get_privacy()) @@ -261,10 +257,10 @@ class EditPerson(DisplayState.ManagedWindow): self.vbox.pack_start(self.notebook,True) self.notebook.show_all() - self.event_list = EventEmbedList(self.dbstate,self.uistate, - self.track,self.person) - self.name_list = NameEmbedList(self.dbstate,self.uistate, - self.track,self.person.get_alternate_names()) + self.event_list = PersonEventEmbedList(self.dbstate,self.uistate, + self.track,self.person) + self.name_list = NameEmbedList(self.dbstate, self.uistate, self.track, + self.person.get_alternate_names()) self.srcref_list = SourceEmbedList(self.dbstate,self.uistate, self.track,self.person.source_list) self.attr_list = AttrEmbedList(self.dbstate,self.uistate,self.track, @@ -410,125 +406,6 @@ class EditPerson(DisplayState.ManagedWindow): """Display the relevant portion of GRAMPS manual""" GrampsDisplay.help('adv-pers') - def lds_field(self,lds_ord,combo,date,place): - build_combo(combo,_temple_names) - temple_code = const.lds_temple_to_abrev.get(lds_ord.get_temple(),"") - index = _temple_names.index(temple_code) - combo.set_active(index) - if not lds_ord.is_empty(): - stat = lds_ord.get_status() - else: - stat = 0 - date.set_text(DateHandler.get_date(lds_ord)) - - build_dropdown(place,self.place_list) - if lds_ord and lds_ord.get_place_handle(): - handle = lds_ord.get_place_handle() - lds_ord_place = self.db.get_place_from_handle(handle) - place.set_text(lds_ord_place.get_title()) - return stat - - def draw_lds(self): - """Draws the LDS window. This window is not always drawn, and in - may cases is hidden.""" - - self.ldsbap_date = self.top.get_widget("ldsbapdate") - self.ldsbap_date.set_editable(not self.db.readonly) - self.ldsbap_temple = self.top.get_widget("ldsbaptemple") - self.ldsbap_temple.set_sensitive(not self.db.readonly) - self.ldsbapplace = self.top.get_widget("lds_bap_place") - self.ldsbapplace.set_editable(not self.db.readonly) - self.ldsbap_date_led = self.top.get_widget("ldsbap_stat") - self.ldsbap_date_led.set_sensitive(not self.db.readonly) - self.ldsbap_date_check = DateEdit.DateEdit( - self.lds_baptism.get_date_object(), self.ldsbap_date, - self.ldsbap_date_led, self.window) - - self.ldsend_date = self.top.get_widget("endowdate") - self.ldsend_date.set_editable(not self.db.readonly) - self.ldsend_temple = self.top.get_widget("endowtemple") - self.ldsend_temple.set_sensitive(not self.db.readonly) - self.ldsendowplace = self.top.get_widget("lds_end_place") - self.ldsendowplace.set_editable(not self.db.readonly) - self.ldsendowstat = self.top.get_widget("endowstat") - self.ldsendowstat.set_sensitive(not self.db.readonly) - self.ldsend_date_led = self.top.get_widget("endow_stat") - self.ldsend_date_led.set_sensitive(not self.db.readonly) - self.ldsend_date_check = DateEdit.DateEdit( - self.lds_endowment.get_date_object(), self.ldsend_date, - self.ldsend_date_led, self.window) - - self.ldsseal_date = self.top.get_widget("sealdate") - self.ldsseal_temple = self.top.get_widget("sealtemple") - self.ldssealplace = self.top.get_widget("lds_seal_place") - self.ldsseal_date.set_editable(not self.db.readonly) - self.ldsseal_temple.set_sensitive(not self.db.readonly) - self.ldssealplace.set_editable(not self.db.readonly) - self.ldsseal_date_led = self.top.get_widget("seal_stat") - self.ldsseal_date_led.set_sensitive(not self.db.readonly) - self.ldsseal_date_check = DateEdit.DateEdit( - self.lds_sealing.get_date_object(), self.ldsseal_date, - self.ldsseal_date_led, self.window) - - self.ldsseal_fam = self.top.get_widget("sealparents") - self.ldsseal_fam.set_sensitive(not self.db.readonly) - - self.ldsbapstat = self.top.get_widget("ldsbapstat") - self.ldsbapstat.set_sensitive(not self.db.readonly) - - self.ldssealstat = self.top.get_widget("sealstat") - self.ldssealstat.set_sensitive(not self.db.readonly) - - self.bstat = self.lds_field( - self.lds_baptism, self.ldsbap_temple, - self.ldsbap_date, self.ldsbapplace) - - self.estat = self.lds_field( - self.lds_endowment, self.ldsend_temple, - self.ldsend_date, self.ldsendowplace) - - self.seal_stat = self.lds_field( - self.lds_sealing, self.ldsseal_temple, - self.ldsseal_date, self.ldssealplace) - - if self.lds_sealing: - self.ldsfam = self.lds_sealing.get_family_handle() - else: - self.ldsfam = None - - cell = gtk.CellRendererText() - self.ldsseal_fam.pack_start(cell,True) - self.ldsseal_fam.add_attribute(cell,'text',0) - - store = gtk.ListStore(str) - store.append(row=[_("None")]) - - index = 0 - hist = 0 - self.lds_fam_list = [None] - flist = [self.person.get_main_parents_family_handle()] - for (fam,mrel,frel) in self.person.get_parent_family_handle_list(): - if fam not in flist: - flist.append(fam) - - for fam_id in flist: - index += 1 - family = self.db.get_family_from_handle(fam_id) - if family == None: - continue - name = Utils.family_name(family,self.db) - store.append(row=[name]) - self.lds_fam_list.append(fam_id) - if fam_id == self.ldsfam: - hist = index - self.ldsseal_fam.set_model(store) - self.ldsseal_fam.set_active(hist) - self.ldsseal_fam.connect("changed",self.menu_changed) - - self.build_bap_menu() - self.build_seal_menu() - self.build_endow_menu() - def on_gender_activate (self, button): self.should_guess_gender = False @@ -551,37 +428,6 @@ class EditPerson(DisplayState.ManagedWindow): opt_menu.connect('changed',task) opt_menu.set_active(type) - def build_bap_menu(self): - self.build_menu(const.lds_baptism,self.set_lds_bap,self.ldsbapstat, - self.bstat) - - def build_endow_menu(self): - self.build_menu(const.lds_baptism,self.set_lds_endow,self.ldsendowstat, - self.estat) - - def build_seal_menu(self): - self.build_menu(const.lds_csealing,self.set_lds_seal,self.ldssealstat, - self.seal_stat) - - def set_lds_bap(self,obj): - self.lds_baptism.set_status(obj.get_active()) - - def set_lds_endow(self,obj): - self.lds_endowment.set_status(obj.get_active()) - - def set_lds_seal(self,obj): - self.lds_sealing.set_status(obj.get_active()) - - def menu_changed(self,obj): - self.ldsfam = self.lds_fam_list[obj.get_active()] - - def strip_id(self,text): - index = text.rfind('[') - if (index > 0): - text = text[:index] - text = text.rstrip() - return text - def on_cancel_edit(self,obj): """If the data has changed, give the user a chance to cancel the close window""" @@ -728,19 +574,6 @@ class EditPerson(DisplayState.ManagedWindow): self.lds_sealing.set_family_handle(self.ldsfam) self.lds_sealing.set_place_handle(self.get_place(self.ldssealplace,1)) - def aka_double_click(self,obj,event): - if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: - self.on_aka_update_clicked(obj) - elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: - menu = gtk.Menu() - item = gtk.TearoffMenuItem() - item.show() - menu.append(item) - if not self.db.readonly: - msg = _("Make the selected name the preferred name") - Utils.add_menuitem(menu,msg,None,self.change_name) - menu.popup(None,None,None,event.button,event.time) - def load_photo(self,photo): """loads, scales, and displays the person's main photo""" self.load_obj = photo @@ -760,6 +593,7 @@ class EditPerson(DisplayState.ManagedWindow): self.person_photo.hide() def on_apply_person_clicked(self,obj): + return if self.gender.get_active() == RelLib.Person.UNKNOWN: dialog = QuestionDialog2( diff --git a/gramps2/src/edit_person.glade b/gramps2/src/edit_person.glade index 647b89c2e..3e2286a63 100644 --- a/gramps2/src/edit_person.glade +++ b/gramps2/src/edit_person.glade @@ -655,28 +655,6 @@ Unknown - - - True - True - Pri_vate - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 7 - 8 - 5 - 6 - fill - - - - True @@ -721,6 +699,37 @@ Unknown fill + + + + True + Indicates if the record is private + True + GTK_RELIEF_NONE + True + False + False + + + + True + unlocked.png + 0.5 + 0.5 + 0 + 0 + + + + + 7 + 8 + 5 + 6 + + + + 10 diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index 563d5a364..619a5e314 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -1490,6 +1490,7 @@ True + Indicates if the record is private True GTK_RELIEF_NONE True