2008-04-07 02:05:38 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2008 Zsolt Foldvari
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
"About dialog"
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import gettext as _
|
2009-10-03 21:40:50 +05:30
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import bsddb
|
2008-04-07 02:05:38 +05:30
|
|
|
|
2008-04-07 18:03:49 +05:30
|
|
|
##import logging
|
|
|
|
##_LOG = logging.getLogger(".GrampsAboutDialog")
|
2008-04-07 02:05:38 +05:30
|
|
|
|
|
|
|
try:
|
|
|
|
from xml.sax import make_parser, handler, SAXParseException
|
2008-04-07 02:24:29 +05:30
|
|
|
except ImportError:
|
2008-04-07 02:05:38 +05:30
|
|
|
from _xmlplus.sax import make_parser, handler, SAXParseException
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Gtk modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
from GrampsDisplay import url as display_url
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-04-07 18:03:49 +05:30
|
|
|
AUTHORS_HEADER = _('==== Authors ====\n')
|
|
|
|
CONTRIB_HEADER = _('\n==== Contributors ====\n')
|
2008-04-07 02:05:38 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GrampsAboutDialog
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class GrampsAboutDialog(gtk.AboutDialog):
|
|
|
|
"""Create an About dialog with all fields set."""
|
|
|
|
def __init__(self):
|
|
|
|
"""Setup all the fields shown in the About dialog."""
|
|
|
|
gtk.AboutDialog.__init__(self)
|
|
|
|
|
|
|
|
self.set_name(const.PROGRAM_NAME)
|
|
|
|
self.set_version(const.VERSION)
|
|
|
|
self.set_copyright(const.COPYRIGHT_MSG)
|
|
|
|
self.set_artists([
|
2009-11-18 01:44:53 +05:30
|
|
|
_("Much of Gramps' artwork is either from\n"
|
2008-04-07 02:05:38 +05:30
|
|
|
"the Tango Project or derived from the Tango\n"
|
|
|
|
"Project. This artwork is released under the\n"
|
2009-02-22 16:37:51 +05:30
|
|
|
"Creative Commons Attribution-ShareAlike 2.5\n"
|
2008-04-07 02:05:38 +05:30
|
|
|
"license.")
|
|
|
|
])
|
|
|
|
|
|
|
|
try:
|
|
|
|
ifile = open(const.LICENSE_FILE, "r")
|
|
|
|
self.set_license(ifile.read().replace('\x0c', ''))
|
|
|
|
ifile.close()
|
2008-04-07 02:24:29 +05:30
|
|
|
except IOError:
|
2008-04-07 02:05:38 +05:30
|
|
|
self.set_license("License file is missing")
|
|
|
|
|
2009-10-03 21:40:50 +05:30
|
|
|
self.set_comments(_(const.COMMENTS) + self.get_versions())
|
2009-11-18 01:44:53 +05:30
|
|
|
self.set_website_label(_('Gramps Homepage'))
|
2008-04-07 02:05:38 +05:30
|
|
|
self.set_website(const.URL_HOMEPAGE)
|
|
|
|
|
|
|
|
self.set_authors(_get_authors())
|
|
|
|
|
|
|
|
# Only set translation credits if they are translated
|
|
|
|
trans_credits = _(const.TRANSLATORS)
|
|
|
|
if trans_credits != const.TRANSLATORS:
|
|
|
|
self.set_translator_credits(trans_credits)
|
|
|
|
|
|
|
|
self.set_documenters(const.DOCUMENTERS)
|
|
|
|
self.set_logo(gtk.gdk.pixbuf_new_from_file(const.SPLASH))
|
|
|
|
self.set_modal(True)
|
|
|
|
|
2009-10-03 21:40:50 +05:30
|
|
|
def get_versions(self):
|
|
|
|
if hasattr(os, "uname"):
|
|
|
|
operatingsystem = os.uname()[0]
|
|
|
|
distribution = os.uname()[2]
|
|
|
|
else:
|
|
|
|
operatingsystem = sys.platform
|
|
|
|
distribution = " "
|
|
|
|
|
|
|
|
return (("\n\n" +
|
|
|
|
"GRAMPS: %s \n" +
|
|
|
|
"Python: %s \n" +
|
|
|
|
"BSDDB: %s \n" +
|
|
|
|
"LANG: %s\n" +
|
|
|
|
"OS: %s\n" +
|
|
|
|
"Distribution: %s")
|
|
|
|
% (elipses(str(const.VERSION)),
|
|
|
|
elipses(str(sys.version).replace('\n','')),
|
2010-05-21 19:48:32 +05:30
|
|
|
elipses(str(bsddb.__version__) + " " + str(bsddb.db.version())),
|
2009-10-03 21:40:50 +05:30
|
|
|
elipses(os.environ.get('LANG','')),
|
|
|
|
elipses(operatingsystem),
|
|
|
|
elipses(distribution)))
|
|
|
|
|
|
|
|
def elipses(text):
|
|
|
|
if len(text) > 40:
|
|
|
|
return text[:40] + "..."
|
|
|
|
return text
|
|
|
|
|
2008-04-07 02:05:38 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# AuthorParser
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class AuthorParser(handler.ContentHandler):
|
2008-04-07 18:03:49 +05:30
|
|
|
"""Parse the 'authors.xml file to show in the About dialog.
|
|
|
|
|
|
|
|
The C{authors.xml} file has the same format as the one in the U{svn2cl
|
|
|
|
<http://ch.tudelft.nl/~arthur/svn2cl/>} package, with an additional
|
|
|
|
C{title} tag in the C{author} element. For example::
|
|
|
|
|
|
|
|
<author uid="dallingham" title="author">
|
|
|
|
Don Allingham <<html:a href="mailto:don@gramps-project.org">don@gramps-project.org</html:a>>
|
|
|
|
</author>}
|
|
|
|
|
|
|
|
"""
|
2008-04-07 02:05:38 +05:30
|
|
|
def __init__(self, author_list, contributor_list):
|
|
|
|
"""Setup initial instance variable values."""
|
|
|
|
handler.ContentHandler.__init__(self)
|
|
|
|
|
|
|
|
self.author_list = author_list
|
|
|
|
self.contributor_list = contributor_list
|
|
|
|
|
|
|
|
# initialize all instance variables to make pylint happy
|
|
|
|
self.uid = ""
|
|
|
|
self.title = ""
|
|
|
|
self.text = ""
|
|
|
|
|
|
|
|
def startElement(self, tag, attrs):
|
2008-04-07 18:03:49 +05:30
|
|
|
"""Handle the start of an element."""
|
2008-04-07 02:05:38 +05:30
|
|
|
if tag == "author":
|
|
|
|
self.uid = attrs['uid']
|
|
|
|
self.title = attrs['title']
|
|
|
|
self.text = ""
|
|
|
|
|
|
|
|
def endElement(self, tag):
|
2008-04-07 18:03:49 +05:30
|
|
|
"""Handle the end of an element."""
|
2008-04-07 02:05:38 +05:30
|
|
|
if tag == "author":
|
2008-05-07 15:18:22 +05:30
|
|
|
developer = self.text.strip()
|
2008-04-07 02:05:38 +05:30
|
|
|
if (self.title == 'author' and
|
2008-05-07 15:18:22 +05:30
|
|
|
developer not in self.author_list):
|
|
|
|
self.author_list.append(developer)
|
2008-04-07 02:05:38 +05:30
|
|
|
elif (self.title == 'contributor' and
|
2008-05-07 15:18:22 +05:30
|
|
|
developer not in self.contributor_list):
|
|
|
|
self.contributor_list.append(developer)
|
2008-04-07 02:05:38 +05:30
|
|
|
|
|
|
|
def characters(self, chunk):
|
2008-04-07 18:03:49 +05:30
|
|
|
"""Receive notification of character data."""
|
2008-04-07 02:05:38 +05:30
|
|
|
if chunk != '\n':
|
|
|
|
self.text += chunk
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# _get_authors
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def _get_authors():
|
|
|
|
"""Return all the authors and contributors in a string.
|
|
|
|
|
2008-04-07 18:03:49 +05:30
|
|
|
Parse the C{authors.xml} file if found, or return the default
|
|
|
|
list from L{const} module in case of I/O or parsing failure.
|
|
|
|
|
|
|
|
If the C{authors.xml} file is successfully parsed the I{Authors} and
|
|
|
|
I{Contributors} are grouped separately with an appropriate header.
|
2008-04-07 02:05:38 +05:30
|
|
|
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
authors = []
|
|
|
|
contributors = []
|
|
|
|
|
|
|
|
parser = make_parser()
|
|
|
|
parser.setContentHandler(AuthorParser(authors, contributors))
|
|
|
|
|
|
|
|
authors_file = open(const.AUTHORS_FILE)
|
|
|
|
parser.parse(authors_file)
|
|
|
|
authors_file.close()
|
|
|
|
|
2008-04-07 18:03:49 +05:30
|
|
|
authors_text = ([AUTHORS_HEADER] + authors +
|
|
|
|
[CONTRIB_HEADER] + contributors)
|
2008-04-07 02:05:38 +05:30
|
|
|
|
|
|
|
except (IOError, OSError, SAXParseException):
|
|
|
|
authors_text = const.AUTHORS
|
|
|
|
|
|
|
|
return authors_text
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# _show_url
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def _show_url(dialog, link, prefix):
|
|
|
|
"""Show links in About dialog."""
|
|
|
|
if prefix is not None:
|
|
|
|
link = prefix + link
|
|
|
|
display_url(link)
|
|
|
|
|
|
|
|
gtk.about_dialog_set_url_hook(_show_url, None)
|
|
|
|
gtk.about_dialog_set_email_hook(_show_url, 'mailto:')
|