2005-08-09 10:11:20 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-06-14 11:02:06 +05:30
|
|
|
# Copyright (C) 2005-2007 Donald N. Allingham
|
2008-05-19 00:54:28 +05:30
|
|
|
# Copyright (C) 2008 Brian G. Matherly
|
2005-08-09 10:11:20 +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.
|
|
|
|
#
|
2006-04-08 11:26:31 +05:30
|
|
|
# This program is distributed in the hope that it will be useful,
|
2005-08-09 10:11:20 +05:30
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
2008-01-25 02:08:10 +05:30
|
|
|
# $Id:ViewManager.py 9912 2008-01-22 09:17:46Z acraphae $
|
2005-08-12 08:20:56 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
"""
|
|
|
|
Manages the main window and the pluggable views
|
|
|
|
"""
|
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-08 11:26:31 +05:30
|
|
|
import os
|
|
|
|
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2005-12-29 04:28:26 +05:30
|
|
|
from cStringIO import StringIO
|
2006-03-05 10:15:44 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# set up logging
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-01-09 16:58:44 +05:30
|
|
|
import logging
|
2007-02-23 03:01:37 +05:30
|
|
|
LOG = logging.getLogger(".")
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-06-19 03:26:37 +05:30
|
|
|
from cli import CLIManager
|
2008-10-02 09:32:10 +05:30
|
|
|
from PluginUtils import Tool, PluginWindows, \
|
2008-05-19 09:44:11 +05:30
|
|
|
ReportPluginDialog, ToolPluginDialog
|
2007-09-09 10:54:15 +05:30
|
|
|
import ReportBase
|
2005-08-12 08:20:56 +05:30
|
|
|
import DisplayState
|
2005-08-09 10:11:20 +05:30
|
|
|
import const
|
2006-03-03 05:40:52 +05:30
|
|
|
import Config
|
2005-08-09 10:11:20 +05:30
|
|
|
import GrampsCfg
|
|
|
|
import Errors
|
2008-02-29 04:02:40 +05:30
|
|
|
from QuestionDialog import (ErrorDialog, WarningDialog, QuestionDialog2,
|
|
|
|
InfoDialog)
|
2005-08-11 05:23:24 +05:30
|
|
|
import PageView
|
|
|
|
import Navigation
|
2007-06-14 11:02:06 +05:30
|
|
|
import RecentFiles
|
2007-06-28 11:11:40 +05:30
|
|
|
from BasicUtils import name_displayer
|
2008-05-09 01:10:56 +05:30
|
|
|
import widgets
|
2006-05-06 03:25:01 +05:30
|
|
|
import UndoHistory
|
2009-06-19 03:26:37 +05:30
|
|
|
from gui.dbloader import DbLoader
|
2006-05-14 06:13:05 +05:30
|
|
|
import GrampsDisplay
|
2007-10-09 02:49:32 +05:30
|
|
|
from gen.utils import ProgressMonitor
|
2008-04-07 02:05:38 +05:30
|
|
|
from GrampsAboutDialog import GrampsAboutDialog
|
2007-02-18 01:29:21 +05:30
|
|
|
import ProgressDialog
|
2006-12-21 08:58:44 +05:30
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-05-19 09:44:11 +05:30
|
|
|
_UNSUPPORTED = _("Unsupported")
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2007-02-23 03:01:37 +05:30
|
|
|
UIDEFAULT = '''<ui>
|
2005-08-09 10:11:20 +05:30
|
|
|
<menubar name="MenuBar">
|
|
|
|
<menu action="FileMenu">
|
|
|
|
<menuitem action="Open"/>
|
2005-12-24 05:39:04 +05:30
|
|
|
<menu action="OpenRecent">
|
|
|
|
</menu>
|
2005-08-09 10:11:20 +05:30
|
|
|
<separator/>
|
|
|
|
<menuitem action="Import"/>
|
|
|
|
<menuitem action="Export"/>
|
2007-02-06 10:49:16 +05:30
|
|
|
<placeholder name="LocalExport"/>
|
2005-08-09 10:11:20 +05:30
|
|
|
<separator/>
|
|
|
|
<menuitem action="Abandon"/>
|
|
|
|
<menuitem action="Quit"/>
|
|
|
|
</menu>
|
|
|
|
<menu action="EditMenu">
|
|
|
|
<menuitem action="Undo"/>
|
2006-01-13 05:04:33 +05:30
|
|
|
<menuitem action="Redo"/>
|
2006-05-06 03:25:01 +05:30
|
|
|
<menuitem action="UndoHistory"/>
|
2005-08-09 10:11:20 +05:30
|
|
|
<separator/>
|
|
|
|
<placeholder name="CommonEdit"/>
|
2006-05-13 09:55:45 +05:30
|
|
|
<separator/>
|
2006-05-25 09:38:05 +05:30
|
|
|
<menuitem action="ScratchPad"/>
|
|
|
|
<placeholder name="Merge"/>
|
2005-08-09 10:11:20 +05:30
|
|
|
<separator/>
|
|
|
|
<menuitem action="Preferences"/>
|
|
|
|
</menu>
|
|
|
|
<menu action="ViewMenu">
|
|
|
|
<menuitem action="Sidebar"/>
|
|
|
|
<menuitem action="Toolbar"/>
|
2006-07-11 03:16:46 +05:30
|
|
|
<menuitem action="Filter"/>
|
2008-06-22 20:04:18 +05:30
|
|
|
<menuitem action="Fullscreen"/>
|
2006-01-08 08:36:58 +05:30
|
|
|
<separator/>
|
2005-08-09 10:11:20 +05:30
|
|
|
</menu>
|
|
|
|
<menu action="GoMenu">
|
|
|
|
<placeholder name="CommonGo"/>
|
2005-08-11 05:23:24 +05:30
|
|
|
<placeholder name="CommonHistory"/>
|
2005-08-09 10:11:20 +05:30
|
|
|
</menu>
|
|
|
|
<menu action="BookMenu">
|
2006-04-27 03:18:13 +05:30
|
|
|
<placeholder name="AddEditBook"/>
|
2006-04-26 09:54:54 +05:30
|
|
|
<separator/>
|
|
|
|
<placeholder name="GoToBook"/>
|
2005-08-09 10:11:20 +05:30
|
|
|
</menu>
|
|
|
|
<menu action="ReportsMenu">
|
|
|
|
</menu>
|
|
|
|
<menu action="ToolsMenu">
|
|
|
|
</menu>
|
|
|
|
<menu action="WindowsMenu">
|
2005-12-15 10:15:20 +05:30
|
|
|
<placeholder name="WinMenu"/>
|
2005-08-09 10:11:20 +05:30
|
|
|
</menu>
|
|
|
|
<menu action="HelpMenu">
|
2005-08-13 08:53:02 +05:30
|
|
|
<menuitem action="UserManual"/>
|
|
|
|
<menuitem action="FAQ"/>
|
2006-12-31 11:20:40 +05:30
|
|
|
<menuitem action="KeyBindings"/>
|
2005-08-25 20:38:07 +05:30
|
|
|
<menuitem action="TipOfDay"/>
|
2005-12-29 04:28:26 +05:30
|
|
|
<menuitem action="PluginStatus"/>
|
2005-08-13 08:53:02 +05:30
|
|
|
<separator/>
|
|
|
|
<menuitem action="HomePage"/>
|
|
|
|
<menuitem action="MailingLists"/>
|
|
|
|
<menuitem action="ReportBug"/>
|
2008-03-07 20:01:04 +05:30
|
|
|
<menuitem action="ExtraPlugins"/>
|
2005-08-13 08:53:02 +05:30
|
|
|
<separator/>
|
2005-08-09 10:11:20 +05:30
|
|
|
<menuitem action="About"/>
|
|
|
|
</menu>
|
|
|
|
</menubar>
|
|
|
|
<toolbar name="ToolBar">
|
|
|
|
<placeholder name="CommonNavigation"/>
|
|
|
|
<separator/>
|
|
|
|
<toolitem action="ScratchPad"/>
|
|
|
|
<toolitem action="Reports"/>
|
|
|
|
<toolitem action="Tools"/>
|
|
|
|
<separator/>
|
|
|
|
<placeholder name="CommonEdit"/>
|
|
|
|
</toolbar>
|
2006-04-27 22:33:23 +05:30
|
|
|
<accelerator action="F2"/>
|
|
|
|
<accelerator action="F3"/>
|
|
|
|
<accelerator action="F4"/>
|
|
|
|
<accelerator action="F5"/>
|
|
|
|
<accelerator action="F6"/>
|
|
|
|
<accelerator action="F7"/>
|
|
|
|
<accelerator action="F8"/>
|
|
|
|
<accelerator action="F9"/>
|
|
|
|
<accelerator action="F11"/>
|
|
|
|
<accelerator action="F12"/>
|
2007-01-26 10:39:25 +05:30
|
|
|
<accelerator action="<CONTROL>BackSpace"/>
|
2007-01-26 05:45:21 +05:30
|
|
|
<accelerator action="<CONTROL>J"/>
|
2008-02-19 19:04:53 +05:30
|
|
|
<accelerator action="<CONTROL>N"/>
|
|
|
|
<accelerator action="<CONTROL>P"/>
|
2005-08-09 10:11:20 +05:30
|
|
|
</ui>
|
|
|
|
'''
|
|
|
|
|
2009-02-26 15:27:08 +05:30
|
|
|
WIKI_HELP_PAGE_FAQ = '%s_-_FAQ' % const.URL_MANUAL_PAGE
|
|
|
|
WIKI_HELP_PAGE_KEY = '%s_-_Keybindings' % const.URL_MANUAL_PAGE
|
|
|
|
WIKI_HELP_PAGE_MAN = '%s' % const.URL_MANUAL_PAGE
|
2009-06-19 03:26:37 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# ViewManager
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-06-19 03:26:37 +05:30
|
|
|
|
|
|
|
class ViewManager(CLIManager):
|
2007-09-09 10:54:15 +05:30
|
|
|
"""
|
|
|
|
Overview
|
|
|
|
========
|
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
The ViewManager is the session manager of the program.
|
|
|
|
Specifically, it manages the main window of the program. It is closely tied
|
2007-09-09 10:54:15 +05:30
|
|
|
into the gtk.UIManager to control all menus and actions.
|
|
|
|
|
|
|
|
The ViewManager controls the various Views within the GRAMPS programs.
|
|
|
|
A View is a particular way of looking a information in the GRAMPS main
|
|
|
|
window. Each view is separate from the others, and has no knowledge of
|
|
|
|
the others. All Views are held in the DisplayViews module. Examples of
|
|
|
|
current views include:
|
|
|
|
|
2008-01-09 12:15:15 +05:30
|
|
|
- Person View
|
|
|
|
- Relationship View
|
|
|
|
- Family View
|
|
|
|
- Source View
|
2007-09-09 10:54:15 +05:30
|
|
|
|
|
|
|
The View Manager does not have to know the number of views, the type of
|
|
|
|
views, or any other details about the views. It simply provides the
|
2009-06-19 03:26:37 +05:30
|
|
|
method of containing each view, and switching between the views.
|
2007-09-09 10:54:15 +05:30
|
|
|
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
def __init__(self, dbstate):
|
|
|
|
CLIManager.__init__(self, dbstate, False)
|
2006-10-02 07:40:12 +05:30
|
|
|
self.page_is_changing = False
|
2005-08-09 10:11:20 +05:30
|
|
|
self.active_page = None
|
|
|
|
self.views = []
|
2005-08-15 09:15:16 +05:30
|
|
|
self.pages = []
|
2007-09-17 00:15:57 +05:30
|
|
|
self.button_handlers = []
|
|
|
|
self.buttons = []
|
|
|
|
self.merge_ids = []
|
2007-03-19 09:49:49 +05:30
|
|
|
self.tips = gtk.Tooltips()
|
2006-08-26 05:16:19 +05:30
|
|
|
self._key = None
|
2007-09-17 00:15:57 +05:30
|
|
|
|
|
|
|
self.show_sidebar = Config.get(Config.VIEW)
|
|
|
|
self.show_toolbar = Config.get(Config.TOOLBAR_ON)
|
|
|
|
self.show_filter = Config.get(Config.FILTER)
|
2008-06-22 20:04:18 +05:30
|
|
|
self.fullscreen = Config.get(Config.FULLSCREEN)
|
2007-09-17 00:15:57 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
self.__build_main_window()
|
|
|
|
self.__connect_signals()
|
2009-06-19 03:26:37 +05:30
|
|
|
self.do_load_plugins()
|
2006-04-08 11:26:31 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
def _errordialog(title, errormessage):
|
|
|
|
"""
|
|
|
|
Show the error.
|
|
|
|
In the GUI, the error is shown, and a return happens
|
|
|
|
"""
|
|
|
|
ErrorDialog(title, errormessage)
|
|
|
|
return 1
|
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __build_main_window(self):
|
2006-04-08 11:26:31 +05:30
|
|
|
"""
|
|
|
|
Builds the GTK interface
|
|
|
|
"""
|
2006-04-25 02:34:01 +05:30
|
|
|
width = Config.get(Config.WIDTH)
|
|
|
|
height = Config.get(Config.HEIGHT)
|
2006-04-08 11:26:31 +05:30
|
|
|
|
|
|
|
self.window = gtk.Window()
|
2007-09-08 11:24:02 +05:30
|
|
|
self.window.set_icon_from_file(const.ICON)
|
2006-04-08 11:26:31 +05:30
|
|
|
self.window.set_default_size(width, height)
|
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
self.rel_class = self._pmgr.get_relationship_calculator()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
vbox = gtk.VBox()
|
|
|
|
self.window.add(vbox)
|
|
|
|
hbox = gtk.HBox()
|
|
|
|
self.ebox = gtk.EventBox()
|
|
|
|
self.bbox = gtk.VBox()
|
|
|
|
self.ebox.add(self.bbox)
|
2006-04-08 11:26:31 +05:30
|
|
|
hbox.pack_start(self.ebox, False)
|
2005-12-16 05:18:06 +05:30
|
|
|
hbox.show_all()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
self.notebook = gtk.Notebook()
|
2008-06-25 01:57:01 +05:30
|
|
|
self.notebook.set_scrollable(True)
|
2005-08-09 10:11:20 +05:30
|
|
|
self.notebook.set_show_tabs(False)
|
2005-12-16 05:18:06 +05:30
|
|
|
self.notebook.show()
|
2007-09-09 10:54:15 +05:30
|
|
|
self.__init_lists()
|
|
|
|
self.__build_ui_manager()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
hbox.pack_start(self.notebook, True)
|
2005-08-09 10:11:20 +05:30
|
|
|
self.menubar = self.uimanager.get_widget('/MenuBar')
|
|
|
|
self.toolbar = self.uimanager.get_widget('/ToolBar')
|
|
|
|
vbox.pack_start(self.menubar, False)
|
|
|
|
vbox.pack_start(self.toolbar, False)
|
|
|
|
vbox.add(hbox)
|
2007-09-10 07:39:50 +05:30
|
|
|
vbox.pack_end(self.__setup_statusbar(), False)
|
|
|
|
vbox.show()
|
|
|
|
|
2007-05-02 09:35:41 +05:30
|
|
|
self.progress_monitor = ProgressMonitor(
|
2007-09-09 10:54:15 +05:30
|
|
|
ProgressDialog.GtkProgressDialog, ("", self.window))
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
self.uistate = DisplayState.DisplayState(
|
|
|
|
self.window, self.statusbar, self.progress, self.warnbtn,
|
2008-02-15 19:48:55 +05:30
|
|
|
self.uimanager, self.progress_monitor, self)
|
2007-09-09 10:54:15 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
self.dbstate.connect('database-changed', self.uistate.db_changed)
|
2005-08-11 05:23:24 +05:30
|
|
|
|
2007-05-02 09:35:41 +05:30
|
|
|
self.filter_menu = self.uimanager.get_widget(
|
|
|
|
'/MenuBar/ViewMenu/Filter/')
|
2007-03-06 09:43:14 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
# handle OPEN button, insert it into the toolbar. Unfortunately,
|
|
|
|
# UIManager has no built in support for and Open Recent button
|
2006-05-10 00:04:58 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
openbtn = self.__build_open_button()
|
2006-01-05 02:36:28 +05:30
|
|
|
self.uistate.set_open_widget(openbtn)
|
2007-09-09 10:54:15 +05:30
|
|
|
self.toolbar.insert(openbtn, 0)
|
2006-05-10 00:04:58 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
self.person_nav = Navigation.PersonNavigation(self.dbstate, self.uistate)
|
2007-09-09 10:54:15 +05:30
|
|
|
self._navigation_type[PageView.NAVIGATION_PERSON] = (self.person_nav,
|
2006-04-08 11:26:31 +05:30
|
|
|
None)
|
2007-06-14 11:02:06 +05:30
|
|
|
self.recent_manager = DisplayState.RecentDocsMenu(
|
2009-06-19 03:26:37 +05:30
|
|
|
self.uistate, self.dbstate, self._read_recent_file)
|
2007-06-14 11:02:06 +05:30
|
|
|
self.recent_manager.build()
|
2006-01-08 08:36:58 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
self.db_loader = DbLoader(self.dbstate, self.uistate)
|
2006-05-18 05:06:31 +05:30
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
self.__setup_sidebar()
|
2006-01-08 08:36:58 +05:30
|
|
|
|
|
|
|
if self.show_toolbar:
|
|
|
|
self.toolbar.show()
|
|
|
|
else:
|
|
|
|
self.toolbar.hide()
|
|
|
|
|
2008-06-22 20:04:18 +05:30
|
|
|
if self.fullscreen:
|
|
|
|
self.window.fullscreen()
|
|
|
|
|
2006-05-18 08:41:15 +05:30
|
|
|
# Showing the main window is deferred so that
|
|
|
|
# ArgHandler can work without it always shown
|
|
|
|
# But we need to realize it here to have gtk.gdk.window handy
|
|
|
|
self.window.realize()
|
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
def __setup_statusbar(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create the statusbar that sits at the bottom of the window
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
self.progress = gtk.ProgressBar()
|
|
|
|
self.progress.set_size_request(100, -1)
|
|
|
|
self.progress.hide()
|
|
|
|
|
2008-05-09 01:10:56 +05:30
|
|
|
self.statusbar = widgets.Statusbar()
|
2007-09-10 07:39:50 +05:30
|
|
|
self.statusbar.show()
|
|
|
|
|
2008-05-09 01:10:56 +05:30
|
|
|
self.warnbtn = widgets.WarnButton()
|
2007-09-10 07:39:50 +05:30
|
|
|
|
|
|
|
hbox2 = gtk.HBox()
|
|
|
|
hbox2.set_spacing(4)
|
|
|
|
hbox2.set_border_width(2)
|
|
|
|
hbox2.pack_start(self.progress, False)
|
|
|
|
hbox2.pack_start(self.warnbtn, False)
|
|
|
|
hbox2.pack_end(self.statusbar, True)
|
|
|
|
hbox2.show()
|
|
|
|
return hbox2
|
|
|
|
|
|
|
|
def __setup_sidebar(self):
|
|
|
|
"""
|
|
|
|
If we have enabled te sidebar, show it, and turn off the tabs. If
|
|
|
|
disabled, hide the sidebar and turn on the tabs.
|
|
|
|
"""
|
|
|
|
if self.show_sidebar:
|
|
|
|
self.ebox.show()
|
|
|
|
self.notebook.set_show_tabs(False)
|
|
|
|
else:
|
|
|
|
self.ebox.hide()
|
|
|
|
self.notebook.set_show_tabs(True)
|
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __build_open_button(self):
|
|
|
|
"""
|
|
|
|
Build the OPEN button. Since GTK's UIManager does not have support for
|
|
|
|
the Open Recent button, we must build in on our own.
|
|
|
|
"""
|
|
|
|
openbtn = gtk.MenuToolButton('gramps-db')
|
|
|
|
openbtn.connect('clicked', self.__open_activate)
|
|
|
|
openbtn.set_sensitive(False)
|
|
|
|
open_tips = gtk.Tooltips()
|
|
|
|
openbtn.set_arrow_tooltip(
|
|
|
|
open_tips,
|
|
|
|
_("Connect to a recent database"),
|
|
|
|
_("Connect to a recent database"))
|
|
|
|
|
|
|
|
openbtn.set_tooltip(
|
|
|
|
open_tips,
|
|
|
|
_("Manage databases"),
|
|
|
|
_("Manage databases")
|
|
|
|
)
|
|
|
|
openbtn.show()
|
|
|
|
return openbtn
|
|
|
|
|
|
|
|
def __connect_signals(self):
|
2006-04-08 11:26:31 +05:30
|
|
|
"""
|
|
|
|
connects the signals needed
|
|
|
|
"""
|
2006-08-13 02:43:45 +05:30
|
|
|
self.window.connect('delete-event', self.quit)
|
2006-04-08 11:26:31 +05:30
|
|
|
self.notebook.connect('switch-page', self.change_page)
|
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __init_lists(self):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Initialize the actions lists for the UIManager
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2006-04-08 11:26:31 +05:30
|
|
|
self._file_action_list = [
|
2007-03-29 07:12:21 +05:30
|
|
|
('FileMenu', None, _('_Family Trees')),
|
2008-01-29 02:52:06 +05:30
|
|
|
('Open', 'gramps-db', _('_Manage Family Trees...'), "<control>o",
|
2007-09-09 10:54:15 +05:30
|
|
|
_("Manage databases"), self.__open_activate),
|
|
|
|
('OpenRecent', None, _('Open _Recent'), None,
|
2006-05-08 06:45:19 +05:30
|
|
|
_("Open an existing database")),
|
2007-09-09 10:54:15 +05:30
|
|
|
('Quit', gtk.STOCK_QUIT, _('_Quit'), "<control>q", None,
|
|
|
|
self.quit),
|
2006-04-28 22:32:53 +05:30
|
|
|
('ViewMenu', None, _('_View')),
|
|
|
|
('EditMenu', None, _('_Edit')),
|
2008-01-30 03:18:19 +05:30
|
|
|
('Preferences', gtk.STOCK_PREFERENCES, _('_Preferences...'), None,
|
2007-09-09 10:54:15 +05:30
|
|
|
None, self.preferences_activate),
|
2006-04-28 22:32:53 +05:30
|
|
|
('HelpMenu', None, _('_Help')),
|
2008-01-29 02:52:06 +05:30
|
|
|
('HomePage', None, _('GRAMPS _Home Page'), None, None,
|
2007-09-09 10:54:15 +05:30
|
|
|
home_page_activate),
|
2008-01-29 02:52:06 +05:30
|
|
|
('MailingLists', None, _('GRAMPS _Mailing Lists'), None, None,
|
2007-09-09 10:54:15 +05:30
|
|
|
mailing_lists_activate),
|
2008-01-29 02:52:06 +05:30
|
|
|
('ReportBug', None, _('_Report a Bug'), None, None,
|
2008-03-07 20:01:04 +05:30
|
|
|
report_bug_activate),
|
|
|
|
('ExtraPlugins', None, _('_Extra Reports/Tools'), None, None,
|
|
|
|
extra_plugins_activate),
|
2007-09-09 10:54:15 +05:30
|
|
|
('About', gtk.STOCK_ABOUT, _('_About'), None, None,
|
|
|
|
display_about_box),
|
2008-01-29 02:52:06 +05:30
|
|
|
('PluginStatus', None, _('_Plugin Status'), None, None,
|
2008-04-01 08:42:08 +05:30
|
|
|
self.__plugin_status),
|
2007-09-09 10:54:15 +05:30
|
|
|
('FAQ', None, _('_FAQ'), None, None, faq_activate),
|
|
|
|
('KeyBindings', None, _('_Key Bindings'), None, None, key_bindings),
|
|
|
|
('UserManual', gtk.STOCK_HELP, _('_User Manual'), 'F1', None,
|
|
|
|
manual_activate),
|
2008-01-29 02:52:06 +05:30
|
|
|
('TipOfDay', None, _('Tip of the Day'), None, None,
|
2006-04-08 11:26:31 +05:30
|
|
|
self.tip_of_day_activate),
|
|
|
|
]
|
|
|
|
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
self._readonly_action_list = [
|
2008-01-29 02:52:06 +05:30
|
|
|
('Export', 'gramps-export', _('_Export...'), "<control>e", None,
|
2006-04-08 11:26:31 +05:30
|
|
|
self.export_data),
|
2007-09-09 10:54:15 +05:30
|
|
|
('Abandon', gtk.STOCK_REVERT_TO_SAVED,
|
2008-01-29 02:52:06 +05:30
|
|
|
_('_Abandon Changes and Quit'), None, None, self.abort),
|
2007-09-09 10:54:15 +05:30
|
|
|
('Reports', 'gramps-reports', _('_Reports'), None,
|
2006-05-08 06:45:19 +05:30
|
|
|
_("Open the reports dialog"), self.reports_clicked),
|
2006-04-28 22:32:53 +05:30
|
|
|
('GoMenu', None, _('_Go')),
|
|
|
|
('ReportsMenu', None, _('_Reports')),
|
2007-09-09 10:54:15 +05:30
|
|
|
('WindowsMenu', None, _('_Windows')),
|
|
|
|
('F2', None, 'F2', "F2", None, self.__keypress),
|
|
|
|
('F3', None, 'F3', "F3", None, self.__keypress),
|
|
|
|
('F4', None, 'F4', "F4", None, self.__keypress),
|
|
|
|
('F5', None, 'F5', "F5", None, self.__keypress),
|
|
|
|
('F6', None, 'F6', "F6", None, self.__keypress),
|
|
|
|
('F7', None, 'F7', "F7", None, self.__keypress),
|
|
|
|
('F8', None, 'F9', "F8", None, self.__keypress),
|
|
|
|
('F9', None, 'F9', "F9", None, self.__keypress),
|
|
|
|
('F11', None, 'F11', "F11", None, self.__keypress),
|
2007-02-23 03:01:37 +05:30
|
|
|
('<CONTROL>BackSpace', None, '<CONTROL>BackSpace',
|
2007-09-09 10:54:15 +05:30
|
|
|
"<CONTROL>BackSpace", None, self.__keypress),
|
2007-02-23 03:01:37 +05:30
|
|
|
('<CONTROL>Delete', None, '<CONTROL>Delete',
|
2007-09-09 10:54:15 +05:30
|
|
|
"<CONTROL>Delete", None, self.__keypress),
|
2007-02-23 03:01:37 +05:30
|
|
|
('<CONTROL>Insert', None, '<CONTROL>Insert',
|
2007-09-09 10:54:15 +05:30
|
|
|
"<CONTROL>Insert", None, self.__keypress),
|
|
|
|
('F12', None, 'F12', "F12", None, self.__keypress),
|
2007-02-23 03:01:37 +05:30
|
|
|
('<CONTROL>J', None, '<CONTROL>J',
|
2007-09-09 10:54:15 +05:30
|
|
|
"<CONTROL>J", None, self.__keypress),
|
2008-02-19 19:04:53 +05:30
|
|
|
('<CONTROL>N', None, '<CONTROL>N', "<CONTROL>N", None,
|
|
|
|
self.__next_view),
|
|
|
|
('<CONTROL>P', None, '<CONTROL>P', "<CONTROL>P", None,
|
|
|
|
self.__prev_view),
|
2006-04-08 11:26:31 +05:30
|
|
|
]
|
|
|
|
|
2006-12-19 07:59:47 +05:30
|
|
|
self._action_action_list = [
|
2008-02-19 14:12:31 +05:30
|
|
|
('ScratchPad', gtk.STOCK_PASTE, _('Clip_board'), "<control>b",
|
2008-01-29 02:52:06 +05:30
|
|
|
_("Open the Clipboard dialog"), self.scratchpad),
|
|
|
|
('Import', 'gramps-import', _('_Import...'), "<control>i", None,
|
2006-12-19 07:59:47 +05:30
|
|
|
self.import_data),
|
2007-09-09 10:54:15 +05:30
|
|
|
('Tools', 'gramps-tools', _('_Tools'), None,
|
|
|
|
_("Open the tools dialog"), self.tools_clicked),
|
2006-12-19 07:59:47 +05:30
|
|
|
('EditMenu', None, _('_Edit')),
|
|
|
|
('BookMenu', None, _('_Bookmarks')),
|
|
|
|
('ToolsMenu', None, _('_Tools')),
|
|
|
|
]
|
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
self._file_toggle_action_list = [
|
2007-09-09 10:54:15 +05:30
|
|
|
('Sidebar', None, _('_Sidebar'), None, None, self.sidebar_toggle,
|
2006-04-08 11:26:31 +05:30
|
|
|
self.show_sidebar ),
|
2007-09-09 10:54:15 +05:30
|
|
|
('Toolbar', None, _('_Toolbar'), None, None, self.toolbar_toggle,
|
2006-04-08 11:26:31 +05:30
|
|
|
self.show_toolbar ),
|
2008-01-29 02:52:06 +05:30
|
|
|
('Filter', None, _('_Filter Sidebar'), None, None,
|
2007-09-09 10:54:15 +05:30
|
|
|
filter_toggle, self.show_filter),
|
2008-06-22 20:04:18 +05:30
|
|
|
('Fullscreen', None, _('F_ull Screen'), "F11", None,
|
|
|
|
self.fullscreen_toggle, self.fullscreen),
|
2006-04-08 11:26:31 +05:30
|
|
|
]
|
|
|
|
|
|
|
|
self._undo_action_list = [
|
2007-09-09 10:54:15 +05:30
|
|
|
('Undo', gtk.STOCK_UNDO, _('_Undo'), '<control>z', None,
|
|
|
|
self.undo),
|
2006-04-08 11:26:31 +05:30
|
|
|
]
|
|
|
|
|
|
|
|
self._redo_action_list = [
|
2007-09-09 10:54:15 +05:30
|
|
|
('Redo', gtk.STOCK_REDO, _('_Redo'), '<shift><control>z', None,
|
|
|
|
self.redo),
|
2006-04-08 11:26:31 +05:30
|
|
|
]
|
|
|
|
|
2006-05-06 03:25:01 +05:30
|
|
|
self._undo_history_action_list = [
|
2007-09-09 10:54:15 +05:30
|
|
|
('UndoHistory', 'gramps-undo-history',
|
2008-01-29 02:52:06 +05:30
|
|
|
_('Undo History...'), "<control>H", None, self.undo_history),
|
2006-05-06 03:25:01 +05:30
|
|
|
]
|
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
self._navigation_type = {
|
|
|
|
PageView.NAVIGATION_NONE: (None, None),
|
|
|
|
PageView.NAVIGATION_PERSON: (None, None),
|
|
|
|
}
|
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __keypress(self, action):
|
|
|
|
"""
|
|
|
|
Callback that is called on a keypress. It works by extracting the
|
|
|
|
name of the associated action, and passes that to the active page
|
|
|
|
(current view) so that it can take the associated action.
|
|
|
|
"""
|
2006-04-27 22:33:23 +05:30
|
|
|
name = action.get_name()
|
2006-05-02 09:20:46 +05:30
|
|
|
try:
|
|
|
|
self.active_page.call_function(name)
|
2007-09-17 00:15:57 +05:30
|
|
|
except Exception:
|
2009-06-19 03:26:37 +05:30
|
|
|
self.uistate.push_message(self.dbstate,
|
In .:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* src/Filters/_SearchBar.py (SearchBar.__init__): Take dbstate as
a constructor argument; (SearchBar.apply_filter): pass dbstate.
* src/PageView.py (BookMarkView.add_bookmark,
PersonNavView.jumpto, PersonNavView.fwd_clicked,
PersonNavView.back_clicked, ListView.build_widget): Pass dbstate.
* src/Navigation.py (BaseNavigation.__init__,
PersonNavigation.__init__): Take dbstate as a constructor argument;
(PersonNavigation.build_item_name): properly access dbstate.
* src/DisplayState.py (__init__): Do not take dbstate as a
constructor argument; Do not connect dbstate signal here (moved to
ViewManager);
(display_relationship,push_message,modify_statusbar): Make dbstate
an argument.
* src/plugins/Checkpoint.py (run_tool): Pass dbstate.
* src/ViewManager.py (_build_main_window): Do not pass dbstate to
uistate DisplayState constructor; connect dbstate signal handler;
pass dbstate to Navigation; (keypress): Pass dbstate;
(statusbar_key_update): Pass dbstate;
(do_load_plugins): Pass dbstate;
(ViewManager.add_bookmark): Pass dbstate.
* src/DataViews/_RelationView.py (shade_update): Pass dbstate.
* src/DataViews/_PersonView.py (build_widget,_goto,
key_goto_home_person, key_edit_selected_person): Pass dbstate.
* src/Filters/Makefile.am (pkgdata_PYTHON): Remove obsolete file.
* src/Filters/__init__.py: Remove importing obsolete module.
* src/Filters/_FilterWidget.py: Remove obsolete module.
In po:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Remove obsolete file.
svn: r7104
2006-08-01 10:01:10 +05:30
|
|
|
_("Key %s is not bound") % name)
|
2006-04-27 22:33:23 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __next_view(self, action):
|
|
|
|
"""
|
|
|
|
Callback that is called when the next view action is selected.
|
|
|
|
It selects the next view as the active view. If we reach the end of
|
|
|
|
the list of views, we wrap around to the first view.
|
|
|
|
"""
|
2006-12-31 10:47:35 +05:30
|
|
|
current_page = self.notebook.get_current_page()
|
|
|
|
if current_page == len(self.pages)-1:
|
|
|
|
new_page = 0
|
|
|
|
else:
|
|
|
|
new_page = current_page + 1
|
2008-02-20 03:46:13 +05:30
|
|
|
if self.show_sidebar:
|
|
|
|
#cause a click signal
|
|
|
|
self.buttons[new_page].set_active(True)
|
|
|
|
else:
|
|
|
|
self.notebook.set_current_page(new_page)
|
2006-12-31 10:47:35 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __prev_view(self, action):
|
|
|
|
"""
|
|
|
|
Callback that is called when the previous view action is selected.
|
|
|
|
It selects the previous view as the active view. If we reach the beginning
|
|
|
|
of the list of views, we wrap around to the last view.
|
|
|
|
"""
|
2006-12-31 10:47:35 +05:30
|
|
|
current_page = self.notebook.get_current_page()
|
|
|
|
if current_page == 0:
|
|
|
|
new_page = len(self.pages)-1
|
|
|
|
else:
|
|
|
|
new_page = current_page - 1
|
2008-02-20 03:46:13 +05:30
|
|
|
if self.show_sidebar:
|
|
|
|
#cause a click signal
|
|
|
|
self.buttons[new_page].set_active(True)
|
|
|
|
else:
|
|
|
|
self.notebook.set_current_page(new_page)
|
2006-12-31 10:47:35 +05:30
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
def init_interface(self):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Initialize the interface, creating the pages
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2007-09-09 10:54:15 +05:30
|
|
|
self.__init_lists()
|
|
|
|
self.__create_pages()
|
2006-04-08 11:26:31 +05:30
|
|
|
|
2006-03-30 00:56:43 +05:30
|
|
|
if not self.file_loaded:
|
|
|
|
self.actiongroup.set_visible(False)
|
2006-12-19 07:59:47 +05:30
|
|
|
self.readonlygroup.set_visible(False)
|
2005-12-29 04:28:26 +05:30
|
|
|
self.fileactions.set_sensitive(False)
|
2009-06-19 03:26:37 +05:30
|
|
|
self.__build_tools_menu(self._pmgr.get_tool_list())
|
|
|
|
self.__build_report_menu(self._pmgr.get_report_list())
|
2007-10-26 04:45:28 +05:30
|
|
|
self.uistate.set_relationship_class()
|
2009-06-19 03:26:37 +05:30
|
|
|
self._pmgr.connect('plugins-reloaded',
|
2007-09-09 10:54:15 +05:30
|
|
|
self.__rebuild_report_and_tool_menus)
|
2005-12-29 04:28:26 +05:30
|
|
|
self.fileactions.set_sensitive(True)
|
2006-01-05 02:36:28 +05:30
|
|
|
self.uistate.widget.set_sensitive(True)
|
2007-09-09 10:54:15 +05:30
|
|
|
Config.client.notify_add("/apps/gramps/interface/statusbar",
|
|
|
|
self.__statusbar_key_update)
|
|
|
|
Config.client.notify_add("/apps/gramps/interface/filter",
|
|
|
|
self.__filter_signal)
|
2006-05-22 23:37:12 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __statusbar_key_update(self, client, cnxn_id, entry, data):
|
2007-02-23 03:01:37 +05:30
|
|
|
"""
|
|
|
|
Callback function for statusbar key update
|
|
|
|
"""
|
2009-06-19 03:26:37 +05:30
|
|
|
self.uistate.modify_statusbar(self.dbstate)
|
2005-12-29 04:28:26 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __filter_signal(self, client, cnxn_id, entry, data):
|
2007-03-06 09:43:14 +05:30
|
|
|
"""
|
|
|
|
Callback function for statusbar key update
|
|
|
|
"""
|
|
|
|
if self.filter_menu.get_active() != Config.get(Config.FILTER):
|
|
|
|
self.filter_menu.set_active(Config.get(Config.FILTER))
|
|
|
|
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
def post_init_interface(self, show_manager=True):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Showing the main window is deferred so that
|
|
|
|
ArgHandler can work without it always shown
|
|
|
|
"""
|
2006-05-18 08:41:15 +05:30
|
|
|
self.window.show()
|
2009-06-19 03:26:37 +05:30
|
|
|
if not self.dbstate.db.is_open() and show_manager:
|
2007-09-09 10:54:15 +05:30
|
|
|
self.__open_activate(None)
|
2006-05-18 08:41:15 +05:30
|
|
|
|
2007-12-11 08:19:58 +05:30
|
|
|
def post_load_newdb(self, filename, filetype):
|
|
|
|
# Attempt to figure out the database title
|
|
|
|
path = os.path.join(filename, "name.txt")
|
|
|
|
try:
|
|
|
|
ifile = open(path)
|
|
|
|
title = ifile.readline().strip()
|
|
|
|
ifile.close()
|
|
|
|
except:
|
|
|
|
title = filename
|
2009-06-19 03:26:37 +05:30
|
|
|
self._post_load_newdb(filename, filetype, title)
|
2007-12-11 08:19:58 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
def do_load_plugins(self):
|
2007-09-09 10:54:15 +05:30
|
|
|
"""
|
2009-01-18 10:29:14 +05:30
|
|
|
Loads the plugins at initialization time. The plugin status window is
|
|
|
|
opened on an error if the user has requested.
|
2007-09-09 10:54:15 +05:30
|
|
|
"""
|
|
|
|
# load plugins
|
2005-12-29 04:28:26 +05:30
|
|
|
self.uistate.status_text(_('Loading plugins...'))
|
2009-06-19 03:26:37 +05:30
|
|
|
error = CLIManager.do_load_plugins(self)
|
2007-09-09 10:54:15 +05:30
|
|
|
|
2009-01-18 10:29:14 +05:30
|
|
|
# get to see if we need to open the plugin status window
|
2008-04-01 08:42:08 +05:30
|
|
|
if error and Config.get(Config.POP_PLUGIN_STATUS):
|
|
|
|
self.__plugin_status()
|
2006-07-30 23:43:38 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
self.uistate.push_message(self.dbstate, _('Ready'))
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2006-08-13 02:43:45 +05:30
|
|
|
def quit(self, *obj):
|
2007-09-09 10:54:15 +05:30
|
|
|
"""
|
|
|
|
Closes out the program, backing up data
|
|
|
|
"""
|
|
|
|
# mark interface insenstitive to prevent unexpected events
|
2007-01-28 08:21:18 +05:30
|
|
|
self.uistate.set_sensitive(False)
|
2007-09-09 10:54:15 +05:30
|
|
|
|
|
|
|
# backup data, and close the database
|
|
|
|
self.__backup()
|
2009-06-19 03:26:37 +05:30
|
|
|
self.dbstate.db.close()
|
2007-09-09 10:54:15 +05:30
|
|
|
|
2007-12-26 21:18:51 +05:30
|
|
|
# have each page save anything, if they need to:
|
|
|
|
self.__delete_pages()
|
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
# save the current window size
|
2006-04-08 11:26:31 +05:30
|
|
|
(width, height) = self.window.get_size()
|
2006-04-25 02:34:01 +05:30
|
|
|
Config.set(Config.WIDTH, width)
|
|
|
|
Config.set(Config.HEIGHT, height)
|
2006-03-03 05:40:52 +05:30
|
|
|
Config.sync()
|
2005-12-22 10:06:26 +05:30
|
|
|
gtk.main_quit()
|
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __backup(self):
|
2006-11-13 10:52:48 +05:30
|
|
|
"""
|
2007-06-12 09:59:15 +05:30
|
|
|
Backup the current file as a backup file.
|
2006-11-13 10:52:48 +05:30
|
|
|
"""
|
2007-02-03 22:41:05 +05:30
|
|
|
import GrampsDbUtils
|
2007-03-25 08:47:25 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
if self.dbstate.db.undoindex >= 0:
|
2007-03-25 07:55:37 +05:30
|
|
|
self.uistate.set_busy_cursor(1)
|
|
|
|
self.uistate.progress.show()
|
2009-06-19 03:26:37 +05:30
|
|
|
self.uistate.push_message(self.dbstate, _("Autobackup..."))
|
|
|
|
GrampsDbUtils.Backup.backup(self.dbstate.db)
|
2007-03-25 07:55:37 +05:30
|
|
|
self.uistate.set_busy_cursor(0)
|
|
|
|
self.uistate.progress.hide()
|
2006-11-13 10:20:38 +05:30
|
|
|
|
2007-02-23 03:01:37 +05:30
|
|
|
def abort(self, obj=None):
|
2006-05-04 04:51:49 +05:30
|
|
|
"""
|
|
|
|
Abandon changes and quit.
|
|
|
|
"""
|
2009-06-19 03:26:37 +05:30
|
|
|
if self.dbstate.db.abort_possible:
|
2006-11-13 08:12:07 +05:30
|
|
|
|
2007-02-23 03:01:37 +05:30
|
|
|
dialog = QuestionDialog2(
|
2007-09-09 10:54:15 +05:30
|
|
|
_("Abort changes?"),
|
2006-11-13 08:12:07 +05:30
|
|
|
_("Aborting changes will return the database to the state "
|
2007-09-09 10:54:15 +05:30
|
|
|
"is was before you started this editing session."),
|
|
|
|
_("Abort changes"),
|
2006-11-13 08:12:07 +05:30
|
|
|
_("Cancel"))
|
|
|
|
|
2007-02-23 03:01:37 +05:30
|
|
|
if dialog.run():
|
2009-06-19 03:26:37 +05:30
|
|
|
self.dbstate.db.disable_signals()
|
|
|
|
while self.dbstate.db.undo():
|
2006-11-13 08:12:07 +05:30
|
|
|
pass
|
|
|
|
self.quit()
|
2006-05-04 04:51:49 +05:30
|
|
|
else:
|
2006-11-13 08:12:07 +05:30
|
|
|
WarningDialog(
|
2007-09-09 10:54:15 +05:30
|
|
|
_("Cannot abandon session's changes"),
|
2006-05-04 05:06:10 +05:30
|
|
|
_('Changes cannot be completely abandoned because the '
|
|
|
|
'number of changes made in the session exceeded the '
|
|
|
|
'limit.'))
|
2006-05-04 04:51:49 +05:30
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
def __init_action_group(self, name, actions, sensitive=True, toggles=None):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Initialize an action group for the UIManager
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
new_group = gtk.ActionGroup(name)
|
|
|
|
new_group.add_actions(actions)
|
|
|
|
if toggles:
|
|
|
|
new_group.add_toggle_actions(toggles)
|
|
|
|
new_group.set_sensitive(sensitive)
|
|
|
|
self.uimanager.insert_action_group(new_group, 1)
|
|
|
|
return new_group
|
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __build_ui_manager(self):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Builds the UIManager, and the associated action groups
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
self.uimanager = gtk.UIManager()
|
|
|
|
|
|
|
|
accelgroup = self.uimanager.get_accel_group()
|
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
self.actiongroup = self.__init_action_group(
|
|
|
|
'MainWindow', self._action_action_list)
|
|
|
|
self.readonlygroup = self.__init_action_group(
|
|
|
|
'AllMainWindow', self._readonly_action_list)
|
|
|
|
self.undohistoryactions = self.__init_action_group(
|
|
|
|
'UndoHistory', self._undo_history_action_list)
|
|
|
|
self.fileactions = self.__init_action_group(
|
|
|
|
'FileWindow', self._file_action_list,
|
|
|
|
toggles=self._file_toggle_action_list)
|
|
|
|
self.undoactions = self.__init_action_group(
|
|
|
|
'Undo', self._undo_action_list, sensitive=False)
|
|
|
|
self.redoactions = self.__init_action_group(
|
|
|
|
'Redo', self._redo_action_list, sensitive=False)
|
|
|
|
self.window.add_accel_group(accelgroup)
|
2006-05-06 03:25:01 +05:30
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
self.uimanager.add_ui_from_string(UIDEFAULT)
|
2006-04-27 03:45:22 +05:30
|
|
|
self.uimanager.ensure_update()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def preferences_activate(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Open the preferences dialog.
|
|
|
|
"""
|
2006-04-26 07:44:37 +05:30
|
|
|
try:
|
2009-06-19 03:26:37 +05:30
|
|
|
GrampsCfg.GrampsPreferences(self.uistate, self.dbstate)
|
2007-09-09 10:54:15 +05:30
|
|
|
self._key = self.uistate.connect('nameformat-changed',
|
2006-08-26 05:16:19 +05:30
|
|
|
self.active_page.build_tree)
|
2006-04-26 07:44:37 +05:30
|
|
|
except Errors.WindowActiveError:
|
2007-09-10 07:39:50 +05:30
|
|
|
return
|
2006-03-06 05:09:20 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def tip_of_day_activate(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Display Tip of the day
|
|
|
|
"""
|
2007-09-09 10:54:15 +05:30
|
|
|
import TipOfDay
|
2005-08-25 20:38:07 +05:30
|
|
|
TipOfDay.TipOfDay(self.uistate)
|
|
|
|
|
2008-04-01 08:42:08 +05:30
|
|
|
def __plugin_status(self, obj=None):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Display plugin status dialog
|
|
|
|
"""
|
2006-07-30 23:43:38 +05:30
|
|
|
try:
|
2008-04-01 08:42:08 +05:30
|
|
|
PluginWindows.PluginStatus(self.uistate, [])
|
2006-07-30 23:43:38 +05:30
|
|
|
except Errors.WindowActiveError:
|
|
|
|
old_win = self.uistate.gwm.get_item_from_id(
|
2007-11-29 12:02:59 +05:30
|
|
|
PluginWindows.PluginStatus)
|
2006-07-30 23:43:38 +05:30
|
|
|
old_win.close()
|
2008-04-01 08:42:08 +05:30
|
|
|
PluginWindows.PluginStatus(self.uistate, [])
|
2006-07-30 23:43:38 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def sidebar_toggle(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Set the sidebar based on the value of the toggle button. Save the
|
|
|
|
results in the configuration settings
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
if obj.get_active():
|
|
|
|
self.ebox.show()
|
|
|
|
self.notebook.set_show_tabs(False)
|
2006-04-28 02:22:58 +05:30
|
|
|
Config.set(Config.VIEW, True)
|
2008-02-20 03:46:13 +05:30
|
|
|
self.show_sidebar = True
|
2005-08-09 10:11:20 +05:30
|
|
|
else:
|
|
|
|
self.ebox.hide()
|
|
|
|
self.notebook.set_show_tabs(True)
|
2006-04-28 02:22:58 +05:30
|
|
|
Config.set(Config.VIEW, False)
|
2008-02-20 03:46:13 +05:30
|
|
|
self.show_sidebar = False
|
2006-03-03 05:40:52 +05:30
|
|
|
Config.sync()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def toolbar_toggle(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2008-01-11 04:57:06 +05:30
|
|
|
Set the toolbar based on the value of the toggle button. Save the
|
2007-09-10 07:39:50 +05:30
|
|
|
results in the configuration settings
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
if obj.get_active():
|
|
|
|
self.toolbar.show()
|
2006-04-28 02:22:58 +05:30
|
|
|
Config.set(Config.TOOLBAR_ON, True)
|
2005-08-09 10:11:20 +05:30
|
|
|
else:
|
|
|
|
self.toolbar.hide()
|
2006-04-28 02:22:58 +05:30
|
|
|
Config.set(Config.TOOLBAR_ON, False)
|
2006-03-03 05:40:52 +05:30
|
|
|
Config.sync()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2008-06-22 20:04:18 +05:30
|
|
|
def fullscreen_toggle(self, obj):
|
|
|
|
"""
|
|
|
|
Set the main Granps window fullscreen based on the value of the
|
|
|
|
toggle button. Save the setting in the config file.
|
|
|
|
"""
|
|
|
|
if obj.get_active():
|
|
|
|
self.window.fullscreen()
|
|
|
|
Config.set(Config.FULLSCREEN, True)
|
|
|
|
else:
|
|
|
|
self.window.unfullscreen()
|
|
|
|
Config.set(Config.FULLSCREEN, False)
|
|
|
|
Config.sync()
|
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
def register_view(self, view):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Allow other objects to register a view with the View Manager
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
self.views.append(view)
|
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
def __switch_page_on_dnd(self, widget, context, xpos, ypos, time, page_no):
|
|
|
|
"""
|
|
|
|
Switches the page based on drag and drop
|
|
|
|
"""
|
|
|
|
self.__vb_handlers_block()
|
2007-01-16 04:28:40 +05:30
|
|
|
if self.notebook.get_current_page() != page_no:
|
|
|
|
self.notebook.set_current_page(page_no)
|
2007-09-10 07:39:50 +05:30
|
|
|
self.__vb_handlers_unblock()
|
2006-05-04 03:51:59 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __setup_text_tips(self, use_text):
|
|
|
|
"""
|
|
|
|
Enable/disable the text tips in the sidebar
|
|
|
|
"""
|
2007-03-19 09:49:49 +05:30
|
|
|
if use_text:
|
|
|
|
self.tips.disable()
|
|
|
|
else:
|
|
|
|
self.tips.enable()
|
2007-09-09 10:54:15 +05:30
|
|
|
|
2007-12-26 21:18:51 +05:30
|
|
|
def __delete_pages(self):
|
|
|
|
"""
|
|
|
|
Calls on_delete() for each view
|
|
|
|
"""
|
|
|
|
for page in self.pages:
|
|
|
|
page.on_delete()
|
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __create_pages(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create the Views
|
2007-09-09 10:54:15 +05:30
|
|
|
"""
|
|
|
|
self.pages = []
|
|
|
|
self.prev_nav = PageView.NAVIGATION_NONE
|
|
|
|
|
|
|
|
use_text = Config.get(Config.SIDEBAR_TEXT)
|
|
|
|
self.__setup_text_tips(use_text)
|
2005-08-11 05:23:24 +05:30
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
index = 0
|
|
|
|
for page_def in self.views:
|
2009-06-19 03:26:37 +05:30
|
|
|
page = page_def(self.dbstate, self.uistate)
|
2006-04-10 11:19:20 +05:30
|
|
|
page_title = page.get_title()
|
|
|
|
page_stock = page.get_stock()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
# create icon/label for notebook
|
|
|
|
hbox = gtk.HBox()
|
|
|
|
image = gtk.Image()
|
2006-04-10 11:19:20 +05:30
|
|
|
image.set_from_stock(page_stock, gtk.ICON_SIZE_MENU)
|
2006-04-08 11:26:31 +05:30
|
|
|
hbox.pack_start(image, False)
|
2006-04-10 11:19:20 +05:30
|
|
|
hbox.add(gtk.Label(page_title))
|
2005-08-09 10:11:20 +05:30
|
|
|
hbox.show_all()
|
|
|
|
|
|
|
|
# create notebook page and add to notebook
|
2005-08-11 22:49:03 +05:30
|
|
|
page.define_actions()
|
2005-08-09 10:11:20 +05:30
|
|
|
page_display = page.get_display()
|
|
|
|
page_display.show_all()
|
2006-06-21 08:13:19 +05:30
|
|
|
page.post()
|
2007-01-16 04:28:40 +05:30
|
|
|
page_no = self.notebook.append_page(page_display, hbox)
|
2005-08-09 10:11:20 +05:30
|
|
|
self.pages.append(page)
|
2007-01-16 04:28:40 +05:30
|
|
|
|
|
|
|
# Enable view switching during DnD
|
|
|
|
hbox.drag_dest_set(0, [], 0)
|
2007-09-09 10:54:15 +05:30
|
|
|
hbox.connect('drag_motion', self.__switch_page_on_dnd, page_no)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2006-04-10 11:19:20 +05:30
|
|
|
# create the button and add it to the sidebar
|
2007-09-09 10:54:15 +05:30
|
|
|
button = self.__make_sidebar_button(use_text, index,
|
|
|
|
page_title, page_stock)
|
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
index += 1
|
2006-04-08 11:26:31 +05:30
|
|
|
self.bbox.pack_start(button, False)
|
2006-04-10 11:19:20 +05:30
|
|
|
self.buttons.append(button)
|
2007-01-16 04:28:40 +05:30
|
|
|
|
|
|
|
# Enable view switching during DnD
|
|
|
|
button.drag_dest_set(0, [], 0)
|
2007-09-09 10:54:15 +05:30
|
|
|
button.connect('drag_motion', self.__switch_page_on_dnd, page_no)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2006-11-12 09:05:52 +05:30
|
|
|
use_current = Config.get(Config.USE_LAST_VIEW)
|
|
|
|
if use_current:
|
2006-12-31 10:47:35 +05:30
|
|
|
current_page = Config.get(Config.LAST_VIEW)
|
2007-04-16 19:27:03 +05:30
|
|
|
if current_page >= len(self.pages):
|
2006-12-31 10:47:35 +05:30
|
|
|
current_page = 0
|
2006-11-12 09:05:52 +05:30
|
|
|
else:
|
2006-12-31 10:47:35 +05:30
|
|
|
current_page = 0
|
2006-05-02 09:20:46 +05:30
|
|
|
|
2006-12-31 10:47:35 +05:30
|
|
|
self.active_page = self.pages[current_page]
|
|
|
|
self.buttons[current_page].set_active(True)
|
2006-01-20 11:03:38 +05:30
|
|
|
self.active_page.set_active()
|
2006-12-31 10:47:35 +05:30
|
|
|
self.notebook.set_current_page(current_page)
|
2006-01-20 11:03:38 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __make_sidebar_button(self, use_text, index, page_title, page_stock):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create the sidebar button. The page_title is the text associated with
|
2007-09-09 10:54:15 +05:30
|
|
|
the button.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# create the button
|
|
|
|
button = gtk.ToggleButton()
|
|
|
|
button.set_relief(gtk.RELIEF_NONE)
|
|
|
|
button.set_alignment(0, 0.5)
|
|
|
|
|
|
|
|
# add the tooltip
|
|
|
|
self.tips.set_tip(button, page_title)
|
|
|
|
|
|
|
|
# connect the signal, along with the index as user data
|
|
|
|
handler_id = button.connect('clicked', self.__vb_clicked, index)
|
|
|
|
self.button_handlers.append(handler_id)
|
|
|
|
button.show()
|
|
|
|
|
|
|
|
# add the image. If we are using text, use the BUTTON (larger) size.
|
|
|
|
# otherwise, use the smaller size
|
|
|
|
hbox = gtk.HBox()
|
|
|
|
hbox.show()
|
|
|
|
image = gtk.Image()
|
|
|
|
if use_text:
|
|
|
|
image.set_from_stock(page_stock, gtk.ICON_SIZE_BUTTON)
|
|
|
|
else:
|
|
|
|
image.set_from_stock(page_stock, gtk.ICON_SIZE_DND)
|
|
|
|
image.show()
|
|
|
|
hbox.pack_start(image, False, False)
|
|
|
|
hbox.set_spacing(4)
|
|
|
|
|
|
|
|
# add text if requested
|
|
|
|
if use_text:
|
|
|
|
label = gtk.Label(page_title)
|
|
|
|
label.show()
|
|
|
|
hbox.pack_start(label, False, True)
|
|
|
|
|
|
|
|
button.add(hbox)
|
|
|
|
return button
|
|
|
|
|
|
|
|
def __vb_clicked(self, button, index):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Called when the button causes a page change
|
|
|
|
"""
|
2006-10-02 08:02:47 +05:30
|
|
|
if Config.get(Config.VIEW):
|
2007-09-10 07:39:50 +05:30
|
|
|
self.__vb_handlers_block()
|
2006-10-02 08:02:47 +05:30
|
|
|
self.notebook.set_current_page(index)
|
2007-01-23 10:47:12 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
# If the click is on the same view we're in,
|
2007-02-11 05:10:48 +05:30
|
|
|
# restore the button state to active
|
|
|
|
if not button.get_active():
|
2007-01-23 10:47:12 +05:30
|
|
|
button.set_active(True)
|
2007-09-10 07:39:50 +05:30
|
|
|
self.__vb_handlers_unblock()
|
2006-08-13 05:02:05 +05:30
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
def __vb_handlers_block(self):
|
|
|
|
"""
|
|
|
|
Block signals to the buttons to prevent spurious events
|
|
|
|
"""
|
2007-02-23 03:01:37 +05:30
|
|
|
for idx in range(len(self.buttons)):
|
|
|
|
self.buttons[idx].handler_block(self.button_handlers[idx])
|
2006-08-13 05:02:05 +05:30
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
def __vb_handlers_unblock(self):
|
|
|
|
"""
|
|
|
|
Unblock signals to the buttons
|
|
|
|
"""
|
2007-02-23 03:01:37 +05:30
|
|
|
for idx in range(len(self.buttons)):
|
|
|
|
self.buttons[idx].handler_unblock(self.button_handlers[idx])
|
2006-08-13 05:02:05 +05:30
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
def __set_active_button(self, num):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Set the corresponding button active, while setting the others
|
2007-09-10 07:39:50 +05:30
|
|
|
inactive
|
|
|
|
"""
|
|
|
|
for idx in range(len(self.buttons)):
|
|
|
|
self.buttons[idx].set_active(idx==num)
|
2006-10-02 07:40:12 +05:30
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
def __disconnect_previous_page(self):
|
|
|
|
"""
|
|
|
|
Disconnects the previous page, removing the old action groups
|
|
|
|
and removes the old UI components.
|
|
|
|
"""
|
|
|
|
for mergeid in self.merge_ids:
|
|
|
|
self.uimanager.remove_ui(mergeid)
|
|
|
|
|
|
|
|
if self.active_page:
|
|
|
|
self.active_page.set_inactive()
|
|
|
|
groups = self.active_page.get_actions()
|
|
|
|
for grp in groups:
|
|
|
|
if grp in self.uimanager.get_action_groups():
|
|
|
|
self.uimanager.remove_action_group(grp)
|
|
|
|
|
|
|
|
def __connect_active_page(self):
|
|
|
|
"""
|
|
|
|
Inserts the action groups associated with the current page
|
|
|
|
into the UIManager
|
|
|
|
"""
|
|
|
|
for grp in self.active_page.get_actions():
|
|
|
|
self.uimanager.insert_action_group(grp, 1)
|
|
|
|
|
|
|
|
uidef = self.active_page.ui_definition()
|
|
|
|
self.merge_ids = [self.uimanager.add_ui_from_string(uidef)]
|
|
|
|
|
|
|
|
for uidef in self.active_page.additional_ui_definitions():
|
|
|
|
mergeid = self.uimanager.add_ui_from_string(uidef)
|
|
|
|
self.merge_ids.append(mergeid)
|
|
|
|
|
|
|
|
def __setup_navigation(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Initialize the navigation scheme
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
old_nav = self._navigation_type[self.prev_nav]
|
2008-06-16 20:31:46 +05:30
|
|
|
if old_nav[0] is not None:
|
2007-09-10 07:39:50 +05:30
|
|
|
old_nav[0].disable()
|
|
|
|
|
|
|
|
page_type = self.active_page.navigation_type()
|
|
|
|
nav_type = self._navigation_type[page_type]
|
2008-06-16 20:31:46 +05:30
|
|
|
if nav_type[0] is not None:
|
2007-09-10 07:39:50 +05:30
|
|
|
nav_type[0].enable()
|
|
|
|
|
|
|
|
def change_page(self, obj, page, num=-1):
|
|
|
|
"""
|
|
|
|
Wrapper for the __do_change_page, to prevent entering into the
|
|
|
|
routine while already in it.
|
|
|
|
"""
|
|
|
|
if not self.page_is_changing:
|
|
|
|
self.page_is_changing = True
|
|
|
|
self.__do_change_page(num)
|
|
|
|
self.page_is_changing = False
|
2006-10-02 07:40:12 +05:30
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
def __do_change_page(self, num):
|
|
|
|
"""
|
|
|
|
Change the page to the new page
|
|
|
|
"""
|
2005-08-14 10:01:29 +05:30
|
|
|
if num == -1:
|
|
|
|
num = self.notebook.get_current_page()
|
2006-08-13 05:02:05 +05:30
|
|
|
|
2007-01-16 04:28:40 +05:30
|
|
|
# set button of current page active
|
2007-09-10 07:39:50 +05:30
|
|
|
self.__set_active_button(num)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
if self.dbstate.open:
|
2007-09-10 07:39:50 +05:30
|
|
|
|
|
|
|
self.__disconnect_previous_page()
|
2005-08-14 10:01:29 +05:30
|
|
|
|
2006-10-03 22:29:51 +05:30
|
|
|
if len(self.pages) > 0:
|
2005-08-14 10:01:29 +05:30
|
|
|
self.active_page = self.pages[num]
|
2006-01-20 11:03:38 +05:30
|
|
|
self.active_page.set_active()
|
2007-02-23 03:01:37 +05:30
|
|
|
Config.set(Config.LAST_VIEW, num)
|
2006-05-02 09:20:46 +05:30
|
|
|
Config.sync()
|
2005-08-14 10:01:29 +05:30
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
self.__setup_navigation()
|
|
|
|
self.__connect_active_page()
|
2005-08-11 05:23:24 +05:30
|
|
|
|
2006-04-27 03:45:22 +05:30
|
|
|
self.uimanager.ensure_update()
|
2007-09-10 07:39:50 +05:30
|
|
|
|
2005-12-23 11:05:32 +05:30
|
|
|
while gtk.events_pending():
|
|
|
|
gtk.main_iteration()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2006-08-25 22:47:37 +05:30
|
|
|
self.active_page.change_page()
|
2006-08-26 05:16:19 +05:30
|
|
|
if self._key:
|
|
|
|
self.uistate.disconnect(self._key)
|
2006-10-02 07:40:12 +05:30
|
|
|
self._key = self.uistate.connect(
|
2007-02-23 03:01:37 +05:30
|
|
|
'nameformat-changed', self.active_page.build_tree)
|
2006-10-02 07:40:12 +05:30
|
|
|
|
2006-05-18 05:06:31 +05:30
|
|
|
def import_data(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Imports a file
|
|
|
|
"""
|
2009-06-19 03:26:37 +05:30
|
|
|
if self.dbstate.db.is_open():
|
2006-05-22 09:47:18 +05:30
|
|
|
self.db_loader.import_file()
|
2008-02-29 04:02:40 +05:30
|
|
|
infotxt = self.db_loader.import_info_text()
|
|
|
|
if infotxt:
|
|
|
|
InfoDialog(_('Import Statistics'), infotxt, self.window)
|
2007-09-09 10:54:15 +05:30
|
|
|
self.__post_load()
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
|
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __open_activate(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
Called when the Open button is clicked, opens the DbManager
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2009-06-19 03:26:37 +05:30
|
|
|
from dbman import DbManager
|
|
|
|
dialog = DbManager(self.dbstate, self.window)
|
2007-03-28 09:03:11 +05:30
|
|
|
value = dialog.run()
|
|
|
|
if value:
|
|
|
|
(filename, title) = value
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
self.db_loader.read_file(filename)
|
2009-06-19 03:26:37 +05:30
|
|
|
self._post_load_newdb(filename, 'x-directory/normal', title)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __post_load(self):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
This method is for the common UI post_load, both new files
|
|
|
|
and added data like imports.
|
|
|
|
"""
|
2009-06-19 03:26:37 +05:30
|
|
|
if self.dbstate.active :
|
2007-09-10 07:39:50 +05:30
|
|
|
# clear history and fill history with first entry, active person
|
2009-06-19 03:26:37 +05:30
|
|
|
self.uistate.clear_history(self.dbstate.active.handle)
|
2007-09-09 03:36:30 +05:30
|
|
|
else :
|
|
|
|
self.uistate.clear_history(None)
|
2006-05-18 02:46:59 +05:30
|
|
|
self.uistate.progress.hide()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
self.dbstate.db.undo_callback = self.__change_undo_label
|
|
|
|
self.dbstate.db.redo_callback = self.__change_redo_label
|
2007-09-17 00:15:57 +05:30
|
|
|
self.__change_undo_label(None)
|
|
|
|
self.__change_redo_label(None)
|
2009-06-19 03:26:37 +05:30
|
|
|
self.dbstate.db.undo_history_callback = self.undo_history_update
|
2006-05-18 05:06:31 +05:30
|
|
|
self.undo_history_close()
|
|
|
|
|
2007-05-02 09:35:41 +05:30
|
|
|
self.uistate.window.window.set_cursor(None)
|
2006-05-18 05:06:31 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
def _post_load_newdb(self, filename, filetype, title=None):
|
2007-09-17 00:15:57 +05:30
|
|
|
"""
|
2009-06-19 03:26:37 +05:30
|
|
|
The method called after load of a new database.
|
|
|
|
Inherit CLI method to add GUI part
|
2007-09-17 00:15:57 +05:30
|
|
|
"""
|
2009-06-19 14:16:17 +05:30
|
|
|
self._post_load_newdb_nongui(filename, title)
|
2009-06-19 03:26:37 +05:30
|
|
|
self._post_load_newdb_gui(filename, filetype, title)
|
|
|
|
|
|
|
|
def _post_load_newdb_gui(self, filename, filetype, title=None):
|
|
|
|
"""
|
|
|
|
Called after a new database is loaded to do GUI stuff
|
|
|
|
"""
|
|
|
|
# GUI related post load db stuff
|
2006-05-18 05:06:31 +05:30
|
|
|
# Update window title
|
2006-09-11 08:37:17 +05:30
|
|
|
if filename[-1] == os.path.sep:
|
2006-05-18 05:06:31 +05:30
|
|
|
filename = filename[:-1]
|
|
|
|
name = os.path.basename(filename)
|
2007-03-28 09:03:11 +05:30
|
|
|
if title:
|
|
|
|
name = title
|
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
if self.dbstate.db.readonly:
|
2006-05-18 05:06:31 +05:30
|
|
|
msg = "%s (%s) - GRAMPS" % (name, _('Read Only'))
|
|
|
|
self.uistate.window.set_title(msg)
|
2006-12-19 07:59:47 +05:30
|
|
|
self.actiongroup.set_sensitive(False)
|
2006-05-18 05:06:31 +05:30
|
|
|
else:
|
|
|
|
msg = "%s - GRAMPS" % name
|
|
|
|
self.uistate.window.set_title(msg)
|
2006-12-19 07:59:47 +05:30
|
|
|
self.actiongroup.set_sensitive(True)
|
2006-05-18 05:06:31 +05:30
|
|
|
|
2005-12-22 11:43:11 +05:30
|
|
|
self.setup_bookmarks()
|
2006-07-31 16:38:44 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
self.change_page(None, None)
|
2005-08-14 10:01:29 +05:30
|
|
|
self.actiongroup.set_visible(True)
|
2007-02-11 05:10:48 +05:30
|
|
|
self.readonlygroup.set_visible(True)
|
2009-06-19 03:26:37 +05:30
|
|
|
|
2007-06-14 11:02:06 +05:30
|
|
|
self.recent_manager.build()
|
2006-05-18 02:46:59 +05:30
|
|
|
|
2009-06-19 03:26:37 +05:30
|
|
|
# Call common __post_load method for GUI update after a change
|
2007-09-09 10:54:15 +05:30
|
|
|
self.__post_load()
|
2005-08-13 08:53:02 +05:30
|
|
|
|
2007-09-17 00:15:57 +05:30
|
|
|
def __change_undo_label(self, label):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Change the UNDO label
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2006-01-14 02:23:10 +05:30
|
|
|
self.uimanager.remove_action_group(self.undoactions)
|
|
|
|
self.undoactions = gtk.ActionGroup('Undo')
|
|
|
|
if label:
|
|
|
|
self.undoactions.add_actions([
|
2007-09-09 10:54:15 +05:30
|
|
|
('Undo', gtk.STOCK_UNDO, label, '<control>z', None, self.undo)])
|
2006-01-14 02:23:10 +05:30
|
|
|
else:
|
|
|
|
self.undoactions.add_actions([
|
2006-10-18 22:41:52 +05:30
|
|
|
('Undo', gtk.STOCK_UNDO, _('_Undo'),
|
2006-04-08 11:26:31 +05:30
|
|
|
'<control>z', None, self.undo)])
|
2006-01-14 02:23:10 +05:30
|
|
|
self.undoactions.set_sensitive(False)
|
2006-04-08 11:26:31 +05:30
|
|
|
self.uimanager.insert_action_group(self.undoactions, 1)
|
2006-01-14 02:23:10 +05:30
|
|
|
|
2007-09-17 00:15:57 +05:30
|
|
|
def __change_redo_label(self, label):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Change the REDO label
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2006-01-14 02:23:10 +05:30
|
|
|
self.uimanager.remove_action_group(self.redoactions)
|
|
|
|
self.redoactions = gtk.ActionGroup('Redo')
|
|
|
|
if label:
|
|
|
|
self.redoactions.add_actions([
|
2006-04-08 11:26:31 +05:30
|
|
|
('Redo', gtk.STOCK_REDO, label, '<shift><control>z',
|
|
|
|
None, self.redo)])
|
2006-01-14 02:23:10 +05:30
|
|
|
else:
|
|
|
|
self.redoactions.add_actions([
|
2007-09-09 10:54:15 +05:30
|
|
|
('Redo', gtk.STOCK_UNDO, _('_Redo'),
|
2006-04-08 11:26:31 +05:30
|
|
|
'<shift><control>z', None, self.redo)])
|
2006-01-14 02:23:10 +05:30
|
|
|
self.redoactions.set_sensitive(False)
|
2006-04-08 11:26:31 +05:30
|
|
|
self.uimanager.insert_action_group(self.redoactions, 1)
|
2006-01-14 02:23:10 +05:30
|
|
|
|
2006-05-06 03:25:01 +05:30
|
|
|
def undo_history_update(self):
|
|
|
|
"""
|
|
|
|
This function is called to update both the state of
|
|
|
|
the Undo History menu item (enable/disable) and
|
|
|
|
the contents of the Undo History window.
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
# Try updating undo history window if it exists
|
|
|
|
self.undo_history_window.update()
|
|
|
|
except AttributeError:
|
|
|
|
# Let it go: history window does not exist
|
2007-09-10 07:39:50 +05:30
|
|
|
return
|
2006-05-06 03:25:01 +05:30
|
|
|
|
2006-05-18 05:06:31 +05:30
|
|
|
def undo_history_close(self):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Closes the undo history
|
|
|
|
"""
|
2006-05-18 05:06:31 +05:30
|
|
|
try:
|
|
|
|
# Try closing undo history window if it exists
|
2006-07-30 08:54:16 +05:30
|
|
|
if self.undo_history_window.opened:
|
|
|
|
self.undo_history_window.close()
|
2006-05-18 05:06:31 +05:30
|
|
|
except AttributeError:
|
|
|
|
# Let it go: history window does not exist
|
2007-09-10 07:39:50 +05:30
|
|
|
return
|
2006-05-18 05:06:31 +05:30
|
|
|
|
2005-12-22 11:43:11 +05:30
|
|
|
def setup_bookmarks(self):
|
2007-09-09 10:54:15 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Initialize the bookmarks based of the database. This needs to
|
2007-09-09 10:54:15 +05:30
|
|
|
be called anytime the database changes.
|
|
|
|
"""
|
|
|
|
import Bookmarks
|
|
|
|
self.bookmarks = Bookmarks.Bookmarks(
|
2009-06-19 03:26:37 +05:30
|
|
|
self.dbstate, self.uistate, self.dbstate.db.get_bookmarks())
|
2005-12-25 09:31:47 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def add_bookmark(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Add a bookmark to the bookmark list
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2009-06-19 03:26:37 +05:30
|
|
|
if self.dbstate.active:
|
|
|
|
self.bookmarks.add(self.dbstate.active.get_handle())
|
|
|
|
name = name_displayer.display(self.dbstate.active)
|
|
|
|
self.uistate.push_message(self.dbstate,
|
In .:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* src/Filters/_SearchBar.py (SearchBar.__init__): Take dbstate as
a constructor argument; (SearchBar.apply_filter): pass dbstate.
* src/PageView.py (BookMarkView.add_bookmark,
PersonNavView.jumpto, PersonNavView.fwd_clicked,
PersonNavView.back_clicked, ListView.build_widget): Pass dbstate.
* src/Navigation.py (BaseNavigation.__init__,
PersonNavigation.__init__): Take dbstate as a constructor argument;
(PersonNavigation.build_item_name): properly access dbstate.
* src/DisplayState.py (__init__): Do not take dbstate as a
constructor argument; Do not connect dbstate signal here (moved to
ViewManager);
(display_relationship,push_message,modify_statusbar): Make dbstate
an argument.
* src/plugins/Checkpoint.py (run_tool): Pass dbstate.
* src/ViewManager.py (_build_main_window): Do not pass dbstate to
uistate DisplayState constructor; connect dbstate signal handler;
pass dbstate to Navigation; (keypress): Pass dbstate;
(statusbar_key_update): Pass dbstate;
(do_load_plugins): Pass dbstate;
(ViewManager.add_bookmark): Pass dbstate.
* src/DataViews/_RelationView.py (shade_update): Pass dbstate.
* src/DataViews/_PersonView.py (build_widget,_goto,
key_goto_home_person, key_edit_selected_person): Pass dbstate.
* src/Filters/Makefile.am (pkgdata_PYTHON): Remove obsolete file.
* src/Filters/__init__.py: Remove importing obsolete module.
* src/Filters/_FilterWidget.py: Remove obsolete module.
In po:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Remove obsolete file.
svn: r7104
2006-08-01 10:01:10 +05:30
|
|
|
_("%s has been bookmarked") % name)
|
2005-12-22 11:43:11 +05:30
|
|
|
else:
|
2008-02-18 15:39:50 +05:30
|
|
|
WarningDialog(
|
2006-04-08 11:26:31 +05:30
|
|
|
_("Could Not Set a Bookmark"),
|
2006-03-23 04:33:57 +05:30
|
|
|
_("A bookmark could not be set because "
|
|
|
|
"no one was selected."))
|
2005-12-22 11:43:11 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def edit_bookmarks(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Displays the Bookmark editor
|
|
|
|
"""
|
2005-12-22 11:43:11 +05:30
|
|
|
self.bookmarks.edit()
|
2005-12-26 10:41:37 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def reports_clicked(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Displays the Reports dialog
|
|
|
|
"""
|
2006-04-28 03:02:44 +05:30
|
|
|
try:
|
2009-06-19 03:26:37 +05:30
|
|
|
ReportPluginDialog(self.dbstate, self.uistate, [])
|
2006-04-28 03:02:44 +05:30
|
|
|
except Errors.WindowActiveError:
|
2007-09-10 07:39:50 +05:30
|
|
|
return
|
2005-12-29 04:28:26 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def tools_clicked(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Displays the Tools dialog
|
|
|
|
"""
|
2006-04-28 03:02:44 +05:30
|
|
|
try:
|
2009-06-19 03:26:37 +05:30
|
|
|
ToolPluginDialog(self.dbstate, self.uistate, [])
|
2006-04-28 03:02:44 +05:30
|
|
|
except Errors.WindowActiveError:
|
2007-09-10 07:39:50 +05:30
|
|
|
return
|
2005-12-22 11:43:11 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def scratchpad(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2008-01-29 02:52:06 +05:30
|
|
|
Displays the Clipboard (was scratchpad)
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
import ScratchPad
|
2006-04-28 22:26:19 +05:30
|
|
|
try:
|
2009-06-19 03:26:37 +05:30
|
|
|
ScratchPad.ScratchPadWindow(self.dbstate, self.uistate)
|
2006-04-28 22:26:19 +05:30
|
|
|
except Errors.WindowActiveError:
|
2007-09-10 07:39:50 +05:30
|
|
|
return
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def undo(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Calls the undo function on the database
|
|
|
|
"""
|
2007-01-20 22:51:45 +05:30
|
|
|
self.uistate.set_busy_cursor(1)
|
2009-06-19 03:26:37 +05:30
|
|
|
self.dbstate.db.undo()
|
2007-01-20 22:51:45 +05:30
|
|
|
self.uistate.set_busy_cursor(0)
|
2006-01-13 03:32:58 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def redo(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Calls the redo function on the database
|
|
|
|
"""
|
2007-01-20 22:51:45 +05:30
|
|
|
self.uistate.set_busy_cursor(1)
|
2009-06-19 03:26:37 +05:30
|
|
|
self.dbstate.db.redo()
|
2007-01-20 22:51:45 +05:30
|
|
|
self.uistate.set_busy_cursor(0)
|
2006-01-13 05:04:33 +05:30
|
|
|
|
2006-05-05 23:07:38 +05:30
|
|
|
def undo_history(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Displays the Undo history window
|
|
|
|
"""
|
2006-05-06 03:25:01 +05:30
|
|
|
try:
|
2009-06-19 03:26:37 +05:30
|
|
|
self.undo_history_window = UndoHistory.UndoHistory(self.dbstate,
|
2006-05-06 03:25:01 +05:30
|
|
|
self.uistate)
|
|
|
|
except Errors.WindowActiveError:
|
2007-09-09 10:54:15 +05:30
|
|
|
return
|
2006-05-05 23:07:38 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def export_data(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Calls the ExportAssistant to export data
|
|
|
|
"""
|
2009-06-19 03:26:37 +05:30
|
|
|
if self.dbstate.db.db_is_open:
|
2007-08-19 02:43:30 +05:30
|
|
|
import ExportAssistant
|
|
|
|
try:
|
2009-06-19 03:26:37 +05:30
|
|
|
ExportAssistant.ExportAssistant(self.dbstate, self.uistate)
|
2007-08-19 02:43:30 +05:30
|
|
|
except Errors.WindowActiveError:
|
|
|
|
return
|
2006-04-08 11:26:31 +05:30
|
|
|
|
2008-05-19 00:54:28 +05:30
|
|
|
def __rebuild_report_and_tool_menus(self):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Callback that rebuilds the tools and reports menu
|
|
|
|
"""
|
2009-06-19 03:26:37 +05:30
|
|
|
tool_menu_list = self._pmgr.get_tool_list()
|
|
|
|
report_menu_list = self._pmgr.get_report_list()
|
2007-09-10 07:39:50 +05:30
|
|
|
self.__build_tools_menu(tool_menu_list)
|
|
|
|
self.__build_report_menu(report_menu_list)
|
2007-10-26 04:45:28 +05:30
|
|
|
self.uistate.set_relationship_class()
|
2006-12-20 12:52:19 +05:30
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
def __build_tools_menu(self, tool_menu_list):
|
|
|
|
"""
|
|
|
|
Builds a new tools menu
|
|
|
|
"""
|
2005-12-29 04:28:26 +05:30
|
|
|
self.toolactions = gtk.ActionGroup('ToolWindow')
|
2007-09-17 00:15:57 +05:30
|
|
|
(uidef, actions) = self.build_plugin_menu(
|
2007-09-10 07:39:50 +05:30
|
|
|
'ToolsMenu', tool_menu_list, Tool.tool_categories,
|
|
|
|
make_tool_callback)
|
2005-12-29 04:28:26 +05:30
|
|
|
self.toolactions.add_actions(actions)
|
2007-09-17 00:15:57 +05:30
|
|
|
self.uistate.uimanager.add_ui_from_string(uidef)
|
2006-04-08 11:26:31 +05:30
|
|
|
self.uimanager.insert_action_group(self.toolactions, 1)
|
2006-04-27 03:45:22 +05:30
|
|
|
self.uistate.uimanager.ensure_update()
|
2005-12-29 04:28:26 +05:30
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
def __build_report_menu(self, report_menu_list):
|
|
|
|
"""
|
|
|
|
Builds a new reports menu
|
|
|
|
"""
|
2005-12-29 04:28:26 +05:30
|
|
|
self.reportactions = gtk.ActionGroup('ReportWindow')
|
2007-09-17 00:15:57 +05:30
|
|
|
(uidef, actions) = self.build_plugin_menu(
|
2007-09-10 07:39:50 +05:30
|
|
|
'ReportsMenu', report_menu_list, ReportBase.standalone_categories,
|
2007-02-23 03:01:37 +05:30
|
|
|
make_report_callback)
|
2005-12-29 04:28:26 +05:30
|
|
|
self.reportactions.add_actions(actions)
|
2007-09-17 00:15:57 +05:30
|
|
|
self.uistate.uimanager.add_ui_from_string(uidef)
|
2006-04-08 11:26:31 +05:30
|
|
|
self.uimanager.insert_action_group(self.reportactions, 1)
|
2006-04-27 03:45:22 +05:30
|
|
|
self.uistate.uimanager.ensure_update()
|
2005-12-29 04:28:26 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def build_plugin_menu(self, text, item_list, categories, func):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Builds a new XML description for a menu based on the item list
|
|
|
|
"""
|
2005-12-29 04:28:26 +05:30
|
|
|
actions = []
|
2007-02-23 03:01:37 +05:30
|
|
|
ofile = StringIO()
|
|
|
|
ofile.write('<ui><menubar name="MenuBar"><menu action="%s">' % text)
|
2005-12-29 04:28:26 +05:30
|
|
|
|
|
|
|
menu = gtk.Menu()
|
|
|
|
menu.show()
|
|
|
|
|
|
|
|
hash_data = {}
|
|
|
|
for item in item_list:
|
|
|
|
if item[9]:
|
2008-05-19 09:44:11 +05:30
|
|
|
category = _UNSUPPORTED
|
2005-12-29 04:28:26 +05:30
|
|
|
else:
|
|
|
|
category = categories[item[3]]
|
2008-07-17 23:40:32 +05:30
|
|
|
if category in hash_data:
|
2005-12-29 04:28:26 +05:30
|
|
|
hash_data[category].append(
|
2006-06-17 02:56:44 +05:30
|
|
|
(item[0], item[1], item[2], item[4], item[3], item[10]))
|
2005-12-29 04:28:26 +05:30
|
|
|
else:
|
|
|
|
hash_data[category] = [
|
2006-06-17 02:56:44 +05:30
|
|
|
(item[0], item[1], item[2], item[4], item[3], item[10])]
|
2005-12-29 04:28:26 +05:30
|
|
|
|
|
|
|
# Sort categories, skipping the unsupported
|
2009-05-27 02:18:09 +05:30
|
|
|
catlist = [item for item in hash_data
|
2008-05-19 09:44:11 +05:30
|
|
|
if item != _UNSUPPORTED]
|
2005-12-29 04:28:26 +05:30
|
|
|
catlist.sort()
|
|
|
|
for key in catlist:
|
2006-04-08 11:26:31 +05:30
|
|
|
new_key = key.replace(' ', '-')
|
2007-02-23 03:01:37 +05:30
|
|
|
ofile.write('<menu action="%s">' % new_key)
|
2006-04-08 11:26:31 +05:30
|
|
|
actions.append((new_key, None, key))
|
2005-12-29 04:28:26 +05:30
|
|
|
lst = hash_data[key]
|
|
|
|
lst.sort(by_menu_name)
|
|
|
|
for name in lst:
|
2006-04-28 10:03:28 +05:30
|
|
|
new_key = name[3].replace(' ', '-')
|
2008-03-02 04:17:48 +05:30
|
|
|
menu_name = ("%s...") % name[2]
|
2007-02-23 03:01:37 +05:30
|
|
|
ofile.write('<menuitem action="%s"/>' % new_key)
|
2008-03-02 04:17:48 +05:30
|
|
|
actions.append((new_key, None, menu_name, None, None,
|
2009-06-19 03:26:37 +05:30
|
|
|
func(name, self.dbstate, self.uistate)))
|
2007-02-23 03:01:37 +05:30
|
|
|
ofile.write('</menu>')
|
2005-12-29 04:28:26 +05:30
|
|
|
|
|
|
|
# If there are any unsupported items we add separator
|
|
|
|
# and the unsupported category at the end of the menu
|
2008-07-17 23:40:32 +05:30
|
|
|
if _UNSUPPORTED in hash_data:
|
2007-02-23 03:01:37 +05:30
|
|
|
ofile.write('<separator/>')
|
2008-05-19 09:44:11 +05:30
|
|
|
ofile.write('<menu action="%s">' % _UNSUPPORTED)
|
|
|
|
actions.append((_UNSUPPORTED, None, _UNSUPPORTED))
|
|
|
|
lst = hash_data[_UNSUPPORTED]
|
2005-12-29 04:28:26 +05:30
|
|
|
lst.sort(by_menu_name)
|
|
|
|
for name in lst:
|
2006-04-28 10:03:28 +05:30
|
|
|
new_key = name[3].replace(' ', '-')
|
2007-02-23 03:01:37 +05:30
|
|
|
ofile.write('<menuitem action="%s"/>' % new_key)
|
2006-04-08 11:26:31 +05:30
|
|
|
actions.append((new_key, None, name[2], None, None,
|
2009-06-19 03:26:37 +05:30
|
|
|
func(name, self.dbstate, self.uistate)))
|
2007-02-23 03:01:37 +05:30
|
|
|
ofile.write('</menu>')
|
2005-12-29 04:28:26 +05:30
|
|
|
|
2007-02-23 03:01:37 +05:30
|
|
|
ofile.write('</menu></menubar></ui>')
|
|
|
|
return (ofile.getvalue(), actions)
|
2005-12-29 04:28:26 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def display_about_box(obj):
|
2008-04-07 02:05:38 +05:30
|
|
|
"""Display the About box."""
|
|
|
|
about = GrampsAboutDialog()
|
2007-09-09 10:54:15 +05:30
|
|
|
about.run()
|
|
|
|
about.destroy()
|
|
|
|
|
|
|
|
def filter_toggle(obj):
|
|
|
|
"""
|
|
|
|
Save the filter state to the config settings on change
|
|
|
|
"""
|
|
|
|
Config.set(Config.FILTER, obj.get_active())
|
|
|
|
Config.sync()
|
2005-12-29 04:28:26 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def key_bindings(obj):
|
|
|
|
"""
|
|
|
|
Display key bindings
|
|
|
|
"""
|
2008-04-17 12:06:49 +05:30
|
|
|
GrampsDisplay.help(webpage=WIKI_HELP_PAGE_KEY)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
def manual_activate(obj):
|
2007-09-09 10:54:15 +05:30
|
|
|
"""
|
|
|
|
Display the GRAMPS manual
|
|
|
|
"""
|
2008-04-17 12:06:49 +05:30
|
|
|
GrampsDisplay.help(webpage=WIKI_HELP_PAGE_MAN)
|
2005-12-29 04:28:26 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def report_bug_activate(obj):
|
|
|
|
"""
|
|
|
|
Display the bug tracker web site
|
|
|
|
"""
|
|
|
|
GrampsDisplay.url(const.URL_BUGTRACKER)
|
2006-09-24 10:07:59 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def home_page_activate(obj):
|
2006-09-24 10:07:59 +05:30
|
|
|
"""
|
2007-09-09 10:54:15 +05:30
|
|
|
Display the GRAMPS home page
|
2006-09-24 10:07:59 +05:30
|
|
|
"""
|
2007-09-09 10:54:15 +05:30
|
|
|
GrampsDisplay.url(const.URL_HOMEPAGE)
|
2006-09-24 10:07:59 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def mailing_lists_activate(obj):
|
|
|
|
"""
|
|
|
|
Display the mailing list web page
|
|
|
|
"""
|
2008-03-07 20:01:04 +05:30
|
|
|
GrampsDisplay.url(const.URL_MAILINGLIST)
|
|
|
|
|
|
|
|
def extra_plugins_activate(obj):
|
|
|
|
"""
|
|
|
|
Display the wiki page with extra plugins
|
|
|
|
"""
|
|
|
|
GrampsDisplay.url(const.URL_WIKISTRING+const.WIKI_EXTRAPLUGINS)
|
2006-09-25 07:49:58 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def faq_activate(obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Display FAQ
|
|
|
|
"""
|
2008-04-17 12:06:49 +05:30
|
|
|
GrampsDisplay.help(webpage=WIKI_HELP_PAGE_FAQ)
|
2006-09-24 10:07:59 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def by_menu_name(first, second):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Sorts menu item lists
|
|
|
|
"""
|
2007-09-09 10:54:15 +05:30
|
|
|
return cmp(first[2], second[2])
|
2006-09-24 10:07:59 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def make_report_callback(lst, dbstate, uistate):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Makes a callback for a report menu item
|
|
|
|
"""
|
2007-09-09 10:54:15 +05:30
|
|
|
return lambda x: ReportBase.report(
|
|
|
|
dbstate, uistate, dbstate.get_active_person(),
|
|
|
|
lst[0], lst[1], lst[2], lst[3], lst[4], lst[5])
|
|
|
|
|
|
|
|
def make_tool_callback(lst, dbstate, uistate):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Makes a callback for a tool menu item
|
|
|
|
"""
|
2007-09-09 10:54:15 +05:30
|
|
|
return lambda x: Tool.gui_tool(dbstate, uistate,
|
|
|
|
lst[0], lst[1], lst[2], lst[3], lst[4],
|
|
|
|
dbstate.db.request_rebuild)
|