AboutDialog moved out from ViewManager to GrampsAboutDialog.
In the About dialog the list of developers is parsed from the authors.xml file. svn: r10509
This commit is contained in:
parent
c200e9922b
commit
3b66dc1e48
195
src/GrampsAboutDialog.py
Normal file
195
src/GrampsAboutDialog.py
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
#
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
from gettext import gettext as _
|
||||||
|
|
||||||
|
import logging
|
||||||
|
_LOG = logging.getLogger(".GrampsAboutDialog")
|
||||||
|
|
||||||
|
try:
|
||||||
|
from xml.sax import make_parser, handler, SAXParseException
|
||||||
|
except:
|
||||||
|
from _xmlplus.sax import make_parser, handler, SAXParseException
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Gtk modules
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
import gtk
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# GRAMPS modules
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
import const
|
||||||
|
from GrampsDisplay import url as display_url
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Constants
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
AUTHORS_TITLE = _('==== Authors ====\n')
|
||||||
|
CONTRIB_TITLE = _('\n==== Contributors ====\n')
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# 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([
|
||||||
|
_("Much of GRAMPS' artwork is either from\n"
|
||||||
|
"the Tango Project or derived from the Tango\n"
|
||||||
|
"Project. This artwork is released under the\n"
|
||||||
|
"Create Commons Attribution-ShareAlike 2.5\n"
|
||||||
|
"license.")
|
||||||
|
])
|
||||||
|
|
||||||
|
try:
|
||||||
|
ifile = open(const.LICENSE_FILE, "r")
|
||||||
|
self.set_license(ifile.read().replace('\x0c', ''))
|
||||||
|
ifile.close()
|
||||||
|
except:
|
||||||
|
self.set_license("License file is missing")
|
||||||
|
|
||||||
|
self.set_comments(_(const.COMMENTS))
|
||||||
|
self.set_website_label(_('GRAMPS Homepage'))
|
||||||
|
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)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# AuthorParser
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
class AuthorParser(handler.ContentHandler):
|
||||||
|
"""Parse the 'authors.xml file to show in the About dialog."""
|
||||||
|
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):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
if tag == "author":
|
||||||
|
self.uid = attrs['uid']
|
||||||
|
self.title = attrs['title']
|
||||||
|
self.text = ""
|
||||||
|
|
||||||
|
def endElement(self, tag):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
if tag == "author":
|
||||||
|
if (self.title == 'author' and
|
||||||
|
self.text not in self.author_list):
|
||||||
|
self.author_list.append(self.text.strip())
|
||||||
|
elif (self.title == 'contributor' and
|
||||||
|
self.text not in self.contributor_list):
|
||||||
|
self.contributor_list.append(self.text.strip())
|
||||||
|
|
||||||
|
def characters(self, chunk):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
if chunk != '\n':
|
||||||
|
self.text += chunk
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# _get_authors
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
def _get_authors():
|
||||||
|
"""Return all the authors and contributors in a string.
|
||||||
|
|
||||||
|
Parse the I{authors.xml} file if found, or return the default
|
||||||
|
list from L{const} module in case of IO or parsing failure.
|
||||||
|
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
authors = []
|
||||||
|
contributors = []
|
||||||
|
|
||||||
|
parser = make_parser()
|
||||||
|
parser.setContentHandler(AuthorParser(authors, contributors))
|
||||||
|
|
||||||
|
authors_file = open(const.AUTHORS_FILE)
|
||||||
|
parser.parse(authors_file)
|
||||||
|
authors_file.close()
|
||||||
|
|
||||||
|
authors_text = ([AUTHORS_TITLE] + authors +
|
||||||
|
[CONTRIB_TITLE] + contributors)
|
||||||
|
|
||||||
|
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:')
|
@ -49,6 +49,7 @@ gdir_PYTHON = \
|
|||||||
ExportAssistant.py\
|
ExportAssistant.py\
|
||||||
ExportOptions.py\
|
ExportOptions.py\
|
||||||
FontScale.py\
|
FontScale.py\
|
||||||
|
GrampsAboutDialog.py\
|
||||||
GrampsCfg.py\
|
GrampsCfg.py\
|
||||||
GrampsDisplay.py\
|
GrampsDisplay.py\
|
||||||
gramps_main.py\
|
gramps_main.py\
|
||||||
|
@ -75,18 +75,10 @@ import UndoHistory
|
|||||||
from DbLoader import DbLoader
|
from DbLoader import DbLoader
|
||||||
import GrampsDisplay
|
import GrampsDisplay
|
||||||
from gen.utils import ProgressMonitor
|
from gen.utils import ProgressMonitor
|
||||||
|
from GrampsAboutDialog import GrampsAboutDialog
|
||||||
|
|
||||||
import ProgressDialog
|
import ProgressDialog
|
||||||
|
|
||||||
def show_url(dialog, link, user_data):
|
|
||||||
"""
|
|
||||||
Set the about dialog callback for showing the URL. Call the GrampsDisplay
|
|
||||||
function to display the link
|
|
||||||
"""
|
|
||||||
GrampsDisplay.url(link)
|
|
||||||
|
|
||||||
gtk.about_dialog_set_url_hook(show_url, None)
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Constants
|
# Constants
|
||||||
@ -1412,39 +1404,8 @@ class ViewManager:
|
|||||||
return (ofile.getvalue(), actions)
|
return (ofile.getvalue(), actions)
|
||||||
|
|
||||||
def display_about_box(obj):
|
def display_about_box(obj):
|
||||||
"""
|
"""Display the About box."""
|
||||||
Displays the About box.
|
about = GrampsAboutDialog()
|
||||||
"""
|
|
||||||
about = gtk.AboutDialog()
|
|
||||||
about.set_name(const.PROGRAM_NAME)
|
|
||||||
about.set_version(const.VERSION)
|
|
||||||
about.set_copyright(const.COPYRIGHT_MSG)
|
|
||||||
about.set_artists([
|
|
||||||
_("Much of GRAMPS' artwork is either from\n"
|
|
||||||
"the Tango Project or derived from the Tango\n"
|
|
||||||
"Project. This artwork is released under the\n"
|
|
||||||
"Create Commons Attribution-ShareAlike 2.5\n"
|
|
||||||
"license.")
|
|
||||||
])
|
|
||||||
try:
|
|
||||||
ifile = open(const.LICENSE_FILE, "r")
|
|
||||||
about.set_license(ifile.read().replace('\x0c', ''))
|
|
||||||
ifile.close()
|
|
||||||
except:
|
|
||||||
about.set_license("License file is missing")
|
|
||||||
about.set_comments(_(const.COMMENTS))
|
|
||||||
about.set_website_label(_('GRAMPS Homepage'))
|
|
||||||
about.set_website(const.URL_HOMEPAGE)
|
|
||||||
about.set_authors(const.AUTHORS)
|
|
||||||
|
|
||||||
# Only set translation credits if they are translated
|
|
||||||
trans_credits = _(const.TRANSLATORS)
|
|
||||||
if trans_credits != const.TRANSLATORS:
|
|
||||||
about.set_translator_credits(trans_credits)
|
|
||||||
|
|
||||||
about.set_documenters(const.DOCUMENTERS)
|
|
||||||
about.set_logo(gtk.gdk.pixbuf_new_from_file(const.SPLASH))
|
|
||||||
about.set_modal(True)
|
|
||||||
about.run()
|
about.run()
|
||||||
about.destroy()
|
about.destroy()
|
||||||
|
|
||||||
|
@ -165,6 +165,8 @@ AUTHORS = [
|
|||||||
"Donald A. Peterson",
|
"Donald A. Peterson",
|
||||||
"David Hampton",
|
"David Hampton",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
AUTHORS_FILE = os.path.join(ROOT_DIR, "authors.xml")
|
||||||
|
|
||||||
DOCUMENTERS = [
|
DOCUMENTERS = [
|
||||||
'Alexander Roitman',
|
'Alexander Roitman',
|
||||||
|
Loading…
Reference in New Issue
Block a user