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
|
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
|
|
|
|
#
|
|
|
|
|
2005-08-12 08:20:56 +05:30
|
|
|
# $Id$
|
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
"""
|
|
|
|
Manages the main window and the pluggable views
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = "Donald N. Allingham"
|
2006-04-10 04:23:53 +05:30
|
|
|
__revision__ = "$Revision$"
|
2006-04-08 11:26:31 +05:30
|
|
|
|
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
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-05-31 07:33:29 +05:30
|
|
|
from PluginUtils import Plugins, Tool, PluginStatus, \
|
2006-03-11 06:48:37 +05:30
|
|
|
relationship_class, load_plugins, \
|
2006-05-18 05:06:31 +05:30
|
|
|
tool_list, report_list
|
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
|
2005-08-11 05:23:24 +05:30
|
|
|
import QuestionDialog
|
|
|
|
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
|
2006-01-23 09:39:20 +05:30
|
|
|
import GrampsWidgets
|
2006-05-06 03:25:01 +05:30
|
|
|
import UndoHistory
|
2006-05-18 02:46:59 +05:30
|
|
|
from 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
|
2007-10-07 08:49:35 +05:30
|
|
|
import gen.db
|
|
|
|
|
2007-02-18 01:29:21 +05:30
|
|
|
import ProgressDialog
|
2006-12-21 08:58:44 +05:30
|
|
|
|
2007-02-23 03:01:37 +05:30
|
|
|
def show_url(dialog, link, user_data):
|
|
|
|
"""
|
|
|
|
Sets the about dialog callback for showing the URL. Call the GrampsDisplay
|
|
|
|
function to display the link
|
|
|
|
"""
|
2006-05-14 06:13:05 +05:30
|
|
|
GrampsDisplay.url(link)
|
2007-02-23 03:01:37 +05:30
|
|
|
|
|
|
|
gtk.about_dialog_set_url_hook(show_url, None)
|
2006-05-14 06:13:05 +05:30
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
_KNOWN_FORMATS = {
|
2007-09-08 11:24:02 +05:30
|
|
|
const.APP_GRAMPS : _('GRAMPS (grdb)'),
|
|
|
|
const.APP_GRAMPS_XML : _('GRAMPS XML'),
|
|
|
|
const.APP_GEDCOM : _('GEDCOM'),
|
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"/>
|
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"/>
|
|
|
|
<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"/>
|
2006-12-31 10:47:35 +05:30
|
|
|
<accelerator action="<Alt>N"/>
|
|
|
|
<accelerator action="<Alt>P"/>
|
2005-08-09 10:11:20 +05:30
|
|
|
</ui>
|
|
|
|
'''
|
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# ViewManager
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-08-09 10:11:20 +05:30
|
|
|
class ViewManager:
|
2007-09-09 10:54:15 +05:30
|
|
|
"""
|
|
|
|
Overview
|
|
|
|
========
|
|
|
|
|
|
|
|
The ViewManager is the main window of the program. It is closely tied
|
|
|
|
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:
|
|
|
|
|
|
|
|
- Person View
|
|
|
|
- Relationship View
|
|
|
|
- Family View
|
|
|
|
- Source View
|
|
|
|
|
|
|
|
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
|
|
|
|
method of containing each view, and switching between the views.s
|
|
|
|
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def __init__(self, state):
|
2007-09-17 00:15:57 +05:30
|
|
|
|
2006-10-02 07:40:12 +05:30
|
|
|
self.page_is_changing = False
|
2005-08-11 05:23:24 +05:30
|
|
|
self.state = state
|
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
|
2006-03-30 00:56:43 +05:30
|
|
|
self.file_loaded = False
|
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)
|
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
self.__build_main_window()
|
|
|
|
self.__connect_signals()
|
|
|
|
self.__do_load_plugins()
|
2006-04-08 11:26:31 +05:30
|
|
|
|
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)
|
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
self.rel_class = relationship_class
|
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()
|
|
|
|
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,
|
2007-02-18 01:29:21 +05:30
|
|
|
self.uimanager, self.progress_monitor)
|
2007-09-09 10:54:15 +05:30
|
|
|
|
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
|
|
|
self.state.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
|
|
|
|
2007-02-23 03:01:37 +05:30
|
|
|
self.person_nav = Navigation.PersonNavigation(self.state, 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(
|
2007-09-17 00:15:57 +05:30
|
|
|
self.uistate, self.state, self.__read_recent_file)
|
2007-06-14 11:02:06 +05:30
|
|
|
self.recent_manager.build()
|
2006-01-08 08:36:58 +05:30
|
|
|
|
2007-02-23 03:01:37 +05:30
|
|
|
self.db_loader = DbLoader(self.state, 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()
|
|
|
|
|
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):
|
|
|
|
"""
|
|
|
|
Creates the statusbar that sits at the bottom of the window
|
|
|
|
"""
|
|
|
|
self.progress = gtk.ProgressBar()
|
|
|
|
self.progress.set_size_request(100, -1)
|
|
|
|
self.progress.hide()
|
|
|
|
|
|
|
|
self.statusbar = GrampsWidgets.Statusbar()
|
|
|
|
self.statusbar.show()
|
|
|
|
|
|
|
|
self.warnbtn = GrampsWidgets.WarnButton()
|
|
|
|
|
|
|
|
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
|
|
|
"""
|
|
|
|
Initializes the actions lists for the UIManager
|
|
|
|
"""
|
2006-04-08 11:26:31 +05:30
|
|
|
self._file_action_list = [
|
2007-03-29 07:12:21 +05:30
|
|
|
('FileMenu', None, _('_Family Trees')),
|
2007-09-09 10:54:15 +05:30
|
|
|
('Open', 'gramps-db', _('_Manage Family Trees'), "<control>o",
|
|
|
|
_("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')),
|
2007-09-09 10:54:15 +05:30
|
|
|
('Preferences', gtk.STOCK_PREFERENCES, _('_Preferences'), None,
|
|
|
|
None, self.preferences_activate),
|
2006-04-28 22:32:53 +05:30
|
|
|
('HelpMenu', None, _('_Help')),
|
2007-09-09 10:54:15 +05:30
|
|
|
('HomePage', None, _('GRAMPS _home page'), None, None,
|
|
|
|
home_page_activate),
|
|
|
|
('MailingLists', None, _('GRAMPS _mailing lists'), None, None,
|
|
|
|
mailing_lists_activate),
|
|
|
|
('ReportBug', None, _('_Report a bug'), None, None,
|
|
|
|
report_bug_activate),
|
|
|
|
('About', gtk.STOCK_ABOUT, _('_About'), None, None,
|
|
|
|
display_about_box),
|
|
|
|
('PluginStatus', None, _('_Plugin status'), None, None,
|
2006-04-08 11:26:31 +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),
|
|
|
|
('TipOfDay', None, _('Tip of the day'), None, None,
|
2006-04-08 11:26:31 +05:30
|
|
|
self.tip_of_day_activate),
|
|
|
|
]
|
|
|
|
|
2006-12-19 07:59:47 +05:30
|
|
|
self._readonly_action_list = [
|
2007-09-09 10:54:15 +05:30
|
|
|
('SaveAs', gtk.STOCK_SAVE_AS, _('_Save As'), "<control><shift>s",
|
2007-09-17 00:15:57 +05:30
|
|
|
None, self.__save_as_activate),
|
2007-09-09 10:54:15 +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,
|
2006-05-04 04:51:49 +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),
|
|
|
|
('<Alt>N', None, '<Alt>N', "<Alt>N", None, self.__next_view),
|
|
|
|
('<Alt>P', None, '<Alt>P', "<Alt>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 = [
|
2007-09-09 10:54:15 +05:30
|
|
|
('ScratchPad', gtk.STOCK_PASTE, _('_ScratchPad'), "<alt>s",
|
2006-12-19 07:59:47 +05:30
|
|
|
_("Open the ScratchPad dialog"), self.scratchpad),
|
2007-09-09 10:54:15 +05:30
|
|
|
('Import', gtk.STOCK_CONVERT, _('_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 ),
|
2007-02-23 03:01:37 +05:30
|
|
|
('Filter', None, _('_Filter sidebar'), None, None,
|
2007-09-09 10:54:15 +05:30
|
|
|
filter_toggle, self.show_filter),
|
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',
|
|
|
|
_('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:
|
2007-09-09 10:54:15 +05:30
|
|
|
self.uistate.push_message(self.state,
|
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
|
|
|
|
self.buttons[new_page].set_active(True)
|
|
|
|
|
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
|
|
|
|
self.buttons[new_page].set_active(True)
|
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
def init_interface(self):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Initializes the interface, creating the pages
|
|
|
|
"""
|
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)
|
2007-09-10 07:39:50 +05:30
|
|
|
self.__build_tools_menu(tool_list)
|
|
|
|
self.__build_report_menu(report_list)
|
2007-09-09 10:54:15 +05:30
|
|
|
self.uistate.connect('plugins-reloaded',
|
|
|
|
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
|
|
|
|
"""
|
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
|
|
|
self.uistate.modify_statusbar(self.state)
|
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))
|
|
|
|
|
2006-05-21 09:43:34 +05:30
|
|
|
def post_init_interface(self):
|
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()
|
2007-03-29 07:12:21 +05:30
|
|
|
if not self.state.db.is_open():
|
2007-09-09 10:54:15 +05:30
|
|
|
self.__open_activate(None)
|
2006-05-18 08:41:15 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __do_load_plugins(self):
|
|
|
|
"""
|
|
|
|
Loads the plugins at initialization time. We load the document
|
|
|
|
generators and the plugins. The plugin status window is opened
|
|
|
|
on an error if the user has requested.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# load document generators
|
2005-12-29 04:28:26 +05:30
|
|
|
self.uistate.status_text(_('Loading document formats...'))
|
2007-09-08 11:24:02 +05:30
|
|
|
error = load_plugins(const.DOCGEN_DIR)
|
|
|
|
error |= load_plugins(os.path.join(const.HOME_DIR, "docgen"))
|
2007-09-09 10:54:15 +05:30
|
|
|
|
|
|
|
# load plugins
|
2005-12-29 04:28:26 +05:30
|
|
|
self.uistate.status_text(_('Loading plugins...'))
|
2007-09-08 11:24:02 +05:30
|
|
|
error |= load_plugins(const.PLUGINS_DIR)
|
|
|
|
error |= load_plugins(os.path.join(const.HOME_DIR, "plugins"))
|
2007-09-09 10:54:15 +05:30
|
|
|
|
|
|
|
# get to ssee if we need to open the plugin status window
|
2006-04-25 02:34:01 +05:30
|
|
|
if Config.get(Config.POP_PLUGIN_STATUS) and error:
|
2006-07-30 23:43:38 +05:30
|
|
|
try:
|
|
|
|
PluginStatus.PluginStatus(self.state, self.uistate, [])
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
old_win = self.uistate.gwm.get_item_from_id(
|
|
|
|
PluginStatus.PluginStatus)
|
|
|
|
old_win.close()
|
2007-02-23 03:01:37 +05:30
|
|
|
PluginStatus.PluginStatus(self.state, self.uistate, [])
|
2006-07-30 23:43:38 +05:30
|
|
|
|
2007-02-23 03:01:37 +05:30
|
|
|
self.uistate.push_message(self.state, _('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()
|
2005-12-22 10:06:26 +05:30
|
|
|
self.state.db.close()
|
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
|
|
|
|
|
|
|
if self.state.db.undoindex >= 0:
|
2007-03-25 07:55:37 +05:30
|
|
|
self.uistate.set_busy_cursor(1)
|
|
|
|
self.uistate.progress.show()
|
|
|
|
self.uistate.push_message(self.state, _("Autobackup..."))
|
2007-06-16 09:53:47 +05:30
|
|
|
GrampsDbUtils.Backup.backup(self.state.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.
|
|
|
|
"""
|
2006-11-13 08:12:07 +05:30
|
|
|
from QuestionDialog import QuestionDialog2, WarningDialog
|
|
|
|
|
2006-05-04 04:51:49 +05:30
|
|
|
if self.state.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():
|
2006-11-13 08:12:07 +05:30
|
|
|
self.state.db.disable_signals()
|
|
|
|
while self.state.db.undo():
|
|
|
|
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):
|
|
|
|
"""
|
|
|
|
Initializes an action group for the UIManager
|
|
|
|
"""
|
|
|
|
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:
|
2007-02-23 03:01:37 +05:30
|
|
|
GrampsCfg.GrampsPreferences(self.uistate, self.state)
|
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)
|
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def plugin_status(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Display plugin status dialog
|
|
|
|
"""
|
2006-07-30 23:43:38 +05:30
|
|
|
try:
|
|
|
|
PluginStatus.PluginStatus(self.state, self.uistate, [])
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
old_win = self.uistate.gwm.get_item_from_id(
|
|
|
|
PluginStatus.PluginStatus)
|
|
|
|
old_win.close()
|
2007-02-23 03:01:37 +05:30
|
|
|
PluginStatus.PluginStatus(self.state, 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)
|
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)
|
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
|
|
|
"""
|
|
|
|
Set the toobar 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.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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
def __create_pages(self):
|
|
|
|
"""
|
|
|
|
Creates the Views
|
|
|
|
"""
|
|
|
|
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:
|
2006-04-08 11:26:31 +05:30
|
|
|
page = page_def(self.state, 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):
|
|
|
|
"""
|
|
|
|
Creates the sidebar button. The page_title is the text associated with
|
|
|
|
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):
|
|
|
|
"""
|
|
|
|
Sets the corresponding button active, while setting the others
|
|
|
|
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):
|
|
|
|
"""
|
|
|
|
Initializes the navigation scheme
|
|
|
|
"""
|
|
|
|
old_nav = self._navigation_type[self.prev_nav]
|
|
|
|
if old_nav[0] != None:
|
|
|
|
old_nav[0].disable()
|
|
|
|
|
|
|
|
page_type = self.active_page.navigation_type()
|
|
|
|
nav_type = self._navigation_type[page_type]
|
|
|
|
if nav_type[0] != None:
|
|
|
|
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
|
|
|
|
2006-04-12 03:54:26 +05:30
|
|
|
if self.state.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
|
|
|
|
2007-01-22 23:21:43 +05:30
|
|
|
def import_pkg(self, filename):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Imports a GRAMPS package
|
|
|
|
"""
|
2007-02-11 05:10:48 +05:30
|
|
|
import ReadPkg
|
|
|
|
ReadPkg.impData(self.state.db, filename, self.uistate.pulse_progressbar)
|
2007-09-09 10:54:15 +05:30
|
|
|
self.__post_load()
|
2007-01-22 23:21:43 +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
|
|
|
|
"""
|
2007-06-13 05:01:40 +05:30
|
|
|
if self.state.db.is_open():
|
2006-05-22 09:47:18 +05:30
|
|
|
self.db_loader.import_file()
|
2007-09-09 10:54:15 +05:30
|
|
|
self.__post_load()
|
2006-05-18 05:06:31 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __open_activate(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Called when the Open button is clicked
|
|
|
|
"""
|
2007-03-27 08:48:49 +05:30
|
|
|
import DbManager
|
2007-03-29 07:12:21 +05:30
|
|
|
dialog = DbManager.DbManager(self.state, self.window)
|
2007-03-28 09:03:11 +05:30
|
|
|
value = dialog.run()
|
|
|
|
if value:
|
|
|
|
(filename, title) = value
|
2007-03-27 08:48:49 +05:30
|
|
|
self.read_file(filename, 'x-directory/normal')
|
|
|
|
try:
|
|
|
|
os.chdir(os.path.dirname(filename))
|
2007-09-17 00:15:57 +05:30
|
|
|
except (IOError, OSError):
|
2007-03-27 08:48:49 +05:30
|
|
|
pass
|
2007-09-09 10:54:15 +05:30
|
|
|
self.__post_load_newdb(filename, 'x-directory/normal', title)
|
2007-03-27 08:48:49 +05:30
|
|
|
|
|
|
|
def read_file(self, filename, filetype):
|
|
|
|
"""
|
|
|
|
This method takes care of changing database, and loading the data.
|
|
|
|
|
|
|
|
This method should only return on success.
|
2007-09-09 10:54:15 +05:30
|
|
|
Returning on failure makes no sense, because we cannot recover,
|
2007-03-27 08:48:49 +05:30
|
|
|
since database has already beeen changed.
|
|
|
|
Therefore, any errors should raise exceptions.
|
|
|
|
|
|
|
|
On success, return with the disabled signals. The post-load routine
|
|
|
|
should enable signals, as well as finish up with other UI goodies.
|
|
|
|
"""
|
|
|
|
|
|
|
|
if os.path.exists(filename):
|
|
|
|
if not os.access(filename, os.W_OK):
|
|
|
|
mode = "r"
|
|
|
|
QuestionDialog.WarningDialog(_('Read only database'),
|
|
|
|
_('You do not have write access '
|
|
|
|
'to the selected file.'))
|
|
|
|
else:
|
|
|
|
mode = "w"
|
|
|
|
elif filetype == 'unknown':
|
|
|
|
QuestionDialog.WarningDialog(
|
2007-09-09 10:54:15 +05:30
|
|
|
_('Missing or Invalid database'),
|
2007-03-27 08:48:49 +05:30
|
|
|
_('%s could not be found.\n'
|
|
|
|
'It is possible that this file no longer exists '
|
|
|
|
'or has been moved.') % filename)
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
mode = 'w'
|
|
|
|
|
|
|
|
try:
|
2007-10-07 08:49:35 +05:30
|
|
|
dbclass = gen.db.dbdir.GrampsDBDir
|
|
|
|
except gen.db.exceptions.GrampsDbException, msg:
|
2007-03-27 08:48:49 +05:30
|
|
|
QuestionDialog.ErrorDialog(
|
|
|
|
_("Could not open file: %s") % filename,
|
|
|
|
_("This may be caused by an improper installation of GRAMPS.") +
|
|
|
|
"\n" + str(msg))
|
|
|
|
return
|
|
|
|
|
|
|
|
self.state.change_database(dbclass(Config.get(Config.TRANSACTIONS)))
|
|
|
|
self.state.db.disable_signals()
|
|
|
|
|
|
|
|
self.uistate.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
|
|
|
self.uistate.progress.show()
|
|
|
|
|
|
|
|
try:
|
2007-05-02 09:35:41 +05:30
|
|
|
self.state.db.load(filename, self.uistate.pulse_progressbar, mode)
|
2007-03-27 08:48:49 +05:30
|
|
|
self.state.db.set_save_path(filename)
|
|
|
|
try:
|
|
|
|
os.chdir(os.path.dirname(filename))
|
2007-09-17 00:15:57 +05:30
|
|
|
except (OSError, IOError):
|
2007-03-27 08:48:49 +05:30
|
|
|
print "could not change directory"
|
2007-06-13 05:01:40 +05:30
|
|
|
except Errors.DbError, msg:
|
2007-06-13 07:57:31 +05:30
|
|
|
QuestionDialog.DBErrorDialog(str(msg.value))
|
2007-06-13 05:01:40 +05:30
|
|
|
self.state.no_database()
|
2007-03-27 08:48:49 +05:30
|
|
|
except Exception:
|
2007-05-02 09:35:41 +05:30
|
|
|
LOG.error("Failed to open database.", exc_info=True)
|
2007-03-27 08:48:49 +05:30
|
|
|
|
|
|
|
return True
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2007-09-17 00:15:57 +05:30
|
|
|
def __save_as_activate(self, obj):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Called when the SaveAs button is clicked
|
|
|
|
"""
|
2007-06-13 05:01:40 +05:30
|
|
|
if self.state.db.is_open():
|
2007-02-23 03:01:37 +05:30
|
|
|
(filename, filetype) = self.db_loader.save_as()
|
2007-09-09 10:54:15 +05:30
|
|
|
self.__post_load_newdb(filename, filetype)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2007-09-17 00:15:57 +05:30
|
|
|
def __read_recent_file(self, filename):
|
2007-09-10 07:39:50 +05:30
|
|
|
"""
|
|
|
|
Called when the recent file is loaded
|
|
|
|
"""
|
2007-09-09 10:54:15 +05:30
|
|
|
if self.db_loader.read_file(filename, 'x-directory/normal'):
|
2007-03-30 09:53:46 +05:30
|
|
|
|
|
|
|
# Attempt to figure out the database title
|
|
|
|
path = os.path.join(filename, "name.txt")
|
|
|
|
try:
|
2007-05-02 09:35:41 +05:30
|
|
|
ifile = open(path)
|
|
|
|
title = ifile.readline().strip()
|
|
|
|
ifile.close()
|
2007-03-30 09:53:46 +05:30
|
|
|
except:
|
|
|
|
title = filename
|
|
|
|
|
2007-09-09 10:54:15 +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.
|
|
|
|
"""
|
2007-09-09 03:36:30 +05:30
|
|
|
if self.state.active :
|
2007-09-10 07:39:50 +05:30
|
|
|
# clear history and fill history with first entry, active person
|
2007-09-09 03:36:30 +05:30
|
|
|
self.uistate.clear_history(self.state.active.handle)
|
|
|
|
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
|
|
|
|
2007-09-17 00:15:57 +05:30
|
|
|
self.state.db.undo_callback = self.__change_undo_label
|
|
|
|
self.state.db.redo_callback = self.__change_redo_label
|
|
|
|
self.__change_undo_label(None)
|
|
|
|
self.__change_redo_label(None)
|
2006-05-18 05:06:31 +05:30
|
|
|
self.state.db.undo_history_callback = self.undo_history_update
|
|
|
|
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
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __post_load_newdb(self, filename, filetype, title=None):
|
2007-09-17 00:15:57 +05:30
|
|
|
"""
|
|
|
|
Called after a new database is loaded.
|
|
|
|
"""
|
2006-05-18 06:32:52 +05:30
|
|
|
if not filename:
|
|
|
|
return
|
|
|
|
|
2006-05-18 05:06:31 +05:30
|
|
|
# This method is for UI stuff when the database has changed.
|
|
|
|
# Window title, recent files, etc related to new file.
|
|
|
|
|
2006-05-18 02:46:59 +05:30
|
|
|
self.state.db.set_save_path(filename)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
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
|
|
|
|
|
2006-05-18 05:06:31 +05:30
|
|
|
if self.state.db.readonly:
|
|
|
|
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
|
|
|
|
2007-02-11 05:10:48 +05:30
|
|
|
# apply preferred researcher if loaded file has none
|
2005-08-09 10:11:20 +05:30
|
|
|
res = self.state.db.get_researcher()
|
|
|
|
owner = GrampsCfg.get_researcher()
|
2007-02-11 05:10:48 +05:30
|
|
|
if res.get_name() == "" and owner.get_name() != "":
|
2005-08-09 10:11:20 +05:30
|
|
|
self.state.db.set_researcher(owner)
|
|
|
|
|
2005-12-22 11:43:11 +05:30
|
|
|
self.setup_bookmarks()
|
2006-07-31 16:38:44 +05:30
|
|
|
|
2007-06-28 11:11:40 +05:30
|
|
|
name_displayer.set_name_format(self.state.db.name_formats)
|
2006-07-16 20:14:13 +05:30
|
|
|
fmt_default = Config.get(Config.NAME_FORMAT)
|
|
|
|
if fmt_default < 0:
|
2007-06-28 11:11:40 +05:30
|
|
|
name_displayer.set_default_format(fmt_default)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2006-05-18 02:46:59 +05:30
|
|
|
self.state.db.enable_signals()
|
2006-05-18 05:06:31 +05:30
|
|
|
self.state.signal_change()
|
2006-01-02 21:30:05 +05:30
|
|
|
|
2007-03-30 09:53:46 +05:30
|
|
|
Config.set(Config.RECENT_FILE, filename)
|
2006-09-24 10:07:59 +05:30
|
|
|
|
|
|
|
try:
|
|
|
|
self.state.change_active_person(self.state.db.find_initial_person())
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
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)
|
2006-05-18 02:46:59 +05:30
|
|
|
|
|
|
|
self.file_loaded = True
|
|
|
|
|
2007-06-14 11:02:06 +05:30
|
|
|
RecentFiles.recent_files(filename, name)
|
|
|
|
self.recent_manager.build()
|
2006-05-18 02:46:59 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
# Call common __post_load
|
|
|
|
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
|
|
|
"""
|
|
|
|
Changes the UNDO label
|
|
|
|
"""
|
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
|
|
|
"""
|
|
|
|
Changes the REDO label
|
|
|
|
"""
|
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
|
|
|
"""
|
|
|
|
Initializes the bookmarks based of the database. This needs to
|
|
|
|
be called anytime the database changes.
|
|
|
|
"""
|
|
|
|
import Bookmarks
|
|
|
|
self.bookmarks = Bookmarks.Bookmarks(
|
|
|
|
self.state, self.uistate, self.state.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
|
|
|
"""
|
|
|
|
Adds a bookmark to the bookmark list
|
|
|
|
"""
|
2005-12-25 09:31:47 +05:30
|
|
|
if self.state.active:
|
|
|
|
self.bookmarks.add(self.state.active.get_handle())
|
2007-06-28 11:11:40 +05:30
|
|
|
name = name_displayer.display(self.state.active)
|
2007-09-09 10:54:15 +05:30
|
|
|
self.uistate.push_message(self.state,
|
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:
|
2006-03-23 04:33:57 +05:30
|
|
|
QuestionDialog.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:
|
|
|
|
Plugins.ReportPlugins(self.state, self.uistate, [])
|
|
|
|
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:
|
|
|
|
Plugins.ToolPlugins(self.state, self.uistate, [])
|
|
|
|
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
|
|
|
"""
|
|
|
|
Displays the scratchpad
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
import ScratchPad
|
2006-04-28 22:26:19 +05:30
|
|
|
try:
|
|
|
|
ScratchPad.ScratchPadWindow(self.state, self.uistate)
|
|
|
|
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)
|
2006-01-13 03:32:58 +05:30
|
|
|
self.state.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)
|
2006-01-13 05:04:33 +05:30
|
|
|
self.state.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:
|
2007-09-09 10:54:15 +05:30
|
|
|
self.undo_history_window = UndoHistory.UndoHistory(self.state,
|
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
|
|
|
|
"""
|
2007-08-19 02:43:30 +05:30
|
|
|
if self.state.db.db_is_open:
|
|
|
|
import ExportAssistant
|
|
|
|
try:
|
|
|
|
ExportAssistant.ExportAssistant(self.state, self.uistate)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
return
|
2006-04-08 11:26:31 +05:30
|
|
|
|
2007-09-10 07:39:50 +05:30
|
|
|
def __rebuild_report_and_tool_menus(self, tool_menu_list, report_menu_list):
|
|
|
|
"""
|
|
|
|
Callback that rebuilds the tools and reports menu
|
|
|
|
"""
|
|
|
|
self.__build_tools_menu(tool_menu_list)
|
|
|
|
self.__build_report_menu(report_menu_list)
|
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]:
|
|
|
|
category = Plugins.UNSUPPORTED
|
|
|
|
else:
|
|
|
|
category = categories[item[3]]
|
|
|
|
if hash_data.has_key(category):
|
|
|
|
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
|
2006-04-28 10:03:28 +05:30
|
|
|
catlist = [item for item in hash_data.keys()
|
|
|
|
if item != Plugins.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(' ', '-')
|
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,
|
2006-04-10 04:23:53 +05:30
|
|
|
func(name, self.state, 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
|
|
|
|
if hash_data.has_key(Plugins.UNSUPPORTED):
|
2007-02-23 03:01:37 +05:30
|
|
|
ofile.write('<separator/>')
|
|
|
|
ofile.write('<menu action="%s">' % Plugins.UNSUPPORTED)
|
2006-04-08 11:26:31 +05:30
|
|
|
actions.append((Plugins.UNSUPPORTED, None, Plugins.UNSUPPORTED))
|
2006-04-28 10:21:44 +05:30
|
|
|
lst = hash_data[Plugins.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,
|
2006-04-10 04:23:53 +05:30
|
|
|
func(name, self.state, 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):
|
|
|
|
"""
|
|
|
|
Displays the About box.
|
|
|
|
"""
|
|
|
|
about = gtk.AboutDialog()
|
|
|
|
about.set_name(const.PROGRAM_NAME)
|
|
|
|
about.set_version(const.VERSION)
|
|
|
|
about.set_copyright(const.COPYRIGHT_MSG)
|
|
|
|
about.set_artists([
|
|
|
|
_("Much of GRAMPS' artwork is either from\n"
|
|
|
|
"the Tango Project or derived from the Tango\n"
|
|
|
|
"Project. This artwork is released under the\n"
|
|
|
|
"Create Commons Attribution-ShareAlike 2.5\n"
|
|
|
|
"license.")
|
|
|
|
])
|
|
|
|
try:
|
|
|
|
ifile = open(const.LICENSE_FILE, "r")
|
|
|
|
about.set_license(ifile.read().replace('\x0c', ''))
|
|
|
|
ifile.close()
|
|
|
|
except:
|
|
|
|
about.set_license("License file is missing")
|
|
|
|
about.set_comments(_(const.COMMENTS))
|
|
|
|
about.set_website_label(_('GRAMPS Homepage'))
|
|
|
|
about.set_website(const.URL_HOMEPAGE)
|
|
|
|
about.set_authors(const.AUTHORS)
|
|
|
|
|
|
|
|
# Only set translation credits if they are translated
|
|
|
|
trans_credits = _(const.TRANSLATORS)
|
|
|
|
if trans_credits != const.TRANSLATORS:
|
|
|
|
about.set_translator_credits(trans_credits)
|
|
|
|
|
|
|
|
about.set_documenters(const.DOCUMENTERS)
|
|
|
|
about.set_logo(gtk.gdk.pixbuf_new_from_file(const.SPLASH))
|
|
|
|
about.set_modal(True)
|
|
|
|
about.show()
|
|
|
|
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
|
|
|
|
"""
|
|
|
|
GrampsDisplay.help('keybind-lists')
|
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
|
|
|
|
"""
|
|
|
|
GrampsDisplay.help('index')
|
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
|
|
|
|
"""
|
|
|
|
GrampsDisplay.url( const.URL_MAILINGLIST)
|
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
|
|
|
|
"""
|
2007-09-09 10:54:15 +05:30
|
|
|
GrampsDisplay.help('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)
|