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
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

View File

@ -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

View File

@ -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
#-------------------------------------------------------------------------
#

View File

@ -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 "

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</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="resizable">True</property>
<property name="destroy_with_parent">False</property>
@ -89,14 +89,13 @@
<child>
<widget class="GtkTreeView" id="tree">
<property name="width_request">175</property>
<property name="width_request">200</property>
<property name="visible">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="reorderable">False</property>
<property name="enable_search">True</property>
<signal name="tree_select_row" handler="on_tree_select_row"/>
</widget>
</child>
</widget>

View File

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

View File

@ -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:

View File

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