2004-08-29 01:19:34 +05:30
|
|
|
#
|
2002-10-20 19:55:16 +05:30
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-03-03 05:07:16 +05:30
|
|
|
# Copyright (C) 2001-2006 Donald N. Allingham
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# 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 07:25:56 +05:30
|
|
|
# $Id$
|
|
|
|
|
2005-08-12 21:55:43 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK+/GNOME modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
import gtk
|
2006-01-06 20:53:28 +05:30
|
|
|
import logging
|
|
|
|
|
|
|
|
log = logging.getLogger(".")
|
2005-08-12 21:55:43 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-08-09 10:11:20 +05:30
|
|
|
import ViewManager
|
2005-12-06 12:08:09 +05:30
|
|
|
import GrampsDisplay
|
|
|
|
import RelLib
|
2005-12-21 16:57:05 +05:30
|
|
|
import GrampsDb
|
2005-08-09 10:11:20 +05:30
|
|
|
import ArgHandler
|
2006-03-03 05:40:52 +05:30
|
|
|
import Config
|
2002-10-20 19:55:16 +05:30
|
|
|
import GrampsCfg
|
2005-08-09 10:11:20 +05:30
|
|
|
import const
|
2005-03-30 07:15:14 +05:30
|
|
|
import Errors
|
2005-08-09 10:11:20 +05:30
|
|
|
import PluginMgr
|
2005-08-09 15:48:56 +05:30
|
|
|
import TipOfDay
|
2006-03-04 21:07:04 +05:30
|
|
|
import DataViews
|
2004-04-10 09:08:48 +05:30
|
|
|
|
2006-03-03 05:53:04 +05:30
|
|
|
from Mime import mime_type_is_defined
|
2005-08-09 10:11:20 +05:30
|
|
|
from QuestionDialog import ErrorDialog
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-03-04 05:18:11 +05:30
|
|
|
iconpaths = [const.image_dir,"."]
|
2005-04-04 06:41:50 +05:30
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
def register_stock_icons ():
|
|
|
|
import os
|
2005-08-12 08:05:27 +05:30
|
|
|
items = [
|
2006-03-04 05:18:11 +05:30
|
|
|
(os.path.join(const.image_dir,'person.svg'),
|
|
|
|
('gramps-person','Person',gtk.gdk.CONTROL_MASK,0,'')),
|
|
|
|
(os.path.join(const.image_dir,'relation.svg'),
|
|
|
|
('gramps-family','Relationships',gtk.gdk.CONTROL_MASK,0,'')),
|
|
|
|
(os.path.join(const.image_dir,'flist.svg'),
|
|
|
|
('gramps-family-list','Family List',gtk.gdk.CONTROL_MASK,0,'')),
|
|
|
|
(os.path.join(const.image_dir,'/media.svg'),
|
|
|
|
('gramps-media','Media',gtk.gdk.CONTROL_MASK,0,'')),
|
|
|
|
(os.path.join(const.image_dir,'ped24.png'),
|
|
|
|
('gramps-pedigree','Pedigree',gtk.gdk.CONTROL_MASK,0,'')),
|
|
|
|
(os.path.join(const.image_dir,'repos.png'),
|
|
|
|
('gramps-repository','Repositories',gtk.gdk.CONTROL_MASK,0,'')),
|
|
|
|
(os.path.join(const.image_dir,'sources.png'),
|
|
|
|
('gramps-source','Sources',gtk.gdk.CONTROL_MASK,0,'')),
|
|
|
|
(os.path.join(const.image_dir,'events.png'),
|
|
|
|
('gramps-event','Events',gtk.gdk.CONTROL_MASK,0,'')),
|
|
|
|
(os.path.join(const.image_dir,'place.png'),
|
|
|
|
('gramps-place','Places',gtk.gdk.CONTROL_MASK,0,'')),
|
|
|
|
(os.path.join(const.image_dir,'place.png'),
|
|
|
|
('gramps-map','Map',gtk.gdk.CONTROL_MASK,0,'')),
|
2005-08-12 08:05:27 +05:30
|
|
|
]
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
# Register our stock items
|
2005-08-12 08:05:27 +05:30
|
|
|
gtk.stock_add (map(lambda x: x[1],items))
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
# Add our custom icon factory to the list of defaults
|
|
|
|
factory = gtk.IconFactory ()
|
|
|
|
factory.add_default ()
|
|
|
|
|
2005-08-12 08:05:27 +05:30
|
|
|
for (key,data) in items:
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
for dirname in iconpaths:
|
|
|
|
icon_file = os.path.expanduser(os.path.join(dirname,key))
|
|
|
|
if os.path.isfile(icon_file):
|
|
|
|
break
|
|
|
|
else:
|
2006-03-04 05:18:11 +05:30
|
|
|
icon_file = os.path.join(const.image_dir,'gramps.png')
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
pixbuf = gtk.gdk.pixbuf_new_from_file (icon_file)
|
|
|
|
pixbuf = pixbuf.add_alpha(True, chr(0xff), chr(0xff), chr(0xff))
|
|
|
|
|
|
|
|
# Register icon to accompany stock item
|
|
|
|
if pixbuf:
|
|
|
|
icon_set = gtk.IconSet (pixbuf)
|
2005-08-12 08:05:27 +05:30
|
|
|
factory.add (data[0], icon_set)
|
2005-08-09 10:11:20 +05:30
|
|
|
else:
|
2006-01-06 20:53:28 +05:30
|
|
|
log.debug('failed to load GTK logo for toolbar')
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
class Gramps:
|
2005-08-12 08:20:56 +05:30
|
|
|
"""
|
|
|
|
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 19:55:16 +05:30
|
|
|
|
2003-05-17 09:44:13 +05:30
|
|
|
def __init__(self,args):
|
2005-03-18 00:58:00 +05:30
|
|
|
try:
|
|
|
|
GrampsCfg.loadConfig()
|
2005-05-11 19:34:47 +05:30
|
|
|
self.welcome()
|
2005-05-07 08:11:08 +05:30
|
|
|
except OSError, msg:
|
|
|
|
ErrorDialog(_("Configuration error"),str(msg))
|
|
|
|
return
|
2005-03-30 07:15:14 +05:30
|
|
|
except Errors.GConfSchemaError, val:
|
2005-08-12 08:20:56 +05:30
|
|
|
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-18 00:58:00 +05:30
|
|
|
gtk.main_quit()
|
|
|
|
return
|
2005-05-07 08:11:08 +05:30
|
|
|
except:
|
2006-01-09 16:58:44 +05:30
|
|
|
log.error("Error reading configuration.", exc_info=True)
|
2005-05-07 08:11:08 +05:30
|
|
|
return
|
2005-03-18 00:58:00 +05:30
|
|
|
|
|
|
|
if not mime_type_is_defined(const.app_gramps):
|
|
|
|
ErrorDialog(_("Configuration error"),
|
2005-08-12 08:20:56 +05:30
|
|
|
_("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-18 00:58:00 +05:30
|
|
|
gtk.main_quit()
|
|
|
|
return
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-06-21 10:40:27 +05:30
|
|
|
|
2005-08-12 21:55:43 +05:30
|
|
|
register_stock_icons()
|
|
|
|
|
2005-12-21 16:57:05 +05:30
|
|
|
state = GrampsDb.DbState()
|
2005-08-12 21:55:43 +05:30
|
|
|
vm = ViewManager.ViewManager(state)
|
2006-03-04 21:07:04 +05:30
|
|
|
for view in DataViews.get_views():
|
|
|
|
vm.register_view(view)
|
2005-08-12 21:55:43 +05:30
|
|
|
|
|
|
|
ArgHandler.ArgHandler(state,vm,args)
|
|
|
|
|
|
|
|
vm.init_interface()
|
2005-08-14 10:01:29 +05:30
|
|
|
state.db.request_rebuild()
|
2005-08-13 00:30:43 +05:30
|
|
|
state.change_active_person(state.db.get_default_person())
|
2005-08-12 21:55:43 +05:30
|
|
|
|
2004-06-22 04:52:55 +05:30
|
|
|
# Don't show main window until ArgHandler is done.
|
2004-06-22 04:54:51 +05:30
|
|
|
# This prevents a window from annoyingly popping up when
|
|
|
|
# the command line args are sufficient to operate without it.
|
2006-03-03 05:40:52 +05:30
|
|
|
Config.client.notify_add("/apps/gramps/researcher",
|
2004-08-07 10:46:57 +05:30
|
|
|
self.researcher_key_update)
|
2006-03-03 05:40:52 +05:30
|
|
|
Config.client.notify_add("/apps/gramps/interface/statusbar",
|
2004-08-07 10:46:57 +05:30
|
|
|
self.statusbar_key_update)
|
2006-03-03 05:40:52 +05:30
|
|
|
# Config.client.notify_add("/apps/gramps/interface/toolbar",
|
2005-08-09 10:11:20 +05:30
|
|
|
## self.toolbar_key_update)
|
2006-03-03 05:40:52 +05:30
|
|
|
# Config.client.notify_add("/apps/gramps/interface/toolbar-on",
|
2005-08-09 10:11:20 +05:30
|
|
|
# self.toolbar_on_key_update)
|
2006-03-03 05:40:52 +05:30
|
|
|
# Config.client.notify_add("/apps/gramps/interface/filter",
|
2005-08-09 10:11:20 +05:30
|
|
|
# self.filter_key_update)
|
2006-03-03 05:40:52 +05:30
|
|
|
# Config.client.notify_add("/apps/gramps/interface/view",
|
2005-08-09 10:11:20 +05:30
|
|
|
# self.sidebar_key_update)
|
2006-03-03 05:40:52 +05:30
|
|
|
# Config.client.notify_add("/apps/gramps/interface/familyview",
|
2005-08-09 10:11:20 +05:30
|
|
|
# self.familyview_key_update)
|
2006-03-03 05:40:52 +05:30
|
|
|
# Config.client.notify_add("/apps/gramps/preferences/name-format",
|
2005-08-09 10:11:20 +05:30
|
|
|
# self.familyview_key_update)
|
2006-03-03 05:40:52 +05:30
|
|
|
# Config.client.notify_add("/apps/gramps/preferences/date-format",
|
2005-08-09 10:11:20 +05:30
|
|
|
# self.date_format_key_update)
|
|
|
|
|
2006-03-03 05:40:52 +05:30
|
|
|
if Config.get_usetips():
|
2005-08-25 20:38:07 +05:30
|
|
|
TipOfDay.TipOfDay(vm.uistate)
|
2004-05-18 12:30:34 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
## # FIXME: THESE will have to be added (ViewManager?)
|
|
|
|
## # once bookmarks work again
|
|
|
|
## self.db.set_researcher(GrampsCfg.get_researcher())
|
|
|
|
## self.db.connect('person-delete',self.on_remove_bookmark)
|
|
|
|
## self.db.connect('person-update',self.on_update_bookmark)
|
|
|
|
|
2005-05-11 19:34:47 +05:30
|
|
|
def welcome(self):
|
2006-03-03 05:40:52 +05:30
|
|
|
if Config.get_welcome() >= 200:
|
2005-05-07 08:11:08 +05:30
|
|
|
return
|
2005-05-11 19:34:47 +05:30
|
|
|
|
|
|
|
glade = gtk.glade.XML(const.gladeFile,'scrollmsg')
|
|
|
|
top = glade.get_widget('scrollmsg')
|
|
|
|
msg = glade.get_widget('msg')
|
|
|
|
msg.get_buffer().set_text(
|
|
|
|
_("Welcome to the 2.0.x series of GRAMPS!\n"
|
|
|
|
"\n"
|
|
|
|
"This version drastically differs from the 1.0.x branch\n"
|
|
|
|
"in a few ways. Please read carefully, as this may affect\n"
|
|
|
|
"the way you are using the program.\n"
|
|
|
|
"\n"
|
|
|
|
"1. This version works with the Berkeley database backend.\n"
|
|
|
|
" Because of this, changes are written to disk immediately.\n"
|
|
|
|
" There is NO Save function anymore!\n"
|
|
|
|
"2. The Media object files are not managed by GRAMPS.\n"
|
|
|
|
" There is no concept of local objects, all objects\n"
|
|
|
|
" are external. You are in charge of keeping track of\n"
|
|
|
|
" your files. If you delete the image file from disk,\n"
|
|
|
|
" it will be lost!\n"
|
|
|
|
"3. The version control provided by previous GRAMPS\n"
|
|
|
|
" versions has been removed. You may set up the versioning\n"
|
|
|
|
" system on your own if you'd like, but it will have to be\n"
|
|
|
|
" outside of GRAMPS.\n"
|
|
|
|
"4. It is possible to directly open GRAMPS XML databases\n"
|
|
|
|
" (used by previous versions) as well as GEDCOM files.\n"
|
|
|
|
" However, any changes will be written to the disk when\n"
|
|
|
|
" you quit GRAMPS. In case of GEDCOM files, this may lead\n"
|
|
|
|
" to a data loss because some GEDCOM files contain data\n"
|
|
|
|
" that does not comply with the GEDCOM standard and cannot\n"
|
|
|
|
" be parsed by GRAMPS. If unsure, set up an empty grdb\n"
|
|
|
|
" database (new GRAMPS format) and import GEDCOM into it.\n"
|
|
|
|
" This will keep the original GEDCOM untouched.\n"
|
|
|
|
"\n"
|
|
|
|
"Enjoy!\n"
|
|
|
|
"The GRAMPS project\n"))
|
|
|
|
top.run()
|
|
|
|
top.destroy()
|
|
|
|
|
2006-03-03 05:40:52 +05:30
|
|
|
Config.save_welcome(200)
|
|
|
|
Config.sync()
|
2005-05-07 08:11:08 +05:30
|
|
|
|
2004-07-20 07:57:55 +05:30
|
|
|
def researcher_key_update(self,client,cnxn_id,entry,data):
|
2005-08-09 10:11:20 +05:30
|
|
|
pass
|
2006-03-03 05:40:52 +05:30
|
|
|
# self.db.set_person_id_prefix(Config.get_person_id_prefix())
|
|
|
|
# self.db.set_family_id_prefix(Config.get_family_id_prefix())
|
|
|
|
# self.db.set_source_id_prefix(Config.get_source_id_prefix())
|
|
|
|
# self.db.set_object_id_prefix(Config.get_object_id_prefix())
|
|
|
|
# self.db.set_place_id_prefix(Config.get_place_id_prefix())
|
|
|
|
# self.db.set_event_id_prefix(Config.get_event_id_prefix())
|
2004-07-15 08:24:04 +05:30
|
|
|
|
2004-07-20 07:57:55 +05:30
|
|
|
def statusbar_key_update(self,client,cnxn_id,entry,data):
|
2003-10-16 22:13:07 +05:30
|
|
|
self.modify_statusbar()
|
2004-07-20 07:57:55 +05:30
|
|
|
|
|
|
|
def toolbar_key_update(self,client,cnxn_id,entry,data):
|
2006-03-03 05:40:52 +05:30
|
|
|
the_style = Config.get_toolbar()
|
2005-01-09 04:05:04 +05:30
|
|
|
if the_style == -1:
|
|
|
|
self.toolbar.unset_style()
|
|
|
|
else:
|
|
|
|
self.toolbar.set_style(the_style)
|