diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 6062fded2..809d82774 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,11 @@ +2004-05-18 Don Allingham + * src/GrampsCfg.py: added support for tip of the day + * src/data/tips.xml: tip data + * src/TipOfDay.py: support for tip of the day + * src/gramps_main.py: support for tip of the day + * src/const.py: support for tip of the day + * src/gramps.glade: support for tip of the day + 2004-05-16 Alex Roitman * src/plugins/RelGraph.py: Menu for family options. * src/plugins/RelGraph.py (_get_event_label): Typo. diff --git a/gramps2/gramps-mdk.spec b/gramps2/gramps-mdk.spec index 52e7702d3..874225379 100644 --- a/gramps2/gramps-mdk.spec +++ b/gramps2/gramps-mdk.spec @@ -1,5 +1,5 @@ %define ver 1.1.0 -%define rel 0.CVS20040505 +%define rel 0.CVS20040516 %define prefix /usr %define localstatedir /var/lib # Ensure that internal RPM macros for configure & makeinstall diff --git a/gramps2/gramps.spec b/gramps2/gramps.spec index 94522c51e..4a7c441be 100644 --- a/gramps2/gramps.spec +++ b/gramps2/gramps.spec @@ -1,5 +1,5 @@ %define ver 1.1.0 -%define rel 0.CVS20040505 +%define rel 0.CVS20040516 %define prefix /usr %define localstatedir /var/lib # Ensure that internal RPM macros for configure & makeinstall diff --git a/gramps2/src/GrampsCfg.py b/gramps2/src/GrampsCfg.py index a618cfc6b..9dbebbb09 100644 --- a/gramps2/src/GrampsCfg.py +++ b/gramps2/src/GrampsCfg.py @@ -155,6 +155,7 @@ globalprop = 1 localprop = 1 defaultview = 0 familyview = 0 +usetips = 1 #------------------------------------------------------------------------- # @@ -221,6 +222,7 @@ def loadConfig(call): global localprop global defaultview global familyview + global usetips _callback = call lastfile = get_string("/apps/gramps/recent-file") @@ -231,6 +233,8 @@ def loadConfig(call): calendar = get_bool("/apps/gramps/show-calendar") id_edit = get_bool("/apps/gramps/id-edit") index_visible = get_bool("/apps/gramps/index-visible") + usetips = get_bool("/apps/gramps/use-tips",1) + familyview = get_int("/apps/gramps/familyview") status_bar = get_int("/apps/gramps/statusbar") gnome_toolbar_str = get_string("/desktop/gnome/interface/toolbar_style","BOTH") @@ -246,7 +250,6 @@ def loadConfig(call): else: toolbar = save_toolbar defaultview = get_int("/apps/gramps/defaultview") - familyview = get_int("/apps/gramps/familyview") autoload = get_bool("/apps/gramps/autoload",0) dateFormat = get_int("/apps/gramps/date-format") @@ -604,6 +607,8 @@ class GrampsPreferences: else: self.top.get_widget('familyview2').set_active(1) + self.top.get_widget('usetips').set_active(usetips) + paper_obj = self.top.get_widget("paper_size") menu = gtk.Menu() choice = 0 @@ -807,6 +812,7 @@ class GrampsPreferences: global save_toolbar global defaultview global familyview + global usetips global paper_preference global output_preference global goutput_preference @@ -850,6 +856,7 @@ class GrampsPreferences: defaultview = not self.top.get_widget("pvbutton").get_active() familyview = not self.top.get_widget("familyview1").get_active() + usetips = self.top.get_widget("usetips").get_active() iprefix = unicode(self.top.get_widget("iprefix").get_text()) if iprefix == "": @@ -894,6 +901,7 @@ class GrampsPreferences: set_int("/apps/gramps/toolbar",save_toolbar) set_int("/apps/gramps/defaultview",defaultview) set_int("/apps/gramps/familyview",familyview) + set_bool("/apps/gramps/use-tips",usetips) set_string("/apps/gramps/paper-preference",paper_preference) set_string("/apps/gramps/output-preference",output_preference) set_string("/apps/gramps/goutput-preference",goutput_preference) diff --git a/gramps2/src/TipOfDay.py b/gramps2/src/TipOfDay.py new file mode 100644 index 000000000..db70fa857 --- /dev/null +++ b/gramps2/src/TipOfDay.py @@ -0,0 +1,94 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2000-2004 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 +# + +import xml.parsers.expat +import string +import gtk +import gtk.glade +import const +import GrampsCfg + +class TipOfDay: + def __init__(self): + xml = gtk.glade.XML(const.gladeFile, "tod", "gramps") + top = xml.get_widget("tod") + tip = xml.get_widget("tip") + use = xml.get_widget('usetips') + + tp = TipParser() + tip_list = tp.get() + use.set_active(GrampsCfg.usetips) + + index = 0 + rval = 0 + while rval == 0: + tip.set_text(tip_list[index]) + rval = top.run() + if index >= len(tip_list)-1: + index = 0 + else: + index += 1 + + GrampsCfg.set_bool("/apps/gramps/use-tips",use.get_active()) + top.destroy() + +class TipParser: + """ + Interface to the document template file + """ + def __init__(self): + """ + Creates a template parser. The parser loads map of tempate names + to the file containing the tempate. + + data - dictionary that holds the name to path mappings + fpath - filename of the XML file + """ + + self.mylist = [] + file = open(const.tipdata) + self.tlist = [] + p = xml.parsers.expat.ParserCreate() + p.StartElementHandler = self.startElement + p.EndElementHandler = self.endElement + p.CharacterDataHandler = self.characters + p.ParseFile(file) + file.close() + + def get(self): + return self.mylist + + def setDocumentLocator(self,locator): + """Sets the XML document locator""" + self.locator = locator + + def startElement(self,tag,attrs): + """ + Loads the dictionary when an XML tag of 'template' is found. The format + XML tag is