2006-05-25 Don Allingham <don@gramps-project.org>
* 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 svn: r6776
This commit is contained in:
parent
524ce620b0
commit
081f5079d5
@ -1,3 +1,9 @@
|
||||
2006-05-25 Don Allingham <don@gramps-project.org>
|
||||
* 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 <shura@gramps-project.org>
|
||||
* src/plugins/Verify.py: Start major rework, still in progress.
|
||||
|
||||
|
@ -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):
|
||||
<menuitem action="Remove"/>
|
||||
</placeholder>
|
||||
<menuitem action="ColumnEdit"/>
|
||||
<placeholder name="Merge">
|
||||
<menuitem action="FastMerge"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
</menubar>
|
||||
<toolbar name="ToolBar">
|
||||
@ -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)
|
||||
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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()
|
||||
|
@ -16,6 +16,8 @@
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="focus_on_map">True</property>
|
||||
<property name="urgency_hint">False</property>
|
||||
<property name="has_separator">False</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
@ -30,7 +32,7 @@
|
||||
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button9">
|
||||
<widget class="GtkButton" id="cancel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
@ -44,7 +46,7 @@
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button7">
|
||||
<widget class="GtkButton" id="ok">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
@ -98,6 +100,10 @@
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">6</property>
|
||||
@ -150,6 +156,10 @@
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
@ -174,6 +184,10 @@
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
@ -291,6 +305,8 @@
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="focus_on_map">True</property>
|
||||
<property name="urgency_hint">False</property>
|
||||
<property name="has_separator">False</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
@ -388,6 +404,10 @@
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">10</property>
|
||||
@ -555,6 +575,8 @@
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="focus_on_map">True</property>
|
||||
<property name="urgency_hint">False</property>
|
||||
<property name="has_separator">False</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
@ -638,6 +660,10 @@
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
@ -661,6 +687,10 @@
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
@ -685,6 +715,10 @@
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">4</property>
|
||||
@ -1155,6 +1189,8 @@
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="focus_on_map">True</property>
|
||||
<property name="urgency_hint">False</property>
|
||||
<property name="has_separator">False</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
@ -1237,6 +1273,10 @@
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
@ -1258,6 +1298,10 @@
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">6</property>
|
||||
@ -1288,6 +1332,10 @@
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
@ -1312,6 +1360,10 @@
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
Loading…
Reference in New Issue
Block a user