Example database menu item

svn: r1413
This commit is contained in:
Don Allingham
2003-03-31 01:33:40 +00:00
parent 35b99b1e04
commit 2c5b7b691d
15 changed files with 395 additions and 359 deletions

View File

@@ -78,6 +78,7 @@ GNOMEHELP = @GNOMEHELP@
GNOMEINC = @GNOMEINC@
GNOMELIB = @GNOMELIB@
GPREF = @GPREF@
GPREFIX = @GPREFIX@
HAVE_JW = @HAVE_JW@
HAVE_PKG_CONFIG = @HAVE_PKG_CONFIG@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@

View File

@@ -75,6 +75,14 @@ def nocnv(s):
photo_types = [ "jpeg", "bmp", "pict", "pntg", "tpic", "png", "gif",
"jpg", "tiff", "pcx" ]
file_systems = {
'VFAT' : _('Windows 9x file system'),
'FAT' : _('Windows 9x file system'),
"NTFS" : _('Windows NT file system'),
"ISO9660" : _('CD ROM'),
"SMBFS" : _('Networked Windows file system')
}
#-------------------------------------------------------------------------
#
# GEDCOM events to GRAMPS events conversion
@@ -215,6 +223,8 @@ class GedcomParser:
self.backoff = 0
self.cnv = nocnv
self.geddir = os.path.dirname(os.path.normpath(os.path.abspath(file)))
self.trans = string.maketrans('','')
self.delc = self.trans[0:31]
@@ -231,6 +241,7 @@ class GedcomParser:
self.errors_obj = window.get_widget("errors")
self.close_done = window.get_widget('close_done')
self.error_text_obj = window.get_widget("error_text")
self.info_text_obj = window.get_widget("info_text")
self.error_count = 0
@@ -241,24 +252,34 @@ class GedcomParser:
self.gedattr[map[val]] = val
if self.window:
self.update(self.file_obj,file)
self.update(self.file_obj,os.path.basename(file))
self.code = 0
self.search_paths = []
try:
f = open("/etc/fstab","r")
mypaths = []
f = open("/proc/mounts","r")
for line in f.readlines():
paths = string.split(line)
if len(paths) < 3:
continue
first = string.strip(paths[0])
if first[0] == '#':
continue
if paths[2].upper() in ["VFAT","FAT","NTFS"]:
ftype = paths[2].upper()
if ftype in file_systems.keys():
mypaths.append((paths[1],file_systems[ftype]))
self.search_paths.append(paths[1])
f.close()
if len(mypaths):
self.infomsg(_("Windows style path names for images will use the following mount "
"points to try to find the images. These paths are based on Windows "
"compatible file systems available on this system:\n\n"))
for p in mypaths:
self.infomsg("\t%s : %s\n" % p)
self.infomsg('\n')
self.infomsg(_("Images that cannot be found in the specfied path in the GEDCOM file "
"will be searched for in the same directory in which the GEDCOM file "
"exists (%s).\n") % self.geddir)
except:
pass
@@ -268,23 +289,34 @@ class GedcomParser:
except TypeError:
self.error_text_obj.get_buffer().insert_at_cursor(msg,len(msg))
def infomsg(self,msg):
try:
self.info_text_obj.get_buffer().insert_at_cursor(msg)
except TypeError:
self.info_text_obj.get_buffer().insert_at_cursor(msg,len(msg))
def find_file(self,fullname,altpath):
tries = []
fullname = string.replace(fullname,'\\','/')
tries.append(fullname)
if os.path.isfile(fullname):
return fullname
return (1,fullname)
other = os.path.join(altpath,os.path.basename(fullname))
tries.append(other)
if os.path.isfile(other):
return other
return (1,other)
if len(fullname) > 3:
if fullname[1] == ':':
fullname = fullname[2:]
for path in self.search_paths:
other = os.path.join(path,os.path.basename(fullname))
other = os.path.normpath("%s/%s" % (path,fullname))
tries.append(other)
if os.path.isfile(other):
return other
return ""
return (1,other)
return (0,tries)
else:
return ""
return (0,tries)
def update(self,field,text):
field.set_text(text)
@@ -317,8 +349,6 @@ class GedcomParser:
msg = "%s\n\t%s\n" % (msg,self.text)
self.errmsg(msg)
self.error_count = self.error_count + 1
if self.window:
self.update(self.errors_obj,str(self.error_count))
self.groups = (999, "XXX", "XXX")
self.backoff = 0
return self.groups
@@ -334,7 +364,6 @@ class GedcomParser:
if self.window:
self.errmsg(msg)
self.error_count = self.error_count + 1
self.update(self.errors_obj,str(self.error_count))
else:
print msg
self.ignore_sub_junk(level)
@@ -343,7 +372,6 @@ class GedcomParser:
if self.window:
self.errmsg(msg)
self.error_count = self.error_count + 1
self.update(self.errors_obj,str(self.error_count))
else:
print msg
@@ -371,8 +399,7 @@ class GedcomParser:
t = time.time() - t
msg = _('Import Complete: %d seconds') % t
if self.window:
self.errmsg(msg)
return self.close_done.get_active()
self.infomsg("\n%s" % msg)
else:
print msg
return None
@@ -901,9 +928,12 @@ class GedcomParser:
url.set_description(title)
self.person.addUrl(url)
else:
path = self.find_file(file,self.dir_path)
if path == "":
self.warn(_("Could not import %s") % file + "\n")
(ok,path) = self.find_file(file,self.dir_path)
if not ok:
self.warn(_("Warning: could not import %s") % file + "\n")
self.warn(_("\tThe following paths were tried:\n\t\t"))
self.warn(string.join(path,"\n\t\t"))
self.warn('\n')
else:
photo = RelLib.Photo()
photo.setPath(path)
@@ -936,9 +966,12 @@ class GedcomParser:
self.barf(level+1)
if form:
path = self.find_file(file,self.dir_path)
if path == "":
self.warn(_("Could not import %s") % file + "\n")
(ok,path) = self.find_file(file,self.dir_path)
if not ok:
self.warn(_("Warning: could not import %s") % file + "\n")
self.warn(_("\tThe following paths were tried:\n\t\t"))
self.warn(string.join(path,"\n\t\t"))
self.warn('\n')
else:
photo = RelLib.Photo()
photo.setPath(path)
@@ -971,9 +1004,12 @@ class GedcomParser:
self.barf(level+1)
if form:
path = self.find_file(file,self.dir_path)
if path == "":
self.warn(_("Could not import %s") % file)
(ok,path) = self.find_file(file,self.dir_path)
if not ok:
self.warn(_("Warning: could not import %s") % file + "\n")
self.warn(_("\tThe following paths were tried:\n\t\t"))
self.warn(string.join(path,"\n\t\t"))
self.warn('\n')
else:
photo = RelLib.Photo()
photo.setPath(path)

View File

@@ -9,8 +9,8 @@
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">True</property>
<property name="default_width">500</property>
<property name="default_height">450</property>
<property name="default_width">600</property>
<property name="default_height">500</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
@@ -45,8 +45,8 @@
<widget class="GtkTable" id="table1">
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="n_rows">11</property>
<property name="n_columns">3</property>
<property name="n_rows">10</property>
<property name="n_columns">5</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
@@ -100,12 +100,12 @@
</child>
<child>
<widget class="GtkLabel" id="label8">
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="label" translatable="yes">Version:</property>
<property name="label" translatable="yes">&lt;b&gt;Status&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
@@ -114,34 +114,10 @@
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="label" translatable="yes">Families:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="left_attach">0</property>
<property name="right_attach">5</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@@ -164,20 +140,76 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label11">
<widget class="GtkEntry" id="people">
<property name="visible">True</property>
<property name="label" translatable="yes">Errors:</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="info_text">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">5</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Information&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
@@ -186,15 +218,96 @@
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="left_attach">0</property>
<property name="right_attach">5</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Warning messages&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">5</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="error_text">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">5</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="x_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="file">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
@@ -210,30 +323,30 @@
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="file">
<widget class="GtkEntry" id="encoding">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="max_length">10</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="left_attach">4</property>
<property name="right_attach">5</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
@@ -267,38 +380,41 @@
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="max_length">10</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="left_attach">4</property>
<property name="right_attach">5</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="encoding">
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
<property name="label" translatable="yes">Version:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
@@ -316,84 +432,21 @@
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="left_attach">4</property>
<property name="right_attach">5</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="people">
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="errors">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="close_done">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Close window when complete</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Status&lt;/b&gt;</property>
<property name="label" translatable="yes">Families:</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
@@ -402,73 +455,14 @@
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">3</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Messages&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">3</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="error_text">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
<property name="top_attach">10</property>
<property name="bottom_attach">11</property>
<property name="x_options">fill</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
@@ -482,7 +476,7 @@
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">30</property>
<property name="spacing">12</property>
<child>
<widget class="GtkButton" id="close">
@@ -498,7 +492,7 @@
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>