Add place name edit button to place editors

This commit is contained in:
Nick Hall 2015-05-27 19:15:59 +01:00
parent 8a9fbc35e3
commit 24c1104f71
4 changed files with 120 additions and 28 deletions

View File

@ -52,7 +52,7 @@ from .displaytabs import (PlaceRefEmbedList, PlaceNameEmbedList,
GalleryTab, NoteTab, WebEmbedList, PlaceBackRefList)
from ..widgets import (MonitoredEntry, PrivacyButton, MonitoredTagList,
MonitoredDataType)
from gramps.gen.errors import ValidationError
from gramps.gen.errors import ValidationError, WindowActiveError
from gramps.gen.utils.place import conv_lat_lon
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.config import config
@ -119,6 +119,9 @@ class EditPlace(EditPrimary):
self.db.readonly,
changed=self.name_changed)
edit_button = self.top.get_object("name_button")
edit_button.connect('clicked', self.edit_place_name)
self.gid = MonitoredEntry(self.top.get_object("gid"),
self.obj.set_gramps_id,
self.obj.get_gramps_id, self.db.readonly)
@ -252,6 +255,18 @@ class EditPlace(EditPrimary):
self._setup_notebook_tabs(notebook)
def edit_place_name(self, obj):
try:
from . import EditPlaceName
EditPlaceName(self.dbstate, self.uistate, self.track,
self.obj.get_name(), self.edit_callback)
except WindowActiveError:
return
def edit_callback(self, obj):
value = self.obj.get_name().get_value()
self.top.get_object("name_entry").set_text(value)
def save(self, *obj):
self.ok_button.set_sensitive(False)

View File

@ -33,7 +33,7 @@ from .displaytabs import (PlaceRefEmbedList, PlaceNameEmbedList,
GalleryTab, NoteTab, WebEmbedList, PlaceBackRefList)
from gramps.gen.lib import NoteType
from gramps.gen.db import DbTxn
from gramps.gen.errors import ValidationError
from gramps.gen.errors import ValidationError, WindowActiveError
from gramps.gen.utils.place import conv_lat_lon
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.config import config
@ -119,6 +119,9 @@ class EditPlaceRef(EditReference):
self.db.readonly,
changed=self.name_changed)
edit_button = self.top.get_object("name_button")
edit_button.connect('clicked', self.edit_place_name)
self.gid = MonitoredEntry(self.top.get_object("gid"),
self.source.set_gramps_id,
self.source.get_gramps_id, self.db.readonly)
@ -253,6 +256,18 @@ class EditPlaceRef(EditReference):
self._setup_notebook_tabs(notebook)
def edit_place_name(self, obj):
try:
from . import EditPlaceName
EditPlaceName(self.dbstate, self.uistate, self.track,
self.source.get_name(), self.edit_callback)
except WindowActiveError:
return
def edit_callback(self, obj):
value = self.source.get_name().get_value()
self.top.get_object("name_entry").set_text(value)
def save(self, *obj):
self.ok_button.set_sensitive(False)

View File

@ -304,19 +304,6 @@ You can set these values via the Geography View by searching the place, or via a
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="UndoableEntry" id="name_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">The name of this place.</property>
<property name="hexpand">True</property>
<property name="invisible_char">●</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="place_type">
<property name="visible">True</property>
@ -376,6 +363,50 @@ You can set these values via the Geography View by searching the place, or via a
<property name="width">5</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="UndoableEntry" id="name_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">The name of this place.</property>
<property name="hexpand">True</property>
<property name="invisible_char">●</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="name_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Invoke place name editor.</property>
<child>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">gtk-edit</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>

View File

@ -386,19 +386,6 @@
<property name="width">4</property>
</packing>
</child>
<child>
<object class="UndoableEntry" id="name_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">The name of this place.</property>
<property name="hexpand">True</property>
<property name="invisible_char">●</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="ValidatableMaskedEntry" id="lat_entry">
<property name="visible">True</property>
@ -534,6 +521,50 @@ You can set these values via the Geography View by searching the place, or via a
<property name="width">5</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="UndoableEntry" id="name_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">The name of this place.</property>
<property name="hexpand">True</property>
<property name="invisible_char">●</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="name_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Invoke place name editor.</property>
<property name="icon_name">gtk-edit</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>