From 716c45645dce0872c5c70fb56596d90f312dea10 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 29 Sep 2004 19:34:16 +0000 Subject: [PATCH] * src/TipOfDay.py: Be tolerant to whitespace; allow markup in the tips, enable random sequence of tips on each startup. * src/data/tips.xml: Merge with old tips. * src/data/tips.xml: Format the tips collection. * src/data/tips.xml: Add huge collection of tips. svn: r3586 --- ChangeLog | 11 ++ src/TipOfDay.py | 49 +++++++- src/data/tips.xml | 291 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 342 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 065dae329..788f628ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-09-29 Alex Roitman + * src/TipOfDay.py: Be tolerant to whitespace; allow markup in + the tips, enable random sequence of tips on each startup. + * src/data/tips.xml: Merge with old tips. + +2004-03-10 Leonid Mamtchenkov + * src/data/tips.xml: Format the tips collection. + +2004-09-29 Frederick Noronha + * src/data/tips.xml: Add huge collection of tips. + 2004-09-28 Alex Roitman * src/NameEdit.py: Typo. diff --git a/src/TipOfDay.py b/src/TipOfDay.py index 336c73570..1a371854d 100644 --- a/src/TipOfDay.py +++ b/src/TipOfDay.py @@ -18,13 +18,37 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + +#------------------------------------------------------------------------- +# +# standard python modules +# +#------------------------------------------------------------------------- import xml.parsers.expat -import string +from random import Random + +#------------------------------------------------------------------------- +# +# GTK/GNOME modules +# +#------------------------------------------------------------------------- import gtk import gtk.glade + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- import const import GrampsGconfKeys +#------------------------------------------------------------------------- +# +# Tip Display class +# +#------------------------------------------------------------------------- class TipOfDay: def __init__(self): xml = gtk.glade.XML(const.gladeFile, "tod", "gramps") @@ -36,10 +60,14 @@ class TipOfDay: tip_list = tp.get() use.set_active(GrampsGconfKeys.get_usetips()) + new_index = range(len(tip_list)) + Random().shuffle(new_index) + index = 0 rval = 0 while rval == 0: - tip.set_text(tip_list[index]) + tip.set_text(tip_list[new_index[index]]) + tip.set_use_markup(1) rval = top.run() if index >= len(tip_list)-1: index = 0 @@ -49,6 +77,11 @@ class TipOfDay: GrampsGconfKeys.save_usetips(use.get_active()) top.destroy() +#------------------------------------------------------------------------- +# +# Tip parser class +# +#------------------------------------------------------------------------- class TipParser: """ Interface to the document template file @@ -84,11 +117,19 @@ class TipParser: Loads the dictionary when an XML tag of 'template' is found. The format XML tag is