* src/Merge/_MergeSource.py: note handling on source merge

* src/glade/mergedata.glade: note handling on source merge


svn: r6786
This commit is contained in:
Don Allingham 2006-05-26 03:07:48 +00:00
parent 82647857d3
commit 1772ac7d01
3 changed files with 342 additions and 230 deletions

View File

@ -1,4 +1,6 @@
2006-05-25 Don Allingham <don@gramps-project.org>
* src/Merge/_MergeSource.py: note handling on source merge
* src/glade/mergedata.glade: note handling on source merge
* src/Makefile.am: remove deleted files
* configure.in: add Merge directory

View File

@ -61,8 +61,8 @@ class MergeSources(ManagedWindow.ManagedWindow):
self.new_handle = new_handle
self.old_handle = old_handle
self.src1 = self.db.get_source_from_handle(self.new_handle)
self.src2 = self.db.get_source_from_handle(self.old_handle)
self.s1 = self.db.get_source_from_handle(self.new_handle)
self.s2 = self.db.get_source_from_handle(self.old_handle)
self.glade = gtk.glade.XML(const.merge_glade,"merge_sources","gramps")
@ -72,29 +72,41 @@ class MergeSources(ManagedWindow.ManagedWindow):
self.title1 = self.glade.get_widget("title1")
self.title2 = self.glade.get_widget("title2")
self.title1.set_text(self.src1.get_title())
self.title2.set_text(self.src2.get_title())
self.title1.set_text(self.s1.get_title())
self.title2.set_text(self.s2.get_title())
self.author1 = self.glade.get_widget("author1")
self.author2 = self.glade.get_widget("author2")
self.author1.set_text(self.src1.get_author())
self.author2.set_text(self.src2.get_author())
self.author1.set_text(self.s1.get_author())
self.author2.set_text(self.s2.get_author())
self.abbrev1 = self.glade.get_widget("abbrev1")
self.abbrev2 = self.glade.get_widget("abbrev2")
self.abbrev1.set_text(self.src1.get_abbreviation())
self.abbrev2.set_text(self.src2.get_abbreviation())
self.abbrev1.set_text(self.s1.get_abbreviation())
self.abbrev2.set_text(self.s2.get_abbreviation())
self.pub1 = self.glade.get_widget("pub1")
self.pub2 = self.glade.get_widget("pub2")
self.pub1.set_text(self.src1.get_publication_info())
self.pub2.set_text(self.src2.get_publication_info())
self.pub1.set_text(self.s1.get_publication_info())
self.pub2.set_text(self.s2.get_publication_info())
self.gramps1 = self.glade.get_widget("gramps1")
self.gramps2 = self.glade.get_widget("gramps2")
self.gramps1.set_text(self.src1.get_gramps_id())
self.gramps2.set_text(self.src2.get_gramps_id())
self.gramps1.set_text(self.s1.get_gramps_id())
self.gramps2.set_text(self.s2.get_gramps_id())
self.note_s1 = self.glade.get_widget('note_s1')
self.note_s2 = self.glade.get_widget('note_s2')
self.note_merge = self.glade.get_widget('note_merge')
self.note_title = self.glade.get_widget('note_title')
self.note_conflict = self.s1.get_note() and self.s2.get_note()
if self.note_conflict:
self.note_title.show()
self.note_s1.show()
self.note_s2.show()
self.note_merge.show()
self.glade.get_widget('ok').connect('clicked',self.merge)
self.glade.get_widget('cancel').connect('clicked',self.close_window)
self.glade.get_widget('help').connect('clicked',self.help)
@ -119,34 +131,39 @@ class MergeSources(ManagedWindow.ManagedWindow):
use_gramps1 = self.glade.get_widget("gramps_btn1").get_active()
if not use_title1:
self.src1.set_title(self.src2.get_title())
self.s1.set_title(self.s2.get_title())
if not use_author1:
self.src1.set_author(self.src2.get_author())
self.s1.set_author(self.s2.get_author())
if not use_abbrev1:
self.src1.set_abbreviation(self.src2.get_abbreviation())
self.s1.set_abbreviation(self.s2.get_abbreviation())
if not use_pub1:
self.src1.set_publication_info(self.src2.get_publication_info())
self.s1.set_publication_info(self.s2.get_publication_info())
if not use_gramps1:
self.src1.set_gramps_id(self.src2.get_gramps_id())
self.s1.set_gramps_id(self.s2.get_gramps_id())
# Copy photos from src2 to src1
for photo in self.src2.get_media_list():
self.src1.add_media_reference(photo)
for photo in self.s2.get_media_list():
self.s1.add_media_reference(photo)
# Add notes from P2 to P1
note = self.src2.get_note()
if note != "":
if self.src1.get_note() == "":
self.src1.set_note(note)
elif self.src1.get_note() != note:
self.src1.set_note("%s\n\n%s" % (self.src1.get_note(),note))
# Add notes from S2 to S1
if self.note_conflict:
note1 = self.s1.get_note()
note2 = self.s2.get_note()
if self.note_s2.get_active():
self.s1.set_note(note2)
elif self.note_merge.get_active():
self.s1.set_note("%s\n\n%s" % (note1,note2))
else:
note = self.s2.get_note()
if note != "" and self.s1.get_note() == "":
self.s1.set_note(note)
src2_map = self.src2.get_data_map()
src1_map = self.src1.get_data_map()
src2_map = self.s2.get_data_map()
src1_map = self.s1.get_data_map()
for key in src2_map.keys():
if not src1_map.has_key(key):
src1_map[key] = src2_map[key]
@ -155,7 +172,7 @@ class MergeSources(ManagedWindow.ManagedWindow):
trans = self.db.transaction_begin()
self.db.remove_source(self.old_handle,trans)
self.db.commit_source(self.src1,trans)
self.db.commit_source(self.s1,trans)
# replace handles

View File

@ -682,6 +682,7 @@
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">500</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
@ -755,39 +756,12 @@
<widget class="GtkTable" id="table8">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="n_rows">7</property>
<property name="n_rows">11</property>
<property name="n_columns">7</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<widget class="GtkLabel" id="title">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<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>
<property name="right_attach">7</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label81">
<property name="visible">True</property>
@ -844,174 +818,6 @@
</packing>
</child>
<child>
<widget class="GtkEntry" id="title1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="title2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">6</property>
<property name="right_attach">7</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="author1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="abbrev1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="pub1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="author2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">6</property>
<property name="right_attach">7</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="abbrev2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">6</property>
<property name="right_attach">7</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="pub2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">6</property>
<property name="right_attach">7</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="title_btn1">
<property name="visible">True</property>
@ -1238,15 +1044,302 @@
</child>
<child>
<widget class="GtkEntry" id="gramps1">
<widget class="GtkLabel" id="title">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<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>
<property name="right_attach">7</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="note_title">
<property name="label" translatable="yes">&lt;b&gt;Note selection&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<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>
<property name="right_attach">7</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="note_s1">
<property name="can_focus">True</property>
<property name="label" translatable="yes">Select note from Source 1</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">7</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="note_s2">
<property name="can_focus">True</property>
<property name="label" translatable="yes">Select note from Source 2</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">note_s1</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">7</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="note_merge">
<property name="can_focus">True</property>
<property name="label" translatable="yes">Merge notes</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">note_s1</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">7</property>
<property name="top_attach">10</property>
<property name="bottom_attach">11</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="title1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="invisible_char">●</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="title2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">●</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">6</property>
<property name="right_attach">7</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="author1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">●</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="author2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">●</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">6</property>
<property name="right_attach">7</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="abbrev1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">●</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="abbrev2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">●</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">6</property>
<property name="right_attach">7</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="pub1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">●</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="pub2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">●</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">6</property>
<property name="right_attach">7</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="gramps1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">●</property>
<property name="activates_default">False</property>
</widget>
<packing>
@ -1262,12 +1355,12 @@
<widget class="GtkEntry" id="gramps2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="invisible_char"></property>
<property name="activates_default">False</property>
</widget>
<packing>