2004-08-28 19:49:34 +00:00
|
|
|
#
|
2002-10-20 14:25:16 +00:00
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-03-02 23:37:16 +00:00
|
|
|
# Copyright (C) 2001-2006 Donald N. Allingham
|
2002-10-20 14:25:16 +00:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
2003-10-13 01:55:56 +00:00
|
|
|
# $Id$
|
|
|
|
|
2005-08-12 16:25:43 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2006-05-22 18:07:12 +00:00
|
|
|
# Python modules
|
2005-08-12 16:25:43 +00:00
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-05-22 18:07:12 +00:00
|
|
|
from gettext import gettext as _
|
2006-04-26 01:44:03 +00:00
|
|
|
import os
|
2006-05-22 18:07:12 +00:00
|
|
|
import platform
|
2006-01-06 15:23:28 +00:00
|
|
|
|
2006-05-22 18:07:12 +00:00
|
|
|
import logging
|
2006-01-06 15:23:28 +00:00
|
|
|
log = logging.getLogger(".")
|
2005-08-12 16:25:43 +00:00
|
|
|
|
2006-05-22 18:07:12 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK+/GNOME modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
2005-08-12 16:25:43 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-08-09 04:41:20 +00:00
|
|
|
import ViewManager
|
2005-12-21 11:27:05 +00:00
|
|
|
import GrampsDb
|
2005-08-09 04:41:20 +00:00
|
|
|
import ArgHandler
|
2006-03-03 00:10:52 +00:00
|
|
|
import Config
|
2005-08-09 04:41:20 +00:00
|
|
|
import const
|
2005-03-30 01:45:14 +00:00
|
|
|
import Errors
|
2005-08-09 10:18:56 +00:00
|
|
|
import TipOfDay
|
2006-03-04 15:37:04 +00:00
|
|
|
import DataViews
|
2006-03-03 00:23:04 +00:00
|
|
|
from Mime import mime_type_is_defined
|
2005-08-09 04:41:20 +00:00
|
|
|
from QuestionDialog import ErrorDialog
|
2002-10-20 14:25:16 +00:00
|
|
|
|
2006-05-22 18:07:12 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# helper functions
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-03-03 23:48:11 +00:00
|
|
|
iconpaths = [const.image_dir,"."]
|
2005-04-04 01:11:50 +00:00
|
|
|
|
2006-05-17 03:01:09 +00:00
|
|
|
if platform.system() == "Windows":
|
|
|
|
person_icon = "person.png"
|
|
|
|
relation_icon = "relation.png"
|
2006-10-11 03:26:56 +00:00
|
|
|
place_icon = "place.png"
|
|
|
|
family_icon = "flist.png"
|
|
|
|
media_icon = "media.png"
|
|
|
|
sources_icon = "sources.png"
|
|
|
|
events_icon = "events.png"
|
|
|
|
tools_icon = "tools.png"
|
|
|
|
reports_icon = "reports.png"
|
2006-11-09 04:18:18 +00:00
|
|
|
parents_icon = "parents.png"
|
|
|
|
spouse_icon = "spouse.png"
|
2006-05-17 03:01:09 +00:00
|
|
|
else:
|
|
|
|
person_icon = "person.svg"
|
|
|
|
relation_icon = "relation.svg"
|
2006-10-11 03:26:56 +00:00
|
|
|
place_icon = "place.svg"
|
|
|
|
family_icon = "flist.svg"
|
|
|
|
media_icon = "media.svg"
|
|
|
|
sources_icon = "sources.svg"
|
|
|
|
events_icon = "events.svg"
|
|
|
|
tools_icon = "tools.svg"
|
|
|
|
reports_icon = "reports.svg"
|
2006-11-09 04:18:18 +00:00
|
|
|
parents_icon = "parents.svg"
|
|
|
|
spouse_icon = "spouse.svg"
|
2006-05-17 03:01:09 +00:00
|
|
|
|
2005-08-09 04:41:20 +00:00
|
|
|
def register_stock_icons ():
|
2005-08-12 02:35:27 +00:00
|
|
|
items = [
|
2006-10-11 03:26:56 +00:00
|
|
|
(os.path.join(const.image_dir, person_icon),
|
2006-03-04 22:53:46 +00:00
|
|
|
('gramps-person',_('Person'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-11-09 04:18:18 +00:00
|
|
|
(os.path.join(const.image_dir, parents_icon),
|
|
|
|
('gramps-parents',_('Add Parents'),gtk.gdk.CONTROL_MASK,0,'')),
|
|
|
|
(os.path.join(const.image_dir, spouse_icon),
|
|
|
|
('gramps-spouse',_('Add Spouse'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-10-11 03:26:56 +00:00
|
|
|
(os.path.join(const.image_dir, relation_icon),
|
2006-03-04 22:53:46 +00:00
|
|
|
('gramps-family',_('Relationships'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-10-11 03:26:56 +00:00
|
|
|
(os.path.join(const.image_dir, family_icon),
|
2006-03-04 22:53:46 +00:00
|
|
|
('gramps-family-list',_('Family List'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-10-11 03:26:56 +00:00
|
|
|
(os.path.join(const.image_dir, media_icon),
|
2006-03-04 22:53:46 +00:00
|
|
|
('gramps-media',_('Media'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-03-03 23:48:11 +00:00
|
|
|
(os.path.join(const.image_dir,'ped24.png'),
|
2006-03-04 22:53:46 +00:00
|
|
|
('gramps-pedigree',_('Pedigree'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-03-03 23:48:11 +00:00
|
|
|
(os.path.join(const.image_dir,'repos.png'),
|
2006-03-04 22:53:46 +00:00
|
|
|
('gramps-repository',_('Repositories'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-10-11 03:26:56 +00:00
|
|
|
(os.path.join(const.image_dir, sources_icon),
|
2006-03-04 22:53:46 +00:00
|
|
|
('gramps-source',_('Sources'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-10-11 03:26:56 +00:00
|
|
|
(os.path.join(const.image_dir, events_icon),
|
2006-03-04 22:53:46 +00:00
|
|
|
('gramps-event',_('Events'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-10-11 03:26:56 +00:00
|
|
|
(os.path.join(const.image_dir, place_icon),
|
2006-03-04 22:53:46 +00:00
|
|
|
('gramps-place',_('Places'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-10-11 03:26:56 +00:00
|
|
|
(os.path.join(const.image_dir, tools_icon),
|
2006-09-24 04:37:59 +00:00
|
|
|
('gramps-tools',_('Tools'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-10-11 03:26:56 +00:00
|
|
|
(os.path.join(const.image_dir, reports_icon),
|
2006-09-24 04:37:59 +00:00
|
|
|
('gramps-reports',_('Reports'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-05-16 03:35:10 +00:00
|
|
|
(os.path.join(const.image_dir,'stock_export.png'),
|
2006-09-24 04:37:59 +00:00
|
|
|
('gramps-export',_('Export'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-05-25 00:23:22 +00:00
|
|
|
(os.path.join(const.image_dir,'stock_notes.png'),
|
2006-09-24 04:37:59 +00:00
|
|
|
('gramps-notes',_('Notes'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-05-16 03:35:10 +00:00
|
|
|
(os.path.join(const.image_dir,'stock_undo-history.png'),
|
|
|
|
('gramps-undo-history',_('Undo History'),gtk.gdk.CONTROL_MASK,0,'')),
|
|
|
|
(os.path.join(const.image_dir,'stock_add-bookmark.png'),
|
|
|
|
('gramps-add-bookmark',_('Add bookmark'),gtk.gdk.CONTROL_MASK,0,'')),
|
|
|
|
(os.path.join(const.image_dir,'stock_edit-bookmark.png'),
|
|
|
|
('gramps-edit-bookmark',_('Edit bookmarks'),gtk.gdk.CONTROL_MASK,0,'')),
|
2006-05-17 03:01:09 +00:00
|
|
|
(os.path.join(const.image_dir,'stock_insert-url.png'),
|
|
|
|
('gramps-url',_('URL'),gtk.gdk.CONTROL_MASK,0,'')),
|
2005-08-12 02:35:27 +00:00
|
|
|
]
|
2005-08-09 04:41:20 +00:00
|
|
|
|
|
|
|
# Register our stock items
|
2005-08-12 02:35:27 +00:00
|
|
|
gtk.stock_add (map(lambda x: x[1],items))
|
2005-08-09 04:41:20 +00:00
|
|
|
|
|
|
|
# Add our custom icon factory to the list of defaults
|
|
|
|
factory = gtk.IconFactory ()
|
|
|
|
factory.add_default ()
|
|
|
|
|
2005-08-12 02:35:27 +00:00
|
|
|
for (key,data) in items:
|
2005-08-09 04:41:20 +00:00
|
|
|
|
|
|
|
for dirname in iconpaths:
|
|
|
|
icon_file = os.path.expanduser(os.path.join(dirname,key))
|
|
|
|
if os.path.isfile(icon_file):
|
2006-03-04 22:53:46 +00:00
|
|
|
try:
|
|
|
|
pixbuf = gtk.gdk.pixbuf_new_from_file (icon_file)
|
|
|
|
break
|
|
|
|
except:
|
|
|
|
pass
|
2005-08-09 04:41:20 +00:00
|
|
|
else:
|
2006-03-03 23:48:11 +00:00
|
|
|
icon_file = os.path.join(const.image_dir,'gramps.png')
|
2006-03-04 22:53:46 +00:00
|
|
|
pixbuf = gtk.gdk.pixbuf_new_from_file (icon_file)
|
2005-08-09 04:41:20 +00:00
|
|
|
|
|
|
|
pixbuf = pixbuf.add_alpha(True, chr(0xff), chr(0xff), chr(0xff))
|
|
|
|
|
2006-03-04 22:53:46 +00:00
|
|
|
icon_set = gtk.IconSet (pixbuf)
|
|
|
|
factory.add (data[0], icon_set)
|
2005-08-09 04:41:20 +00:00
|
|
|
|
2006-04-26 01:44:03 +00:00
|
|
|
|
|
|
|
def build_user_paths():
|
|
|
|
user_paths = [const.home_dir,
|
|
|
|
os.path.join(const.home_dir,"filters"),
|
|
|
|
os.path.join(const.home_dir,"plugins"),
|
|
|
|
os.path.join(const.home_dir,"templates"),
|
|
|
|
os.path.join(const.home_dir,"thumb")]
|
|
|
|
|
|
|
|
for path in user_paths:
|
|
|
|
if not os.path.isdir(path):
|
|
|
|
os.mkdir(path)
|
|
|
|
|
2006-05-22 18:07:12 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Main Gramps class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-08-09 04:41:20 +00:00
|
|
|
class Gramps:
|
2005-08-12 02:50:56 +00:00
|
|
|
"""
|
|
|
|
Main class corresponding to a running gramps process.
|
|
|
|
|
|
|
|
There can be only one instance of this class per gramps application
|
|
|
|
process. It may spawn several windows and control several databases.
|
|
|
|
"""
|
2002-10-20 14:25:16 +00:00
|
|
|
|
2003-05-17 04:14:13 +00:00
|
|
|
def __init__(self,args):
|
2005-03-17 19:28:00 +00:00
|
|
|
try:
|
2006-04-26 01:44:03 +00:00
|
|
|
build_user_paths()
|
2005-05-11 14:04:47 +00:00
|
|
|
self.welcome()
|
2005-05-07 02:41:08 +00:00
|
|
|
except OSError, msg:
|
|
|
|
ErrorDialog(_("Configuration error"),str(msg))
|
|
|
|
return
|
2005-03-30 01:45:14 +00:00
|
|
|
except Errors.GConfSchemaError, val:
|
2005-08-12 02:50:56 +00:00
|
|
|
ErrorDialog(_("Configuration error"),str(val) +
|
|
|
|
_("\n\nPossibly the installation of GRAMPS "
|
|
|
|
"was incomplete. Make sure the GConf schema "
|
|
|
|
"of GRAMPS is properly installed."))
|
2005-03-17 19:28:00 +00:00
|
|
|
gtk.main_quit()
|
|
|
|
return
|
2005-05-07 02:41:08 +00:00
|
|
|
except:
|
2006-01-09 11:28:44 +00:00
|
|
|
log.error("Error reading configuration.", exc_info=True)
|
2005-05-07 02:41:08 +00:00
|
|
|
return
|
2005-03-17 19:28:00 +00:00
|
|
|
|
|
|
|
if not mime_type_is_defined(const.app_gramps):
|
|
|
|
ErrorDialog(_("Configuration error"),
|
2005-08-12 02:50:56 +00:00
|
|
|
_("A definition for the MIME-type %s could not "
|
|
|
|
"be found \n\nPossibly the installation of GRAMPS "
|
|
|
|
"was incomplete. Make sure the MIME-types "
|
|
|
|
"of GRAMPS are properly installed.")
|
|
|
|
% const.app_gramps)
|
2005-03-17 19:28:00 +00:00
|
|
|
gtk.main_quit()
|
|
|
|
return
|
2002-10-20 14:25:16 +00:00
|
|
|
|
2005-08-12 16:25:43 +00:00
|
|
|
register_stock_icons()
|
|
|
|
|
2005-12-21 11:27:05 +00:00
|
|
|
state = GrampsDb.DbState()
|
2006-04-22 22:09:16 +00:00
|
|
|
self.vm = ViewManager.ViewManager(state)
|
2006-03-04 15:37:04 +00:00
|
|
|
for view in DataViews.get_views():
|
2006-04-22 22:09:16 +00:00
|
|
|
self.vm.register_view(view)
|
2005-08-12 16:25:43 +00:00
|
|
|
|
2006-05-21 04:13:34 +00:00
|
|
|
self.vm.init_interface()
|
2006-05-22 18:07:12 +00:00
|
|
|
|
|
|
|
# Depending on the nature of this session,
|
|
|
|
# we may need to change the order of operation
|
|
|
|
ah = ArgHandler.ArgHandler(state,self.vm,args)
|
|
|
|
if ah.need_gui():
|
|
|
|
self.vm.post_init_interface()
|
|
|
|
ah.handle_args()
|
|
|
|
else:
|
|
|
|
ah.handle_args()
|
|
|
|
self.vm.post_init_interface()
|
2005-08-12 16:25:43 +00:00
|
|
|
|
2005-08-14 04:31:29 +00:00
|
|
|
state.db.request_rebuild()
|
2005-08-12 19:00:43 +00:00
|
|
|
state.change_active_person(state.db.get_default_person())
|
2005-08-12 16:25:43 +00:00
|
|
|
|
2006-04-24 21:04:01 +00:00
|
|
|
if Config.get(Config.USE_TIPS):
|
2006-04-22 22:09:16 +00:00
|
|
|
TipOfDay.TipOfDay(self.vm.uistate)
|
2004-05-18 07:00:34 +00:00
|
|
|
|
2005-08-18 05:58:28 +00:00
|
|
|
|
2005-05-11 14:04:47 +00:00
|
|
|
def welcome(self):
|
2006-03-29 04:48:50 +00:00
|
|
|
return
|
2006-10-30 14:44:04 +00:00
|
|
|
# if not Config.get(Config.BETAWARN):
|
|
|
|
# from QuestionDialog import WarningDialog
|
|
|
|
# WarningDialog(
|
|
|
|
# _('Danger: This is unstable code!'),
|
|
|
|
# _("The GRAMPS 2.1 release is an early, experimental "
|
|
|
|
# "branch of the future 2.2 release. This version is "
|
|
|
|
# "not meant for normal usage. Use at your own risk.\n\n"
|
|
|
|
# "This version may:\n1) Fail to run properly\n"
|
|
|
|
# "2) Corrupt your data\n3) Cause your hair to turn "
|
|
|
|
# "pink and fall out.\n\nAny databases opened by this "
|
|
|
|
# "version will <b>NO LONGER WORK</b> in older versions of "
|
|
|
|
# "GRAMPS, and <b>MAY NOT WORK</b> in with future "
|
|
|
|
# "releases of GRAMPS. <b>BACKUP</b> your existing databases "
|
|
|
|
# "before opening them with this version, and make "
|
|
|
|
# "sure to export your data to XML every now and then."))
|
|
|
|
# Config.set(Config.AUTOLOAD,False)
|
|
|
|
# Config.set(Config.BETAWARN,True)
|
|
|
|
|