2007-09-08 Don Allingham <don@gramps-project.org>

* src/ViewManager.py: code cleanup
	* src/FontScale.py: code cleanup
	* src/GrampsWidgets.py: code cleanup
	* src/ExportOptions.py: code cleanup
	* src/GrampsDisplay.py: code cleanup
	* src/DateEdit.py: code cleanup
	* src/DbLoader.py: code cleanup



svn: r8951
This commit is contained in:
Don Allingham
2007-09-09 05:24:15 +00:00
parent 651e29ead4
commit 6d9dbfee49
8 changed files with 593 additions and 501 deletions

View File

@@ -1,3 +1,12 @@
2007-09-08 Don Allingham <don@gramps-project.org>
* src/ViewManager.py: code cleanup
* src/FontScale.py: code cleanup
* src/GrampsWidgets.py: code cleanup
* src/ExportOptions.py: code cleanup
* src/GrampsDisplay.py: code cleanup
* src/DateEdit.py: code cleanup
* src/DbLoader.py: code cleanup
2007-09-08 Benny Malengier <benny.malengier@gramps-project.org> 2007-09-08 Benny Malengier <benny.malengier@gramps-project.org>
* src/DataViews/_RelationView.py : expand/collapse, edit button on/off bug fix * src/DataViews/_RelationView.py : expand/collapse, edit button on/off bug fix
* src/GrampsWidgets.py : Expand widget, changes link labels * src/GrampsWidgets.py : Expand widget, changes link labels

View File

@@ -264,7 +264,7 @@ class DateEditorDialog(ManagedWindow.ManagedWindow):
if response == gtk.RESPONSE_HELP: if response == gtk.RESPONSE_HELP:
GrampsDisplay.help('adv-dates') GrampsDisplay.help('adv-dates')
elif response == gtk.RESPONSE_DELETE_EVENT: elif response == gtk.RESPONSE_DELETE_EVENT:
return break
else: else:
if response == gtk.RESPONSE_OK: if response == gtk.RESPONSE_OK:
(the_quality, the_modifier, the_calendar, (the_quality, the_modifier, the_calendar,
@@ -277,9 +277,11 @@ class DateEditorDialog(ManagedWindow.ManagedWindow):
value=the_value, value=the_value,
text=the_text) text=the_text)
self.close() self.close()
return
def build_menu_names(self, obj): def build_menu_names(self, obj):
"""
Define the menu entry for the ManagedWindows
"""
return (_("Date selection"), None) return (_("Date selection"), None)
def build_date_from_ui(self): def build_date_from_ui(self):

View File

@@ -87,6 +87,9 @@ class DbLoader:
self.uistate = uistate self.uistate = uistate
def open_file(self): def open_file(self):
"""
Presents a file open dialog and opens the corresponding exsting file
"""
choose = gtk.FileChooserDialog( choose = gtk.FileChooserDialog(
_('GRAMPS: Open database'), _('GRAMPS: Open database'),
self.uistate.window, self.uistate.window,
@@ -140,63 +143,6 @@ class DbLoader:
choose.destroy() choose.destroy()
return ('', '') return ('', '')
def new_file(self):
choose = gtk.FileChooserDialog(
_('GRAMPS: Create GRAMPS database'),
self.uistate.window,
gtk.FILE_CHOOSER_ACTION_SAVE,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_NEW, gtk.RESPONSE_OK))
# Always add automatic (macth all files) filter
add_all_files_filter(choose)
add_grdb_filter(choose)
default_dir = get_default_dir()
new_filename = Utils.get_new_filename('grdb', default_dir)
choose.set_current_folder(default_dir)
choose.set_current_name(os.path.split(new_filename)[1])
while (True):
response = choose.run()
if response == gtk.RESPONSE_OK:
filename = unicode(choose.get_filename(),
sys.getfilesystemencoding())
if self.check_errors(filename):
return ('','')
ext = os.path.splitext(filename)[1].lower()
if ext == ".ged":
filetype = const.APP_GEDCOM
elif ext == ".gramps":
filetype = const.APP_GRAMPS_XML
elif ext == ".grdb":
filetype = const.APP_GRAMPS
else:
filename = filename + ".grdb"
filetype = const.APP_GRAMPS
choose.destroy()
try:
self.dbstate.db.close()
except:
pass
self.read_file(filename, filetype)
try:
os.chdir(os.path.dirname(filename))
except:
return ('', '')
self.dbstate.db.db_is_open = True
return (filename, filetype)
else:
choose.destroy()
return ('', '')
choose.destroy()
return ('', '')
def save_as(self): def save_as(self):
choose = gtk.FileChooserDialog( choose = gtk.FileChooserDialog(
_('GRAMPS: Create GRAMPS database'), _('GRAMPS: Create GRAMPS database'),
@@ -343,8 +289,8 @@ class DbLoader:
# Then we try all the known plugins # Then we try all the known plugins
(the_path, the_file) = os.path.split(filename) (the_path, the_file) = os.path.split(filename)
Config.set(Config.RECENT_IMPORT_DIR, the_path) Config.set(Config.RECENT_IMPORT_DIR, the_path)
for (importData, mime_filter, mime_type, native_format, format_name) \ for (importData, mime_filter, mime_type, native_format,
in import_list: format_name) in import_list:
if filetype == mime_type or the_file == mime_type: if filetype == mime_type or the_file == mime_type:
self.do_import(choose, importData, filename) self.do_import(choose, importData, filename)
return True return True

View File

@@ -17,10 +17,24 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
"""
Provides the common export options for Exporters
"""
#-------------------------------------------------------------------------
#
# python modules
#
#-------------------------------------------------------------------------
import gtk import gtk
from gettext import gettext as _ from gettext import gettext as _
import RelLib #-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import Config import Config
from BasicUtils import name_displayer from BasicUtils import name_displayer
@@ -28,7 +42,7 @@ from Filters import GenericFilter, Rules
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# # WriterOptionBox
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class WriterOptionBox: class WriterOptionBox:
@@ -38,13 +52,24 @@ class WriterOptionBox:
""" """
def __init__(self, person): def __init__(self, person):
self.person = person self.person = person
self.private = 0
self.restrict = 0
self.cfilter = None
self.restrict_check = None
self.private_check = None
self.filter_obj = None
def get_option_box(self): def get_option_box(self):
"""
Builds up a gtk.Table that contains the standard options
"""
table = gtk.Table(3, 2) table = gtk.Table(3, 2)
label = gtk.Label('Filter') label = gtk.Label('Filter')
self.filter_obj = gtk.ComboBox() self.filter_obj = gtk.ComboBox()
self.private_check = gtk.CheckButton(_('Do not include records marked private')) self.private_check = gtk.CheckButton(
self.restrict_check = gtk.CheckButton(_('Restrict data on living people')) _('Do not include records marked private'))
self.restrict_check = gtk.CheckButton(
_('Restrict data on living people'))
self.private_check.set_active(Config.get(Config.EXPORT_NO_PRIVATE)) self.private_check.set_active(Config.get(Config.EXPORT_NO_PRIVATE))
self.restrict_check.set_active(Config.get(Config.EXPORT_RESTRICT)) self.restrict_check.set_active(Config.get(Config.EXPORT_RESTRICT))
@@ -57,40 +82,19 @@ class WriterOptionBox:
table.attach(self.private_check, 1, 2, 1, 2, yoptions=0) table.attach(self.private_check, 1, 2, 1, 2, yoptions=0)
table.attach(self.restrict_check, 1, 2, 2, 3, yoptions=0) table.attach(self.restrict_check, 1, 2, 2, 3, yoptions=0)
#filter_obj = self.topDialog.get_widget("filter") entire_db = GenericFilter()
entire_db.set_name(_("Entire Database"))
all = GenericFilter() the_filters = [entire_db]
all.set_name(_("Entire Database"))
the_filters = [all]
if self.person: if self.person:
des = GenericFilter() the_filters += self.__define_person_filters()
des.set_name(_("Descendants of %s") %
name_displayer.display(self.person))
des.add_rule(Rules.Person.IsDescendantOf(
[self.person.get_gramps_id(), 1]))
ans = GenericFilter()
ans.set_name(_("Ancestors of %s")
% name_displayer.display(self.person))
ans.add_rule(Rules.Person.IsAncestorOf(
[self.person.get_gramps_id(), 1]))
com = GenericFilter()
com.set_name(_("People with common ancestor with %s") %
name_displayer.display(self.person))
com.add_rule(Rules.Person.HasCommonAncestorWith(
[self.person.get_gramps_id()]))
the_filters += [des, ans, com]
from Filters import CustomFilters from Filters import CustomFilters
the_filters.extend(CustomFilters.get_filters('Person')) the_filters.extend(CustomFilters.get_filters('Person'))
model = gtk.ListStore(str, object) model = gtk.ListStore(str, object)
for f in the_filters: for item in the_filters:
model.append(row=[f.get_name(), f]) model.append(row=[item.get_name(), item])
cell = gtk.CellRendererText() cell = gtk.CellRendererText()
self.filter_obj.pack_start(cell, True) self.filter_obj.pack_start(cell, True)
@@ -101,8 +105,40 @@ class WriterOptionBox:
table.show() table.show()
return table return table
def parse_options(self): def __define_person_filters(self):
"""
Add person filters if the active person is defined
"""
des = GenericFilter()
des.set_name(_("Descendants of %s") %
name_displayer.display(self.person))
des.add_rule(Rules.Person.IsDescendantOf(
[self.person.get_gramps_id(), 1]))
ans = GenericFilter()
ans.set_name(_("Ancestors of %s")
% name_displayer.display(self.person))
ans.add_rule(Rules.Person.IsAncestorOf(
[self.person.get_gramps_id(), 1]))
com = GenericFilter()
com.set_name(_("People with common ancestor with %s") %
name_displayer.display(self.person))
com.add_rule(Rules.Person.HasCommonAncestorWith(
[self.person.get_gramps_id()]))
return [des, ans, com]
def parse_options(self):
"""
Extract the common values from the GTK widgets. After this function
is called, the following variables are defined:
private = privacy requested
restrict = restrict information on living peoplel
cfitler = return the GenericFilter selected
"""
self.restrict = self.restrict_check.get_active() self.restrict = self.restrict_check.get_active()
self.private = self.private_check.get_active() self.private = self.private_check.get_active()

View File

@@ -17,7 +17,12 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
_swiss = [
"""
Provides a rough estimate of the width of a text string.
"""
SWISS = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -45,7 +50,7 @@ _swiss = [
0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.584, 0.611, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.584, 0.611, 0.556,
0.556, 0.556, 0.556, 0.500, 0.556, 0.500] 0.556, 0.556, 0.556, 0.500, 0.556, 0.500]
_swiss_b = [ SWISS_B = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -73,7 +78,7 @@ _swiss_b = [
0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.584, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.584, 0.611, 0.611,
0.611, 0.611, 0.611, 0.556, 0.611, 0.556] 0.611, 0.611, 0.611, 0.556, 0.611, 0.556]
_swiss_i = [ SWISS_I = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -101,7 +106,7 @@ _swiss_i = [
0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.584, 0.611, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.584, 0.611, 0.556,
0.556, 0.556, 0.556, 0.500, 0.556, 0.500] 0.556, 0.556, 0.556, 0.500, 0.556, 0.500]
_swiss_bi = [ SWISS_BI = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -129,7 +134,7 @@ _swiss_bi = [
0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.584, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.584, 0.611, 0.611,
0.611, 0.611, 0.611, 0.556, 0.611, 0.556] 0.611, 0.611, 0.611, 0.556, 0.611, 0.556]
_roman = [ ROMAN = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -157,7 +162,7 @@ _roman = [
0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.564, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.564, 0.500, 0.500,
0.500, 0.500, 0.500, 0.500, 0.500, 0.500] 0.500, 0.500, 0.500, 0.500, 0.500, 0.500]
_roman_b = [ ROMAN_B = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -185,7 +190,7 @@ _roman_b = [
0.500, 0.556, 0.500, 0.500, 0.500, 0.500, 0.500, 0.570, 0.500, 0.556, 0.500, 0.556, 0.500, 0.500, 0.500, 0.500, 0.500, 0.570, 0.500, 0.556,
0.556, 0.556, 0.556, 0.500, 0.556, 0.500] 0.556, 0.556, 0.556, 0.500, 0.556, 0.500]
_roman_i = [ ROMAN_I = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -213,7 +218,7 @@ _roman_i = [
0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.675, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.675, 0.500, 0.500,
0.500, 0.500, 0.500, 0.444, 0.500, 0.444] 0.500, 0.500, 0.500, 0.444, 0.500, 0.444]
_roman_bi = [ ROMAN_BI = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -241,19 +246,22 @@ _roman_bi = [
0.500, 0.556, 0.500, 0.500, 0.500, 0.500, 0.500, 0.570, 0.500, 0.556, 0.500, 0.556, 0.500, 0.500, 0.500, 0.500, 0.500, 0.570, 0.500, 0.556,
0.556, 0.556, 0.556, 0.444, 0.500, 0.444] 0.556, 0.556, 0.556, 0.444, 0.500, 0.444]
_font_array = [ [_swiss, _swiss_b, _swiss_i, _swiss_bi ], FONT_ARRAY = [ [SWISS, SWISS_B, SWISS_I, SWISS_BI ],
[_roman, _roman_b, _roman_i, _roman_bi ] ] [ROMAN, ROMAN_B, ROMAN_I, ROMAN_BI ] ]
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# # string_width
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def string_width(font,text): def string_width(font, text):
"""
returns with width of a string in the specified font
"""
i = font.get_type_face() i = font.get_type_face()
j = font.get_bold() + font.get_italic()*2 j = font.get_bold() + font.get_italic()*2
s = font.get_size() s = font.get_size()
l = _font_array[i][j] l = FONT_ARRAY[i][j]
r = 0 r = 0
for c in text: for c in text:
try: try:
@@ -270,7 +278,7 @@ def string_trim(font, text, width, ellipses = "..."):
i = font.get_type_face() i = font.get_type_face()
j = font.get_bold() + font.get_italic()*2 j = font.get_bold() + font.get_italic()*2
s = font.get_size() s = font.get_size()
l = _font_array[i][j] l = FONT_ARRAY[i][j]
ellipses_length = 0 ellipses_length = 0
# get length of each letter # get length of each letter
for c in ellipses: for c in ellipses:

View File

@@ -23,15 +23,21 @@
import const import const
def help(target): def help(target):
"""
Display the specified target in a help window. If this fails,
open the manual on the web site.
"""
try: try:
import gnome import gnome
gnome.help_display('gramps',target) gnome.help_display('gramps',target)
except: except:
# FIXME: as manual translations appear online, this needs to
# become more complex to directo to the correct language
url(const.url_manual+'en/') url(const.url_manual+'en/')
def url(target): def url(target):
"""
Open the specified URL in a browser. Attempt using the GNOME system if
available, if not, try to find a browser.
"""
try: try:
import gnome import gnome
gnome.url_show(target) gnome.url_show(target)
@@ -40,6 +46,10 @@ def url(target):
def run_browser(url): def run_browser(url):
"""
Attempt of find a browswer, and launch with the browser with the
specified URL
"""
import os import os
search = os.environ['PATH'].split(':') search = os.environ['PATH'].split(':')

View File

@@ -8,7 +8,7 @@
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
@@ -75,7 +75,7 @@ except:
INFO_ICON = gtk.STOCK_DIALOG_INFO INFO_ICON = gtk.STOCK_DIALOG_INFO
# Enabling custom widgets to be included in Glade # Enabling custom widgets to be included in Glade
def get_custom_handler(glade, function_name, widget_name, def get_custom_handler(glade, function_name, widget_name,
str1, str2, int1, int2): str1, str2, int1, int2):
if function_name == 'ValidatableMaskedEntry': if function_name == 'ValidatableMaskedEntry':
return ValidatableMaskedEntry() return ValidatableMaskedEntry()
@@ -164,7 +164,7 @@ class LinkLabel(gtk.EventBox):
class IconButton(gtk.Button): class IconButton(gtk.Button):
def __init__(self, func, handle, icon=gtk.STOCK_EDIT, def __init__(self, func, handle, icon=gtk.STOCK_EDIT,
size=gtk.ICON_SIZE_MENU): size=gtk.ICON_SIZE_MENU):
gtk.Button.__init__(self) gtk.Button.__init__(self)
image = gtk.Image() image = gtk.Image()
@@ -366,7 +366,7 @@ class MonitoredCheckbox:
class MonitoredEntry: class MonitoredEntry:
def __init__(self, obj, set_val, get_val, read_only=False, def __init__(self, obj, set_val, get_val, read_only=False,
autolist=None, changed=None): autolist=None, changed=None):
self.obj = obj self.obj = obj
self.set_val = set_val self.set_val = set_val
@@ -379,7 +379,7 @@ class MonitoredEntry:
self.obj.set_editable(not read_only) self.obj.set_editable(not read_only)
if autolist: if autolist:
AutoComp.fill_entry(obj,autolist) AutoComp.fill_entry(obj, autolist)
def reinit(self, set_val, get_val): def reinit(self, set_val, get_val):
self.set_val = set_val self.set_val = set_val
@@ -432,7 +432,7 @@ class MonitoredText:
class MonitoredType: class MonitoredType:
def __init__(self, obj, set_val, get_val, mapping, custom, readonly=False, def __init__(self, obj, set_val, get_val, mapping, custom, readonly=False,
custom_values=None): custom_values=None):
self.set_val = set_val self.set_val = set_val
self.get_val = get_val self.get_val = get_val
@@ -467,7 +467,7 @@ class MonitoredType:
class MonitoredDataType: class MonitoredDataType:
def __init__(self, obj, set_val, get_val, readonly=False, def __init__(self, obj, set_val, get_val, readonly=False,
custom_values=None, ignore_values=None): custom_values=None, ignore_values=None):
""" """
Constructor for the MonitoredDataType class. Constructor for the MonitoredDataType class.
@@ -509,13 +509,13 @@ class MonitoredDataType:
del map[key] del map[key]
self.sel = AutoComp.StandardCustomSelector( self.sel = AutoComp.StandardCustomSelector(
map, map,
obj, obj,
get_val().get_custom(), get_val().get_custom(),
default, default,
additional=custom_values) additional=custom_values)
self.sel.set_values((int(get_val()),str(get_val()))) self.sel.set_values((int(get_val()), str(get_val())))
self.obj.set_sensitive(not readonly) self.obj.set_sensitive(not readonly)
self.obj.connect('changed', self.on_change) self.obj.connect('changed', self.on_change)
@@ -528,14 +528,14 @@ class MonitoredDataType:
if value[0] == self.get_val().get_custom(): if value[0] == self.get_val().get_custom():
return value return value
else: else:
return (value[0],'') return (value[0], '')
def update(self): def update(self):
val = self.get_val() val = self.get_val()
if type(val) == tuple : if type(val) == tuple :
self.sel.set_values(val) self.sel.set_values(val)
else: else:
self.sel.set_values((int(val),str(val))) self.sel.set_values((int(val), str(val)))
def on_change(self, obj): def on_change(self, obj):
value = self.fix_value(self.sel.get_values()) value = self.fix_value(self.sel.get_values())
@@ -543,7 +543,7 @@ class MonitoredDataType:
class MonitoredMenu: class MonitoredMenu:
def __init__(self, obj, set_val, get_val, mapping, def __init__(self, obj, set_val, get_val, mapping,
readonly=False, changed=None): readonly=False, changed=None):
self.set_val = set_val self.set_val = set_val
self.get_val = get_val self.get_val = get_val
@@ -567,7 +567,7 @@ class MonitoredMenu:
self.data[v] = index self.data[v] = index
index += 1 index += 1
self.obj.set_model(self.model) self.obj.set_model(self.model)
self.obj.set_active(self.data.get(self.get_val(),0)) self.obj.set_active(self.data.get(self.get_val(), 0))
def on_change(self, obj): def on_change(self, obj):
self.set_val(self.model.get_value(obj.get_active_iter(), 1)) self.set_val(self.model.get_value(obj.get_active_iter(), 1))
@@ -622,7 +622,7 @@ class PlaceEntry:
Handles the selection of a existing or new Place. Supports Drag and Drop Handles the selection of a existing or new Place. Supports Drag and Drop
to select a place. to select a place.
""" """
def __init__(self, dbstate, uistate, track, obj, set_val, def __init__(self, dbstate, uistate, track, obj, set_val,
get_val, add_del, share): get_val, add_del, share):
self.obj = obj self.obj = obj
@@ -643,7 +643,7 @@ class PlaceEntry:
if get_val(): if get_val():
self.set_button(True) self.set_button(True)
p = self.db.get_place_from_handle(self.get_val()) p = self.db.get_place_from_handle(self.get_val())
name = "%s [%s]" % (p.get_title(),p.gramps_id) name = "%s [%s]" % (p.get_title(), p.gramps_id)
else: else:
name = u"" name = u""
self.set_button(False) self.set_button(False)
@@ -665,7 +665,7 @@ class PlaceEntry:
obj.set_text(name) obj.set_text(name)
def after_edit(self, place): def after_edit(self, place):
name = "%s [%s]" % (place.get_title(),place.gramps_id) name = "%s [%s]" % (place.get_title(), place.gramps_id)
self.obj.set_text(name) self.obj.set_text(name)
def add_del_clicked(self, obj): def add_del_clicked(self, obj):
@@ -679,7 +679,7 @@ class PlaceEntry:
place = Place() place = Place()
try: try:
EditPlace(self.dbstate, self.uistate, self.track, EditPlace(self.dbstate, self.uistate, self.track,
place, self.place_added) place, self.place_added)
except WindowActiveError: except WindowActiveError:
pass pass
@@ -692,7 +692,7 @@ class PlaceEntry:
def place_added(self, data): def place_added(self, data):
self.set_val(data.handle) self.set_val(data.handle)
self.obj.set_text("%s [%s]" % (data.get_title(),data.gramps_id)) self.obj.set_text("%s [%s]" % (data.get_title(), data.gramps_id))
self.set_button(True) self.set_button(True)
def share_clicked(self, obj): def share_clicked(self, obj):
@@ -701,7 +701,7 @@ class PlaceEntry:
place = self.db.get_place_from_handle(self.get_val()) place = self.db.get_place_from_handle(self.get_val())
try: try:
EditPlace(self.dbstate, self.uistate, self.track, place, EditPlace(self.dbstate, self.uistate, self.track, place,
self.after_edit) self.after_edit)
except WindowActiveError: except WindowActiveError:
pass pass
@@ -721,22 +721,22 @@ class PlaceEntry:
if use_add: if use_add:
image = gtk.Image() image = gtk.Image()
image.set_from_stock(gtk.STOCK_REMOVE,gtk.ICON_SIZE_BUTTON) image.set_from_stock(gtk.STOCK_REMOVE, gtk.ICON_SIZE_BUTTON)
image.show() image.show()
self.add_del.add(image) self.add_del.add(image)
image = gtk.Image() image = gtk.Image()
image.set_from_stock(gtk.STOCK_EDIT,gtk.ICON_SIZE_BUTTON) image.set_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_BUTTON)
image.show() image.show()
self.share.add(image) self.share.add(image)
self.tooltips.set_tip(self.share, _('Edit place')) self.tooltips.set_tip(self.share, _('Edit place'))
self.tooltips.set_tip(self.add_del, _('Remove place')) self.tooltips.set_tip(self.add_del, _('Remove place'))
else: else:
image = gtk.Image() image = gtk.Image()
image.set_from_stock(gtk.STOCK_ADD,gtk.ICON_SIZE_BUTTON) image.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON)
image.show() image.show()
self.add_del.add(image) self.add_del.add(image)
image = gtk.Image() image = gtk.Image()
image.set_from_stock(gtk.STOCK_INDEX,gtk.ICON_SIZE_BUTTON) image.set_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)
image.show() image.show()
self.share.add(image) self.share.add(image)
self.tooltips.set_tip(self.share, _('Select an existing place')) self.tooltips.set_tip(self.share, _('Select an existing place'))
@@ -747,7 +747,7 @@ class Statusbar(gtk.HBox):
Statusbar can have any number of fields included, each identified Statusbar can have any number of fields included, each identified
by it's own bar id. It has by default one field with id = 0. This by it's own bar id. It has by default one field with id = 0. This
defult field is used when no bar id is given in the relevant (push, pop, defult field is used when no bar id is given in the relevant (push, pop,
etc.) methods, thus Statusbar behaves as a single gtk.Statusbar. etc.) methods, thus Statusbar behaves as a single gtk.Statusbar.
To add a new field use the "insert" method. Using the received bar id To add a new field use the "insert" method. Using the received bar id
@@ -757,16 +757,16 @@ class Statusbar(gtk.HBox):
__gtype_name__ = 'Statusbar' __gtype_name__ = 'Statusbar'
##__gsignals__ = { ##__gsignals__ = {
##'text-popped': , ##'text-popped': ,
##'text-pushed': , ##'text-pushed': ,
##} ##}
__gproperties__ = { __gproperties__ = {
'has-resize-grip': (gobject.TYPE_BOOLEAN, 'has-resize-grip': (gobject.TYPE_BOOLEAN,
'Resize grip', 'Resize grip',
'Whether resize grip is visible', 'Whether resize grip is visible',
True, True,
gobject.PARAM_READWRITE), gobject.PARAM_READWRITE),
} }
def __init__(self, min_width=30): def __init__(self, min_width=30):
@@ -812,7 +812,7 @@ class Statusbar(gtk.HBox):
def _set_resize_grip(self): def _set_resize_grip(self):
"""Set the resize grip for the statusbar. """Set the resize grip for the statusbar.
Resize grip is disabled for all statusbars except the last one, Resize grip is disabled for all statusbars except the last one,
which is set according to the "has-resize-grip" propery. which is set according to the "has-resize-grip" propery.
""" """
@@ -824,7 +824,7 @@ class Statusbar(gtk.HBox):
def _set_packing(self): def _set_packing(self):
"""Set packing style of the statusbars. """Set packing style of the statusbars.
All bars are packed with "expand"=True, "fill"=True parameters, All bars are packed with "expand"=True, "fill"=True parameters,
except the last one, which is packed with "expand"=False, "fill"=False. except the last one, which is packed with "expand"=False, "fill"=False.
""" """
@@ -937,12 +937,12 @@ class FadeOut(gobject.GObject):
Call my methods start() and stop() to control the fading. Call my methods start() and stop() to control the fading.
""" """
__gsignals__ = { __gsignals__ = {
'done': (gobject.SIGNAL_RUN_FIRST, 'done': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, gobject.TYPE_NONE,
()), ()),
'color-changed': (gobject.SIGNAL_RUN_FIRST, 'color-changed': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, gobject.TYPE_NONE,
(gtk.gdk.Color,)), (gtk.gdk.Color, )),
} }
# How long time it'll take before we start (in ms) # How long time it'll take before we start (in ms)
@@ -975,8 +975,8 @@ class FadeOut(gobject.GObject):
rs += rinc rs += rinc
gs += ginc gs += ginc
bs += binc bs += binc
col = gtk.gdk.color_parse("#%02X%02X%02X" % (int(rs) >> 8, col = gtk.gdk.color_parse("#%02X%02X%02X" % (int(rs) >> 8,
int(gs) >> 8, int(gs) >> 8,
int(bs) >> 8)) int(bs) >> 8))
self.emit('color-changed', col) self.emit('color-changed', col)
yield True yield True
@@ -993,7 +993,7 @@ class FadeOut(gobject.GObject):
return return
##log.debug('_start_merging: Starting') ##log.debug('_start_merging: Starting')
func = self._merge_colors(self._start_color, func = self._merge_colors(self._start_color,
gtk.gdk.color_parse(self.ERROR_COLOR)).next gtk.gdk.color_parse(self.ERROR_COLOR)).next
self._background_timeout_id = ( self._background_timeout_id = (
gobject.timeout_add(FadeOut.MERGE_COLORS_DELAY, func)) gobject.timeout_add(FadeOut.MERGE_COLORS_DELAY, func))
@@ -1034,7 +1034,7 @@ class FadeOut(gobject.GObject):
self._widget.update_background(self._start_color) self._widget.update_background(self._start_color)
self._done = False self._done = False
if gtk.pygtk_version < (2,8,0): if gtk.pygtk_version < (2, 8, 0):
gobject.type_register(FadeOut) gobject.type_register(FadeOut)
class Tooltip(gtk.Window): class Tooltip(gtk.Window):
@@ -1095,9 +1095,9 @@ class Tooltip(gtk.Window):
# from gtktooltips.c:gtk_tooltips_paint_window # from gtktooltips.c:gtk_tooltips_paint_window
def _on__expose_event(self, window, event): def _on__expose_event(self, window, event):
w, h = window.size_request() w, h = window.size_request()
window.style.paint_flat_box(window.window, window.style.paint_flat_box(window.window,
gtk.STATE_NORMAL, gtk.SHADOW_OUT, gtk.STATE_NORMAL, gtk.SHADOW_OUT,
None, window, "tooltip", None, window, "tooltip",
0, 0, w, h) 0, 0, w, h)
return False return False
@@ -1124,17 +1124,17 @@ class Tooltip(gtk.Window):
if self._show_timeout_id != -1: if self._show_timeout_id != -1:
return return
self._show_timeout_id = gobject.timeout_add(Tooltip.DEFAULT_DELAY, self._show_timeout_id = gobject.timeout_add(Tooltip.DEFAULT_DELAY,
self._real_display, self._real_display,
widget) widget)
# This is tricky and contains quite a few hacks: # This is tricky and contains quite a few hacks:
# An entry contains 2 GdkWindows, one for the background and one for # An entry contains 2 GdkWindows, one for the background and one for
# the text area. The normal one, on which the (normally white) background # the text area. The normal one, on which the (normally white) background
# is drawn can be accessed through entry.window (after realization) # is drawn can be accessed through entry.window (after realization)
# The other window is the one where the cursor and the text is drawn upon, # The other window is the one where the cursor and the text is drawn upon,
# it's refered to as "text area" inside the GtkEntry code and it is called # it's refered to as "text area" inside the GtkEntry code and it is called
# the same here. It can only be accessed through window.get_children()[0], # the same here. It can only be accessed through window.get_children()[0],
# since it's considered private to the entry. # since it's considered private to the entry.
# #
# +-------------------------------------+ # +-------------------------------------+
@@ -1149,7 +1149,7 @@ class Tooltip(gtk.Window):
# +-------------------------------------| # +-------------------------------------|
# #
# So, now we want to put an icon in the edge: # So, now we want to put an icon in the edge:
# An earlier approached by Lorzeno drew the icon directly on the text area, # An earlier approached by Lorzeno drew the icon directly on the text area,
# which is not desired since if the text is using the whole width of the # which is not desired since if the text is using the whole width of the
# entry the icon will be drawn on top of the text. # entry the icon will be drawn on top of the text.
# Now what we want to do is to resize the text area and create a # Now what we want to do is to resize the text area and create a
@@ -1168,7 +1168,7 @@ class Tooltip(gtk.Window):
# #
# When resizing the text area the cursor and text is not moved into the # When resizing the text area the cursor and text is not moved into the
# correct position, it'll still be off by the width of the icon window # correct position, it'll still be off by the width of the icon window
# To fix this we need to call a private function, gtk_entry_recompute, # To fix this we need to call a private function, gtk_entry_recompute,
# a workaround is to call set_visiblity() which calls recompute() # a workaround is to call set_visiblity() which calls recompute()
# internally. # internally.
# #
@@ -1191,11 +1191,11 @@ class IconEntry(object):
self._entry = entry self._entry = entry
self._tooltip = Tooltip(self) self._tooltip = Tooltip(self)
self._locked = False self._locked = False
entry.connect('enter-notify-event', entry.connect('enter-notify-event',
self._on_entry__enter_notify_event) self._on_entry__enter_notify_event)
entry.connect('leave-notify-event', entry.connect('leave-notify-event',
self._on_entry__leave_notify_event) self._on_entry__leave_notify_event)
entry.connect('notify::xalign', entry.connect('notify::xalign',
self._on_entry__notify_xalign) self._on_entry__notify_xalign)
self._update_position() self._update_position()
@@ -1278,17 +1278,17 @@ class IconEntry(object):
self._text_area_pos = self._text_area.get_position() self._text_area_pos = self._text_area.get_position()
# PyGTK should allow default values for most of the values here. # PyGTK should allow default values for most of the values here.
win = gtk.gdk.Window(entry.window, win = gtk.gdk.Window(entry.window,
self._pixw, self._pixh, self._pixw, self._pixh,
gtk.gdk.WINDOW_CHILD, gtk.gdk.WINDOW_CHILD,
(gtk.gdk.ENTER_NOTIFY_MASK | (gtk.gdk.ENTER_NOTIFY_MASK |
gtk.gdk.LEAVE_NOTIFY_MASK), gtk.gdk.LEAVE_NOTIFY_MASK),
gtk.gdk.INPUT_OUTPUT, gtk.gdk.INPUT_OUTPUT,
'icon window', 'icon window',
0, 0, 0, 0,
entry.get_visual(), entry.get_visual(),
entry.get_colormap(), entry.get_colormap(),
gtk.gdk.Cursor(entry.get_display(), gtk.gdk.LEFT_PTR), gtk.gdk.Cursor(entry.get_display(), gtk.gdk.LEFT_PTR),
'', '', True) '', '', True)
self._icon_win = win self._icon_win = win
win.set_user_data(entry) win.set_user_data(entry)
@@ -1365,13 +1365,13 @@ class IconEntry(object):
# Draw background first # Draw background first
color = self._entry.style.base_gc[self._entry.state] color = self._entry.style.base_gc[self._entry.state]
win.draw_rectangle(color, True, win.draw_rectangle(color, True,
0, 0, self._pixw, self._pixh) 0, 0, self._pixw, self._pixh)
# If sensitive draw the icon, regardless of the window emitting the # If sensitive draw the icon, regardless of the window emitting the
# event since makes it a bit smoother on resize # event since makes it a bit smoother on resize
if self._entry.flags() & gtk.SENSITIVE: if self._entry.flags() & gtk.SENSITIVE:
win.draw_pixbuf(None, self._pixbuf, 0, 0, 0, 0, win.draw_pixbuf(None, self._pixbuf, 0, 0, 0, 0,
self._pixw, self._pixh) self._pixw, self._pixh)
def _update_position(self): def _update_position(self):
@@ -1403,17 +1403,17 @@ HAVE_2_6 = gtk.pygtk_version[:2] == (2, 6)
(DIRECTION_LEFT, DIRECTION_RIGHT) = (1, -1) (DIRECTION_LEFT, DIRECTION_RIGHT) = (1, -1)
(INPUT_ASCII_LETTER, (INPUT_ASCII_LETTER,
INPUT_ALPHA, INPUT_ALPHA,
INPUT_ALPHANUMERIC, INPUT_ALPHANUMERIC,
INPUT_DIGIT) = range(4) INPUT_DIGIT) = range(4)
INPUT_FORMATS = { INPUT_FORMATS = {
'0': INPUT_DIGIT, '0': INPUT_DIGIT,
'L': INPUT_ASCII_LETTER, 'L': INPUT_ASCII_LETTER,
'A': INPUT_ALPHANUMERIC, 'A': INPUT_ALPHANUMERIC,
'a': INPUT_ALPHANUMERIC, 'a': INPUT_ALPHANUMERIC,
'&': INPUT_ALPHA, '&': INPUT_ALPHA,
} }
# Todo list: Other usefull Masks # Todo list: Other usefull Masks
@@ -1422,13 +1422,13 @@ INPUT_FORMATS = {
# C - Alpha, optional # C - Alpha, optional
INPUT_CHAR_MAP = { INPUT_CHAR_MAP = {
INPUT_ASCII_LETTER: lambda text: text in string.ascii_letters, INPUT_ASCII_LETTER: lambda text: text in string.ascii_letters,
INPUT_ALPHA: unicode.isalpha, INPUT_ALPHA: unicode.isalpha,
INPUT_ALPHANUMERIC: unicode.isalnum, INPUT_ALPHANUMERIC: unicode.isalnum,
INPUT_DIGIT: unicode.isdigit, INPUT_DIGIT: unicode.isdigit,
} }
(COL_TEXT, (COL_TEXT,
COL_OBJECT) = range(2) COL_OBJECT) = range(2)
class MaskedEntry(gtk.Entry): class MaskedEntry(gtk.Entry):
@@ -1455,7 +1455,7 @@ class MaskedEntry(gtk.Entry):
self.connect('focus-out-event', self._on_focus_out_event) self.connect('focus-out-event', self._on_focus_out_event)
self.connect('move-cursor', self._on_move_cursor) self.connect('move-cursor', self._on_move_cursor)
self.connect('button-press-event', self._on_button_press_event) self.connect('button-press-event', self._on_button_press_event)
self.connect('notify::cursor-position', self.connect('notify::cursor-position',
self._on_notify_cursor_position) self._on_notify_cursor_position)
self._completion = None self._completion = None
@@ -1482,7 +1482,7 @@ class MaskedEntry(gtk.Entry):
# Virtual methods # Virtual methods
# PyGTK 2.6 does not support the virtual method do_size_allocate so # PyGTK 2.6 does not support the virtual method do_size_allocate so
# we have to use the signal instead # we have to use the signal instead
# PyGTK 2.9.0 and later (bug #327715) does not work using the old code, # PyGTK 2.9.0 and later (bug #327715) does not work using the old code,
# so we have to make this conditionally # so we have to make this conditionally
if HAVE_2_6: if HAVE_2_6:
gsignal('size-allocate', 'override') gsignal('size-allocate', 'override')
@@ -1675,7 +1675,7 @@ class MaskedEntry(gtk.Entry):
start, end = self._mask_fields[field] start, end = self._mask_fields[field]
return end - start return end - start
def _shift_text(self, start, end, direction=DIRECTION_LEFT, def _shift_text(self, start, end, direction=DIRECTION_LEFT,
positions=1): positions=1):
""" """
Shift the text, to the right or left, n positions. Note that this Shift the text, to the right or left, n positions. Note that this
@@ -1705,11 +1705,11 @@ class MaskedEntry(gtk.Entry):
# Non-static char shoud be here. Get the next one (depending # Non-static char shoud be here. Get the next one (depending
# on the direction, and the number of positions to skip.) # on the direction, and the number of positions to skip.)
# #
# When shifting left, the next char will be on the right, # When shifting left, the next char will be on the right,
# so, it will be appended, to the new text. # so, it will be appended, to the new text.
# Otherwise, when shifting right, the char will be # Otherwise, when shifting right, the char will be
# prepended. # prepended.
next_pos = self._get_next_non_static_char_pos(i, direction, next_pos = self._get_next_non_static_char_pos(i, direction,
positions-1) positions-1)
# If its outside the bounds of the region, ignore it. # If its outside the bounds of the region, ignore it.
@@ -1737,7 +1737,7 @@ class MaskedEntry(gtk.Entry):
return new_text return new_text
def _get_next_non_static_char_pos(self, pos, direction=DIRECTION_LEFT, def _get_next_non_static_char_pos(self, pos, direction=DIRECTION_LEFT,
skip=0): skip=0):
""" """
Get next non-static char position, skiping some chars, if necessary. Get next non-static char position, skiping some chars, if necessary.
@@ -1827,7 +1827,7 @@ class MaskedEntry(gtk.Entry):
def _get_completion(self): def _get_completion(self):
# Check so we have completion enabled, not this does not # Check so we have completion enabled, not this does not
# depend on the property, the user can manually override it, # depend on the property, the user can manually override it,
# as long as there is a completion object set # as long as there is a completion object set
completion = self.get_completion() completion = self.get_completion()
if completion: if completion:
@@ -1846,7 +1846,7 @@ class MaskedEntry(gtk.Entry):
#completion.set_model(gtk.ListStore(str, object)) #completion.set_model(gtk.ListStore(str, object))
completion.set_model(gtk.ListStore(str)) completion.set_model(gtk.ListStore(str))
completion.set_text_column(0) completion.set_text_column(0)
#completion.connect("match-selected", #completion.connect("match-selected",
#self._on_completion__match_selected) #self._on_completion__match_selected)
self._completion = gtk.Entry.get_completion(self) self._completion = gtk.Entry.get_completion(self)
@@ -1920,7 +1920,7 @@ class MaskedEntry(gtk.Entry):
@param new: The char that wants to be inserted. @param new: The char that wants to be inserted.
@param pos: The position where it wants to be inserted. @param pos: The position where it wants to be inserted.
@return: Returns None if it can be inserted. If it cannot be, @return: Returns None if it can be inserted. If it cannot be,
return the next position where it can be successfuly return the next position where it can be successfuly
inserted. inserted.
""" """
@@ -1954,7 +1954,7 @@ class MaskedEntry(gtk.Entry):
return None return None
# When inserting new text, supose, the entry, at some time is like this, # When inserting new text, supose, the entry, at some time is like this,
# ahd the user presses '0', for instance: # ahd the user presses '0', for instance:
# -------------------------------- # --------------------------------
# | ( 1 2 ) 3 4 5 - 6 7 8 9 | # | ( 1 2 ) 3 4 5 - 6 7 8 9 |
@@ -2105,7 +2105,7 @@ class MaskedEntry(gtk.Entry):
# Shift Left # Shift Left
new_text = (text[:start] + new_text = (text[:start] +
self._shift_text(start, _end, DIRECTION_LEFT, self._shift_text(start, _end, DIRECTION_LEFT,
end-start) + end-start) +
text[_end:]) text[_end:])
@@ -2271,9 +2271,9 @@ class MaskedEntry(gtk.Entry):
else: else:
values[item] = None values[item] = None
model.append((item,)) model.append((item, ))
if gtk.pygtk_version < (2,8,0): if gtk.pygtk_version < (2, 8, 0):
gobject.type_register(MaskedEntry) gobject.type_register(MaskedEntry)
#number = (int, float, long) #number = (int, float, long)
@@ -2293,32 +2293,32 @@ class ValidatableMaskedEntry(MaskedEntry):
__gtype_name__ = 'ValidatableMaskedEntry' __gtype_name__ = 'ValidatableMaskedEntry'
__gsignals__ = { __gsignals__ = {
'content-changed': (gobject.SIGNAL_RUN_FIRST, 'content-changed': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, gobject.TYPE_NONE,
()), ()),
'validation-changed': (gobject.SIGNAL_RUN_FIRST, 'validation-changed': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, gobject.TYPE_NONE,
(gobject.TYPE_BOOLEAN,)), (gobject.TYPE_BOOLEAN, )),
'validate': (gobject.SIGNAL_RUN_LAST, 'validate': (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT,
(gobject.TYPE_PYOBJECT,)), (gobject.TYPE_PYOBJECT, )),
'changed': 'override', 'changed': 'override',
} }
__gproperties__ = { __gproperties__ = {
'data-type': (gobject.TYPE_PYOBJECT, 'data-type': (gobject.TYPE_PYOBJECT,
'Data Type of the widget', 'Data Type of the widget',
'Type object', 'Type object',
gobject.PARAM_READWRITE), gobject.PARAM_READWRITE),
'mandatory': (gobject.TYPE_BOOLEAN, 'mandatory': (gobject.TYPE_BOOLEAN,
'Mandatory', 'Mandatory',
'Mandatory', 'Mandatory',
False, False,
gobject.PARAM_READWRITE), gobject.PARAM_READWRITE),
} }
# FIXME put the data type support back # FIXME put the data type support back
#allowed_data_types = (basestring, datetime.date, datetime.time, #allowed_data_types = (basestring, datetime.date, datetime.time,
#datetime.datetime, object) + number #datetime.datetime, object) + number
def __init__(self, data_type=None, err_color = "#ffd5d5", error_icon=ERROR_ICON): def __init__(self, data_type=None, err_color = "#ffd5d5", error_icon=ERROR_ICON):
@@ -2367,8 +2367,8 @@ class ValidatableMaskedEntry(MaskedEntry):
#if not issubclass(value, self.allowed_data_types): #if not issubclass(value, self.allowed_data_types):
#raise TypeError( #raise TypeError(
#"%s only accept %s types, not %r" #"%s only accept %s types, not %r"
#% (self, #% (self,
#' or '.join([t.__name__ for t in self.allowed_data_types]), #' or '.join([t.__name__ for t in self.allowed_data_types]),
#value)) #value))
self.data_type = value self.data_type = value
elif prop.name == 'mandatory': elif prop.name == 'mandatory':
@@ -2565,10 +2565,9 @@ class ValidatableMaskedEntry(MaskedEntry):
def _on_fadeout__color_changed(self, fadeout, color): def _on_fadeout__color_changed(self, fadeout, color):
self.update_background(color) self.update_background(color)
if gtk.pygtk_version < (2,8,0): if gtk.pygtk_version < (2, 8, 0):
gobject.type_register(ValidatableMaskedEntry) gobject.type_register(ValidatableMaskedEntry)
def main(args): def main(args):
from DateHandler import parser from DateHandler import parser
@@ -2621,7 +2620,7 @@ def main(args):
statusbar.push(1, "A short one", yet_another_statusbar) statusbar.push(1, "A short one", yet_another_statusbar)
last_statusbar = statusbar.insert(min_width=41, ralign=True) last_statusbar = statusbar.insert(min_width=41, ralign=True)
statusbar.push(1, "The last statusbar has always fixed width", statusbar.push(1, "The last statusbar has always fixed width",
last_statusbar) last_statusbar)
# ========================================================================= # =========================================================================

File diff suppressed because it is too large Load Diff