Built in web page templates, Date indicators

svn: r852
This commit is contained in:
Don Allingham 2002-03-21 03:04:13 +00:00
parent 3afd7ea406
commit 6b921b3d97
14 changed files with 398 additions and 82 deletions

View File

@ -179,6 +179,11 @@ class Date:
""" Returns true if any part of the date is valid""" """ 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 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): def getStopYear(self):
if self.stop == None: if self.stop == None:
self.stop = SingleDate() self.stop = SingleDate()

157
gramps/src/DateEdit.py Normal file
View File

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

View File

@ -177,7 +177,7 @@
<class>GtkTable</class> <class>GtkTable</class>
<name>table16</name> <name>table16</name>
<rows>2</rows> <rows>2</rows>
<columns>4</columns> <columns>5</columns>
<homogeneous>False</homogeneous> <homogeneous>False</homogeneous>
<row_spacing>0</row_spacing> <row_spacing>0</row_spacing>
<column_spacing>0</column_spacing> <column_spacing>0</column_spacing>
@ -310,6 +310,36 @@
</child> </child>
</widget> </widget>
<widget>
<class>GtkButton</class>
<name>button99</name>
<border_width>1</border_width>
<tooltip>Invoke birth event editor</tooltip>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_edit_birth_clicked</handler>
<object>editPerson</object>
<last_modification_time>Tue, 02 Oct 2001 22:28:32 GMT</last_modification_time>
</signal>
<label>Edit</label>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<left_attach>4</left_attach>
<right_attach>5</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>3</xpad>
<ypad>3</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget> <widget>
<class>GtkCombo</class> <class>GtkCombo</class>
<name>bpcombo</name> <name>bpcombo</name>
@ -322,7 +352,7 @@
<items></items> <items></items>
<child> <child>
<left_attach>2</left_attach> <left_attach>2</left_attach>
<right_attach>4</right_attach> <right_attach>5</right_attach>
<top_attach>1</top_attach> <top_attach>1</top_attach>
<bottom_attach>2</bottom_attach> <bottom_attach>2</bottom_attach>
<xpad>3</xpad> <xpad>3</xpad>
@ -348,32 +378,21 @@
</widget> </widget>
<widget> <widget>
<class>GtkButton</class> <class>GnomePixmap</class>
<name>button99</name> <name>birth_stat</name>
<border_width>1</border_width>
<tooltip>Invoke birth event editor</tooltip>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_edit_birth_clicked</handler>
<object>editPerson</object>
<last_modification_time>Tue, 02 Oct 2001 22:28:32 GMT</last_modification_time>
</signal>
<label>Edit</label>
<relief>GTK_RELIEF_NORMAL</relief>
<child> <child>
<left_attach>3</left_attach> <left_attach>3</left_attach>
<right_attach>4</right_attach> <right_attach>4</right_attach>
<top_attach>0</top_attach> <top_attach>0</top_attach>
<bottom_attach>1</bottom_attach> <bottom_attach>1</bottom_attach>
<xpad>3</xpad> <xpad>0</xpad>
<ypad>3</ypad> <ypad>0</ypad>
<xexpand>False</xexpand> <xexpand>False</xexpand>
<yexpand>False</yexpand> <yexpand>False</yexpand>
<xshrink>False</xshrink> <xshrink>True</xshrink>
<yshrink>False</yshrink> <yshrink>False</yshrink>
<xfill>True</xfill> <xfill>True</xfill>
<yfill>False</yfill> <yfill>True</yfill>
</child> </child>
</widget> </widget>
</widget> </widget>

View File

@ -50,6 +50,7 @@ from RelLib import *
import ImageSelect import ImageSelect
import sort import sort
import AutoComp import AutoComp
from DateEdit import DateEdit
from intl import gettext from intl import gettext
_ = gettext _ = gettext
@ -598,6 +599,7 @@ class EditPerson:
self.bdate.set_text(self.birth.getDate()) self.bdate.set_text(self.birth.getDate())
self.bplace.set_text(self.birth.getPlaceName()) self.bplace.set_text(self.birth.getPlaceName())
self.dplace.set_text(prev_dtext) 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 # Update death with new values, make sure birth values don't change
if (self.update_death): if (self.update_death):

View File

@ -384,6 +384,7 @@ def loadConfig(call):
make_path(os.path.expanduser("~/.gramps")) make_path(os.path.expanduser("~/.gramps"))
make_path(os.path.expanduser("~/.gramps/filters")) make_path(os.path.expanduser("~/.gramps/filters"))
make_path(os.path.expanduser("~/.gramps/plugins")) make_path(os.path.expanduser("~/.gramps/plugins"))
make_path(os.path.expanduser("~/.gramps/templates"))
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -57,11 +57,13 @@ def import_media_object(filename,path,base):
if not os.path.exists(filename): if not os.path.exists(filename):
GnomeErrorDialog(_("Could not import %s\nThe file has been moved or deleted") % filename) GnomeErrorDialog(_("Could not import %s\nThe file has been moved or deleted") % filename)
return "" return ""
ext = os.path.splitext(filename)[1]
type = Utils.get_mime_type(filename) type = Utils.get_mime_type(filename)
if type[0:5] == "image": if type[0:5] == "image":
name = "%s/%s.jpg" % (path,base) name = "%s/%s%s" % (path,base,ext)
base = "%s.jpg" % (base) #base = "%s%s" % (base,ext)
thumb = "%s/.thumb" % (path) thumb = "%s/.thumb" % (path)
@ -76,7 +78,7 @@ def import_media_object(filename,path,base):
return "" return ""
try: try:
path = "%s/%s" % (thumb,base) path = "%s/%s.jpg" % (thumb,base)
mk_thumb(filename,path,const.thumbScale) mk_thumb(filename,path,const.thumbScale)
except: except:
GnomeErrorDialog(_("Error creating the thumbnail : %s")) GnomeErrorDialog(_("Error creating the thumbnail : %s"))

View File

@ -30,6 +30,16 @@ import Plugins
_ = intl.gettext _ = intl.gettext
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
try:
from xml.sax import make_parser,handler,SAXParseException
except:
from _xmlplus.sax import make_parser,handler,SAXParseException
from TextDoc import * from TextDoc import *
from StyleEditor import * from StyleEditor import *
@ -40,6 +50,13 @@ from gtk import *
from gnome.ui import * from gnome.ui import *
import libglade 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 # 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(GtkLabel(_("Page Count")),2,1,3,2,FILL,FILL,pad,pad)
table.attach(self.pagecount_menu,3,2,4,2,xpadding=pad,ypadding=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): def setup_html_frame(self):
"""Set up the html frame of the dialog. This sole purpose of """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 this function is to grab a pointer for later use in the parse
html frame function.""" html frame function."""
hbox = GtkHBox() table = GtkTable(2,2)
hbox.set_border_width(ReportDialog.border_pad) self.html_frame.add(table)
hbox.pack_start(GtkLabel(_("Template")),0,0,5) 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")) self.html_fileentry = GnomeFileEntry(_("HTML Template"),_("Choose File"))
hbox.add(self.html_fileentry) self.html_fileentry.set_sensitive(0)
self.html_frame.add(hbox) table.attach(self.html_fileentry,1,2,1,2,FILL|EXPAND,FILL|EXPAND,pad,pad)
def setup_report_options_frame(self): def setup_report_options_frame(self):
"""Set up the report options frame of the dialog. This """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 retrieves a value whether or not the file entry box is
displayed on the screen. The subclass will know whether this displayed on the screen. The subclass will know whether this
entry was enabled. This is for simplicity of programming.""" 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): def parse_report_options_frame(self):
"""Parse the report options frame of the dialog. Save the """Parse the report options frame of the dialog. Save the
@ -942,3 +998,33 @@ class DrawReportDialog(ReportDialog):
def make_document(self): def make_document(self):
"""Create a document of the type requested by the user.""" """Create a document of the type requested by the user."""
self.doc = self.format(self.selected_style,self.paper,self.orien) 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

View File

@ -78,6 +78,7 @@ docgenDir = "%s/docgen" % rootDir
filtersDir = "%s/filters" % rootDir filtersDir = "%s/filters" % rootDir
dataDir = "%s/data" % rootDir dataDir = "%s/data" % rootDir
gtkrcFile = "%s/gtkrc" % rootDir gtkrcFile = "%s/gtkrc" % rootDir
template_dir = "%s/templates" % dataDir
startup = 1 startup = 1
@ -87,7 +88,7 @@ startup = 1
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
progName = "gramps" progName = "gramps"
version = "0.7.2" version = "0.7.3pre"
copyright = "© 2001 Donald N. Allingham" copyright = "© 2001 Donald N. Allingham"
authors = ["Donald N. Allingham", "David Hampton"] authors = ["Donald N. Allingham", "David Hampton"]
comments = _("GRAMPS (Genealogical Research and Analysis Management Programming System) is a personal genealogy program.") comments = _("GRAMPS (Genealogical Research and Analysis Management Programming System) is a personal genealogy program.")

View File

@ -45,7 +45,7 @@ _top = [
' <TITLE>\n', ' <TITLE>\n',
' </TITLE>\n', ' </TITLE>\n',
' <STYLE type="text/css">\n', ' <STYLE type="text/css">\n',
' <!--\n', ' <!--\n',
' BODY { background-color: #ffffff }\n', ' BODY { background-color: #ffffff }\n',
' .parent_name { font-family: Arial; font-style: bold }\n', ' .parent_name { font-family: Arial; font-style: bold }\n',
' .child_name { font-family: Arial; font-style: bold }\n', ' .child_name { font-family: Arial; font-style: bold }\n',

Binary file not shown.

View File

@ -1,55 +1,100 @@
/* XPM */ /* XPM */
static char * gramps_xpm[] = { static char * gramps_xpm[] = {
"48 48 5 1", "48 48 50 1",
" c None", " c None",
". c #999999", ". c #B39169",
"+ c #FFFFCC", "+ c #E8D3B9",
"@ c #000000", "@ c #E8D3B8",
"# c #CCCCCC", "# c #E8D2B7",
" ", "$ c #E7D2B6",
" ", "% c #E7D1B6",
"& c #E7D1B5",
"* c #E7D1B4",
"= c #000000",
"- c #E7D0B4",
"; c #E6D0B3",
"> c #EAD7BE",
", c #EAD6BE",
"' c #EAD6BD",
") c #E9D6BC",
"! c #E9D5BC",
"~ c #E9D5BB",
"{ c #E9D4BA",
"] c #E8D4B9",
"^ c #E6CFB2",
"/ c #E6CFB1",
"( c #E6CEB1",
"_ c #E5CEB0",
": c #E5CDAF",
"< c #E5CDAE",
"[ c #E5CCAE",
"} c #EBD9C1",
"| c #EBD8C1",
"1 c #EBD8C0",
"2 c #EAD8C0",
"3 c #EAD7BF",
"4 c #E4CCAD",
"5 c #E4CCAC",
"6 c #E4CBAC",
"7 c #E4CBAB",
"8 c #E4CAAA",
"9 c #E3CAAA",
"0 c #E3CAA9",
"a c #E3C9A9",
"b c #E3C9A8",
"c c #E3C8A7",
"d c #E2C8A7",
"e c #E2C8A6",
"f c #E2C7A6",
"g c #E2C7A5",
"h c #E2C7A4",
"i c #E2C6A4",
"j c #E1C6A3",
"k c #E1C5A2",
" ", " ",
" ", " ",
" ", " ",
" ", " ",
" .......... ", " .......... ",
" .++++++++. ", " .+@@##$%&. ",
" .++++++++. ", " .@@##$%&*.= ",
" @@@.++++++++. ", " ===.@##$%&*-.= ",
" @##.++++++++. ", " = .##$%&*-;.= ",
" @# .++++++++. ", " = .#$%&*-;;.= ",
" .......... @# .......... ", " .......... = ..........= ",
" .++++++++. @# ", " .>,')!~~{. = ======== ",
" .++++++++. @# ", " .,')!~~{{.= = ",
" @@@.++++++++.@@@@# ", " ===.')!~~{{].==== ",
" @##.++++++++.###@# .......... ", " = .)!~~{{]+.= = .......... ",
" @# .++++++++. @# .++++++++. ", " = .!~~{{]+@.= = .;;^^/(__. ",
" @# .......... @# .++++++++. ", " = ..........= = .;^^/(__:.= ",
" @# @@@.++++++++. ", " = ======== ===.^^/(__::.= ",
" @# ##.++++++++. ", " = .^/(__::<.= ",
" @# .++++++++. ", " = ./(__::<[.= ",
" .......... @# .......... ", " .......... = ..........= ",
" .++++++++. @# ", " .}|1233>,. = ======== ",
" .++++++++. @# ", " .|1233>,'.= = ",
" .++++++++.@@@@# ", " .1233>,').==== ",
" .++++++++.###@# ", " .233>,')!.= = ",
" .++++++++. @# .......... ", " .33>,')!~.= = .......... ",
" .......... @# .++++++++. ", " ..........= = .[4567789. ",
" @# .++++++++. ", " ======== = .45677890.= ",
" @# @@@.++++++++. ", " = ===.5677890a.= ",
" @# @##.++++++++. ", " = = .677890ab.= ",
" @# .......... @# .++++++++. ", " = .......... = .77890abb.= ",
" @# .++++++++. @# .......... ", " = .;;^^/(__. = ..........= ",
" @# .++++++++. @# ", " = .;^^/(__:.= = ======== ",
" @@@.++++++++.@@@@# ", " ===.^^/(__::.==== ",
" ##.++++++++.###@# ", " .^/(__::<.= = ",
" .++++++++. @# .......... ", " ./(__::<[.= = .......... ",
" .......... @# .++++++++. ", " ..........= = .bbcdefgh. ",
" @# .++++++++. ", " ======== = .bcdefghi.= ",
" @@@.++++++++. ", " ===.cdefghij.= ",
" ##.++++++++. ", " .defghijj.= ",
" .++++++++. ", " .efghijjk.= ",
" .......... ", " ..........= ",
" ======== ",
" ",
" ", " ",
" ", " ",
" ", " ",

View File

@ -44,6 +44,7 @@ import gtk
import gnome.ui import gnome.ui
import GDK import GDK
import GTK import GTK
import GdkImlib
import libglade import libglade
#------------------------------------------------------------------------- #-------------------------------------------------------------------------

View File

@ -146,14 +146,9 @@
</child> </child>
<widget> <widget>
<class>GtkPixmap</class> <class>GnomePixmap</class>
<name>image</name> <name>pixmap1</name>
<filename>gramps.xpm</filename> <filename>gramps.png</filename>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<build_insensitive>True</build_insensitive>
<child> <child>
<padding>10</padding> <padding>10</padding>
<expand>False</expand> <expand>False</expand>

View File

@ -690,12 +690,14 @@ class WebReport(Report):
doc.end_paragraph() doc.end_paragraph()
person_list.sort(sort.by_last_name) person_list.sort(sort.by_last_name)
doc.write_text('<div class="PersonIndex">')
for person in person_list: for person in person_list:
name = person.getPrimaryName().getName() name = person.getPrimaryName().getName()
doc.start_link("%s.html" % person.getId()) doc.start_link("%s.html" % person.getId())
doc.write_text(name) doc.write_text(name)
doc.end_link() doc.end_link()
doc.newline() doc.newline()
doc.write_text('<div class="PersonIndex"/>')
doc.close() doc.close()
def write_report(self): def write_report(self):