From a274422171b695eeab962547c4bd8e62afc89cc9 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 3 Nov 2002 06:35:06 +0000 Subject: [PATCH] GEDCOM importing working, Plugin dialog working svn: r1161 --- src/Makefile.am | 4 +-- src/Makefile.in | 7 +++-- src/Plugins.py | 51 ++++++++++++++++++++++++---------- src/const.py | 2 +- src/data/Makefile.in | 1 + src/data/templates/Makefile.in | 1 + src/docgen/Makefile.in | 1 + src/filters/Makefile.in | 1 + src/plugins.glade | 7 ++--- src/plugins/Makefile.in | 1 + src/plugins/ReadGedcom.py | 51 +++++++++++++++++----------------- src/po/Makefile.in | 1 + 12 files changed, 78 insertions(+), 50 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 392de1c3e..a9dd2dc49 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,7 +23,7 @@ GRAPHICS := ${wildcard *.xpm} ${wildcard *.png} ${wildcard *.jpg} # Other stuff that we need to install pkgdata_DATA = ${INTLLIBS} ${GLADEFILES} ${GRAPHICS} gramps.desktop -#EXTRA_DIST =@DISTLANGS@ +EXTRA_DIST = grampslib.i all: ${INTLLIBS} grampslib.so @@ -37,7 +37,7 @@ intl22.so: intl.c $(CC) $(CFLAGS) $(LDFLAGS) @P22_INCLUDES@ -DVER22 -o $@ intl.c grampslib.so: grampslib.i - swig -python grampslib.i + $(SWIG) -python grampslib.i $(CC) $(CFLAGS) @P22_INCLUDES@ -o $@ grampslib_wrap.c $(LDFLAGS) # In principle the following rule slightly violates the automake/autoconf diff --git a/src/Makefile.in b/src/Makefile.in index cb1733178..9540d46fa 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -98,6 +98,7 @@ RELEASE = @RELEASE@ SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@ SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@ STRIP = @STRIP@ +SWIG = @SWIG@ VERSION = @VERSION@ VERSIONSTRING = @VERSIONSTRING@ ZIP = @ZIP@ @@ -134,6 +135,8 @@ GRAPHICS := ${wildcard *.xpm} ${wildcard *.png} ${wildcard *.jpg} # Other stuff that we need to install pkgdata_DATA = ${INTLLIBS} ${GLADEFILES} ${GRAPHICS} gramps.desktop +EXTRA_DIST = grampslib.i + DIST_SOURCES = intl.c dist_pkgdata_DATA = ${pkgdata_DATA} subdir = src @@ -446,8 +449,6 @@ uninstall-info: uninstall-info-recursive uninstall-recursive -#EXTRA_DIST =@DISTLANGS@ - all: ${INTLLIBS} grampslib.so # These can prbably be done in a better or more elegant/generic way @@ -456,7 +457,7 @@ intl22.so: intl.c $(CC) $(CFLAGS) $(LDFLAGS) @P22_INCLUDES@ -DVER22 -o $@ intl.c grampslib.so: grampslib.i - swig -python grampslib.i + $(SWIG) -python grampslib.i $(CC) $(CFLAGS) @P22_INCLUDES@ -o $@ grampslib_wrap.c $(LDFLAGS) # In principle the following rule slightly violates the automake/autoconf diff --git a/src/Plugins.py b/src/Plugins.py index e86f3df56..71d17bbc7 100644 --- a/src/Plugins.py +++ b/src/Plugins.py @@ -32,7 +32,7 @@ filters, importer, exporters, and document generators. # GTK libraries # #------------------------------------------------------------------------- -#import GdkImlib +import gobject import gtk import gtk.glade @@ -44,6 +44,7 @@ import gtk.glade import traceback import os import sys +import string from re import compile #------------------------------------------------------------------------- @@ -54,8 +55,7 @@ from re import compile import const import Utils import GrampsCfg -from intl import gettext -_ = gettext +from intl import gettext as _ #------------------------------------------------------------------------- # @@ -76,6 +76,7 @@ _drawdoc = [] _failmsg = [] _unavailable = _("No description was provided"), + #------------------------------------------------------------------------- # # Exception Strings @@ -111,16 +112,23 @@ class PluginDialog: self.db = db self.active = active self.update = None + self.imap = {} self.dialog = gtk.glade.XML(const.pluginsFile,"report") self.dialog.signal_autoconnect({ "on_report_apply_clicked" : self.on_apply_clicked, "on_report_ok_clicked" : self.on_apply_clicked, - "on_tree_select_row" : self.on_node_selected, "destroy_passed_object" : Utils.destroy_passed_object }) self.tree = self.dialog.get_widget("tree") + self.store = gtk.TreeStore(gobject.TYPE_STRING) + self.selection = self.tree.get_selection() + self.selection.connect('changed', self.on_node_selected) + col = gtk.TreeViewColumn('',gtk.CellRendererText(),text=0) + self.tree.append_column(col) + self.tree.set_model(self.store) + self.top = self.dialog.get_widget("report") self.img = self.dialog.get_widget("image") self.description = self.dialog.get_widget("description") @@ -143,24 +151,28 @@ class PluginDialog: else: self.run_tool(self.db,self.active) - def on_node_selected(self,obj,node,other): + def on_node_selected(self,obj): """Updates the informational display on the right hand side of the dialog box with the description of the selected report""" - data = self.tree.node_get_row_data(node) - if not data: - return - task = data[1] + store,iter = self.selection.get_selected() + path = store.get_path(iter) + if not iter or not self.imap.has_key(path): + return + data = self.imap[path] + title = data[0] + task = data[1] doc = data[2] xpm = data[3] status = data[4] - #image = GdkImlib.create_image_from_xpm(xpm) + st = string.join(xpm,'\n') + # image = gtk.gdk.pixbuf_new_from_inline(len(st),st,0) self.description.set_text(doc) self.status.set_text(": %s" % status) self.label.show() - #self.img.load_imlib(image) + # self.img.set_from_pixbuf(image) self.title.set_text(title) self.dialog.get_widget("title").set_text(title) @@ -175,6 +187,8 @@ class PluginDialog: Items in the same category are grouped under the same submen. The task_to_call is bound to the 'select' callback of the menu entry.""" + + ilist = [] # build the tree items and group together based on the category name item_hash = {} @@ -189,17 +203,24 @@ class PluginDialog: # GtkTreeItems that are associated with it. key_list = item_hash.keys() key_list.sort() + key_list.reverse() + prev = None + self.ilist = [] for key in key_list: data = item_hash[key] - node = self.tree.insert_node(None,prev,[key],is_leaf=0,expanded=1) - self.tree.node_set_row_data(node,0) + node = self.store.insert_after(None,prev) + self.store.set(node,0,key) next = None data.sort() data.reverse() for item in data: - next = self.tree.insert_node(node,next,[item[0]],is_leaf=1,expanded=1) - self.tree.node_set_row_data(next,item) + next = self.store.insert_after(node,next) + ilist.append((next,item)) + self.store.set(next,0,item[0]) + for next,tab in ilist: + path = self.store.get_path(next) + self.imap[path] = tab #------------------------------------------------------------------------- # diff --git a/src/const.py b/src/const.py index 3fb09ef11..70bc739e5 100644 --- a/src/const.py +++ b/src/const.py @@ -96,7 +96,7 @@ startup = 1 # #------------------------------------------------------------------------- progName = "GRAMPS" -version = "0.9.0pre1-rc4" +version = "0.9.0pre2-rc4" copyright = "© 2001-2002 Donald N. Allingham" authors = ["Donald N. Allingham", "David Hampton","Donald A. Peterson"] comments = _("GRAMPS (Genealogical Research and Analysis " diff --git a/src/data/Makefile.in b/src/data/Makefile.in index bfed43a90..71ac7e014 100644 --- a/src/data/Makefile.in +++ b/src/data/Makefile.in @@ -98,6 +98,7 @@ RELEASE = @RELEASE@ SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@ SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@ STRIP = @STRIP@ +SWIG = @SWIG@ VERSION = @VERSION@ VERSIONSTRING = @VERSIONSTRING@ ZIP = @ZIP@ diff --git a/src/data/templates/Makefile.in b/src/data/templates/Makefile.in index 0d43f0f04..786b30eff 100644 --- a/src/data/templates/Makefile.in +++ b/src/data/templates/Makefile.in @@ -99,6 +99,7 @@ RELEASE = @RELEASE@ SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@ SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@ STRIP = @STRIP@ +SWIG = @SWIG@ VERSION = @VERSION@ VERSIONSTRING = @VERSIONSTRING@ ZIP = @ZIP@ diff --git a/src/docgen/Makefile.in b/src/docgen/Makefile.in index 574ef4223..410a8b2cf 100644 --- a/src/docgen/Makefile.in +++ b/src/docgen/Makefile.in @@ -98,6 +98,7 @@ RELEASE = @RELEASE@ SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@ SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@ STRIP = @STRIP@ +SWIG = @SWIG@ VERSION = @VERSION@ VERSIONSTRING = @VERSIONSTRING@ ZIP = @ZIP@ diff --git a/src/filters/Makefile.in b/src/filters/Makefile.in index dea77d19f..1607b1293 100644 --- a/src/filters/Makefile.in +++ b/src/filters/Makefile.in @@ -98,6 +98,7 @@ RELEASE = @RELEASE@ SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@ SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@ STRIP = @STRIP@ +SWIG = @SWIG@ VERSION = @VERSION@ VERSIONSTRING = @VERSIONSTRING@ ZIP = @ZIP@ diff --git a/src/plugins.glade b/src/plugins.glade index 864243583..2e3ad5e93 100644 --- a/src/plugins.glade +++ b/src/plugins.glade @@ -9,7 +9,7 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False - 475 + 550 350 True False @@ -89,14 +89,13 @@ - 175 + 200 True True - True + False False False True - diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in index 2de692cc5..e7bb641dd 100644 --- a/src/plugins/Makefile.in +++ b/src/plugins/Makefile.in @@ -99,6 +99,7 @@ RELEASE = @RELEASE@ SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@ SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@ STRIP = @STRIP@ +SWIG = @SWIG@ VERSION = @VERSION@ VERSIONSTRING = @VERSIONSTRING@ ZIP = @ZIP@ diff --git a/src/plugins/ReadGedcom.py b/src/plugins/ReadGedcom.py index cd84783bb..d4cccacb8 100644 --- a/src/plugins/ReadGedcom.py +++ b/src/plugins/ReadGedcom.py @@ -53,11 +53,10 @@ except: from latin_ansel import ansel_to_latin import latin_utf8 -import intl import Utils from GedcomInfo import * - -_ = intl.gettext +from QuestionDialog import ErrorDialog +from intl import gettext as _ ANSEL = 1 UNICODE = 2 @@ -127,12 +126,12 @@ def importData(database, filename, cb=None): g = GedcomParser(database,filename,statusTop) except IOError,msg: Utils.destroy_passed_object(statusWindow) - gnome.ui.GnomeErrorDialog(_("%s could not be opened\n") % filename + str(msg)) - return - except: - Utils.destroy_passed_object(statusWindow) - gnome.ui.GnomeErrorDialog(_("%s could not be opened\n") % filename) + ErrorDialog(_("%s could not be opened\n") % filename + str(msg)) return +# except: +# Utils.destroy_passed_object(statusWindow) +# ErrorDialog(_("%s could not be opened\n") % filename) +# return close = g.parse_gedcom_file() g.resolve_refns() @@ -208,8 +207,6 @@ class GedcomParser: self.error_text_obj = window.get_widget("error_text") self.window = window self.error_count = 0 - self.error_text_obj.set_point(0) - self.error_text_obj.set_word_wrap(0) map = const.personalConstantAttributes self.attrs = map.values() @@ -281,9 +278,9 @@ class GedcomParser: self.groups = (int(l[0]),l[1],l[2]) except: msg = _("Warning: line %d was not understood, so it was ignored.") % self.index - self.error_text_obj.insert_defaults(msg) + self.error_text_obj.get_buffer().insert_at_cursor(msg,len(msg)) msg = "\n\t%s\n" % self.text - self.error_text_obj.insert_defaults(msg) + self.error_text_obj.get_buffer().insert_at_cursor(msg,len(msg)) self.error_count = self.error_count + 1 self.update(self.errors_obj,str(self.error_count)) self.groups = (999, "XXX", "XXX") @@ -292,15 +289,15 @@ class GedcomParser: def barf(self,level): msg = _("Warning: line %d was not understood, so it was ignored.") % self.index - self.error_text_obj.insert_defaults(msg) + self.error_text_obj.get_buffer().insert_at_cursor(msg,len(msg)) msg = "\n\t%s\n" % self.text - self.error_text_obj.insert_defaults(msg) + self.error_text_obj.get_buffer().insert_at_cursor(msg,len(msg)) self.error_count = self.error_count + 1 self.update(self.errors_obj,str(self.error_count)) self.ignore_sub_junk(level) def warn(self,msg): - self.error_text_obj.insert_defaults(msg) + self.error_text_obj.get_buffer().insert_at_cursor(msg,len(msg)) self.error_count = self.error_count + 1 self.update(self.errors_obj,str(self.error_count)) @@ -318,14 +315,15 @@ class GedcomParser: self.parse_record() self.parse_trailer() except UNEXPECTED_EOF: - self.error_text_obj.insert_defaults('Error: Incomplete file') - self.error_text_obj.insert_defaults('\n') + msg = 'Error: Incomplete file\n' + self.error_text_obj.get_buffer().insert_at_cursor(msg,len(msg)) self.update(self.families_obj,str(self.fam_count)) self.update(self.people_obj,str(self.indi_count)) self.break_note_links() t = time.time() - t - self.error_text_obj.insert_defaults(_('Import Complete: %d seconds') % t) + msg = _('Import Complete: %d seconds') % t + self.error_text_obj.get_buffer().insert_at_cursor(msg,len(msg)) return self.close_done.get_active() def break_note_links(self): @@ -1648,18 +1646,21 @@ class GedcomParser: self.db.pmapIndex = new_pmax +global file_top + def readData(database,active_person,cb): global db global callback + global file_top db = database callback = cb - top = gtk.FileSelection("%s - GRAMPS" % _("Import from GEDCOM")) - top.hide_fileop_buttons() - top.ok_button.connect_object('clicked', on_ok_clicked,top) - top.cancel_button.connect_object('clicked', Utils.destroy_passed_object,top) - top.show() + file_top = gtk.FileSelection("%s - GRAMPS" % _("Import from GEDCOM")) + file_top.hide_fileop_buttons() + file_top.ok_button.connect('clicked', on_ok_clicked) + file_top.cancel_button.connect('clicked', Utils.destroy_passed_object) + file_top.show() #------------------------------------------------------------------------- # @@ -1668,10 +1669,10 @@ def readData(database,active_person,cb): #------------------------------------------------------------------------- def on_ok_clicked(obj): - name = obj.get_filename() + name = file_top.get_filename() if name == "": return - Utils.destroy_passed_object(obj) + Utils.destroy_passed_object(file_top) try: importData(db,name) except: diff --git a/src/po/Makefile.in b/src/po/Makefile.in index 1d351bc20..e73ef2489 100644 --- a/src/po/Makefile.in +++ b/src/po/Makefile.in @@ -98,6 +98,7 @@ RELEASE = @RELEASE@ SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@ SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@ STRIP = @STRIP@ +SWIG = @SWIG@ VERSION = @VERSION@ VERSIONSTRING = @VERSIONSTRING@ ZIP = @ZIP@