diff --git a/src/Date.py b/src/Date.py
index e8d265c05..e2c97758e 100644
--- a/src/Date.py
+++ b/src/Date.py
@@ -179,6 +179,11 @@ class Date:
""" Returns true if any part of the date is valid"""
return self.start.year != UNDEF or self.start.month != UNDEF or self.start.day != UNDEF
+
+ def getIncomplete(self):
+ return self.range == 0 and self.start.year == UNDEF or \
+ self.start.month == UNDEF or self.start.day == UNDEF
+
def getStopYear(self):
if self.stop == None:
self.stop = SingleDate()
diff --git a/src/DateEdit.py b/src/DateEdit.py
new file mode 100644
index 000000000..d3723d573
--- /dev/null
+++ b/src/DateEdit.py
@@ -0,0 +1,157 @@
+#
+# Gramps - a GTK+/GNOME based genealogy program
+#
+# Copyright (C) 2002 Donald N. Allingham
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+"""
+Adds autocompletion to a GtkEntry box, using the passed list of
+strings as the possible completions.
+"""
+
+import string
+import GdkImlib
+import Date
+
+_good = [
+ "10 10 24 1",
+ " c None",
+ ". c #0EB40E",
+ "+ c #11A711",
+ "@ c #11A211",
+ "# c #0DA10D",
+ "$ c #09CB09",
+ "% c #0BCC0B",
+ "& c #08CD08",
+ "* c #098609",
+ "= c #05E705",
+ "- c #02F502",
+ "; c #07E007",
+ "> c #0A9D0A",
+ ", c #01F901",
+ "' c #00FF00",
+ ") c #01F801",
+ "! c #05E605",
+ "~ c #0AC40A",
+ "{ c #0AC30A",
+ "] c #000000",
+ "^ c #099209",
+ "/ c #08CB08",
+ "( c #033403",
+ "_ c #098509",
+ " .+++@# ",
+ ".$%%%%&* ",
+ "+%===-;> ",
+ "+%=,')!~ ",
+ "+%='')!{] ",
+ "@%-))-;^] ",
+ "#&;!!;/( ",
+ " _>~{^(] ",
+ " ]] ",
+ " "]
+
+_bad = [
+ "10 10 21 1",
+ " c None",
+ ". c #A21818",
+ "+ c #A31818",
+ "@ c #9A1717",
+ "# c #C80E0E",
+ "$ c #C90F0F",
+ "% c #CA0C0C",
+ "& c #E60606",
+ "* c #F40202",
+ "= c #DE0909",
+ "- c #8F0D0D",
+ "; c #F90101",
+ "> c #FF0000",
+ ", c #F80101",
+ "' c #E50707",
+ ") c #C20E0E",
+ "! c #C10E0E",
+ "~ c #000000",
+ "{ c #810C0C",
+ "] c #C80C0C",
+ "^ c #130202",
+ " .++@ ",
+ " #$$$$% ",
+ ".$&&&*=- ",
+ "+$&;>,') ",
+ "+$&>>,'!~ ",
+ "@$*,,*={~ ",
+ " %=''=]^ ",
+ " -)!{^~ ",
+ " ~~ ",
+ " "]
+
+_caution = [
+ "10 10 21 1",
+ " c None",
+ ". c #B0AF28",
+ "+ c #B2B028",
+ "@ c #A9A726",
+ "# c #D1D017",
+ "$ c #D2D118",
+ "% c #D2D114",
+ "& c #EAEA0B",
+ "* c #F6F604",
+ "= c #E3E30F",
+ "- c #979615",
+ "; c #F9F902",
+ "> c #FFFF00",
+ ", c #F9F903",
+ "' c #E9E90B",
+ ") c #CACA18",
+ "! c #C9C918",
+ "~ c #000000",
+ "{ c #898813",
+ "] c #CFCF14",
+ "^ c #151504",
+ " .++@ ",
+ " #$$$$% ",
+ ".$&&&*=- ",
+ "+$&;>,') ",
+ "+$&>>,'!~ ",
+ "@$*,,*={~ ",
+ " %=''=]^ ",
+ " -)!{^~ ",
+ " ~~ ",
+ " "]
+
+
+class DateEdit:
+ def __init__(self,input,output):
+ self.input = input
+ self.output = output
+ self.checkval = Date.Date()
+ self.input.connect('focus-out-event',self.check)
+ self.good = GdkImlib.create_image_from_xpm(_good)
+ self.bad = GdkImlib.create_image_from_xpm(_bad)
+ self.caution = GdkImlib.create_image_from_xpm(_caution)
+ self.check(None,None)
+
+ def check(self,obj,val):
+ text = self.input.get_text()
+ self.checkval.set(text)
+ if not self.checkval.isValid():
+ self.output.load_imlib(self.bad)
+ elif self.checkval.getIncomplete():
+ self.output.load_imlib(self.caution)
+ else:
+ self.output.load_imlib(self.good)
+
+
diff --git a/src/EditPerson.glade b/src/EditPerson.glade
index 7b4c1d251..0304901b3 100644
--- a/src/EditPerson.glade
+++ b/src/EditPerson.glade
@@ -177,7 +177,7 @@
GtkTable
table16
2
- 4
+ 5
False
0
0
@@ -310,6 +310,36 @@
+
+ GtkButton
+ button99
+ 1
+ Invoke birth event editor
+ True
+
+ clicked
+ on_edit_birth_clicked
+
+ Tue, 02 Oct 2001 22:28:32 GMT
+
+
+ GTK_RELIEF_NORMAL
+
+ 4
+ 5
+ 0
+ 1
+ 3
+ 3
+ False
+ False
+ False
+ False
+ True
+ False
+
+
+
GtkCombo
bpcombo
@@ -322,7 +352,7 @@
2
- 4
+ 5
1
2
3
@@ -348,32 +378,21 @@
- GtkButton
- button99
- 1
- Invoke birth event editor
- True
-
- clicked
- on_edit_birth_clicked
-
- Tue, 02 Oct 2001 22:28:32 GMT
-
-
- GTK_RELIEF_NORMAL
+ GnomePixmap
+ birth_stat
3
4
0
1
- 3
- 3
+ 0
+ 0
False
False
- False
+ True
False
True
- False
+ True
diff --git a/src/EditPerson.py b/src/EditPerson.py
index b0e72243d..816886a3f 100644
--- a/src/EditPerson.py
+++ b/src/EditPerson.py
@@ -50,6 +50,7 @@ from RelLib import *
import ImageSelect
import sort
import AutoComp
+from DateEdit import DateEdit
from intl import gettext
_ = gettext
@@ -598,6 +599,7 @@ class EditPerson:
self.bdate.set_text(self.birth.getDate())
self.bplace.set_text(self.birth.getPlaceName())
self.dplace.set_text(prev_dtext)
+ self.bdate_check = DateEdit(self.bdate,self.get_widget("birth_stat"))
# Update death with new values, make sure birth values don't change
if (self.update_death):
diff --git a/src/GrampsCfg.py b/src/GrampsCfg.py
index c2eab05ef..509b60448 100644
--- a/src/GrampsCfg.py
+++ b/src/GrampsCfg.py
@@ -384,6 +384,7 @@ def loadConfig(call):
make_path(os.path.expanduser("~/.gramps"))
make_path(os.path.expanduser("~/.gramps/filters"))
make_path(os.path.expanduser("~/.gramps/plugins"))
+ make_path(os.path.expanduser("~/.gramps/templates"))
#-------------------------------------------------------------------------
#
diff --git a/src/RelImage.py b/src/RelImage.py
index 3ed68639a..f32d3c11f 100644
--- a/src/RelImage.py
+++ b/src/RelImage.py
@@ -57,11 +57,13 @@ def import_media_object(filename,path,base):
if not os.path.exists(filename):
GnomeErrorDialog(_("Could not import %s\nThe file has been moved or deleted") % filename)
return ""
+
+ ext = os.path.splitext(filename)[1]
type = Utils.get_mime_type(filename)
if type[0:5] == "image":
- name = "%s/%s.jpg" % (path,base)
- base = "%s.jpg" % (base)
+ name = "%s/%s%s" % (path,base,ext)
+ #base = "%s%s" % (base,ext)
thumb = "%s/.thumb" % (path)
@@ -76,7 +78,7 @@ def import_media_object(filename,path,base):
return ""
try:
- path = "%s/%s" % (thumb,base)
+ path = "%s/%s.jpg" % (thumb,base)
mk_thumb(filename,path,const.thumbScale)
except:
GnomeErrorDialog(_("Error creating the thumbnail : %s"))
diff --git a/src/Report.py b/src/Report.py
index a404c43f1..766bb5d8f 100644
--- a/src/Report.py
+++ b/src/Report.py
@@ -30,6 +30,16 @@ import Plugins
_ = intl.gettext
+#-------------------------------------------------------------------------
+#
+#
+#
+#-------------------------------------------------------------------------
+try:
+ from xml.sax import make_parser,handler,SAXParseException
+except:
+ from _xmlplus.sax import make_parser,handler,SAXParseException
+
from TextDoc import *
from StyleEditor import *
@@ -40,6 +50,13 @@ from gtk import *
from gnome.ui import *
import libglade
+_default_template = _("Default Template")
+_user_template = _("User Defined Template")
+
+_template_map = {
+ _user_template : None
+ }
+
#------------------------------------------------------------------------
#
# The Report base class. This is a base class for generating
@@ -567,17 +584,48 @@ class ReportDialog:
table.attach(GtkLabel(_("Page Count")),2,1,3,2,FILL,FILL,pad,pad)
table.attach(self.pagecount_menu,3,2,4,2,xpadding=pad,ypadding=pad)
+ def html_file_enable(self,obj):
+ text = obj.get_text()
+ if _template_map.has_key(text):
+ if _template_map[text]:
+ self.html_fileentry.set_sensitive(0)
+ else:
+ self.html_fileentry.set_sensitive(1)
+ else:
+ self.html_fileentry.set_sensitive(0)
+
def setup_html_frame(self):
"""Set up the html frame of the dialog. This sole purpose of
this function is to grab a pointer for later use in the parse
html frame function."""
- hbox = GtkHBox()
- hbox.set_border_width(ReportDialog.border_pad)
- hbox.pack_start(GtkLabel(_("Template")),0,0,5)
+ table = GtkTable(2,2)
+ self.html_frame.add(table)
+ l = GtkLabel(_("Template"))
+ pad = ReportDialog.border_pad
+ l.set_alignment(1.0,0.5)
+ table.attach(l,0,1,0,1,FILL,FILL,pad,pad)
+ self.template_combo = GtkCombo()
+
+ template_list = [ _default_template ]
+ tlist = _template_map.keys()
+ tlist.sort()
+
+ for template in tlist:
+ if template != _user_template:
+ template_list.append(template)
+ template_list.append(_user_template)
+
+ self.template_combo.set_popdown_strings(template_list)
+ self.template_combo.entry.set_editable(0)
+ self.template_combo.entry.connect('changed',self.html_file_enable)
+
+ table.attach(self.template_combo,1,2,0,1,FILL|EXPAND,FILL|EXPAND,pad,pad)
+
+ table.attach(GtkLabel(_("User Template")),0,1,1,2,FILL,FILL,pad,pad)
self.html_fileentry = GnomeFileEntry(_("HTML Template"),_("Choose File"))
- hbox.add(self.html_fileentry)
- self.html_frame.add(hbox)
+ self.html_fileentry.set_sensitive(0)
+ table.attach(self.html_fileentry,1,2,1,2,FILL|EXPAND,FILL|EXPAND,pad,pad)
def setup_report_options_frame(self):
"""Set up the report options frame of the dialog. This
@@ -751,7 +799,15 @@ class ReportDialog:
retrieves a value whether or not the file entry box is
displayed on the screen. The subclass will know whether this
entry was enabled. This is for simplicity of programming."""
- self.template_name = self.html_fileentry.get_full_path(0)
+
+ text = self.template_combo.entry.get_text()
+ if _template_map.has_key(text):
+ if text == _user_template:
+ self.template_name = self.html_fileentry.get_full_path(0)
+ else:
+ self.template_name = "%s/%s" % (const.template_dir,_template_map[text])
+ else:
+ self.template_name = None
def parse_report_options_frame(self):
"""Parse the report options frame of the dialog. Save the
@@ -942,3 +998,33 @@ class DrawReportDialog(ReportDialog):
def make_document(self):
"""Create a document of the type requested by the user."""
self.doc = self.format(self.selected_style,self.paper,self.orien)
+
+class TemplateParser(handler.ContentHandler):
+ def __init__(self,data,path):
+ handler.ContentHandler.__init__(self)
+ self.data = data
+ self.path = path
+
+ def setDocumentLocator(self,locator):
+ self.locator = locator
+
+ def startElement(self,tag,attrs):
+ if tag == "template":
+ self.data[attrs['title']] = "%s/%s" % (path,attrs['file'])
+
+ def characters(self, data):
+ pass
+
+try:
+ parser = make_parser()
+ path = const.template_dir
+ parser.setContentHandler(TemplateParser(_template_map,path))
+ parser.parse("%s/templates.xml" % path)
+ parser = make_parser()
+ path = os.path.expanduser("~/.gramps/templates")
+ parser.setContentHandler(TemplateParser(_template_map,path))
+ parser.parse("%s/templates.xml" % path)
+except (IOError,OSError,SAXParseException):
+ pass
+
+
diff --git a/src/const.py b/src/const.py
index 046711d9e..651e526af 100644
--- a/src/const.py
+++ b/src/const.py
@@ -78,6 +78,7 @@ docgenDir = "%s/docgen" % rootDir
filtersDir = "%s/filters" % rootDir
dataDir = "%s/data" % rootDir
gtkrcFile = "%s/gtkrc" % rootDir
+template_dir = "%s/templates" % dataDir
startup = 1
@@ -87,7 +88,7 @@ startup = 1
#
#-------------------------------------------------------------------------
progName = "gramps"
-version = "0.7.2"
+version = "0.7.3pre"
copyright = "© 2001 Donald N. Allingham"
authors = ["Donald N. Allingham", "David Hampton"]
comments = _("GRAMPS (Genealogical Research and Analysis Management Programming System) is a personal genealogy program.")
diff --git a/src/docgen/HtmlDoc.py b/src/docgen/HtmlDoc.py
index d055820b0..eb5ba408c 100644
--- a/src/docgen/HtmlDoc.py
+++ b/src/docgen/HtmlDoc.py
@@ -45,7 +45,7 @@ _top = [
'
\n',
' \n',
'