* src/GrampsLocale.py: handle platform specific locale issues

* src/DateDisplay.py: use GrampsLocale
* src/DateParser.py: use GrampsLocale
* src/DisplayModels.py: use GrampsLocale
* src/Exporter.py: start conversion to Assistant
* src/RecentFiles.py: fcntl option for broken platforms
* src/StartupDialog.py: convert to Assistant
* src/ViewManager.py: remove debug statement
* src/RelLib/_PrimaryObject.py: use GrampsLocale
* src/plugins/Checkpoint.py: use GrampsLocale
* src/plugins/NavWebPage.py: use GrampsLocale


svn: r5644
This commit is contained in:
Don Allingham 2005-12-30 03:57:31 +00:00
parent 1abaa98a40
commit 85fbf617d1
13 changed files with 258 additions and 139 deletions

View File

@ -1,3 +1,17 @@
2005-12-29 Don Allingham <don@gramps-project.org>
* src/GrampsLocale.py: handle platform specific locale issues
* src/DateDisplay.py: use GrampsLocale
* src/DateParser.py: use GrampsLocale
* src/DisplayModels.py: use GrampsLocale
* src/Exporter.py: start conversion to Assistant
* src/PeopleModel.py: use GrampsLocale
* src/RecentFiles.py: fcntl option for broken platforms
* src/StartupDialog.py: convert to Assistant
* src/ViewManager.py: remove debug statement
* src/RelLib/_PrimaryObject.py: use GrampsLocale
* src/plugins/Checkpoint.py: use GrampsLocale
* src/plugins/NavWebPage.py: use GrampsLocale
2005-12-29 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/PedView.py: Use a DrawingArea for nicer person boxes
* src/GrampsDb/_GrampsDbBase.py (_update_reference_map): Sync

View File

@ -29,52 +29,16 @@ __author__ = "Donald N. Allingham"
__version__ = "$Revision$"
import Date
import locale
from gettext import gettext as _
import GrampsLocale
class DateDisplay:
# determine the code set returned by nl_langinfo
_codeset = locale.nl_langinfo(locale.CODESET)
_months = GrampsLocale.long_months
_MONS = GrampsLocale.short_months
# get month information from nl_langinfo. Since nl_langinfo
# returns data in the code set specified by the user, and
# gnome wants unicode, we need to convert each string from
# the native code set into unicode
_months = (
"",
unicode(locale.nl_langinfo(locale.MON_1),_codeset),
unicode(locale.nl_langinfo(locale.MON_2),_codeset),
unicode(locale.nl_langinfo(locale.MON_3),_codeset),
unicode(locale.nl_langinfo(locale.MON_4),_codeset),
unicode(locale.nl_langinfo(locale.MON_5),_codeset),
unicode(locale.nl_langinfo(locale.MON_6),_codeset),
unicode(locale.nl_langinfo(locale.MON_7),_codeset),
unicode(locale.nl_langinfo(locale.MON_8),_codeset),
unicode(locale.nl_langinfo(locale.MON_9),_codeset),
unicode(locale.nl_langinfo(locale.MON_10),_codeset),
unicode(locale.nl_langinfo(locale.MON_11),_codeset),
unicode(locale.nl_langinfo(locale.MON_12),_codeset),
)
_MONS = (
"",
unicode(locale.nl_langinfo(locale.ABMON_1),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_2),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_3),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_4),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_5),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_6),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_7),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_8),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_9),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_10),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_11),_codeset),
unicode(locale.nl_langinfo(locale.ABMON_12),_codeset),
)
_tformat = locale.nl_langinfo(locale.D_FMT).replace('%y','%Y')
_tformat = GrampsLocale.tformat
_hebrew = (
"", "Tishri", "Heshvan", "Kislev", "Tevet", "Shevat",

View File

@ -35,7 +35,6 @@ __version__ = "$Revision$"
#
#-------------------------------------------------------------------------
import re
import locale
import calendar
#-------------------------------------------------------------------------
@ -44,6 +43,7 @@ import calendar
#
#-------------------------------------------------------------------------
import Date
import GrampsLocale
from Errors import DateError
#-------------------------------------------------------------------------
#
@ -80,8 +80,6 @@ class DateParser:
converted, the text string is assigned.
"""
# determine the code set returned by nl_langinfo
_codeset = locale.nl_langinfo(locale.CODESET)
_fmt_parse = re.compile(".*%(\S).*%(\S).*%(\S).*")
# RFC-2822 only uses capitalized English abbreviated names, no locales.
@ -92,32 +90,7 @@ class DateParser:
'Sep' : 9, 'Oct' : 10, 'Nov' : 11, 'Dec' : 12,
}
month_to_int = {
unicode(locale.nl_langinfo(locale.MON_1),_codeset).lower() : 1,
unicode(locale.nl_langinfo(locale.ABMON_1),_codeset).lower() : 1,
unicode(locale.nl_langinfo(locale.MON_2),_codeset).lower() : 2,
unicode(locale.nl_langinfo(locale.ABMON_2),_codeset).lower() : 2,
unicode(locale.nl_langinfo(locale.MON_3),_codeset).lower() : 3,
unicode(locale.nl_langinfo(locale.ABMON_3),_codeset).lower() : 3,
unicode(locale.nl_langinfo(locale.MON_4),_codeset).lower() : 4,
unicode(locale.nl_langinfo(locale.ABMON_4),_codeset).lower() : 4,
unicode(locale.nl_langinfo(locale.MON_5),_codeset).lower() : 5,
unicode(locale.nl_langinfo(locale.ABMON_5),_codeset).lower() : 5,
unicode(locale.nl_langinfo(locale.MON_6),_codeset).lower() : 6,
unicode(locale.nl_langinfo(locale.ABMON_6),_codeset).lower() : 6,
unicode(locale.nl_langinfo(locale.MON_7),_codeset).lower() : 7,
unicode(locale.nl_langinfo(locale.ABMON_7),_codeset).lower() : 7,
unicode(locale.nl_langinfo(locale.MON_8),_codeset).lower() : 8,
unicode(locale.nl_langinfo(locale.ABMON_8),_codeset).lower() : 8,
unicode(locale.nl_langinfo(locale.MON_9),_codeset).lower() : 9,
unicode(locale.nl_langinfo(locale.ABMON_9),_codeset).lower() : 9,
unicode(locale.nl_langinfo(locale.MON_10),_codeset).lower() : 10,
unicode(locale.nl_langinfo(locale.ABMON_10),_codeset).lower(): 10,
unicode(locale.nl_langinfo(locale.MON_11),_codeset).lower() : 11,
unicode(locale.nl_langinfo(locale.ABMON_11),_codeset).lower(): 11,
unicode(locale.nl_langinfo(locale.MON_12),_codeset).lower() : 12,
unicode(locale.nl_langinfo(locale.ABMON_12),_codeset).lower(): 12,
}
month_to_int = GrampsLocale.month_to_int
# modifiers before the date
modifier_to_int = {
@ -215,7 +188,7 @@ class DateParser:
Date.CAL_ISLAMIC : self._parse_islamic,
}
fmt = locale.nl_langinfo(locale.D_FMT)
fmt = GrampsLocale.tformat
match = self._fmt_parse.match(fmt.lower())
if match:
self.dmy = (match.groups() == ('d','m','y'))

View File

@ -47,6 +47,7 @@ import RelLib
import Utils
import ToolTips
import DisplayTrace
import GrampsLocale
_GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]
@ -55,8 +56,7 @@ _GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]
# Localized constants
#
#-------------------------------------------------------------------------
_date_format = locale.nl_langinfo(locale.D_T_FMT)
_codeset = locale.nl_langinfo(locale.CODESET)
_codeset = GrampsLocale.codeset
#-------------------------------------------------------------------------
#
@ -327,8 +327,9 @@ class SourceModel(BaseModel):
return unicode(data[4])
def column_change(self,data):
return unicode(time.strftime(_date_format,time.localtime(data[8])),
_codeset)
return unicode(time.strftime('%x %X',time.localtime(data[8])),
GrampsLocale.codeset)
def sort_change(self,data):
return time.localtime(data[8])
@ -435,7 +436,7 @@ class PlaceModel(BaseModel):
return time.localtime(data[11])
def column_change(self,data):
return unicode(time.strftime(_date_format,time.localtime(data[11])),
return unicode(time.strftime('%x %X',time.localtime(data[11])),
_codeset)
def column_tooltip(self,data):
@ -513,7 +514,7 @@ class MediaModel(BaseModel):
return time.localtime(data[8])
def column_change(self,data):
return unicode(time.strftime(_date_format,time.localtime(data[8])),
return unicode(time.strftime('%x %X',time.localtime(data[8])),
_codeset)
def column_tooltip(self,data):
@ -597,7 +598,7 @@ class EventModel(BaseModel):
return time.localtime(data[11])
def column_change(self,data):
return unicode(time.strftime(_date_format,time.localtime(data[11])),
return unicode(time.strftime('%x %X',time.localtime(data[11])),
_codeset)
def column_tooltip(self,data):

View File

@ -36,7 +36,7 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
import gtk
from gnome.ui import Druid, DruidPageEdge, DruidPageStandard
import Assistant
#-------------------------------------------------------------------------
#
@ -83,31 +83,30 @@ class Exporter:
self.confirm_label = gtk.Label()
self.extra_pages = []
self.w = gtk.Window()
self.w = Assistant.Assistant(_('Saving your data'),None)
self.fg_color = gtk.gdk.color_parse('#7d684a')
self.bg_color = gtk.gdk.color_parse('#e1dbc5')
self.logo = gtk.gdk.pixbuf_new_from_file("%s/gramps.png" % const.rootDir)
self.splash = gtk.gdk.pixbuf_new_from_file("%s/splash.jpg" % const.rootDir)
self.w.set_intro(
_('Under normal circumstances, GRAMPS does not require you '
'to directly save your changes. All changes you make are '
'immediately saved to the database.\n\n'
'This process will help you save a copy of your data '
'in any of the several formats supported by GRAMPS. '
'This can be used to make a copy of your data, backup '
'your data, or convert it to a format that will allow '
'you to transfer it to a different program.\n\n'
'If you change your mind during this process, you '
'can safely press the Cancel button at any time and your '
'present database will still be intact.'))
self.d = Druid()
self.w.add(self.d)
self.w.set_title(_('GRAMPS: Export'))
self.d.add(self.build_info_page())
self.d.add(self.build_format_page())
self.w.add_page(self.build_info_page())
self.w.add_page(self.build_format_page())
self.file_sel_page = self.build_file_sel_page()
self.d.add(self.file_sel_page)
self.d.add(self.build_confirm_page())
self.w.add_page(self.file_sel_page)
self.w.add_page(self.build_confirm_page())
self.last_page = self.build_last_page()
self.d.add(self.last_page)
self.w.add_page(self.last_page)
self.d.set_show_help(True)
self.d.connect('cancel',self.close)
self.d.connect('help',self.help)
self.w.connect("destroy_event",self.close)
self.w.set_transient_for(self.parent_window)
self.w.show_all()
self.w.show()
def close(self,obj,obj2=None):
"""
@ -127,7 +126,7 @@ class Exporter:
This is a static page, nothing fun here :-)
"""
p = DruidPageEdge(0)
p.set_title(_('Saving your data'))
p.set_title()
p.set_title_color(self.fg_color)
p.set_bg_color(self.bg_color)
p.set_logo(self.logo)

168
src/GrampsLocale.py Normal file
View File

@ -0,0 +1,168 @@
# -*- coding: iso-8859-1 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2004-2005 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
import locale
"""
Some OS environments do not support the locale.nl_langinfo() method
of determing month names and other date related information.
If nl_langinfo fails, that means we have to resort to shinanigans with
strftime.
Since these routines return values encoded into selected character
set, we have to convert to unicode.
"""
try:
codeset = locale.nl_langinfo(locale.CODESET)
month_to_int = {
unicode(locale.nl_langinfo(locale.MON_1),codeset).lower() : 1,
unicode(locale.nl_langinfo(locale.ABMON_1),codeset).lower() : 1,
unicode(locale.nl_langinfo(locale.MON_2),codeset).lower() : 2,
unicode(locale.nl_langinfo(locale.ABMON_2),codeset).lower() : 2,
unicode(locale.nl_langinfo(locale.MON_3),codeset).lower() : 3,
unicode(locale.nl_langinfo(locale.ABMON_3),codeset).lower() : 3,
unicode(locale.nl_langinfo(locale.MON_4),codeset).lower() : 4,
unicode(locale.nl_langinfo(locale.ABMON_4),codeset).lower() : 4,
unicode(locale.nl_langinfo(locale.MON_5),codeset).lower() : 5,
unicode(locale.nl_langinfo(locale.ABMON_5),codeset).lower() : 5,
unicode(locale.nl_langinfo(locale.MON_6),codeset).lower() : 6,
unicode(locale.nl_langinfo(locale.ABMON_6),codeset).lower() : 6,
unicode(locale.nl_langinfo(locale.MON_7),codeset).lower() : 7,
unicode(locale.nl_langinfo(locale.ABMON_7),codeset).lower() : 7,
unicode(locale.nl_langinfo(locale.MON_8),codeset).lower() : 8,
unicode(locale.nl_langinfo(locale.ABMON_8),codeset).lower() : 8,
unicode(locale.nl_langinfo(locale.MON_9),codeset).lower() : 9,
unicode(locale.nl_langinfo(locale.ABMON_9),codeset).lower() : 9,
unicode(locale.nl_langinfo(locale.MON_10),codeset).lower() : 10,
unicode(locale.nl_langinfo(locale.ABMON_10),codeset).lower(): 10,
unicode(locale.nl_langinfo(locale.MON_11),codeset).lower() : 11,
unicode(locale.nl_langinfo(locale.ABMON_11),codeset).lower(): 11,
unicode(locale.nl_langinfo(locale.MON_12),codeset).lower() : 12,
unicode(locale.nl_langinfo(locale.ABMON_12),codeset).lower(): 12,
}
long_months = (
"",
unicode(locale.nl_langinfo(locale.MON_1),codeset),
unicode(locale.nl_langinfo(locale.MON_2),codeset),
unicode(locale.nl_langinfo(locale.MON_3),codeset),
unicode(locale.nl_langinfo(locale.MON_4),codeset),
unicode(locale.nl_langinfo(locale.MON_5),codeset),
unicode(locale.nl_langinfo(locale.MON_6),codeset),
unicode(locale.nl_langinfo(locale.MON_7),codeset),
unicode(locale.nl_langinfo(locale.MON_8),codeset),
unicode(locale.nl_langinfo(locale.MON_9),codeset),
unicode(locale.nl_langinfo(locale.MON_10),codeset),
unicode(locale.nl_langinfo(locale.MON_11),codeset),
unicode(locale.nl_langinfo(locale.MON_12),codeset),
)
short_months = (
"",
unicode(locale.nl_langinfo(locale.ABMON_1),codeset),
unicode(locale.nl_langinfo(locale.ABMON_2),codeset),
unicode(locale.nl_langinfo(locale.ABMON_3),codeset),
unicode(locale.nl_langinfo(locale.ABMON_4),codeset),
unicode(locale.nl_langinfo(locale.ABMON_5),codeset),
unicode(locale.nl_langinfo(locale.ABMON_6),codeset),
unicode(locale.nl_langinfo(locale.ABMON_7),codeset),
unicode(locale.nl_langinfo(locale.ABMON_8),codeset),
unicode(locale.nl_langinfo(locale.ABMON_9),codeset),
unicode(locale.nl_langinfo(locale.ABMON_10),codeset),
unicode(locale.nl_langinfo(locale.ABMON_11),codeset),
unicode(locale.nl_langinfo(locale.ABMON_12),codeset),
)
tformat = locale.nl_langinfo(locale.D_FMT).replace('%y','%Y')
except:
import time
codeset = locale.getpreferredencoding()
month_to_int = {
unicode(time.strftime('%B',(0,1,1,1,1,1,1,1,1)),codeset).lower() : 1,
unicode(time.strftime('%b',(0,1,1,1,1,1,1,1,1)),codeset).lower() : 1,
unicode(time.strftime('%B',(0,2,1,1,1,1,1,1,1)),codeset).lower() : 2,
unicode(time.strftime('%b',(0,2,1,1,1,1,1,1,1)),codeset).lower() : 2,
unicode(time.strftime('%B',(0,3,1,1,1,1,1,1,1)),codeset).lower() : 3,
unicode(time.strftime('%b',(0,3,1,1,1,1,1,1,1)),codeset).lower() : 3,
unicode(time.strftime('%B',(0,4,1,1,1,1,1,1,1)),codeset).lower() : 4,
unicode(time.strftime('%b',(0,4,1,1,1,1,1,1,1)),codeset).lower() : 4,
unicode(time.strftime('%B',(0,5,1,1,1,1,1,1,1)),codeset).lower() : 5,
unicode(time.strftime('%b',(0,5,1,1,1,1,1,1,1)),codeset).lower() : 5,
unicode(time.strftime('%B',(0,6,1,1,1,1,1,1,1)),codeset).lower() : 6,
unicode(time.strftime('%b',(0,6,1,1,1,1,1,1,1)),codeset).lower() : 6,
unicode(time.strftime('%B',(0,7,1,1,1,1,1,1,1)),codeset).lower() : 7,
unicode(time.strftime('%b',(0,7,1,1,1,1,1,1,1)),codeset).lower() : 7,
unicode(time.strftime('%B',(0,8,1,1,1,1,1,1,1)),codeset).lower() : 8,
unicode(time.strftime('%b',(0,8,1,1,1,1,1,1,1)),codeset).lower() : 8,
unicode(time.strftime('%B',(0,9,1,1,1,1,1,1,1)),codeset).lower() : 9,
unicode(time.strftime('%b',(0,9,1,1,1,1,1,1,1)),codeset).lower() : 9,
unicode(time.strftime('%B',(0,10,1,1,1,1,1,1,1)),codeset).lower() : 10,
unicode(time.strftime('%b',(0,10,1,1,1,1,1,1,1)),codeset).lower() : 10,
unicode(time.strftime('%B',(0,11,1,1,1,1,1,1,1)),codeset).lower() : 11,
unicode(time.strftime('%b',(0,11,1,1,1,1,1,1,1)),codeset).lower() : 11,
unicode(time.strftime('%B',(0,12,1,1,1,1,1,1,1)),codeset).lower() : 12,
unicode(time.strftime('%b',(0,12,1,1,1,1,1,1,1)),codeset).lower() : 12,
}
long_months = (
"",
unicode(time.strftime('%B',(0,1,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,2,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,3,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,4,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,5,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,6,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,7,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,8,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,9,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,10,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,11,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%B',(0,12,1,1,1,1,1,1,1)),codeset),
)
short_months = (
"",
unicode(time.strftime('%b',(0,1,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,2,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,3,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,4,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,5,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,6,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,7,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,8,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,9,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,10,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,11,1,1,1,1,1,1,1)),codeset),
unicode(time.strftime('%b',(0,12,1,1,1,1,1,1,1)),codeset),
)
if time.strftime('%x',(2005,1,2,1,1,1,1,1,1)) == '2/1/2005':
tformat = '%d/%m/%y'
else:
tformat = '%m/%d/%y'

View File

@ -27,11 +27,11 @@
#-------------------------------------------------------------------------
from gettext import gettext as _
import time
import locale
import cgi
import sets
import sys
import traceback
import locale
#-------------------------------------------------------------------------
#
@ -51,14 +51,14 @@ from RelLib import *
import NameDisplay
import DateHandler
import ToolTips
import GrampsLocale
#-------------------------------------------------------------------------
#
# Localized constants
#
#-------------------------------------------------------------------------
_date_format = locale.nl_langinfo(locale.D_T_FMT)
_codeset = locale.nl_langinfo(locale.CODESET)
_codeset = GrampsLocale.codeset
#-------------------------------------------------------------------------
#
@ -325,8 +325,7 @@ class PeopleModel(gtk.GenericTreeModel):
return data[_ID_COL]
def column_change(self,data,node):
return unicode(time.strftime(_date_format,
time.localtime(data[_CHANGE_COL])),
return unicode(time.strftime('%x %X',time.localtime(data[_CHANGE_COL])),
_codeset)
def column_gender(self,data,node):

View File

@ -28,10 +28,16 @@
#
#-------------------------------------------------------------------------
import os
import fcntl
import time
from xml.parsers.expat import ParserCreate
try:
import fcntl
use_lock = True
except:
use_lock = False
#-------------------------------------------------------------------------
#
# Constants
@ -174,7 +180,8 @@ class GnomeRecentFiles:
Saves the current GNOME RecentFiles collection to the associated file.
"""
xml_file = file(os.path.expanduser(GNOME_FILENAME),'w')
fcntl.lockf(xml_file,fcntl.LOCK_EX)
if use_lock:
fcntl.lockf(xml_file,fcntl.LOCK_EX)
xml_file.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
xml_file.write('<RecentFiles>\n')
index = 0
@ -194,7 +201,8 @@ class GnomeRecentFiles:
xml_file.write(' </Groups>\n')
xml_file.write(' </RecentItem>\n')
xml_file.write('</RecentFiles>\n')
fcntl.lockf(xml_file,fcntl.LOCK_UN)
if use_lock:
fcntl.lockf(xml_file,fcntl.LOCK_UN)
xml_file.close()
#-------------------------------------------------------------------------
@ -251,7 +259,8 @@ class GrampsRecentFiles:
Saves the current GRAMPS RecentFiles collection to the associated file.
"""
xml_file = file(os.path.expanduser(GRAMPS_FILENAME),'w')
fcntl.lockf(xml_file,fcntl.LOCK_EX)
if use_lock:
fcntl.lockf(xml_file,fcntl.LOCK_EX)
xml_file.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
xml_file.write('<RecentFiles>\n')
index = 0
@ -265,7 +274,8 @@ class GrampsRecentFiles:
xml_file.write(' <Timestamp>%d</Timestamp>\n' % item.get_time())
xml_file.write(' </RecentItem>\n')
xml_file.write('</RecentFiles>\n')
fcntl.lockf(xml_file,fcntl.LOCK_UN)
if use_lock:
fcntl.lockf(xml_file,fcntl.LOCK_UN)
xml_file.close()
#-------------------------------------------------------------------------
@ -283,7 +293,8 @@ class GnomeRecentParser:
try:
xml_file = open(os.path.expanduser(GNOME_FILENAME))
fcntl.lockf(xml_file,fcntl.LOCK_SH)
if use_lock:
fcntl.lockf(xml_file,fcntl.LOCK_SH)
p = ParserCreate()
p.StartElementHandler = self.startElement
@ -291,7 +302,8 @@ class GnomeRecentParser:
p.CharacterDataHandler = self.characters
p.ParseFile(xml_file)
fcntl.lockf(xml_file,fcntl.LOCK_UN)
if use_lock:
fcntl.lockf(xml_file,fcntl.LOCK_UN)
xml_file.close()
except:
pass
@ -343,7 +355,8 @@ class GrampsRecentParser:
try:
xml_file = open(os.path.expanduser(GRAMPS_FILENAME))
fcntl.lockf(xml_file,fcntl.LOCK_SH)
if use_lock:
fcntl.lockf(xml_file,fcntl.LOCK_SH)
p = ParserCreate()
p.StartElementHandler = self.startElement
@ -351,7 +364,8 @@ class GrampsRecentParser:
p.CharacterDataHandler = self.characters
p.ParseFile(xml_file)
fcntl.lockf(xml_file,fcntl.LOCK_UN)
if use_lock:
fcntl.lockf(xml_file,fcntl.LOCK_UN)
xml_file.close()
except:
pass

View File

@ -30,7 +30,7 @@ Primary Object class for GRAMPS
#
#-------------------------------------------------------------------------
import time
import locale
import GrampsLocale
#-------------------------------------------------------------------------
#
@ -47,8 +47,7 @@ from _MediaBase import MediaBase
# Localized constants
#
#-------------------------------------------------------------------------
_date_format = locale.nl_langinfo(locale.D_T_FMT)
_codeset = locale.nl_langinfo(locale.CODESET)
_codeset = GrampsLocale.codeset
#-------------------------------------------------------------------------
#
@ -111,8 +110,7 @@ class PrimaryObject(BaseObject,PrivacyBase):
"""
if self.change:
return unicode(time.strftime(_date_format,
time.localtime(self.change)),
return unicode(time.strftime('%x %X',time.localtime(self.change)),
_codeset)
else:
return ''

View File

@ -43,13 +43,6 @@ import gtk.glade
import Assistant
import const
if not const.no_gconf:
try:
import gconf
except ImportError:
import gnome.gconf
gconf = gnome.gconf
import GrampsKeys
from QuestionDialog import ErrorDialog
@ -59,10 +52,6 @@ from QuestionDialog import ErrorDialog
#
#-------------------------------------------------------------------------
if not const.no_gconf:
client = gconf.client_get_default()
client.add_dir("/apps/gramps",gconf.CLIENT_PRELOAD_NONE)
def need_to_run():
val = GrampsKeys.get_startup()
if val < const.startup:
@ -76,6 +65,9 @@ def upgrade_prefs():
On failure, print message and return False.
"""
try:
client = gconf.client_get_default()
client.add_dir("/apps/gramps",gconf.CLIENT_PRELOAD_NONE)
GrampsKeys.save_fprefix(client.get_string('/apps/gramps/fprefix'))
GrampsKeys.save_sprefix(client.get_string('/apps/gramps/sprefix'))
GrampsKeys.save_pprefix(client.get_string('/apps/gramps/pprefix'))
@ -104,10 +96,8 @@ def upgrade_prefs():
toolbar = -1
GrampsKeys.save_toolbar(toolbar)
GrampsKeys.save_toolbar_on(client.get_bool('/apps/gramps/toolbar-on'))
print "Successfully imported preferences from the 1.0.x version."
return True
except:
print "Failed to import preferences from the 1.0.x version."
return False
#-------------------------------------------------------------------------

View File

@ -166,7 +166,6 @@ class ViewManager:
try:
width = GrampsKeys.get_width()
height = GrampsKeys.get_height()
print width,height
self.window.set_default_size(width,height)
except:
self.window.set_default_size(775,500)

View File

@ -237,8 +237,7 @@ class Checkpoint(Tool.Tool):
self.parent.modify_statusbar()
def timestamp(self):
format = locale.nl_langinfo(locale.D_T_FMT)
return unicode(time.strftime(format,time.localtime(time.time())))
return unicode(time.strftime('%x %X',time.localtime(time.time())))
def custom(self,cmd,checkin,cli):
"""

View File

@ -63,6 +63,7 @@ import Utils
import ReportOptions
import ReportUtils
import ImgManip
import GrampsLocale
from QuestionDialog import ErrorDialog, WarningDialog
from NameDisplay import displayer as _nd
from DateHandler import displayer as _dd
@ -282,8 +283,8 @@ class BasePage:
of.write(' </div>\n')
of.write('<div id="navheader">\n')
format = locale.nl_langinfo(locale.D_FMT)
value = time.strftime(format,time.localtime(time.time()))
value = unicode(time.strftime('%x',time.localtime(time.time())),
GrampsLocale.codeset)
msg = _('Generated by <a href="http://gramps-project.org">'
'GRAMPS</a> on %(date)s') % { 'date' : value }