diff --git a/ChangeLog b/ChangeLog index 80f2b0d5c..07986345c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-05-25 Don Allingham + * src/DataViews/_PlaceView.py: place merge support + * src/glade/mergedata.glade: place merge support + * src/MergeData.py: place merge support + * src/PageView.py: add support for multiselection + 2006-05-24 Alex Roitman * src/plugins/Verify.py: Start major rework, still in progress. diff --git a/src/DataViews/_PlaceView.py b/src/DataViews/_PlaceView.py index 71a97e252..cfb64712b 100644 --- a/src/DataViews/_PlaceView.py +++ b/src/DataViews/_PlaceView.py @@ -88,7 +88,8 @@ class PlaceView(PageView.ListView): self, _('Places'), dbstate, uistate, column_names, len(column_names), DisplayModels.PlaceModel, signal_map, dbstate.db.get_place_bookmarks(), - Bookmarks.PlaceBookmarks) + Bookmarks.PlaceBookmarks, + multiple=True) def get_bookmarks(self): return self.dbstate.db.get_place_bookmarks() @@ -97,6 +98,8 @@ class PlaceView(PageView.ListView): PageView.ListView.define_actions(self) self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor'), callback=self.column_editor) + self.add_action('FastMerge', None, _('_Merge'), + callback=self.fast_merge) def column_editor(self,obj): import ColumnOrder @@ -134,6 +137,9 @@ class PlaceView(PageView.ListView): + + + @@ -204,3 +210,19 @@ class PlaceView(PageView.ListView): except Errors.WindowActiveError: pass + def fast_merge(self, obj): + mlist = [] + self.selection.selected_foreach(self.blist,mlist) + + if len(mlist) != 2: + msg = _("Cannot merge places.") + msg2 = _("Exactly two places must be selected to perform a merge. " + "A second place can be selected by holding down the " + "control key while clicking on the desired place.") + ErrorDialog(msg,msg2) + else: + import MergeData + MergeData.MergePlaces(self.dbstate, self.uistate, mlist[0], + mlist[1], self.build_tree) + + diff --git a/src/MergeData.py b/src/MergeData.py index 94450d824..7813cce22 100644 --- a/src/MergeData.py +++ b/src/MergeData.py @@ -42,47 +42,56 @@ import gtk import Utils import const import GrampsDisplay +import ManagedWindow #------------------------------------------------------------------------- # # Merge Places # #------------------------------------------------------------------------- -class MergePlaces: +class MergePlaces(ManagedWindow.ManagedWindow): """ Merges to places into a single place. Displays a dialog box that allows the places to be combined into one. """ - def __init__(self,database,new_handle,old_handle,update): - self.db = database + def __init__(self, dbstate, uistate, new_handle, old_handle, update): + + ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__) + + self.db = dbstate.db self.new_handle = new_handle self.old_handle = old_handle self.p1 = self.db.get_place_from_handle(self.new_handle) self.p2 = self.db.get_place_from_handle(self.old_handle) self.update = update - self.trans = self.db.transaction_begin() self.glade = gtk.glade.XML(const.merge_glade,"merge_places","gramps") - self.top = self.glade.get_widget("merge_places") - Utils.set_titles(self.top,self.glade.get_widget('title'), - _("Select title")) + self.set_window(self.glade.get_widget("merge_places"), + self.glade.get_widget('title'), + _("Select title")) + self.glade.get_widget("title1_text").set_text(self.p1.get_title()) self.glade.get_widget("title2_text").set_text(self.p2.get_title()) self.t3 = self.glade.get_widget("title3_text") self.t3.set_text(self.p1.get_title()) + + self.glade.get_widget('cancel').connect('clicked', self.close_window) + self.glade.get_widget('ok').connect('clicked', self.merge) + self.glade.get_widget('help').connect('clicked', self.help) - self.glade.signal_autoconnect({ - "destroy_passed_object" : Utils.destroy_passed_object, - "on_merge_places_clicked" : self.on_merge_places_clicked, - "on_help_places_clicked" : self.help, - }) - self.top.show() + self.window.show() + + def close_window(self, obj): + self.close() + + def build_menu_names(self,obj): + return (_('Merge Places'),None) def help(self,obj): """Display the relevant portion of GRAMPS manual""" GrampsDisplay.help('adv-merge-places') - def on_merge_places_clicked(self,obj): + def merge(self,obj): """ Performs the merge of the places when the merge button is clicked. """ @@ -134,8 +143,10 @@ class MergePlaces: self.p1.add_alternate_locations(l) # remove old and commit new source - self.db.remove_place(self.old_handle,self.trans) - self.db.commit_place(self.p1,self.trans) + trans = self.db.transaction_begin() + + self.db.remove_place(self.old_handle,trans) + self.db.commit_place(self.p1,trans) # replace references in other objetcs # people @@ -143,23 +154,23 @@ class MergePlaces: person = self.db.get_person_from_handle(handle) if person.has_handle_reference('Place',self.old_handle): person.replace_handle_reference('Place',self.old_handle,self.new_handle) - self.db.commit_person(person,self.trans) + self.db.commit_person(person,trans) # families for handle in self.db.get_family_handles(): family = self.db.get_family_from_handle(handle) if family.has_handle_reference('Place',self.old_handle): family.replace_handle_reference('Place',self.old_handle,self.new_handle) - self.db.commit_family(family,self.trans) + self.db.commit_family(family,trans) # events for handle in self.db.get_event_handles(): event = self.db.get_event_from_handle(handle) if event.has_handle_reference('Place',self.old_handle): event.replace_handle_reference('Place',self.old_handle,self.new_handle) - self.db.commit_event(event,self.trans) + self.db.commit_event(event,trans) - self.db.transaction_commit(self.trans,_("Merge Places")) + self.db.transaction_commit(trans,_("Merge Places")) self.update() - Utils.destroy_passed_object(obj) + self.close() #------------------------------------------------------------------------- # @@ -212,7 +223,7 @@ class MergeSources: self.glade.get_widget('ok').connect('clicked',self.merge) self.glade.get_widget('cancel').connect('clicked',self.close) self.glade.get_widget('help').connect('clicked',self.help) - self.trans = self.db.transaction_begin() + trans = self.db.transaction_begin() self.top.show() def close(self,obj): diff --git a/src/PageView.py b/src/PageView.py index 586e3206d..d5eb74894 100644 --- a/src/PageView.py +++ b/src/PageView.py @@ -427,7 +427,7 @@ class ListView(BookMarkView): DEL_MSG = "" def __init__(self, title, dbstate, uistate, columns, handle_col, - make_model, signal_map, get_bookmarks, bm_type): + make_model, signal_map, get_bookmarks, bm_type, multiple=False): BookMarkView.__init__(self, title, dbstate, uistate, get_bookmarks, bm_type) @@ -440,6 +440,7 @@ class ListView(BookMarkView): self.handle_col = handle_col self.make_model = make_model self.signal_map = signal_map + self.multiple_selection = multiple dbstate.connect('database-changed',self.change_db) def add_bookmark(self, obj): @@ -503,6 +504,8 @@ class ListView(BookMarkView): self.columns = [] self.build_columns() self.selection = self.list.get_selection() + if self.multiple_selection: + self.selection.set_mode(gtk.SELECTION_MULTIPLE) self.selection.connect('changed',self.row_changed) self.setup_filter() diff --git a/src/glade/mergedata.glade b/src/glade/mergedata.glade index 035dec827..deb5d86bf 100644 --- a/src/glade/mergedata.glade +++ b/src/glade/mergedata.glade @@ -16,6 +16,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False False @@ -30,7 +32,7 @@ GTK_BUTTONBOX_END - + True True True @@ -44,7 +46,7 @@ - + True True True @@ -98,6 +100,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 6 @@ -150,6 +156,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1 @@ -174,6 +184,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1 @@ -291,6 +305,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False False @@ -388,6 +404,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 10 @@ -555,6 +575,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False False @@ -638,6 +660,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -661,6 +687,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -685,6 +715,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 4 @@ -1155,6 +1189,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False False @@ -1237,6 +1273,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1258,6 +1298,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 6 @@ -1288,6 +1332,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1 @@ -1312,6 +1360,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1