GEDCOM importing working, Plugin dialog working

svn: r1161
This commit is contained in:
Don Allingham 2002-11-03 06:35:06 +00:00
parent 457b760ecd
commit d3301bf9d6
12 changed files with 78 additions and 50 deletions

View File

@ -23,7 +23,7 @@ GRAPHICS := ${wildcard *.xpm} ${wildcard *.png} ${wildcard *.jpg}
# Other stuff that we need to install # Other stuff that we need to install
pkgdata_DATA = ${INTLLIBS} ${GLADEFILES} ${GRAPHICS} gramps.desktop pkgdata_DATA = ${INTLLIBS} ${GLADEFILES} ${GRAPHICS} gramps.desktop
#EXTRA_DIST =@DISTLANGS@ EXTRA_DIST = grampslib.i
all: ${INTLLIBS} grampslib.so all: ${INTLLIBS} grampslib.so
@ -37,7 +37,7 @@ intl22.so: intl.c
$(CC) $(CFLAGS) $(LDFLAGS) @P22_INCLUDES@ -DVER22 -o $@ intl.c $(CC) $(CFLAGS) $(LDFLAGS) @P22_INCLUDES@ -DVER22 -o $@ intl.c
grampslib.so: grampslib.i grampslib.so: grampslib.i
swig -python grampslib.i $(SWIG) -python grampslib.i
$(CC) $(CFLAGS) @P22_INCLUDES@ -o $@ grampslib_wrap.c $(LDFLAGS) $(CC) $(CFLAGS) @P22_INCLUDES@ -o $@ grampslib_wrap.c $(LDFLAGS)
# In principle the following rule slightly violates the automake/autoconf # In principle the following rule slightly violates the automake/autoconf

View File

@ -98,6 +98,7 @@ RELEASE = @RELEASE@
SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@ SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@
SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@ SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@
STRIP = @STRIP@ STRIP = @STRIP@
SWIG = @SWIG@
VERSION = @VERSION@ VERSION = @VERSION@
VERSIONSTRING = @VERSIONSTRING@ VERSIONSTRING = @VERSIONSTRING@
ZIP = @ZIP@ ZIP = @ZIP@
@ -134,6 +135,8 @@ GRAPHICS := ${wildcard *.xpm} ${wildcard *.png} ${wildcard *.jpg}
# Other stuff that we need to install # Other stuff that we need to install
pkgdata_DATA = ${INTLLIBS} ${GLADEFILES} ${GRAPHICS} gramps.desktop pkgdata_DATA = ${INTLLIBS} ${GLADEFILES} ${GRAPHICS} gramps.desktop
EXTRA_DIST = grampslib.i
DIST_SOURCES = intl.c DIST_SOURCES = intl.c
dist_pkgdata_DATA = ${pkgdata_DATA} dist_pkgdata_DATA = ${pkgdata_DATA}
subdir = src subdir = src
@ -446,8 +449,6 @@ uninstall-info: uninstall-info-recursive
uninstall-recursive uninstall-recursive
#EXTRA_DIST =@DISTLANGS@
all: ${INTLLIBS} grampslib.so all: ${INTLLIBS} grampslib.so
# These can prbably be done in a better or more elegant/generic way # 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 $(CC) $(CFLAGS) $(LDFLAGS) @P22_INCLUDES@ -DVER22 -o $@ intl.c
grampslib.so: grampslib.i grampslib.so: grampslib.i
swig -python grampslib.i $(SWIG) -python grampslib.i
$(CC) $(CFLAGS) @P22_INCLUDES@ -o $@ grampslib_wrap.c $(LDFLAGS) $(CC) $(CFLAGS) @P22_INCLUDES@ -o $@ grampslib_wrap.c $(LDFLAGS)
# In principle the following rule slightly violates the automake/autoconf # In principle the following rule slightly violates the automake/autoconf

View File

@ -32,7 +32,7 @@ filters, importer, exporters, and document generators.
# GTK libraries # GTK libraries
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
#import GdkImlib import gobject
import gtk import gtk
import gtk.glade import gtk.glade
@ -44,6 +44,7 @@ import gtk.glade
import traceback import traceback
import os import os
import sys import sys
import string
from re import compile from re import compile
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -54,8 +55,7 @@ from re import compile
import const import const
import Utils import Utils
import GrampsCfg import GrampsCfg
from intl import gettext from intl import gettext as _
_ = gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -76,6 +76,7 @@ _drawdoc = []
_failmsg = [] _failmsg = []
_unavailable = _("No description was provided"), _unavailable = _("No description was provided"),
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Exception Strings # Exception Strings
@ -111,16 +112,23 @@ class PluginDialog:
self.db = db self.db = db
self.active = active self.active = active
self.update = None self.update = None
self.imap = {}
self.dialog = gtk.glade.XML(const.pluginsFile,"report") self.dialog = gtk.glade.XML(const.pluginsFile,"report")
self.dialog.signal_autoconnect({ self.dialog.signal_autoconnect({
"on_report_apply_clicked" : self.on_apply_clicked, "on_report_apply_clicked" : self.on_apply_clicked,
"on_report_ok_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 "destroy_passed_object" : Utils.destroy_passed_object
}) })
self.tree = self.dialog.get_widget("tree") 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.top = self.dialog.get_widget("report")
self.img = self.dialog.get_widget("image") self.img = self.dialog.get_widget("image")
self.description = self.dialog.get_widget("description") self.description = self.dialog.get_widget("description")
@ -143,24 +151,28 @@ class PluginDialog:
else: else:
self.run_tool(self.db,self.active) 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 """Updates the informational display on the right hand side of
the dialog box with the description of the selected report""" the dialog box with the description of the selected report"""
data = self.tree.node_get_row_data(node) store,iter = self.selection.get_selected()
if not data: path = store.get_path(iter)
return if not iter or not self.imap.has_key(path):
task = data[1] return
data = self.imap[path]
title = data[0] title = data[0]
task = data[1]
doc = data[2] doc = data[2]
xpm = data[3] xpm = data[3]
status = data[4] 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.description.set_text(doc)
self.status.set_text(": %s" % status) self.status.set_text(": %s" % status)
self.label.show() self.label.show()
#self.img.load_imlib(image) # self.img.set_from_pixbuf(image)
self.title.set_text(title) self.title.set_text(title)
self.dialog.get_widget("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 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.""" 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 # build the tree items and group together based on the category name
item_hash = {} item_hash = {}
@ -189,17 +203,24 @@ class PluginDialog:
# GtkTreeItems that are associated with it. # GtkTreeItems that are associated with it.
key_list = item_hash.keys() key_list = item_hash.keys()
key_list.sort() key_list.sort()
key_list.reverse()
prev = None prev = None
self.ilist = []
for key in key_list: for key in key_list:
data = item_hash[key] data = item_hash[key]
node = self.tree.insert_node(None,prev,[key],is_leaf=0,expanded=1) node = self.store.insert_after(None,prev)
self.tree.node_set_row_data(node,0) self.store.set(node,0,key)
next = None next = None
data.sort() data.sort()
data.reverse() data.reverse()
for item in data: for item in data:
next = self.tree.insert_node(node,next,[item[0]],is_leaf=1,expanded=1) next = self.store.insert_after(node,next)
self.tree.node_set_row_data(next,item) 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
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -96,7 +96,7 @@ startup = 1
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
progName = "GRAMPS" progName = "GRAMPS"
version = "0.9.0pre1-rc4" version = "0.9.0pre2-rc4"
copyright = "© 2001-2002 Donald N. Allingham" copyright = "© 2001-2002 Donald N. Allingham"
authors = ["Donald N. Allingham", "David Hampton","Donald A. Peterson"] authors = ["Donald N. Allingham", "David Hampton","Donald A. Peterson"]
comments = _("GRAMPS (Genealogical Research and Analysis " comments = _("GRAMPS (Genealogical Research and Analysis "

View File

@ -98,6 +98,7 @@ RELEASE = @RELEASE@
SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@ SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@
SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@ SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@
STRIP = @STRIP@ STRIP = @STRIP@
SWIG = @SWIG@
VERSION = @VERSION@ VERSION = @VERSION@
VERSIONSTRING = @VERSIONSTRING@ VERSIONSTRING = @VERSIONSTRING@
ZIP = @ZIP@ ZIP = @ZIP@

View File

@ -99,6 +99,7 @@ RELEASE = @RELEASE@
SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@ SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@
SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@ SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@
STRIP = @STRIP@ STRIP = @STRIP@
SWIG = @SWIG@
VERSION = @VERSION@ VERSION = @VERSION@
VERSIONSTRING = @VERSIONSTRING@ VERSIONSTRING = @VERSIONSTRING@
ZIP = @ZIP@ ZIP = @ZIP@

View File

@ -98,6 +98,7 @@ RELEASE = @RELEASE@
SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@ SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@
SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@ SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@
STRIP = @STRIP@ STRIP = @STRIP@
SWIG = @SWIG@
VERSION = @VERSION@ VERSION = @VERSION@
VERSIONSTRING = @VERSIONSTRING@ VERSIONSTRING = @VERSIONSTRING@
ZIP = @ZIP@ ZIP = @ZIP@

View File

@ -98,6 +98,7 @@ RELEASE = @RELEASE@
SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@ SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@
SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@ SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@
STRIP = @STRIP@ STRIP = @STRIP@
SWIG = @SWIG@
VERSION = @VERSION@ VERSION = @VERSION@
VERSIONSTRING = @VERSIONSTRING@ VERSIONSTRING = @VERSIONSTRING@
ZIP = @ZIP@ ZIP = @ZIP@

View File

@ -9,7 +9,7 @@
<property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property> <property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property> <property name="modal">False</property>
<property name="default_width">475</property> <property name="default_width">550</property>
<property name="default_height">350</property> <property name="default_height">350</property>
<property name="resizable">True</property> <property name="resizable">True</property>
<property name="destroy_with_parent">False</property> <property name="destroy_with_parent">False</property>
@ -89,14 +89,13 @@
<child> <child>
<widget class="GtkTreeView" id="tree"> <widget class="GtkTreeView" id="tree">
<property name="width_request">175</property> <property name="width_request">200</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="headers_visible">True</property> <property name="headers_visible">False</property>
<property name="rules_hint">False</property> <property name="rules_hint">False</property>
<property name="reorderable">False</property> <property name="reorderable">False</property>
<property name="enable_search">True</property> <property name="enable_search">True</property>
<signal name="tree_select_row" handler="on_tree_select_row"/>
</widget> </widget>
</child> </child>
</widget> </widget>

View File

@ -99,6 +99,7 @@ RELEASE = @RELEASE@
SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@ SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@
SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@ SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@
STRIP = @STRIP@ STRIP = @STRIP@
SWIG = @SWIG@
VERSION = @VERSION@ VERSION = @VERSION@
VERSIONSTRING = @VERSIONSTRING@ VERSIONSTRING = @VERSIONSTRING@
ZIP = @ZIP@ ZIP = @ZIP@

View File

@ -53,11 +53,10 @@ except:
from latin_ansel import ansel_to_latin from latin_ansel import ansel_to_latin
import latin_utf8 import latin_utf8
import intl
import Utils import Utils
from GedcomInfo import * from GedcomInfo import *
from QuestionDialog import ErrorDialog
_ = intl.gettext from intl import gettext as _
ANSEL = 1 ANSEL = 1
UNICODE = 2 UNICODE = 2
@ -127,12 +126,12 @@ def importData(database, filename, cb=None):
g = GedcomParser(database,filename,statusTop) g = GedcomParser(database,filename,statusTop)
except IOError,msg: except IOError,msg:
Utils.destroy_passed_object(statusWindow) Utils.destroy_passed_object(statusWindow)
gnome.ui.GnomeErrorDialog(_("%s could not be opened\n") % filename + str(msg)) ErrorDialog(_("%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)
return return
# except:
# Utils.destroy_passed_object(statusWindow)
# ErrorDialog(_("%s could not be opened\n") % filename)
# return
close = g.parse_gedcom_file() close = g.parse_gedcom_file()
g.resolve_refns() g.resolve_refns()
@ -208,8 +207,6 @@ class GedcomParser:
self.error_text_obj = window.get_widget("error_text") self.error_text_obj = window.get_widget("error_text")
self.window = window self.window = window
self.error_count = 0 self.error_count = 0
self.error_text_obj.set_point(0)
self.error_text_obj.set_word_wrap(0)
map = const.personalConstantAttributes map = const.personalConstantAttributes
self.attrs = map.values() self.attrs = map.values()
@ -281,9 +278,9 @@ class GedcomParser:
self.groups = (int(l[0]),l[1],l[2]) self.groups = (int(l[0]),l[1],l[2])
except: except:
msg = _("Warning: line %d was not understood, so it was ignored.") % self.index 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 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.error_count = self.error_count + 1
self.update(self.errors_obj,str(self.error_count)) self.update(self.errors_obj,str(self.error_count))
self.groups = (999, "XXX", "XXX") self.groups = (999, "XXX", "XXX")
@ -292,15 +289,15 @@ class GedcomParser:
def barf(self,level): def barf(self,level):
msg = _("Warning: line %d was not understood, so it was ignored.") % self.index 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 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.error_count = self.error_count + 1
self.update(self.errors_obj,str(self.error_count)) self.update(self.errors_obj,str(self.error_count))
self.ignore_sub_junk(level) self.ignore_sub_junk(level)
def warn(self,msg): 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.error_count = self.error_count + 1
self.update(self.errors_obj,str(self.error_count)) self.update(self.errors_obj,str(self.error_count))
@ -318,14 +315,15 @@ class GedcomParser:
self.parse_record() self.parse_record()
self.parse_trailer() self.parse_trailer()
except UNEXPECTED_EOF: except UNEXPECTED_EOF:
self.error_text_obj.insert_defaults('Error: Incomplete file') msg = 'Error: Incomplete file\n'
self.error_text_obj.insert_defaults('\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.families_obj,str(self.fam_count))
self.update(self.people_obj,str(self.indi_count)) self.update(self.people_obj,str(self.indi_count))
self.break_note_links() self.break_note_links()
t = time.time() - t 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() return self.close_done.get_active()
def break_note_links(self): def break_note_links(self):
@ -1648,18 +1646,21 @@ class GedcomParser:
self.db.pmapIndex = new_pmax self.db.pmapIndex = new_pmax
global file_top
def readData(database,active_person,cb): def readData(database,active_person,cb):
global db global db
global callback global callback
global file_top
db = database db = database
callback = cb callback = cb
top = gtk.FileSelection("%s - GRAMPS" % _("Import from GEDCOM")) file_top = gtk.FileSelection("%s - GRAMPS" % _("Import from GEDCOM"))
top.hide_fileop_buttons() file_top.hide_fileop_buttons()
top.ok_button.connect_object('clicked', on_ok_clicked,top) file_top.ok_button.connect('clicked', on_ok_clicked)
top.cancel_button.connect_object('clicked', Utils.destroy_passed_object,top) file_top.cancel_button.connect('clicked', Utils.destroy_passed_object)
top.show() file_top.show()
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -1668,10 +1669,10 @@ def readData(database,active_person,cb):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def on_ok_clicked(obj): def on_ok_clicked(obj):
name = obj.get_filename() name = file_top.get_filename()
if name == "": if name == "":
return return
Utils.destroy_passed_object(obj) Utils.destroy_passed_object(file_top)
try: try:
importData(db,name) importData(db,name)
except: except:

View File

@ -98,6 +98,7 @@ RELEASE = @RELEASE@
SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@ SCROLLKEEPER_CONFIG = @SCROLLKEEPER_CONFIG@
SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@ SCROLLKEEPER_REQUIRED = @SCROLLKEEPER_REQUIRED@
STRIP = @STRIP@ STRIP = @STRIP@
SWIG = @SWIG@
VERSION = @VERSION@ VERSION = @VERSION@
VERSIONSTRING = @VERSIONSTRING@ VERSIONSTRING = @VERSIONSTRING@
ZIP = @ZIP@ ZIP = @ZIP@