2007-03-24 Zsolt Foldvari <zfoldvar@users.sourceforge.net>

* src/MarkupText.py (MarkupBuffer.set_text): better unicode encoding.
	* src/Editors/_EditPlace.py: source code encoding comment removed;
	EditPlace._validate_coordinate: proper unicode coding;
	EditPlace._setup_fields: longitude and latitude entries moved out to
	glade.
	* src/Editors/_EditNote.py (EditNote._local_init): redundant method
	call removed.
	* src/GrampsWidgets.py: enable custom widget support from glade;
	MonitoredEntry.connect: enable support for custom data for signal.
	* src/glade/gramps.glade (place_editor): include ValidatableMaskedEntry
	for longitude and latitude entries.
	* src/ManagedWindow.py (ManagedWindow.show): replace window.show() with
	window.show_all().



svn: r8311
This commit is contained in:
Zsolt Foldvari 2007-03-23 23:18:32 +00:00
parent 7db878ef61
commit 901f282088
7 changed files with 73 additions and 25 deletions

View File

@ -1,3 +1,18 @@
2007-03-24 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
* src/MarkupText.py (MarkupBuffer.set_text): better unicode encoding.
* src/Editors/_EditPlace.py: source code encoding comment removed;
EditPlace._validate_coordinate: proper unicode coding;
EditPlace._setup_fields: longitude and latitude entries moved out to
glade.
* src/Editors/_EditNote.py (EditNote._local_init): redundant method
call removed.
* src/GrampsWidgets.py: enable custom widget support from glade;
MonitoredEntry.connect: enable support for custom data for signal.
* src/glade/gramps.glade (place_editor): include ValidatableMaskedEntry
for longitude and latitude entries.
* src/ManagedWindow.py (ManagedWindow.show): replace window.show() with
window.show_all().
2007-03-21 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
* src/MarkupText.py (MarkupBuffer.set_text): convert unicode to byte
string for parseString.

View File

@ -90,7 +90,6 @@ class EditNote(EditPrimary):
self.window.set_default_size(width, height)
self.build_interface()
self.window.show_all()
def _setup_fields(self):
"""Get control widgets and attached them to Note's attributes."""

View File

@ -1,4 +1,4 @@
# -*- coding: latin-1 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2006 Donald N. Allingham
@ -68,7 +68,8 @@ class EditPlace(EditPrimary):
def _local_init(self):
self.top = gtk.glade.XML(const.gladeFile,"place_editor","gramps")
self.set_window(self.top.get_widget("place_editor"), None, self.get_menu_title())
self.set_window(self.top.get_widget("place_editor"), None,
self.get_menu_title())
width = Config.get(Config.PLACE_WIDTH)
height = Config.get(Config.PLACE_HEIGHT)
self.window.resize(width, height)
@ -134,37 +135,27 @@ class EditPlace(EditPrimary):
self.country = MonitoredEntry(
self.top.get_widget("country"),
mloc.set_country, mloc.get_country, self.db.readonly)
table = self.top.get_widget("table66")
entry = ValidatableMaskedEntry()
entry.connect("validate", self._validate_coordinate, "lon")
entry.show()
table.attach(entry, 3, 4, 1, 2, yoptions=gtk.EXPAND)
self.longitude = MonitoredEntry(
entry,
self.top.get_widget("lon_entry"),
self.obj.set_longitude, self.obj.get_longitude,
self.db.readonly)
self.longitude.connect("validate", self._validate_coordinate, "lon")
entry = ValidatableMaskedEntry()
entry.connect("validate", self._validate_coordinate, "lat")
entry.show()
table.attach(entry, 1, 2, 1, 2, yoptions=gtk.EXPAND)
self.latitude = MonitoredEntry(
entry,
self.top.get_widget("lat_entry"),
self.obj.set_latitude, self.obj.get_latitude,
self.db.readonly)
self.latitude.connect("validate", self._validate_coordinate, "lat")
def _validate_coordinate(self, widget, text, typedeg):
if (typedeg == 'lat') and not conv_lat_lon(text, "0", "ISO-D"):
return ValidationError(_("Invalid latitude (syntax: 18°9'" +
return ValidationError(_(u"Invalid latitude (syntax: 18\u00b09'" +
'48.21"S, -18.2412 or -18:9:48.21)'))
elif (typedeg == 'lon') and not conv_lat_lon("0", text, "ISO-D"):
return ValidationError(_("Invalid longitude (syntax: 18°9'" +
return ValidationError(_(u"Invalid longitude (syntax: 18\u00b09'" +
'48.21"E, -18.2412 or -18:9:48.21)'))
def build_menu_names(self,place):
return (_('Edit Place'), self.get_menu_title())

View File

@ -74,6 +74,15 @@ try:
except:
INFO_ICON = gtk.STOCK_DIALOG_INFO
# Enabling custom widgets to be included in Glade
def get_custom_handler(glade, function_name, widget_name,
str1, str2, int1, int2):
if function_name == 'ValidatableMaskedEntry':
return ValidatableMaskedEntry()
gtk.glade.set_custom_handler(get_custom_handler)
hand_cursor = gtk.gdk.Cursor(gtk.gdk.HAND2)
def realize_cb(widget):
widget.window.set_cursor(hand_cursor)
@ -349,8 +358,8 @@ class MonitoredEntry:
def set_text(self, text):
self.obj.set_text(text)
def connect(self, signal, callback):
self.obj.connect(signal, callback)
def connect(self, signal, callback, *data):
self.obj.connect(signal, callback, *data)
def _on_change(self, obj):
self.set_val(unicode(obj.get_text()))

View File

@ -369,7 +369,7 @@ class ManagedWindow:
assert self.window, "ManagedWindow: self.window does not exist!"
self.window.set_transient_for(self.parent_window)
self.opened = True
self.window.show()
self.window.show_all()
def close(self,*obj):
"""

View File

@ -272,7 +272,7 @@ class MarkupBuffer(gtk.TextBuffer):
Also translates Gramps XML markup language to gtk.TextTag's and vice versa.
Based on 'gourmet-0.13.3' L{http://grecipe-manager.sourceforge.net}
Pango markup format is replaces by custom Gramps XML format.
Pango markup format is replaced by custom Gramps XML format.
"""
texttag_to_xml = {
@ -297,7 +297,7 @@ class MarkupBuffer(gtk.TextBuffer):
def set_text(self, xmltext):
"""Set the content of the buffer with markup tags."""
try:
parseString(str(xmltext), self.parser)
parseString(xmltext.encode('utf-8'), self.parser)
text = self.parser.content
except:
# if parse fails remove all tags and use clear text instead

View File

@ -1708,6 +1708,40 @@
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="Custom" id="lon_entry">
<property name="visible">True</property>
<property name="creation_function">ValidatableMaskedEntry</property>
<property name="int1">0</property>
<property name="int2">0</property>
<property name="last_modification_time">Fri, 23 Mar 2007 20:18:43 GMT</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="Custom" id="lat_entry">
<property name="visible">True</property>
<property name="creation_function">ValidatableMaskedEntry</property>
<property name="int1">0</property>
<property name="int2">0</property>
<property name="last_modification_time">Fri, 23 Mar 2007 20:17:51 GMT</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>