From e21dac81bfa9f7ccbd4f8cd36283f2296e66fc1b Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 9 Mar 2005 22:59:24 +0000 Subject: [PATCH] * src/EditPerson.py: add srcref as a drag and drop item * src/EditPlace.py: add srcref as a drag and drop item * src/Marriage.py: add srcref as a drag and drop item * src/WriteGedcom.py: catch empty event * src/Sources.py: add drag-n-drop for source references svn: r4147 --- gramps2/ChangeLog | 28 +++++++++++--------- gramps2/src/EditPerson.py | 7 ++--- gramps2/src/EditPlace.py | 4 ++- gramps2/src/Marriage.py | 6 ++++- gramps2/src/Sources.py | 52 +++++++++++++++++++++++++++++++++++--- gramps2/src/WriteGedcom.py | 2 +- 6 files changed, 77 insertions(+), 22 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 8e3b0d07e..d87ccb1ec 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,16 +1,23 @@ -2005-03-09 Martin Hawlisch - * src/GenericFilter.py (IsDefaultPerson,IsSiblingOfFilterMatch): - Add filter rules. - 2005-03-09 Don Allingham - * srcNameEdit.py: assign date on close + * src/EditPerson.py: add srcref as a drag and drop item + * src/EditPlace.py: add srcref as a drag and drop item + * src/Marriage.py: add srcref as a drag and drop item + * src/WriteGedcom.py: catch empty event + * src/Sources.py: add drag-n-drop for source references + +2005-03-09 Martin Hawlisch + * src/GenericFilter.py (IsDefaultPerson,IsSiblingOfFilterMatch): + Add filter rules. 2005-03-09 Alex Roitman - * src/PedView.py: Import RelLib for accessing relationship constants. - * src/NameEdit.py: Use empty Date for newly created name. + * src/PedView.py: Import RelLib for accessing relationship constants. + * src/NameEdit.py: Use empty Date for newly created name. - * src/data/gramps.schemas: Place dont-ask key into interface dir. - * src/Marriage.py (did_data_change): Compare gramps_id, not handle. + * src/data/gramps.schemas: Place dont-ask key into interface dir. + * src/Marriage.py (did_data_change): Compare gramps_id, not handle. + +2005-03-09 Don Allingham + * src/NameEdit.py: assign date on close 2005-03-08 Don Allingham * src/ChooseParents.py: change _nsort to _model @@ -37,9 +44,6 @@ Update filter ComboBox in the main window. * src/gramps_main.py (init_filters): Clear layout before rebuilding. - * src/ChooseParents.py: Stop parent selection window from being - modal; fix child/parent relations from strings to integers. - 2005-03-07 Alex Roitman * src/AddrEdit.py: Typo. * src/EditPerson.py (on_add_addr_clicked): Typos. diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index f483680ee..56bff0220 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -76,10 +76,11 @@ _temple_names = const.lds_temple_codes.keys() _temple_names.sort() _temple_names = [""] + _temple_names -pycode_tgts = [('url', 0, 0), +pycode_tgts = [('url', 0, 0), ('pevent', 0, 1), - ('pattr', 0, 2), - ('paddr', 0, 3)] + ('pattr', 0, 2), + ('paddr', 0, 3), + ('srcref', 0, 4)] _use_patronymic = [ diff --git a/gramps2/src/EditPlace.py b/gramps2/src/EditPlace.py index 5c4b70eaa..6a9073bb8 100644 --- a/gramps2/src/EditPlace.py +++ b/gramps2/src/EditPlace.py @@ -54,7 +54,9 @@ import NameDisplay # Constants # #------------------------------------------------------------------------- -pycode_tgts = [('url', 0, 0)] +pycode_tgts = [ + ('url' , 0, 0) + ('srcref', 0, 4)] #------------------------------------------------------------------------- # diff --git a/gramps2/src/Marriage.py b/gramps2/src/Marriage.py index 092ea5f93..97e11fe98 100644 --- a/gramps2/src/Marriage.py +++ b/gramps2/src/Marriage.py @@ -66,7 +66,11 @@ _temple_names = const.lds_temple_codes.keys() _temple_names.sort() _temple_names = [""] + _temple_names -pycode_tgts = [('fevent', 0, 0), ('fattr', 0, 1)] +pycode_tgts = [ + ('fevent', 0, 0), + ('fattr', 0, 1), + ('srcref', 0, 4), + ] #------------------------------------------------------------------------- # diff --git a/gramps2/src/Sources.py b/gramps2/src/Sources.py index 6d1c4e4df..f2d6d94e8 100644 --- a/gramps2/src/Sources.py +++ b/gramps2/src/Sources.py @@ -32,10 +32,12 @@ from gettext import gettext as _ # GTK/Gnome modules # #------------------------------------------------------------------------- -import gobject import gtk import gtk.glade import gnome +from gtk.gdk import ACTION_COPY, BUTTON1_MASK, INTERP_BILINEAR, pixbuf_new_from_file +from gobject import TYPE_PYOBJECT +import pickle #------------------------------------------------------------------------- # @@ -49,6 +51,12 @@ import Date import DateEdit import DateHandler +pycode_tgts = [('url', 0, 0), + ('pevent', 0, 1), + ('pattr', 0, 2), + ('paddr', 0, 3), + ('srcref', 0, 4)] + #------------------------------------------------------------------------- # # SourceSelector @@ -94,7 +102,7 @@ class SourceSelector: self.delete = self.top.get_widget('delete') self.delete.set_sensitive(not self.db.readonly) self.selection = self.slist.get_selection() - self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) + self.model = gtk.ListStore(str,str) self.slist.set_model(self.model) self.top.get_widget('add').set_sensitive(not self.db.readonly) self.top.get_widget('ok').set_sensitive(not self.db.readonly) @@ -229,7 +237,7 @@ class SourceTab: self.window = window self.slist = clist self.selection = clist.get_selection() - self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) + self.model = gtk.ListStore(str,str,TYPE_PYOBJECT) add_btn.set_sensitive(not readonly) del_btn.set_sensitive(not readonly) @@ -251,8 +259,43 @@ class SourceTab: edit_btn.connect('clicked', self.edit_src_clicked) del_btn.connect('clicked', self.del_src_clicked) self.slist.connect('button-press-event',self.double_click) + self.setup_drag_n_drop() self.redraw() + def setup_drag_n_drop(self): + self.slist.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY) + self.slist.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY) + self.slist.connect('drag_data_get', self.drag_data_get) + self.slist.connect('drag_begin', self.drag_begin) + self.slist.connect('drag_data_received',self.drag_data_received) + + def drag_data_received(self,widget,context,x,y,sel_data,info,time): + 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 != 'srcref': + return + else: + foo = pickle.loads(data[2]); + self.list.append(foo) + + self.lists_changed = True + self.redraw() + + def drag_data_get(self,widget, context, sel_data, info, time): + + store,node = self.selection.get_selected() + ev = store.get_value(node,2) + + bits_per = 8; # we're going to pass a string + pickled = pickle.dumps(ev); + data = str(('srcref',None,pickled)); + sel_data.set(sel_data.target, bits_per, data) + + def drag_begin(self, context, a): + return + def double_click(self,obj,event): if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: self.edit_src_clicked(obj) @@ -263,7 +306,8 @@ class SourceTab: base_handle = s.get_base_handle() node = self.model.append() base = self.db.get_source_from_handle(base_handle) - self.model.set(node,0,base.get_gramps_id(),1,base.get_title()) + self.model.set(node,0,base.get_gramps_id(),1,base.get_title(), + 2,s) if self.list: Utils.bold_label(self.parent.sources_label) else: diff --git a/gramps2/src/WriteGedcom.py b/gramps2/src/WriteGedcom.py index 06216c018..45cf5682c 100644 --- a/gramps2/src/WriteGedcom.py +++ b/gramps2/src/WriteGedcom.py @@ -693,7 +693,7 @@ class GedcomWriter: for event_handle in family.get_event_list(): event = self.db.get_event_from_handle(event_handle) - if self.private and event.get_privacy(): + if not event or self.private and event.get_privacy(): continue name = event.get_name() val = ""