diff --git a/src/DisplayTrace.py b/src/DisplayTrace.py index 97d878cad..5e7485879 100644 --- a/src/DisplayTrace.py +++ b/src/DisplayTrace.py @@ -54,10 +54,11 @@ class DisplayTrace: def __init__(self): data = sys.exc_info() msg = cStringIO.StringIO() - msg.write(_('GRAMPS has encountered an internal error.\n' + msg.write(_('GRAMPS %s has encountered an internal error.\n' 'Please copy the message below and post a bug report ' 'at http://sourceforge.net/projects/gramps or send an ' - 'email message to gramps-users@lists.sourceforge.net\n\n')) + 'email message to gramps-users@lists.sourceforge.net\n\n') + % const.version) traceback.print_exception(data[0],data[1],data[2],None,msg) diff --git a/src/GedcomInfo.py b/src/GedcomInfo.py index bd220ce8f..a2bb202b0 100644 --- a/src/GedcomInfo.py +++ b/src/GedcomInfo.py @@ -19,8 +19,6 @@ # import const -from latin_utf8 import utf8_to_latin -u2l = utf8_to_latin ADOPT_NONE = 0 ADOPT_EVENT = 1 @@ -175,15 +173,13 @@ class GedInfoParser: p.ParseFile(file) def startElement(self,tag,attrs): - tag = u2l(tag) if tag == "target": - name = u2l(attrs['name']) + name = attrs['name'] self.current = GedcomDescription(name) self.parent.add_description(name,self.current) elif tag == "dest": - self.current.set_dest(u2l(attrs['val'])) + self.current.set_dest(attrs['val']) elif tag == "adopt": - val = u2l(attrs['val']) if val == 'none': self.current.set_adopt(ADOPT_NONE) elif val == 'event': @@ -195,10 +191,9 @@ class GedInfoParser: elif val == 'pedigree': self.current.set_adopt(ADOPT_PEDI) elif tag == "conc": - if u2l(attrs['val']) == 'broken': + if attrs['val'] == 'broken': self.current.set_conc(CONC_BROKEN) elif tag == "alternate_names": - val = u2l(attrs['val']) if val == 'none': self.current.set_alt_name(ALT_NAME_NONE) elif val == 'event_aka': @@ -210,13 +205,13 @@ class GedInfoParser: elif val == '_alias': self.current.set_alt_name(ALT_NAME_UALIAS) elif tag == "calendars": - if u2l(attrs['val']) == 'no': + if attrs['val'] == 'no': self.current.set_alt_calendar(CALENDAR_NO) elif tag == "event": - self.current.add_tag_value(u2l(attrs['tag']),u2l(attrs['value'])) + self.current.add_tag_value(attrs['tag'],attrs['value']) elif tag == "object_support": - if u2l(attrs['val']) == 'no': + if attrs['val'] == 'no': self.current.set_obje(OBJE_NO) elif tag == "residence": - if u2l(attrs['val']) == 'place': + if attrs['val'] == 'place': self.current.set_resi(RESIDENCE_PLAC) diff --git a/src/GenericFilter.py b/src/GenericFilter.py index 91216b8f4..292020d82 100644 --- a/src/GenericFilter.py +++ b/src/GenericFilter.py @@ -41,9 +41,6 @@ import os from string import find,join,strip,replace import gtk -from latin_utf8 import utf8_to_latin -u2l = utf8_to_latin - #------------------------------------------------------------------------- # # GRAMPS modules @@ -777,32 +774,30 @@ class FilterParser(handler.ContentHandler): def startElement(self,tag,attrs): if tag == "filter": self.f = GenericFilter() - self.f.set_name(u2l(attrs['name'])) + self.f.set_name(attrs['name']) if attrs.has_key('function'): try: - if int(u2l(attrs['function'])): + if int(attrs['function']): op = 'or' else: op = 'and' except ValueError: - op = u2l(attrs['function']) + op = attrs['function'] self.f.set_logical_op(op) if attrs.has_key('comment'): - self.f.set_comment(u2l(attrs['comment'])) + self.f.set_comment(attrs['comment']) if attrs.has_key('invert'): try: - self.f.set_invert(int(u2l(attrs['invert']))) + self.f.set_invert(int(attrs['invert'])) except ValueError: pass self.gfilter_list.add(self.f) elif tag == "rule": - c = attrs['class'] - name = _(u2l(c)) + name = _(attrs['class']) self.a = [] self.cname = tasks[name] elif tag == "arg": - c = attrs['value'] - self.a.append(u2l(c)) + self.a.append(attrs['value']) def endElement(self,tag): if tag == "rule": diff --git a/src/ListModel.py b/src/ListModel.py index 5bdd1b2c0..9b9dd75fd 100644 --- a/src/ListModel.py +++ b/src/ListModel.py @@ -28,7 +28,6 @@ class ListModel: self.mylist = [TYPE_STRING]*l + [TYPE_PYOBJECT] self.new_model() - self.connect_model() self.selection = self.tree.get_selection() @@ -45,17 +44,21 @@ class ListModel: else: column.set_resizable(gtk.TRUE) cnum = cnum + 1 - tree.append_column(column) + self.tree.append_column(column) + self.column = None num = 0 for name in dlist: - column = tree.get_column(num) + column = self.tree.get_column(num) if name[1] != -1: column.set_sort_column_id(name[1]) - if num == 0: - column.clicked() - num = num + 1 - + if not self.column: + self.column = column + num = num + 1 + + self.connect_model() + self.column.clicked() + if select_func: self.selection.connect('changed',select_func) if event_func: @@ -67,6 +70,7 @@ class ListModel: def connect_model(self): self.tree.set_model(self.model) + self.column.clicked() def get_selected(self): return self.selection.get_selected() diff --git a/src/PaperMenu.py b/src/PaperMenu.py index d2bcf2a3c..d4c8b2261 100644 --- a/src/PaperMenu.py +++ b/src/PaperMenu.py @@ -18,26 +18,45 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -import TextDoc +#------------------------------------------------------------------------- +# +# GNOME modules +# +#------------------------------------------------------------------------- import gtk + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +import TextDoc import GrampsCfg +import const +from intl import gettext as _ -from intl import gettext -_ = gettext +#------------------------------------------------------------------------- +# +# Try to abstract SAX1 from SAX2 +# +#------------------------------------------------------------------------- +try: + from xml.sax import make_parser,handler,SAXParseException +except: + from _xmlplus.sax import make_parser,handler,SAXParseException -paper_sizes = [ - TextDoc.PaperStyle("Letter",27.94,21.59), - TextDoc.PaperStyle("Legal",35.56,21.59), - TextDoc.PaperStyle("A3",42.0,29.7), - TextDoc.PaperStyle("A4",29.7,21.0), - TextDoc.PaperStyle("A5",21.0,14.8), - TextDoc.PaperStyle("B4",35.3,25.0), - TextDoc.PaperStyle("B6",17.6,12.5), - TextDoc.PaperStyle("C4",32.4,22.9), - TextDoc.PaperStyle("C5",22.9,16.2), - TextDoc.PaperStyle("C6",16.2,11.4) - ] +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +paper_sizes = [] +#------------------------------------------------------------------------- +# +# make_paper_menu +# +#------------------------------------------------------------------------- def make_paper_menu(main_menu): index = 0 @@ -53,6 +72,11 @@ def make_paper_menu(main_menu): index = index + 1 main_menu.set_menu(myMenu) +#------------------------------------------------------------------------- +# +# make_orientation_menu +# +#------------------------------------------------------------------------- def make_orientation_menu(main_menu): myMenu = gtk.Menu() @@ -68,3 +92,46 @@ def make_orientation_menu(main_menu): main_menu.set_menu(myMenu) +#------------------------------------------------------------------------- +# +# FilterParser +# +#------------------------------------------------------------------------- +class PageSizeParser(handler.ContentHandler): + """Parses the XML file and builds the list of page sizes""" + + def __init__(self,paper_list): + handler.ContentHandler.__init__(self) + self.paper_list = paper_list + + def setDocumentLocator(self,locator): + self.locator = locator + + def startElement(self,tag,attrs): + if tag == "page": + name = attrs['name'] + height = float(attrs['height']) + width = float(attrs['width']) + self.paper_list.append(TextDoc.PaperStyle(name,height,width)) + +#------------------------------------------------------------------------- +# +# Parse XML file. If failed, used default +# +#------------------------------------------------------------------------- +try: + parser = make_parser() + parser.setContentHandler(PageSizeParser(paper_sizes)) + parser.parse(const.papersize) +except (IOError,OSError,SAXParseException): + paper_sizes = [ + TextDoc.PaperStyle("Letter",27.94,21.59), + TextDoc.PaperStyle("Legal",35.56,21.59), + TextDoc.PaperStyle("A4",29.7,21.0), + TextDoc.PaperStyle("A5",21.0,14.8), + TextDoc.PaperStyle("B4",35.3,25.0), + TextDoc.PaperStyle("B6",17.6,12.5), + TextDoc.PaperStyle("C4",32.4,22.9), + TextDoc.PaperStyle("C5",22.9,16.2), + TextDoc.PaperStyle("C6",16.2,11.4) + ] diff --git a/src/Report.py b/src/Report.py index 4f0fe91dc..2331b61ae 100644 --- a/src/Report.py +++ b/src/Report.py @@ -52,11 +52,7 @@ import TextDoc import StyleEditor import GrampsCfg import PaperMenu -import intl -import latin_utf8 - -u2l = latin_utf8.utf8_to_latin -_ = intl.gettext +from intl import gettext as _ from QuestionDialog import ErrorDialog @@ -1077,7 +1073,7 @@ class TemplateParser(handler.ContentHandler): """ if tag == "template": - self.data[u2l(attrs['title'])] = u2l(attrs['file']) + self.data[attrs['title']] = attrs['file'] try: parser = make_parser() diff --git a/src/const.py b/src/const.py index d8a6cc647..ceaa59bb4 100644 --- a/src/const.py +++ b/src/const.py @@ -30,8 +30,7 @@ import os # internationalization # #------------------------------------------------------------------------- -from intl import gettext -_ = gettext +from intl import gettext as _ #------------------------------------------------------------------------- # @@ -61,6 +60,7 @@ good_xpm = "%s/good.xpm" % rootDir bad_xpm = "%s/bad.xpm" % rootDir caution_xpm = "%s/caution.xpm" % rootDir +papersize = "%s/papersize.xml" % rootDir system_filters = "%s/system_filters.xml" % rootDir custom_filters = "~/.gramps/custom_filters.xml" icon = "%s/gramps.xpm" % rootDir diff --git a/src/papersize.xml b/src/papersize.xml new file mode 100644 index 000000000..ca0b151b0 --- /dev/null +++ b/src/papersize.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/plugins/RelCalc.py b/src/plugins/RelCalc.py index be81fb39c..564e47f2e 100644 --- a/src/plugins/RelCalc.py +++ b/src/plugins/RelCalc.py @@ -20,18 +20,33 @@ "Utilities/Relationship calculator" +#------------------------------------------------------------------------- +# +# Standard python modules +# +#------------------------------------------------------------------------- import os +#------------------------------------------------------------------------- +# +# GNOME libraries +# +#------------------------------------------------------------------------- from gtk import * from gnome.ui import * import gtk.glade +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- + import RelLib import sort -import intl import Utils - -_ = intl.gettext +import ListModel +from intl import gettext as _ #------------------------------------------------------------------------- # @@ -297,7 +312,7 @@ class RelCalc: self.db = database base = os.path.dirname(__file__) - glade_file = base + os.sep + "relcalc.glade" + glade_file = "%s/relcalc.glade" % base self.glade = gtk.glade.XML(glade_file,"relcalc") name = self.person.getPrimaryName().getRegularName() @@ -305,18 +320,16 @@ class RelCalc: self.glade.get_widget("name").set_text(_("Relationship to %s") % name) self.people = self.glade.get_widget("peopleList") - name_list = self.db.getPersonMap().values() - name_list.sort(sort.by_last_name) - index = 0 - self.people.freeze() - for p in name_list: - name = p.getPrimaryName().getName() - birthday = p.getBirth().getDate() - id = p.getId() - self.people.append([name,id,birthday]) - self.people.set_row_data(index,p) - index = index + 1 - self.people.thaw() + self.clist = ListModel.ListModel(self.people, [(_('Name'),3,150),(_('ID'),1,50), + (_('Birthday'),4,150), + ('',-1,0),('',-1,0)]) + self.clist.new_model() + for key in self.db.getPersonKeys(): + p = self.db.getPerson(key) + val = self.db.getPersonDisplay(key) + self.clist.add([val[0],val[1],val[3],val[5],val[6]],p.getId()) + + self.clist.connect_model() self.glade.signal_autoconnect({ "on_close_clicked" : Utils.destroy_passed_object, @@ -331,10 +344,12 @@ class RelCalc: common = [] rank = 9999999 - if len(self.people.selection) == 0: + model,iter = self.clist.get_selected() + if not iter: return - - other_person = self.people.get_row_data(self.people.selection[0]) + + id = self.clist.get_object(iter) + other_person = self.db.getPerson(id) filter(self.person,0,firstList,firstMap) filter(other_person,0,secondList,secondMap) diff --git a/src/plugins/relcalc.glade b/src/plugins/relcalc.glade index d29f64ebe..e51cfba84 100644 --- a/src/plugins/relcalc.glade +++ b/src/plugins/relcalc.glade @@ -108,59 +108,13 @@ GTK_CORNER_TOP_LEFT - + True True - 3 - 236,56,80 - GTK_SELECTION_SINGLE - True - GTK_SHADOW_IN - - - - Name - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - - - - ID - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - - - - Birthday - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - + True + True + False + True