diff --git a/ChangeLog b/ChangeLog index ca8dc1e4e..8dd62e8ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-02-07 Don Allingham + * src/DisplayModels.py: gobject.TYPE_STRING -> str + * src/EditFamily.py: privacy widget + * src/EditPerson.py: privacy widget + * src/EventEdit.py: save support + * src/GrampsWidgets.py: Add PrivacyButton support + * src/PageView.py: make sure active before updating rows + * src/edit_person.glade: privacy icons + * src/gramps.glade: privacy icons + 2006-02-06 Don Allingham * src/SourceView.py: fix source query dialog, fix source deleting * src/ansel_utf8.py: fix unicode conversion diff --git a/src/DisplayModels.py b/src/DisplayModels.py index 1ac605948..300aff26f 100644 --- a/src/DisplayModels.py +++ b/src/DisplayModels.py @@ -126,7 +126,6 @@ class BaseModel(gtk.GenericTreeModel): def delete_row_by_handle(self,handle): index = self.indexlist[handle] - self.indexlist = {} self.datalist = [] i = 0 @@ -157,7 +156,7 @@ class BaseModel(gtk.GenericTreeModel): def on_get_column_type(self,index): if index == self.tooltip_column: return object - return gobject.TYPE_STRING + return str def on_get_iter(self, path): try: diff --git a/src/EditFamily.py b/src/EditFamily.py index e5d03e77c..4d89f4406 100644 --- a/src/EditFamily.py +++ b/src/EditFamily.py @@ -276,15 +276,12 @@ class EditFamily(DisplayState.ManagedWindow): self.ok.connect('clicked', self.apply_changes) def _setup_monitored_values(self): - private= self.top.get_widget('private') - private.set_active(self.family.get_privacy()) - private.connect('toggled', self.privacy_toggled) + self.private= GrampsWidgets.PrivacyButton(self.top.get_widget('private'), + self.family) - gid = self.top.get_widget('gid') - if self.family.get_gramps_id(): - gid.set_text(self.family.get_gramps_id()) - gid.connect('changed', - lambda x: self.family.set_gramps_id(x.get_text())) + self.gid = GrampsWidgets.MonitoredEntry(self.top.get_widget('gid'), + self.family.set_gramps_id, + self.family.get_gramps_id) rel_types = dict(Utils.family_relations) @@ -350,19 +347,6 @@ class EditFamily(DisplayState.ManagedWindow): self.notebook.set_tab_label(self.gallery_tab, self.gallery_tab.get_tab_widget()) - def privacy_toggled(self,obj): - for o in obj.get_children(): - obj.remove(o) - img = gtk.Image() - if obj.get_active(): - img.set_from_file(os.path.join(const.rootDir,"locked.png")) - self.family.set_privacy(True) - else: - img.set_from_file(os.path.join(const.rootDir,"unlocked.png")) - self.family.set_privacy(False) - img.show() - obj.add(img) - def update_father(self,handle): self.load_parent(handle, self.fbox, self.fbirth, self.fdeath, self.fbutton) diff --git a/src/EditPerson.py b/src/EditPerson.py index 7e450c287..a2abc2ecc 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -57,6 +57,7 @@ import NameDisplay import NameEdit import DisplayState import GrampsDisplay +import GrampsWidgets from DisplayTabs import * from WindowUtils import GladeIf @@ -144,8 +145,9 @@ class EditPerson(DisplayState.ManagedWindow): self.gender = self.top.get_widget('gender') self.gender.set_sensitive(mod) - self.private = self.top.get_widget('private') - self.private.set_sensitive(mod) + self.private = GrampsWidgets.PrivacyButton(self.top.get_widget('private'), + self.person) + self.ntype_field = self.top.get_widget("ntype") self.ntype_field.set_sensitive(mod) @@ -222,8 +224,6 @@ class EditPerson(DisplayState.ManagedWindow): self.on_given_focus_out_event) self.gladeif.connect("button177", "clicked", self.on_edit_name_clicked) - self.private.set_active(self.person.get_privacy()) - self.eventbox.connect('button-press-event',self.image_button_press) self._create_tabbed_pages() diff --git a/src/EventEdit.py b/src/EventEdit.py index 3d633ad60..519f9c57b 100644 --- a/src/EventEdit.py +++ b/src/EventEdit.py @@ -26,9 +26,11 @@ # #------------------------------------------------------------------------- from gettext import gettext as _ -import sets -import gc -from cgi import escape + +try: + set() +except: + from sets import Set as set #------------------------------------------------------------------------- # @@ -57,6 +59,7 @@ import DisplayState from QuestionDialog import WarningDialog, ErrorDialog from WindowUtils import GladeIf from DisplayTabs import * +from GrampsWidgets import * #------------------------------------------------------------------------- # @@ -140,13 +143,15 @@ class EventEditor(DisplayState.ManagedWindow): self.place_field = self.top.get_widget("eventPlace") self.place_field.set_editable(not noedit) self.cause_field = self.top.get_widget("eventCause") - self.cause_field.set_editable(not noedit) + self.cause_monitor = MonitoredEntry(self.cause_field,self.event.set_cause, + self.event.get_cause, noedit) self.date_field = self.top.get_widget("eventDate") self.date_field.set_editable(not noedit) - self.descr_field = self.top.get_widget("event_description") - self.descr_field.set_editable(not noedit) + self.descr_field = MonitoredEntry(self.top.get_widget("event_description"), + self.event.set_description, + self.event.get_description, noedit) self.event_menu = self.top.get_widget("personal_events") - self.priv = self.top.get_widget("priv") + self.priv = PrivacyButton(self.top.get_widget("private"),self.event) self.priv.set_sensitive(not noedit) self.ok = self.top.get_widget('ok') @@ -176,9 +181,6 @@ class EventEditor(DisplayState.ManagedWindow): self.place_field.set_text(place_name) self.date_field.set_text(_dd.display(self.date)) - self.cause_field.set_text(event.get_cause()) - self.descr_field.set_text(event.get_description()) - self.priv.set_active(event.get_privacy()) else: event = RelLib.Event() @@ -257,96 +259,40 @@ class EventEditor(DisplayState.ManagedWindow): def on_event_edit_ok_clicked(self,obj): event_data = self.type_selector.get_values() - ecause = unicode(self.cause_field.get_text()) eplace_obj = get_place(self.place_field,self.pmap,self.db) - buf = self.note_field.get_buffer() - start = buf.get_start_iter() - stop = buf.get_end_iter() - enote = unicode(buf.get_text(start,stop,False)) - eformat = self.preform.get_active() - edesc = unicode(self.descr_field.get_text()) - epriv = self.priv.get_active() + self.update_event(event_data,self.date,eplace_obj) -# if ename not in self.elist: -# WarningDialog( -# _('New event type created'), -# _('The "%s" event type has been added to this database.\n' -# 'It will now appear in the event menus for this database') % ename) -# self.elist.append(ename) -# self.elist.sort() - - just_added = self.event.handle == None - - self.update_event(event_data,self.date,eplace_obj,edesc,enote,eformat, - epriv,ecause) - - if just_added: + if self.event.handle == None: trans = self.db.transaction_begin() self.db.add_event(self.event,trans) self.db.transaction_commit(trans,_("Add Event")) - elif self.parent.lists_changed: - trans = self.db.transaction_begin() - self.db.commit_event(self.event,trans) - self.db.transaction_commit(trans,_("Edit Event")) + else: + orig = self.dbstate.db.get_event_from_handle(self.event.handle) + if cmp(self.event.serialize(),orig.serialize()): + trans = self.db.transaction_begin() + self.db.commit_event(self.event,trans) + self.db.transaction_commit(trans,_("Edit Event")) + if self.callback: self.callback(self.event) - self.close(obj) - def update_event(self,the_type,date,place,desc,note,format,priv,cause): + def update_event(self,the_type,date,place): # FIXME: commented because we no longer have parent - #self.parent.lists_changed = 0 if place: if self.event.get_place_handle() != place.get_handle(): self.event.set_place_handle(place.get_handle()) - #self.parent.lists_changed = 1 else: if self.event.get_place_handle(): self.event.set_place_handle("") - #self.parent.lists_changed = 1 if self.event.get_type() != the_type: self.event.set_type(the_type) - #self.parent.lists_changed = 1 - if self.event.get_description() != desc: - self.event.set_description(desc) - #self.parent.lists_changed = 1 - - if self.event.get_note() != note: - self.event.set_note(note) - #self.parent.lists_changed = 1 - - if self.event.get_note_format() != format: - self.event.set_note_format(format) - #self.parent.lists_changed = 1 - dobj = self.event.get_date_object() - - self.event.set_source_reference_list(self.srcreflist) - if not dobj.is_equal(date): self.event.set_date_object(date) - #self.parent.lists_changed = 1 - - if self.event.get_cause() != cause: - self.event.set_cause(cause) - #self.parent.lists_changed = 1 - - if self.event.get_privacy() != priv: - self.event.set_privacy(priv) - #self.parent.lists_changed = 1 - - def on_switch_page(self,obj,a,page): - buf = self.note_field.get_buffer() - start = buf.get_start_iter() - stop = buf.get_end_iter() - text = unicode(buf.get_text(start,stop,False)) - if text: - Utils.bold_label(self.notes_label) - else: - Utils.unbold_label(self.notes_label) def commit(self,event,trans): self.db.commit_event(event,trans) @@ -388,15 +334,24 @@ class EventRefEditor(DisplayState.ManagedWindow): self.window = self.top.get_widget('event_eref_edit') self.ref_note_field = self.top.get_widget('eer_ref_note') self.role_combo = self.top.get_widget('eer_role_combo') - self.ref_privacy = self.top.get_widget('eer_ref_priv') + self.ref_privacy = PrivacyButton(self.top.get_widget('eer_ref_priv'), + self.event_ref) self.place_field = self.top.get_widget("eer_place") self.cause_field = self.top.get_widget("eer_cause") + self.cause_monitor = MonitoredEntry(self.cause_field,self.event.set_cause, + self.event.get_cause, False) + self.date_field = self.top.get_widget("eer_date") - self.descr_field = self.top.get_widget("eer_description") + self.descr_field = MonitoredEntry(self.top.get_widget("eer_description"), + self.event.set_description, + self.event.get_description, False) + self.ev_note_field = self.top.get_widget("eer_ev_note") self.type_combo = self.top.get_widget("eer_type_combo") - self.ev_privacy = self.top.get_widget("eer_ev_priv") + self.ev_privacy = PrivacyButton(self.top.get_widget("eer_ev_priv"), + self.event) + self.general_label = self.top.get_widget("eer_general_tab") self.ok = self.top.get_widget('ok') self.expander = self.top.get_widget("eer_expander") @@ -468,7 +423,6 @@ class EventRefEditor(DisplayState.ManagedWindow): # set event_ref values self.role_selector.set_values(self.event_ref.get_role()) self.ref_note_field.get_buffer().set_text(self.event_ref.get_note()) - self.ref_privacy.set_active(self.event_ref.get_privacy()) # set event values self.type_selector.set_values(self.event.get_type()) @@ -479,9 +433,6 @@ class EventRefEditor(DisplayState.ManagedWindow): place_name = self.db.get_place_from_handle(place_handle).get_title() self.place_field.set_text(place_name) self.date_field.set_text(_dd.display(self.date)) - self.cause_field.set_text(self.event.get_cause()) - self.descr_field.set_text(self.event.get_description()) - self.ev_privacy.set_active(self.event.get_privacy()) self._create_tabbed_pages() @@ -536,18 +487,8 @@ class EventRefEditor(DisplayState.ManagedWindow): # first, save event if changed etype = self.type_selector.get_values() - ecause = unicode(self.cause_field.get_text()) eplace_obj = get_place(self.place_field,self.pmap,self.db) - buf = self.ev_note_field.get_buffer() - start = buf.get_start_iter() - stop = buf.get_end_iter() - enote = unicode(buf.get_text(start,stop,False)) - eformat = self.preform.get_active() - edesc = unicode(self.descr_field.get_text()) - epriv = self.ev_privacy.get_active() - self.lists_changed = 0 - self.update_event(etype,self.date,eplace_obj,edesc,enote,eformat, - epriv,ecause) + self.update_event(etype,self.date,eplace_obj) trans = self.db.transaction_begin() self.db.commit_event(self.event,trans) @@ -559,67 +500,26 @@ class EventRefEditor(DisplayState.ManagedWindow): # then, set properties of the event_ref self.event_ref.set_role(self.role_selector.get_values()) self.event_ref.set_privacy(self.ref_privacy.get_active()) - buf = self.ref_note_field.get_buffer() - start = buf.get_start_iter() - stop = buf.get_end_iter() - note = unicode(buf.get_text(start,stop,False)) - self.event_ref.set_note(note) self.close(None) if self.update: self.update((self.event_ref,self.event)) - def update_event(self,the_type,date,place,desc,note,format,priv,cause): + def update_event(self,the_type,date,place): if place: if self.event.get_place_handle() != place.get_handle(): self.event.set_place_handle(place.get_handle()) - self.lists_changed = 1 else: if self.event.get_place_handle(): self.event.set_place_handle("") - self.lists_changed = 1 if self.event.get_type() != the_type: self.event.set_type(the_type) - self.lists_changed = 1 - if self.event.get_description() != desc: - self.event.set_description(desc) - self.lists_changed = 1 - - if self.event.get_note() != note: - self.event.set_note(note) - self.lists_changed = 1 - - if self.event.get_note_format() != format: - self.event.set_note_format(format) - self.lists_changed = 1 - dobj = self.event.get_date_object() - self.event.set_source_reference_list(self.srcreflist) - if not dobj.is_equal(date): self.event.set_date_object(date) - self.lists_changed = 1 - - if self.event.get_cause() != cause: - self.event.set_cause(cause) - self.lists_changed = 1 - - if self.event.get_privacy() != priv: - self.event.set_privacy(priv) - self.lists_changed = 1 - - def on_switch_page(self,obj,a,page): - buf = self.ev_note_field.get_buffer() - start = buf.get_start_iter() - stop = buf.get_end_iter() - text = unicode(buf.get_text(start,stop,False)) - if text: - Utils.bold_label(self.eer_notes_label) - else: - Utils.unbold_label(self.eer_notes_label) #------------------------------------------------------------------------- # diff --git a/src/GrampsWidgets.py b/src/GrampsWidgets.py index f6f725b78..ab5353890 100644 --- a/src/GrampsWidgets.py +++ b/src/GrampsWidgets.py @@ -185,3 +185,48 @@ class TypeCellRenderer(gtk.CellRendererCombo): self.set_property('model',model) self.set_property('text-column',0) +class PrivacyButton: + + def __init__(self,button,obj): + self.button = button + self.button.connect('toggled',self._on_toggle) + self.tooltips = gtk.Tooltips() + self.obj = obj + self.set_active(obj.get_privacy()) + + def set_sensitive(self,val): + self.button.set_sensitive(val) + + def set_active(self,val): + self.button.set_active(val) + self._on_toggle(self.button) + + def get_active(self): + return self.button.get_active() + + def _on_toggle(self,obj): + child = obj.child + if child: + obj.remove(child) + image = gtk.Image() + if obj.get_active(): + image.set_from_icon_name('stock_lock',gtk.ICON_SIZE_BUTTON) + self.tooltips.set_tip(obj,_('Record is private')) + self.obj.set_privacy(True) + else: + image.set_from_icon_name('stock_lock-open',gtk.ICON_SIZE_BUTTON) + self.tooltips.set_tip(obj,_('Record is public')) + self.obj.set_privacy(False) + image.show() + obj.add(image) + +class MonitoredEntry: + + def __init__(self,obj,set_val,get_val,read_only=False): + self.obj = obj + self.set_val = set_val + self.get_val = get_val + + self.obj.set_text(get_val()) + self.obj.connect('changed', lambda x: self.set_val(unicode(x.get_text()))) + self.obj.set_editable(not read_only) diff --git a/src/PageView.py b/src/PageView.py index d5226bb49..fea91e18e 100644 --- a/src/PageView.py +++ b/src/PageView.py @@ -448,16 +448,19 @@ class ListView(PageView): self.dirty = True def row_add(self,handle_list): - for handle in handle_list: - self.model.add_row_by_handle(handle) + if self.active: + for handle in handle_list: + self.model.add_row_by_handle(handle) def row_update(self,handle_list): - for handle in handle_list: - self.model.update_row_by_handle(handle) + if self.active: + for handle in handle_list: + self.model.update_row_by_handle(handle) def row_delete(self,handle_list): - for handle in handle_list: - self.model.delete_row_by_handle(handle) + if self.active: + for handle in handle_list: + self.model.delete_row_by_handle(handle) def define_actions(self): """ diff --git a/src/edit_person.glade b/src/edit_person.glade index c8933ca5b..3124b099c 100644 --- a/src/edit_person.glade +++ b/src/edit_person.glade @@ -714,7 +714,7 @@ Unknown True 4 - gtk-dialog-authentication + stock_lock-open 0.5 0.5 0 diff --git a/src/gramps.glade b/src/gramps.glade index fd4f07632..fca028c77 100644 --- a/src/gramps.glade +++ b/src/gramps.glade @@ -1334,7 +1334,8 @@ True - unlocked.png + 4 + stock_lock-open 0.5 0.5 0 @@ -10672,20 +10673,29 @@ Very High - + True True - _Private record - True - GTK_RELIEF_NORMAL + GTK_RELIEF_NONE True False False - True + + + + True + 4 + stock_lock-open + 0.5 + 0.5 + 0 + 0 + + - 4 - 5 + 5 + 6 3 4 fill @@ -16779,7 +16789,7 @@ Given name, Family name 12 True 6 - 3 + 4 False 6 12 @@ -16840,6 +16850,78 @@ Given name, Family name + + + True + False + True + True + + + 2 + 3 + 2 + 3 + fill + + + + + + True + + True + True + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 3 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 4 + 0 + 1 + fill + + + + + + + True + <b>Reference information</b> + True + True + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 3 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 4 + 1 + 2 + fill + + + + True @@ -16879,94 +16961,31 @@ Given name, Family name - - True - False - True - True - - - 2 - 3 - 2 - 3 - fill - - - - - - True - <b>Reference information</b> - True - True - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 3 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 3 - 1 - 2 - fill - - - - - - - True - - True - True - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 3 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 3 - 0 - 1 - fill - - - - - - + True True - _Private record - True - GTK_RELIEF_NORMAL + GTK_RELIEF_NONE True False False - True + + + + True + 4 + stock_lock-open + 0.5 + 0.5 + 0 + 0 + + - 2 - 3 - 4 - 5 + 3 + 4 + 2 + 4 fill @@ -16995,7 +17014,7 @@ Given name, Family name 12 True - 7 + 6 3 False 6 @@ -17166,108 +17185,6 @@ Given name, Family name - - - True - True - True - True - 0 - - True - * - False - - - 1 - 3 - 4 - 5 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 3 - 3 - 4 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 3 - 2 - 3 - - - - - - - True - True - _Private record - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 1 - 3 - 5 - 6 - fill - - - - - - - True - False - True - True - - - 1 - 3 - 0 - 1 - fill - fill - - - True @@ -17298,7 +17215,6 @@ Given name, Family name 6 - True False 12 @@ -17347,16 +17263,127 @@ Given name, Family name 0 3 - 6 - 7 + 5 + 6 expand|shrink|fill expand|shrink|fill + + + + True + False + True + True + + + 1 + 2 + 0 + 1 + fill + fill + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 2 + 3 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 3 + 4 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 4 + 5 + + + + + + + True + True + GTK_RELIEF_NONE + True + False + False + + + + True + 4 + stock_lock-open + 0.5 + 0.5 + 0 + 0 + + + + + 2 + 3 + 2 + 5 + fill + + + False - True + False @@ -17439,11 +17466,10 @@ Given name, Family name 0 - 3 + 4 5 6 - expand|shrink|fill - expand|shrink|fill + shrink