Sidebar tidy-up and bug fixes
svn: r16319
This commit is contained in:
parent
a5ab94721f
commit
6f7ce7726f
@ -89,7 +89,6 @@ src/gui/grampsgui.py
|
||||
src/gui/makefilter.py
|
||||
src/gui/utils.py
|
||||
src/gui/viewmanager.py
|
||||
src/gui/workspace.py
|
||||
|
||||
# gui/editors - the GUI editors package
|
||||
src/gui/editors/addmedia.py
|
||||
|
@ -27,8 +27,7 @@ pkgdata_PYTHON = \
|
||||
pluginmanager.py \
|
||||
sidebar.py \
|
||||
utils.py \
|
||||
viewmanager.py \
|
||||
workspace.py
|
||||
viewmanager.py
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/gui
|
||||
pkgpythondir = @pkgpythondir@/gui
|
||||
|
@ -92,7 +92,6 @@ from gui.configure import GrampsPreferences
|
||||
from gen.db.backup import backup
|
||||
from gen.db.exceptions import DbException
|
||||
from GrampsAboutDialog import GrampsAboutDialog
|
||||
from workspace import Workspace
|
||||
from gui.navigator import Navigator
|
||||
from gui.views.tags import Tags
|
||||
from gen.utils.configmanager import safe_eval
|
||||
@ -1149,21 +1148,13 @@ class ViewManager(CLIManager):
|
||||
"""
|
||||
Create a new page and set it as the current page.
|
||||
"""
|
||||
wspace = Workspace(self.uistate, self.dbstate)
|
||||
try:
|
||||
page = page_def(self.dbstate, self.uistate, wspace)
|
||||
page = page_def(pdata, self.dbstate, self.uistate)
|
||||
except:
|
||||
import traceback
|
||||
LOG.warn("View '%s' failed to load." % pdata.id)
|
||||
traceback.print_exc()
|
||||
return
|
||||
# Category is (string, trans):
|
||||
page.set_category(pdata.category)
|
||||
page.set_ident(page.get_category() + '_' + pdata.id)
|
||||
page_title = page.get_title()
|
||||
page_category = page.get_category()
|
||||
page_translated_category = page.get_translated_category()
|
||||
page_stock = page.get_stock()
|
||||
|
||||
page.define_actions()
|
||||
try:
|
||||
@ -1173,22 +1164,18 @@ class ViewManager(CLIManager):
|
||||
print("ERROR: '%s' failed to create view" % pdata.name)
|
||||
traceback.print_exc()
|
||||
return
|
||||
page_display.show_all()
|
||||
page.post()
|
||||
|
||||
wspace.add_view(page)
|
||||
self.pages.append(page)
|
||||
|
||||
wspace.define_actions()
|
||||
|
||||
# create icon/label for workspace notebook
|
||||
hbox = gtk.HBox()
|
||||
image = gtk.Image()
|
||||
image.set_from_stock(page_stock, gtk.ICON_SIZE_MENU)
|
||||
image.set_from_stock(page.get_stock(), gtk.ICON_SIZE_MENU)
|
||||
hbox.pack_start(image, False)
|
||||
hbox.add(gtk.Label(pdata.name))
|
||||
hbox.show_all()
|
||||
page_num = self.notebook.append_page(wspace.get_display(), hbox)
|
||||
page_num = self.notebook.append_page(page.get_display(), hbox)
|
||||
|
||||
def view_changed(self, notebook, page, page_num):
|
||||
"""
|
||||
|
@ -50,6 +50,7 @@ import pango
|
||||
# GRAMPS
|
||||
#
|
||||
#----------------------------------------------------------------
|
||||
from gui.views.pageview import PageView, FILTER_PAGE
|
||||
from gui.views.navigationview import NavigationView
|
||||
from gui.columnorder import ColumnOrder
|
||||
import config
|
||||
@ -91,10 +92,10 @@ class ListView(NavigationView):
|
||||
FILTER_TYPE = None # Set in inheriting class
|
||||
QR_CATEGORY = -1
|
||||
|
||||
def __init__(self, title, dbstate, uistate, columns, handle_col,
|
||||
def __init__(self, title, pdata, dbstate, uistate, columns, handle_col,
|
||||
make_model, signal_map, get_bookmarks, bm_type, nav_group,
|
||||
multiple=False, filter_class=None, markup=None):
|
||||
NavigationView.__init__(self, title, dbstate, uistate,
|
||||
NavigationView.__init__(self, title, pdata, dbstate, uistate,
|
||||
get_bookmarks, bm_type, nav_group)
|
||||
#default is listviews keep themself in sync with database
|
||||
self._dirty_on_change_inactive = False
|
||||
@ -861,6 +862,16 @@ class ListView(NavigationView):
|
||||
self.edit_action.set_visible(True)
|
||||
self.edit_action.set_sensitive(not self.dbstate.db.readonly)
|
||||
|
||||
def sidebar_changed(self, page_type, active, index):
|
||||
"""
|
||||
Called when the sidebar page is changed.
|
||||
"""
|
||||
PageView.sidebar_changed(self, page_type, active, index)
|
||||
if active and page_type == FILTER_PAGE:
|
||||
self.search_bar.hide()
|
||||
else:
|
||||
self.search_bar.show()
|
||||
|
||||
def on_delete(self):
|
||||
"""
|
||||
Save the column widths when the view is shutdown.
|
||||
@ -877,7 +888,7 @@ class ListView(NavigationView):
|
||||
index += 1
|
||||
newsize.append(size)
|
||||
self._config.set('columns.size', newsize)
|
||||
self._config.save()
|
||||
PageView.on_delete(self)
|
||||
|
||||
####################################################################
|
||||
# Export data
|
||||
|
@ -78,8 +78,8 @@ class NavigationView(PageView):
|
||||
should derive from this class.
|
||||
"""
|
||||
|
||||
def __init__(self, title, state, uistate, bookmarks, bm_type, nav_group):
|
||||
PageView.__init__(self, title, state, uistate)
|
||||
def __init__(self, title, pdata, state, uistate, bookmarks, bm_type, nav_group):
|
||||
PageView.__init__(self, title, pdata, state, uistate)
|
||||
self.bookmarks = bm_type(self.dbstate, self.uistate, bookmarks,
|
||||
self.goto_handle)
|
||||
|
||||
@ -107,6 +107,7 @@ class NavigationView(PageView):
|
||||
"""
|
||||
Define menu actions.
|
||||
"""
|
||||
PageView.define_actions(self)
|
||||
self.bookmark_actions()
|
||||
self.navigation_actions()
|
||||
|
||||
|
@ -49,8 +49,19 @@ from gen.ggettext import gettext as _
|
||||
import Errors
|
||||
from gui.dbguielement import DbGUIElement
|
||||
from gui.widgets.menutoolbuttonaction import MenuToolButtonAction
|
||||
from gui.sidebar import Sidebar
|
||||
from gui.widgets.grampletpane import GrampletPane
|
||||
from gui.configure import ConfigureDialog
|
||||
from config import config
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
GRAMPLET_PAGE = 0
|
||||
FILTER_PAGE = 1
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# PageView
|
||||
@ -88,8 +99,9 @@ class PageView(DbGUIElement):
|
||||
|
||||
CONFIGSETTINGS = []
|
||||
|
||||
def __init__(self, title, dbstate, uistate):
|
||||
def __init__(self, title, pdata, dbstate, uistate):
|
||||
self.title = title
|
||||
self.pdata = pdata
|
||||
self.dbstate = dbstate
|
||||
self.uistate = uistate
|
||||
self.action_list = []
|
||||
@ -99,15 +111,29 @@ class PageView(DbGUIElement):
|
||||
self.action_group = None
|
||||
self.additional_action_groups = []
|
||||
self.additional_uis = []
|
||||
self.widget = None
|
||||
self.ui_def = '<ui></ui>'
|
||||
self.ui_def = '''<ui>
|
||||
<menubar name="MenuBar">
|
||||
<menu action="ViewMenu">
|
||||
<placeholder name="Bars">
|
||||
<menuitem action="Sidebar"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
</menubar>
|
||||
<popup name="GrampletPopup">
|
||||
<menuitem action="AddGramplet"/>
|
||||
<menuitem action="RestoreGramplet"/>
|
||||
</popup>
|
||||
</ui>'''
|
||||
self.dirty = True
|
||||
self.active = False
|
||||
self._dirty_on_change_inactive = True
|
||||
self.func_list = {}
|
||||
self.category = "Miscellaneous"
|
||||
self.ident = None
|
||||
self.translated_category = _("Miscellaneous")
|
||||
|
||||
if isinstance(self.pdata.category, tuple):
|
||||
self.category, self.translated_category = self.pdata.category
|
||||
else:
|
||||
raise AttributeError("View category must be (name, translated-name)")
|
||||
self.ident = self.category + '_' + self.pdata.id
|
||||
|
||||
self.dbstate.connect('no-database', self.disable_action_group)
|
||||
self.dbstate.connect('database-changed', self.enable_action_group)
|
||||
@ -118,10 +144,108 @@ class PageView(DbGUIElement):
|
||||
self.handle_col = 0
|
||||
|
||||
self._config = None
|
||||
self.__configure_content = None
|
||||
self.init_config()
|
||||
|
||||
self.filter_class = None
|
||||
self.top = None
|
||||
self.gramplet_pane = None
|
||||
self.sidebar = None
|
||||
|
||||
DbGUIElement.__init__(self, dbstate.db)
|
||||
|
||||
def build_interface(self):
|
||||
"""
|
||||
Builds the container widget for the interface.
|
||||
Returns a gtk container widget.
|
||||
"""
|
||||
self.sidebar = Sidebar(self.sidebar_changed, self.sidebar_closed)
|
||||
hpane = gtk.HPaned()
|
||||
vpane = gtk.VPaned()
|
||||
hpane.pack1(vpane, resize=True, shrink=True)
|
||||
hpane.pack2(self.sidebar.get_display(), resize=False, shrink=False)
|
||||
hpane.show()
|
||||
vpane.show()
|
||||
|
||||
widget = self.build_widget()
|
||||
widget.show_all()
|
||||
vpane.add1(widget)
|
||||
initial_page = self._config.get('sidebar.page')
|
||||
|
||||
self.gramplet_pane = self.__create_gramplet_pane()
|
||||
|
||||
if self.filter_class:
|
||||
self.add_filter(self.filter_class)
|
||||
|
||||
self.sidebar.set_current_page(initial_page)
|
||||
if self._config.get('sidebar.visible'):
|
||||
self.sidebar.show()
|
||||
else:
|
||||
self.sidebar.hide()
|
||||
|
||||
return hpane
|
||||
|
||||
def add_filter(self, filter_class):
|
||||
"""
|
||||
Add a filter to the workspace sidebar.
|
||||
"""
|
||||
self.filter_sidebar = filter_class(self.dbstate, self.uistate,
|
||||
self.__filter_clicked)
|
||||
top = self.filter_sidebar.get_widget()
|
||||
top.show_all()
|
||||
self.sidebar.add(_('Filter'), top, FILTER_PAGE)
|
||||
|
||||
def remove_filter(self):
|
||||
"""
|
||||
Remove the filter from the workspace sidebar.
|
||||
"""
|
||||
self.filter_sidebar = None
|
||||
self.sidebar.remove(FILTER_PAGE)
|
||||
|
||||
def __create_gramplet_pane(self):
|
||||
"""
|
||||
Create a gramplet pane.
|
||||
"""
|
||||
gramplet_pane = GrampletPane(self.ident + "_sidebar",
|
||||
self, self.dbstate, self.uistate,
|
||||
column_count=1)
|
||||
gramplet_pane.show_all()
|
||||
self.sidebar.add(_('Gramplets'), gramplet_pane, GRAMPLET_PAGE)
|
||||
return gramplet_pane
|
||||
|
||||
def __filter_clicked(self):
|
||||
"""
|
||||
Called when the filter 'Find' button is clicked.
|
||||
"""
|
||||
self.generic_filter = self.filter_sidebar.get_filter()
|
||||
self.build_tree()
|
||||
|
||||
def __sidebar_toggled(self, action):
|
||||
"""
|
||||
Called when the sidebar is toggled.
|
||||
"""
|
||||
active = action.get_active()
|
||||
if active:
|
||||
self.sidebar.show()
|
||||
self.sidebar_changed(self.sidebar.get_page_type(), True, None)
|
||||
else:
|
||||
self.sidebar.hide()
|
||||
self.sidebar_changed(None, False, None)
|
||||
self._config.set('sidebar.visible', active)
|
||||
|
||||
def sidebar_changed(self, page_type, active, index):
|
||||
"""
|
||||
Called when the sidebar page is changed.
|
||||
"""
|
||||
if index is not None:
|
||||
self._config.set('sidebar.page', index)
|
||||
|
||||
def sidebar_closed(self):
|
||||
"""
|
||||
Called when the sidebar close button is clicked.
|
||||
"""
|
||||
uimanager = self.uistate.uimanager
|
||||
uimanager.get_action('/MenuBar/ViewMenu/Bars/Sidebar').activate()
|
||||
|
||||
def key_press_handler(self, widget, event):
|
||||
"""
|
||||
A general keypress handler. Override if you want to handle
|
||||
@ -212,6 +336,7 @@ class PageView(DbGUIElement):
|
||||
Called with the PageView is set as active. If the page is "dirty",
|
||||
then we rebuild the data.
|
||||
"""
|
||||
self.gramplet_pane.set_active()
|
||||
self.active = True
|
||||
if self.dirty:
|
||||
self.uistate.set_busy_cursor(True)
|
||||
@ -222,6 +347,7 @@ class PageView(DbGUIElement):
|
||||
"""
|
||||
Marks page as being inactive (not currently displayed)
|
||||
"""
|
||||
self.gramplet_pane.set_inactive()
|
||||
self.active = False
|
||||
|
||||
def build_tree(self):
|
||||
@ -279,20 +405,6 @@ class PageView(DbGUIElement):
|
||||
"""
|
||||
return self.title
|
||||
|
||||
|
||||
def set_category(self, category):
|
||||
"""
|
||||
Set the category of the view. This is used to define the text for the
|
||||
button, and for the tab label.
|
||||
|
||||
category - a tuple of the form (category, translated-category)
|
||||
"""
|
||||
if isinstance(category, tuple):
|
||||
self.category = category[0]
|
||||
self.translated_category = category[1]
|
||||
else:
|
||||
raise AttributeError("View category must be (name, translated-name)")
|
||||
|
||||
def get_category(self):
|
||||
"""
|
||||
Return the category name of the view. This is used to define
|
||||
@ -307,25 +419,18 @@ class PageView(DbGUIElement):
|
||||
"""
|
||||
return self.translated_category
|
||||
|
||||
def set_ident(self, ident):
|
||||
"""
|
||||
Set the id of the view. This is an unique ident
|
||||
"""
|
||||
self.ident = ident
|
||||
self.init_config()
|
||||
|
||||
def get_display(self):
|
||||
"""
|
||||
Builds the graphical display, returning the top level widget.
|
||||
"""
|
||||
if not self.widget:
|
||||
self.widget = self.build_widget()
|
||||
return self.widget
|
||||
if not self.top:
|
||||
self.top = self.build_interface()
|
||||
return self.top
|
||||
|
||||
def build_widget(self):
|
||||
"""
|
||||
Builds the container widget for the interface. Must be overridden by the
|
||||
the base class. Returns a gtk container widget.
|
||||
Builds the container widget for the main view pane. Must be overridden
|
||||
by the the base class. Returns a gtk container widget.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
@ -334,10 +439,12 @@ class PageView(DbGUIElement):
|
||||
Defines the UIManager actions. Called by the ViewManager to set up the
|
||||
View. The user typically defines self.action_list and
|
||||
self.action_toggle_list in this function.
|
||||
|
||||
Derived classes must override this function.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
self._add_toggle_action('Sidebar', None, _('_Sidebar'),
|
||||
None, None, self.__sidebar_toggled,
|
||||
self._config.get('sidebar.visible'))
|
||||
self._add_action("AddGramplet", gtk.STOCK_ADD, _("Add a gramplet"))
|
||||
self._add_action("RestoreGramplet", None, _("Restore a gramplet"))
|
||||
|
||||
def __build_action_group(self):
|
||||
"""
|
||||
@ -454,7 +561,8 @@ class PageView(DbGUIElement):
|
||||
Method called on shutdown. Data views should put code here
|
||||
that should be called when quiting the main application.
|
||||
"""
|
||||
pass
|
||||
self.gramplet_pane.on_delete()
|
||||
self._config.save()
|
||||
|
||||
def init_config(self):
|
||||
"""
|
||||
@ -512,3 +620,56 @@ class PageView(DbGUIElement):
|
||||
:return: list of functions
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def __get_configure_funcs(self):
|
||||
"""
|
||||
Return a combined list of configuration functions for all of the panes
|
||||
in the view.
|
||||
|
||||
:return: list of functions
|
||||
"""
|
||||
retval = []
|
||||
if self.can_configure():
|
||||
other = self._get_configure_page_funcs()
|
||||
if callable(other):
|
||||
retval += other()
|
||||
else:
|
||||
retval += other
|
||||
|
||||
if self.gramplet_pane is not None:
|
||||
func = self.gramplet_pane._get_configure_page_funcs()
|
||||
retval += func()
|
||||
|
||||
return retval
|
||||
|
||||
def configure(self):
|
||||
"""
|
||||
Open the configure dialog for the workspace.
|
||||
"""
|
||||
title = _("Configure %(cat)s - %(view)s") % \
|
||||
{'cat': self.get_translated_category(),
|
||||
'view': self.get_title()}
|
||||
try:
|
||||
ViewConfigureDialog(self.uistate, self.dbstate,
|
||||
self.__get_configure_funcs(),
|
||||
self, self._config, dialogtitle=title,
|
||||
ident=_("%(cat)s - %(view)s") %
|
||||
{'cat': self.get_translated_category(),
|
||||
'view': self.get_title()})
|
||||
except Errors.WindowActiveError:
|
||||
return
|
||||
|
||||
class ViewConfigureDialog(ConfigureDialog):
|
||||
"""
|
||||
All workspaces can have their own configuration dialog
|
||||
"""
|
||||
def __init__(self, uistate, dbstate, configure_page_funcs, configobj,
|
||||
configmanager,
|
||||
dialogtitle=_("Preferences"), on_close=None, ident=''):
|
||||
self.ident = ident
|
||||
ConfigureDialog.__init__(self, uistate, dbstate, configure_page_funcs,
|
||||
configobj, configmanager,
|
||||
dialogtitle=dialogtitle, on_close=on_close)
|
||||
|
||||
def build_menu_names(self, obj):
|
||||
return (_('Configure %s View') % self.ident, None)
|
||||
|
@ -227,8 +227,9 @@ class GrampletWindow(ManagedWindow.ManagedWindow):
|
||||
self.gramplet.gvproperties.hide()
|
||||
if self.gramplet.titlelabel_entry:
|
||||
self.gramplet.titlelabel_entry.hide()
|
||||
for widget in self.gramplet.pui.hidden_widgets():
|
||||
widget.hide()
|
||||
if self.gramplet.pui:
|
||||
for widget in self.gramplet.pui.hidden_widgets():
|
||||
widget.hide()
|
||||
|
||||
def handle_response(self, object, response):
|
||||
"""
|
||||
@ -1288,8 +1289,8 @@ class GrampletPane(gtk.ScrolledWindow):
|
||||
def _button_press(self, obj, event):
|
||||
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||
self._popup_xy = (event.x, event.y)
|
||||
menu = self.uistate.uimanager.get_widget('/Popup')
|
||||
ag_menu = self.uistate.uimanager.get_widget('/Popup/AddGramplet')
|
||||
uiman = self.uistate.uimanager
|
||||
ag_menu = uiman.get_widget('/GrampletPopup/AddGramplet')
|
||||
if ag_menu:
|
||||
qr_menu = ag_menu.get_submenu()
|
||||
qr_menu = gtk.Menu()
|
||||
@ -1297,10 +1298,9 @@ class GrampletPane(gtk.ScrolledWindow):
|
||||
in AVAILABLE_GRAMPLETS()]
|
||||
names.sort()
|
||||
for name in names:
|
||||
add_menuitem(qr_menu, name,
|
||||
None, self.add_gramplet)
|
||||
self.uistate.uimanager.get_widget('/Popup/AddGramplet').set_submenu(qr_menu)
|
||||
rg_menu = self.uistate.uimanager.get_widget('/Popup/RestoreGramplet')
|
||||
add_menuitem(qr_menu, name, None, self.add_gramplet)
|
||||
ag_menu.set_submenu(qr_menu)
|
||||
rg_menu = uiman.get_widget('/GrampletPopup/RestoreGramplet')
|
||||
if rg_menu:
|
||||
qr_menu = rg_menu.get_submenu()
|
||||
if qr_menu is not None:
|
||||
@ -1311,9 +1311,9 @@ class GrampletPane(gtk.ScrolledWindow):
|
||||
if len(names) > 0:
|
||||
qr_menu = gtk.Menu()
|
||||
for name in names:
|
||||
add_menuitem(qr_menu, name,
|
||||
None, self.restore_gramplet)
|
||||
self.uistate.uimanager.get_widget('/Popup/RestoreGramplet').set_submenu(qr_menu)
|
||||
add_menuitem(qr_menu, name, None, self.restore_gramplet)
|
||||
rg_menu.set_submenu(qr_menu)
|
||||
menu = uiman.get_widget('/GrampletPopup')
|
||||
if menu:
|
||||
menu.popup(None, None, None, 1, event.time)
|
||||
return True
|
||||
|
@ -1,340 +0,0 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2010 Nick Hall
|
||||
# Copyright (C) 2010 Douglas S. Blank <doug.blank@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Workspace
|
||||
"""
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GNOME modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Errors
|
||||
from gui.sidebar import Sidebar
|
||||
from gui.widgets.grampletpane import GrampletPane
|
||||
from gui.views.listview import ListView
|
||||
from gui.configure import ConfigureDialog
|
||||
import config
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
GRAMPLET_PAGE = 0
|
||||
FILTER_PAGE = 1
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Workspace class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Workspace(object):
|
||||
"""
|
||||
A Workspace contains panes to contain a view and associated objects such as
|
||||
a filter and gramplet pane.
|
||||
"""
|
||||
def __init__(self, uistate, dbstate):
|
||||
self.uistate = uistate
|
||||
self.dbstate = dbstate
|
||||
self.active = False
|
||||
self.view = None
|
||||
self._config = None
|
||||
self.sidebar = Sidebar(self.sidebar_changed, self.sidebar_closed)
|
||||
self.hpane = gtk.HPaned()
|
||||
self.vpane = gtk.VPaned()
|
||||
self.hpane.pack1(self.vpane, resize=True, shrink=True)
|
||||
self.hpane.pack2(self.sidebar.get_display(), resize=False, shrink=False)
|
||||
self.hpane.show()
|
||||
self.vpane.show()
|
||||
|
||||
def get_display(self):
|
||||
"""
|
||||
Return the top container widget for the GUI.
|
||||
"""
|
||||
return self.hpane
|
||||
|
||||
def add_view(self, view):
|
||||
"""
|
||||
Add a view to the workspace.
|
||||
"""
|
||||
self.view = view
|
||||
self.vpane.add1(view.get_display())
|
||||
initial_page = self.view._config.get('sidebar.page')
|
||||
|
||||
self.gramplet_pane = self.__create_gramplet_pane()
|
||||
|
||||
if isinstance(view, ListView):
|
||||
self.add_filter(view.filter_class)
|
||||
|
||||
if self.view._config.get('sidebar.visible'):
|
||||
self.sidebar.show()
|
||||
else:
|
||||
self.sidebar.hide()
|
||||
|
||||
self.sidebar.set_current_page(initial_page)
|
||||
|
||||
def add_aux(self, aux):
|
||||
"""
|
||||
Add an auxilliary object to the workspace.
|
||||
"""
|
||||
self.aux = aux
|
||||
self.vpane.add2(aux.get_display())
|
||||
|
||||
def add_filter(self, filter_class):
|
||||
"""
|
||||
Add a filter to the workspace sidebar.
|
||||
"""
|
||||
self.filter_sidebar = filter_class(self.dbstate, self.uistate,
|
||||
self.__filter_clicked)
|
||||
top = self.filter_sidebar.get_widget()
|
||||
top.show_all()
|
||||
self.sidebar.add(_('Filter'), top, FILTER_PAGE)
|
||||
|
||||
def remove_filter(self,):
|
||||
"""
|
||||
Remove the filter from the workspace sidebar.
|
||||
"""
|
||||
self.filter_sidebar = None
|
||||
self.sidebar.remove(FILTER_PAGE)
|
||||
|
||||
def __create_gramplet_pane(self):
|
||||
"""
|
||||
Create a gramplet pane.
|
||||
"""
|
||||
self.uidef = '''<ui>
|
||||
<menubar name="MenuBar">
|
||||
<menu action="ViewMenu">
|
||||
<placeholder name="Bars">
|
||||
<menuitem action="Sidebar"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
</menubar>
|
||||
<popup name="Popup">
|
||||
<menuitem action="AddGramplet"/>
|
||||
<menuitem action="RestoreGramplet"/>
|
||||
</popup>
|
||||
</ui>'''
|
||||
|
||||
eb = gtk.EventBox()
|
||||
eb.connect('button-press-event', self._gramplet_button_press)
|
||||
|
||||
gramplet_pane = GrampletPane(self.view.ident + "_sidebar",
|
||||
self, self.dbstate, self.uistate,
|
||||
column_count=1)
|
||||
gramplet_pane.show_all()
|
||||
eb.add(gramplet_pane)
|
||||
eb.show()
|
||||
self.sidebar.add(_('Gramplets'), eb, GRAMPLET_PAGE)
|
||||
return gramplet_pane
|
||||
|
||||
def _gramplet_button_press(self, obj, event):
|
||||
"""
|
||||
Called to display the context menu in the gramplet pane.
|
||||
"""
|
||||
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||
menu = self.uistate.uimanager.get_widget('/Popup')
|
||||
if menu:
|
||||
menu.popup(None, None, None, event.button, event.time)
|
||||
return True
|
||||
|
||||
def __filter_clicked(self):
|
||||
"""
|
||||
Called when the filter 'Find' button is clicked.
|
||||
"""
|
||||
self.view.generic_filter = self.filter_sidebar.get_filter()
|
||||
self.view.build_tree()
|
||||
|
||||
def __sidebar_toggled(self, action):
|
||||
"""
|
||||
Called when the sidebar is toggled.
|
||||
"""
|
||||
active = action.get_active()
|
||||
if active:
|
||||
self.sidebar.show()
|
||||
self.sidebar_changed(self.sidebar.get_page_type(), True, None)
|
||||
else:
|
||||
self.sidebar.hide()
|
||||
self.sidebar_changed(None, False, None)
|
||||
self.view._config.set('sidebar.visible', active)
|
||||
|
||||
def sidebar_changed(self, page_type, active, index):
|
||||
"""
|
||||
Called when the sidebar page is changed.
|
||||
"""
|
||||
if index is not None:
|
||||
self.view._config.set('sidebar.page', index)
|
||||
if isinstance(self.view, ListView):
|
||||
if active and page_type == FILTER_PAGE:
|
||||
self.view.search_bar.hide()
|
||||
else:
|
||||
self.view.search_bar.show()
|
||||
|
||||
def sidebar_closed(self):
|
||||
"""
|
||||
Called when the sidebar close button is clicked.
|
||||
"""
|
||||
uimanager = self.uistate.uimanager
|
||||
uimanager.get_action('/MenuBar/ViewMenu/Bars/Sidebar').activate()
|
||||
|
||||
def get_title(self):
|
||||
"""
|
||||
Return the title of the view.
|
||||
"""
|
||||
if self.view:
|
||||
return self.view.title
|
||||
return ''
|
||||
|
||||
def define_actions(self):
|
||||
"""
|
||||
Defines the UIManager actions.
|
||||
"""
|
||||
self.action_group = gtk.ActionGroup('Workspace')
|
||||
self.action_group.add_toggle_actions([
|
||||
('Sidebar', None, _('_Sidebar'),
|
||||
None, None, self.__sidebar_toggled,
|
||||
self.view._config.get('sidebar.visible'))
|
||||
])
|
||||
self.action_group.add_actions([
|
||||
("AddGramplet", None, _("Add a gramplet")),
|
||||
("RestoreGramplet", None, _("Restore a gramplet")
|
||||
)])
|
||||
|
||||
def set_active(self):
|
||||
"""
|
||||
Called when the view is set as active.
|
||||
"""
|
||||
self.active = True
|
||||
self.gramplet_pane.set_active()
|
||||
self.view.set_active()
|
||||
|
||||
def set_inactive(self):
|
||||
"""
|
||||
Called when the view is set as inactive.
|
||||
"""
|
||||
self.active = False
|
||||
self.gramplet_pane.set_inactive()
|
||||
self.view.set_inactive()
|
||||
|
||||
def get_actions(self):
|
||||
"""
|
||||
Return the actions that should be used for the view.
|
||||
"""
|
||||
action_list = self.view.get_actions()
|
||||
action_list.append(self.action_group)
|
||||
return action_list
|
||||
|
||||
def ui_definition(self):
|
||||
"""
|
||||
Returns the XML UI definition for the UIManager.
|
||||
"""
|
||||
return self.view.ui_definition()
|
||||
|
||||
def additional_ui_definitions(self):
|
||||
"""
|
||||
Return any additional interfaces for the UIManager that the view
|
||||
needs to define.
|
||||
"""
|
||||
defs = self.view.additional_ui_definitions()
|
||||
defs.append(self.uidef)
|
||||
return defs
|
||||
|
||||
def change_page(self):
|
||||
"""
|
||||
Called when the view changes.
|
||||
"""
|
||||
self.view.change_page()
|
||||
|
||||
def on_delete(self):
|
||||
"""
|
||||
Method called on shutdown.
|
||||
"""
|
||||
self.view.on_delete()
|
||||
self.gramplet_pane.on_delete()
|
||||
|
||||
def can_configure(self):
|
||||
"""
|
||||
Returns True if the workspace has a configure window.
|
||||
"""
|
||||
return self.view.can_configure() or self.gramplet_pane.can_configure()
|
||||
|
||||
def _get_configure_page_funcs(self):
|
||||
"""
|
||||
Return a list of functions that create gtk elements to use in the
|
||||
notebook pages of the Configuration dialog.
|
||||
"""
|
||||
retval = []
|
||||
if self.view.can_configure():
|
||||
other = self.view._get_configure_page_funcs()
|
||||
if callable(other):
|
||||
retval += other()
|
||||
else:
|
||||
retval += other
|
||||
func = self.gramplet_pane._get_configure_page_funcs()
|
||||
return retval + func()
|
||||
|
||||
def configure(self):
|
||||
"""
|
||||
Open the configure dialog for the workspace.
|
||||
"""
|
||||
__configure_content = self._get_configure_page_funcs()
|
||||
title = _("Configure %(cat)s - %(view)s") % \
|
||||
{'cat': self.view.get_translated_category(),
|
||||
'view': self.view.get_title()}
|
||||
try:
|
||||
ViewConfigureDialog(self.uistate, self.dbstate,
|
||||
__configure_content,
|
||||
self, self.view._config, dialogtitle=title,
|
||||
ident=_("%(cat)s - %(view)s") %
|
||||
{'cat': self.view.get_translated_category(),
|
||||
'view': self.view.get_title()})
|
||||
except Errors.WindowActiveError:
|
||||
return
|
||||
|
||||
class ViewConfigureDialog(ConfigureDialog):
|
||||
"""
|
||||
All workspaces can have their own configuration dialog
|
||||
"""
|
||||
def __init__(self, uistate, dbstate, configure_page_funcs, configobj,
|
||||
configmanager,
|
||||
dialogtitle=_("Preferences"), on_close=None, ident=''):
|
||||
self.ident = ident
|
||||
ConfigureDialog.__init__(self, uistate, dbstate, configure_page_funcs,
|
||||
configobj, configmanager,
|
||||
dialogtitle=dialogtitle, on_close=on_close)
|
||||
|
||||
def build_menu_names(self, obj):
|
||||
return (_('Configure %s View') % self.ident, None)
|
@ -114,7 +114,7 @@ class BasePersonView(ListView):
|
||||
FILTER_TYPE = "Person"
|
||||
QR_CATEGORY = CATEGORY_QR_PERSON
|
||||
|
||||
def __init__(self, dbstate, uistate, title, model, nav_group=0):
|
||||
def __init__(self, pdata, dbstate, uistate, title, model, nav_group=0):
|
||||
"""
|
||||
Create the Person View
|
||||
"""
|
||||
@ -128,7 +128,7 @@ class BasePersonView(ListView):
|
||||
}
|
||||
|
||||
ListView.__init__(
|
||||
self, title, dbstate, uistate,
|
||||
self, title, pdata, dbstate, uistate,
|
||||
BasePersonView.COLUMN_NAMES, len(BasePersonView.COLUMN_NAMES),
|
||||
model, signal_map, dbstate.db.get_bookmarks(),
|
||||
Bookmarks.PersonBookmarks, nav_group,
|
||||
@ -143,6 +143,8 @@ class BasePersonView(ListView):
|
||||
|
||||
uistate.connect('nameformat-changed', self.build_tree)
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
|
||||
def navigation_type(self):
|
||||
"""
|
||||
Return the navigation type of the view.
|
||||
@ -174,7 +176,7 @@ class BasePersonView(ListView):
|
||||
"""
|
||||
return 'gramps-person'
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
"""
|
||||
Defines the UI string for UIManager
|
||||
"""
|
||||
|
@ -120,7 +120,7 @@ class PlaceBaseView(ListView):
|
||||
FILTER_TYPE = "Place"
|
||||
QR_CATEGORY = CATEGORY_QR_PLACE
|
||||
|
||||
def __init__(self, dbstate, uistate, title, model, nav_group,
|
||||
def __init__(self, pdata, dbstate, uistate, title, model, nav_group,
|
||||
markup=None):
|
||||
|
||||
signal_map = {
|
||||
@ -134,7 +134,7 @@ class PlaceBaseView(ListView):
|
||||
self.mapservicedata = {}
|
||||
|
||||
ListView.__init__(
|
||||
self, title, dbstate, uistate,
|
||||
self, title, pdata, dbstate, uistate,
|
||||
self.COLUMN_NAMES, 14,
|
||||
model, signal_map,
|
||||
dbstate.db.get_place_bookmarks(),
|
||||
@ -147,6 +147,8 @@ class PlaceBaseView(ListView):
|
||||
'<CONTROL>BackSpace' : self.key_delete,
|
||||
})
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
|
||||
def navigation_type(self):
|
||||
return 'Place'
|
||||
|
||||
@ -289,7 +291,7 @@ class PlaceBaseView(ListView):
|
||||
def get_stock(self):
|
||||
return 'gramps-place'
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
return '''<ui>
|
||||
<menubar name="MenuBar">
|
||||
<menu action="FileMenu">
|
||||
|
@ -100,7 +100,7 @@ class EventView(ListView):
|
||||
FILTER_TYPE = "Event"
|
||||
QR_CATEGORY = CATEGORY_QR_EVENT
|
||||
|
||||
def __init__(self, dbstate, uistate, wspace, nav_group=0):
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
"""
|
||||
Create the Event View
|
||||
"""
|
||||
@ -112,7 +112,7 @@ class EventView(ListView):
|
||||
}
|
||||
|
||||
ListView.__init__(
|
||||
self, _('Events'), dbstate, uistate,
|
||||
self, _('Events'), pdata, dbstate, uistate,
|
||||
EventView.COLUMN_NAMES, len(EventView.COLUMN_NAMES),
|
||||
EventModel,
|
||||
signal_map, dbstate.db.get_event_bookmarks(),
|
||||
@ -128,6 +128,8 @@ class EventView(ListView):
|
||||
|
||||
uistate.connect('nameformat-changed', self.build_tree)
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
|
||||
def navigation_type(self):
|
||||
return 'Event'
|
||||
|
||||
@ -149,7 +151,7 @@ class EventView(ListView):
|
||||
"""
|
||||
return 'gramps-event'
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
"""
|
||||
Defines the UI string for UIManager
|
||||
"""
|
||||
|
@ -98,7 +98,7 @@ class FamilyView(ListView):
|
||||
FILTER_TYPE = "Family"
|
||||
QR_CATEGORY = CATEGORY_QR_FAMILY
|
||||
|
||||
def __init__(self, dbstate, uistate, wspace, nav_group=0):
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
|
||||
signal_map = {
|
||||
'family-add' : self.row_add,
|
||||
@ -109,7 +109,7 @@ class FamilyView(ListView):
|
||||
}
|
||||
|
||||
ListView.__init__(
|
||||
self, _('Families'), dbstate, uistate,
|
||||
self, _('Families'), pdata, dbstate, uistate,
|
||||
FamilyView.COLUMN_NAMES, len(FamilyView.COLUMN_NAMES),
|
||||
FamilyModel,
|
||||
signal_map, dbstate.db.get_family_bookmarks(),
|
||||
@ -125,13 +125,15 @@ class FamilyView(ListView):
|
||||
|
||||
uistate.connect('nameformat-changed', self.build_tree)
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
|
||||
def navigation_type(self):
|
||||
return 'Family'
|
||||
|
||||
def get_stock(self):
|
||||
return 'gramps-family'
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
return '''<ui>
|
||||
<menubar name="MenuBar">
|
||||
<menu action="FileMenu">
|
||||
|
@ -566,9 +566,9 @@ class FanChartView(NavigationView):
|
||||
"""
|
||||
The Gramplet code that realizes the FanChartWidget.
|
||||
"""
|
||||
def __init__(self, dbstate, uistate, wspace, nav_group=0):
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
NavigationView.__init__(self, _('Fan Chart'),
|
||||
dbstate, uistate,
|
||||
pdata, dbstate, uistate,
|
||||
dbstate.db.get_bookmarks(),
|
||||
Bookmarks.PersonBookmarks,
|
||||
nav_group)
|
||||
@ -579,6 +579,8 @@ class FanChartView(NavigationView):
|
||||
self.generations = 9
|
||||
self.format_helper = FormattingHelper(self.dbstate)
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
|
||||
def navigation_type(self):
|
||||
return 'Person'
|
||||
|
||||
@ -598,7 +600,7 @@ class FanChartView(NavigationView):
|
||||
"""
|
||||
return 'gramps-fanchart'
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
return '''<ui>
|
||||
<menubar name="MenuBar">
|
||||
<menu action="GoMenu">
|
||||
|
@ -78,7 +78,6 @@ from gui.views.pageview import PageView
|
||||
from gui.editors import EditPlace
|
||||
from gui.selectors.selectplace import SelectPlace
|
||||
from Filters.SideBar import PlaceSidebarFilter, EventSidebarFilter
|
||||
from gui.views.navigationview import NavigationView
|
||||
import Bookmarks
|
||||
from Utils import navigation_label
|
||||
|
||||
@ -143,42 +142,6 @@ MRU_BTM = [
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
_UI_DEF = '''\
|
||||
<ui>
|
||||
<menubar name="MenuBar">
|
||||
<menu action="GoMenu">
|
||||
<placeholder name="CommonGo">
|
||||
<menuitem action="PersonMapsMenu"/>
|
||||
<menuitem action="FamilyMapsMenu"/>
|
||||
<menuitem action="EventMapsMenu"/>
|
||||
<menuitem action="AllPlacesMapsMenu"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
<menu action="EditMenu">
|
||||
<separator/>
|
||||
<menuitem action="AddPlaceMenu"/>
|
||||
<menuitem action="LinkPlaceMenu"/>
|
||||
</menu>
|
||||
</menubar>
|
||||
<toolbar name="ToolBar">
|
||||
<placeholder name="CommonEdit">
|
||||
<toolitem action="AddPlace"/>
|
||||
<toolitem action="LinkPlace"/>
|
||||
<separator/>
|
||||
<toolitem action="PersonMaps"/>
|
||||
<toolitem action="FamilyMaps"/>
|
||||
<toolitem action="EventMaps"/>
|
||||
<toolitem action="AllPlacesMaps"/>
|
||||
</placeholder>
|
||||
<placeholder name="CommonNavigation">
|
||||
<toolitem action="Back"/>
|
||||
<toolitem action="Forward"/>
|
||||
<toolitem action="HomePerson"/>
|
||||
</placeholder>
|
||||
</toolbar>
|
||||
</ui>
|
||||
'''
|
||||
|
||||
_HTMLHEADER = '''\
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
@ -343,9 +306,8 @@ class GeoView(HtmlView):
|
||||
('preferences.webkit', True),
|
||||
)
|
||||
|
||||
def __init__(self, dbstate, uistate, wspace):
|
||||
HtmlView.__init__(self, dbstate, uistate, wspace, title=_("GeoView"))
|
||||
self.wspace = wspace
|
||||
def __init__(self, pdata, dbstate, uistate):
|
||||
HtmlView.__init__(self, pdata, dbstate, uistate, title=_("GeoView"))
|
||||
self.dbstate = dbstate
|
||||
self.uistate = uistate
|
||||
self.dbstate.connect('database-changed', self._new_database)
|
||||
@ -366,6 +328,8 @@ class GeoView(HtmlView):
|
||||
self.bookmarks = Bookmarks.PersonBookmarks(self.dbstate, self.uistate,
|
||||
dbstate.db.get_bookmarks(), self.goto_handle)
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
|
||||
def build_widget(self):
|
||||
self.no_network = False
|
||||
self.placeslist = []
|
||||
@ -909,7 +873,7 @@ class GeoView(HtmlView):
|
||||
config.set('geoview.latitude', "0.0")
|
||||
config.set('geoview.longitude', "0.0")
|
||||
config.set('geoview.map', "person")
|
||||
self._config.save()
|
||||
PageView.on_delete(self)
|
||||
|
||||
def init_parent_signals_for_map(self, widget, event):
|
||||
"""
|
||||
@ -1124,19 +1088,51 @@ class GeoView(HtmlView):
|
||||
self.renderer.execute_script(
|
||||
"javascript:selectmarkers('%s')" % year )
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
"""
|
||||
Specifies the UIManager XML code that defines the menus and buttons
|
||||
associated with the interface.
|
||||
"""
|
||||
return _UI_DEF
|
||||
return '''<ui>
|
||||
<menubar name="MenuBar">
|
||||
<menu action="GoMenu">
|
||||
<placeholder name="CommonGo">
|
||||
<menuitem action="PersonMapsMenu"/>
|
||||
<menuitem action="FamilyMapsMenu"/>
|
||||
<menuitem action="EventMapsMenu"/>
|
||||
<menuitem action="AllPlacesMapsMenu"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
<menu action="EditMenu">
|
||||
<separator/>
|
||||
<menuitem action="AddPlaceMenu"/>
|
||||
<menuitem action="LinkPlaceMenu"/>
|
||||
</menu>
|
||||
</menubar>
|
||||
<toolbar name="ToolBar">
|
||||
<placeholder name="CommonEdit">
|
||||
<toolitem action="AddPlace"/>
|
||||
<toolitem action="LinkPlace"/>
|
||||
<separator/>
|
||||
<toolitem action="PersonMaps"/>
|
||||
<toolitem action="FamilyMaps"/>
|
||||
<toolitem action="EventMaps"/>
|
||||
<toolitem action="AllPlacesMaps"/>
|
||||
</placeholder>
|
||||
<placeholder name="CommonNavigation">
|
||||
<toolitem action="Back"/>
|
||||
<toolitem action="Forward"/>
|
||||
<toolitem action="HomePerson"/>
|
||||
</placeholder>
|
||||
</toolbar>
|
||||
</ui>'''
|
||||
|
||||
def define_actions(self):
|
||||
"""
|
||||
Required define_actions function for PageView. Builds the action
|
||||
group information required.
|
||||
"""
|
||||
#NavigationView.define_actions(self)
|
||||
PageView.define_actions(self)
|
||||
#self.bookmark_actions()
|
||||
self.book_action = gtk.ActionGroup(self.title + '/Bookmark')
|
||||
self.book_action.add_actions([
|
||||
@ -1488,8 +1484,8 @@ class GeoView(HtmlView):
|
||||
Specifies the place for the home person to display with mapstraction.
|
||||
"""
|
||||
self.displaytype = "places"
|
||||
self.wspace.remove_filter()
|
||||
self.wspace.add_filter(PlaceSidebarFilter)
|
||||
self.remove_filter()
|
||||
self.add_filter(PlaceSidebarFilter)
|
||||
self._geo_places()
|
||||
|
||||
def _person_places(self, handle=None): # pylint: disable-msg=W0613
|
||||
@ -1497,7 +1493,7 @@ class GeoView(HtmlView):
|
||||
Specifies the person places.
|
||||
"""
|
||||
self.displaytype = "person"
|
||||
self.wspace.remove_filter()
|
||||
self.remove_filter()
|
||||
if not self.uistate.get_active('Person'):
|
||||
return
|
||||
self._geo_places()
|
||||
@ -1507,7 +1503,7 @@ class GeoView(HtmlView):
|
||||
Specifies the family places to display with mapstraction.
|
||||
"""
|
||||
self.displaytype = "family"
|
||||
self.wspace.remove_filter()
|
||||
self.remove_filter()
|
||||
if not self.uistate.get_active('Person'):
|
||||
return
|
||||
self._geo_places()
|
||||
@ -1517,8 +1513,8 @@ class GeoView(HtmlView):
|
||||
Specifies all event places to display with mapstraction.
|
||||
"""
|
||||
self.displaytype = "event"
|
||||
self.wspace.remove_filter()
|
||||
self.wspace.add_filter(EventSidebarFilter)
|
||||
self.remove_filter()
|
||||
self.add_filter(EventSidebarFilter)
|
||||
self._geo_places()
|
||||
|
||||
def _new_database(self, database):
|
||||
|
@ -45,11 +45,26 @@ class GrampletView(PageView):
|
||||
GrampletView interface
|
||||
"""
|
||||
|
||||
def __init__(self, dbstate, uistate, wspace):
|
||||
def __init__(self, pdata, dbstate, uistate):
|
||||
"""
|
||||
Create a GrampletView, with the current dbstate and uistate
|
||||
"""
|
||||
PageView.__init__(self, _('Gramplets'), dbstate, uistate)
|
||||
PageView.__init__(self, _('Gramplets'), pdata, dbstate, uistate)
|
||||
self.ui_def = '''<ui>
|
||||
<popup name="GrampletPopup">
|
||||
<menuitem action="AddGramplet"/>
|
||||
<menuitem action="RestoreGramplet"/>
|
||||
</popup>
|
||||
</ui>'''
|
||||
|
||||
def build_interface(self):
|
||||
"""
|
||||
Builds the container widget for the interface.
|
||||
Returns a gtk container widget.
|
||||
"""
|
||||
top = self.build_widget()
|
||||
top.show_all()
|
||||
return top
|
||||
|
||||
def build_widget(self):
|
||||
"""
|
||||
@ -57,20 +72,9 @@ class GrampletView(PageView):
|
||||
the base class. Returns a gtk container widget.
|
||||
"""
|
||||
# load the user's gramplets and set columns, etc
|
||||
return GrampletPane("Gramplets_grampletview_gramplets", self,
|
||||
self.widget = GrampletPane("Gramplets_grampletview_gramplets", self,
|
||||
self.dbstate, self.uistate)
|
||||
|
||||
def define_actions(self):
|
||||
"""
|
||||
Defines the UIManager actions. Called by the ViewManager to set up the
|
||||
View. The user typically defines self.action_list and
|
||||
self.action_toggle_list in this function.
|
||||
"""
|
||||
self.action = gtk.ActionGroup(self.title + "/Gramplets")
|
||||
self.action.add_actions([('AddGramplet',gtk.STOCK_ADD,_("_Add a gramplet")),
|
||||
('RestoreGramplet',None,_("_Undelete gramplet")),
|
||||
])
|
||||
self._add_action_group(self.action)
|
||||
return self.widget
|
||||
|
||||
def get_stock(self):
|
||||
"""
|
||||
@ -92,16 +96,6 @@ class GrampletView(PageView):
|
||||
self.active = True
|
||||
self.widget.set_active()
|
||||
|
||||
def ui_definition(self):
|
||||
return """
|
||||
<ui>
|
||||
<popup name="Popup">
|
||||
<menuitem action="AddGramplet"/>
|
||||
<menuitem action="RestoreGramplet"/>
|
||||
</popup>
|
||||
</ui>
|
||||
"""
|
||||
|
||||
def on_delete(self):
|
||||
self.widget.on_delete()
|
||||
self._config.save()
|
||||
|
@ -441,8 +441,8 @@ class HtmlView(PageView):
|
||||
with an embedded webbrowser showing a given URL
|
||||
"""
|
||||
|
||||
def __init__(self, dbstate, uistate, wspace, title=_('HtmlView')):
|
||||
PageView.__init__(self, title, dbstate, uistate)
|
||||
def __init__(self, pdata, dbstate, uistate, title=_('HtmlView')):
|
||||
PageView.__init__(self, title, pdata, dbstate, uistate)
|
||||
self.dbstate = dbstate
|
||||
self.back_action = None
|
||||
self.forward_action = None
|
||||
@ -456,6 +456,8 @@ class HtmlView(PageView):
|
||||
self.box = None
|
||||
self.toolkit = None
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
|
||||
def build_widget(self):
|
||||
"""
|
||||
Builds the interface and returns a gtk.Container type that
|
||||
@ -602,7 +604,7 @@ class HtmlView(PageView):
|
||||
"""
|
||||
return 'gramps-view'
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
"""
|
||||
Specifies the UIManager XML code that defines the menus and buttons
|
||||
associated with the interface.
|
||||
@ -622,6 +624,7 @@ class HtmlView(PageView):
|
||||
Required define_actions function for PageView. Builds the action
|
||||
group information required.
|
||||
"""
|
||||
PageView.define_actions(self)
|
||||
HtmlView._define_actions_fw_bw(self)
|
||||
|
||||
def _define_actions_fw_bw(self):
|
||||
|
@ -113,7 +113,7 @@ class MediaView(ListView):
|
||||
|
||||
_DND_TYPE = DdTargets.URI_LIST
|
||||
|
||||
def __init__(self, dbstate, uistate, wspace, nav_group=0):
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
|
||||
signal_map = {
|
||||
'media-add' : self.row_add,
|
||||
@ -124,7 +124,7 @@ class MediaView(ListView):
|
||||
}
|
||||
|
||||
ListView.__init__(
|
||||
self, _('Media'), dbstate, uistate,
|
||||
self, _('Media'), pdata, dbstate, uistate,
|
||||
MediaView.COLUMN_NAMES, len(MediaView.COLUMN_NAMES),
|
||||
MediaModel,
|
||||
signal_map, dbstate.db.get_media_bookmarks(),
|
||||
@ -137,6 +137,8 @@ class MediaView(ListView):
|
||||
'<CONTROL>BackSpace' : self.key_delete,
|
||||
})
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
|
||||
def navigation_type(self):
|
||||
return 'Media'
|
||||
|
||||
@ -335,7 +337,7 @@ class MediaView(ListView):
|
||||
Utils.media_path_full(self.dbstate.db, obj.get_path()))
|
||||
self.image.set_from_pixbuf(pix)
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
"""
|
||||
Return the UIManager XML description of the menus
|
||||
"""
|
||||
|
@ -92,7 +92,7 @@ class NoteView(ListView):
|
||||
FILTER_TYPE = "Note"
|
||||
QR_CATEGORY = CATEGORY_QR_NOTE
|
||||
|
||||
def __init__(self, dbstate, uistate, wspace, nav_group=0):
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
|
||||
signal_map = {
|
||||
'note-add' : self.row_add,
|
||||
@ -103,7 +103,7 @@ class NoteView(ListView):
|
||||
}
|
||||
|
||||
ListView.__init__(
|
||||
self, _('Notes'), dbstate, uistate, NoteView.COLUMN_NAMES,
|
||||
self, _('Notes'), pdata, dbstate, uistate, NoteView.COLUMN_NAMES,
|
||||
len(NoteView.COLUMN_NAMES), NoteModel, signal_map,
|
||||
dbstate.db.get_note_bookmarks(),
|
||||
Bookmarks.NoteBookmarks, nav_group,
|
||||
@ -115,6 +115,8 @@ class NoteView(ListView):
|
||||
'<CONTROL>BackSpace' : self.key_delete,
|
||||
})
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
|
||||
def navigation_type(self):
|
||||
return 'Note'
|
||||
|
||||
@ -136,7 +138,7 @@ class NoteView(ListView):
|
||||
"""
|
||||
return 'gramps-notes'
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
"""
|
||||
Defines the UI string for UIManager
|
||||
"""
|
||||
|
@ -671,8 +671,8 @@ class PedigreeView(NavigationView):
|
||||
('interface.pedview-show-unknown-people', True),
|
||||
)
|
||||
|
||||
def __init__(self, dbstate, uistate, wspace, nav_group=0):
|
||||
NavigationView.__init__(self, _('Pedigree'), dbstate, uistate,
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
NavigationView.__init__(self, _('Pedigree'), pdata, dbstate, uistate,
|
||||
dbstate.db.get_bookmarks(),
|
||||
Bookmarks.PersonBookmarks,
|
||||
nav_group)
|
||||
@ -699,6 +699,24 @@ class PedigreeView(NavigationView):
|
||||
self.scrolledwindow = None
|
||||
self.table = None
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
|
||||
# Automatic resize
|
||||
self.force_size = self._config.get('interface.pedview-tree-size')
|
||||
# Nice tree
|
||||
self.tree_style = self._config.get('interface.pedview-layout')
|
||||
# Show photos of persons
|
||||
self.show_images = self._config.get('interface.pedview-show-images')
|
||||
# Hide marriage data by default
|
||||
self.show_marriage_data = self._config.get(
|
||||
'interface.pedview-show-marriage')
|
||||
# Tree draw direction
|
||||
self.tree_direction = self._config.get('interface.pedview-tree-direction')
|
||||
# Show on not unknown people.
|
||||
# Default - not show, for mo fast display hight tree
|
||||
self.show_unknown_people = self._config.get(
|
||||
'interface.pedview-show-unknown-people')
|
||||
|
||||
def change_page(self):
|
||||
"""Called when the page changes."""
|
||||
NavigationView.change_page(self)
|
||||
@ -749,7 +767,7 @@ class PedigreeView(NavigationView):
|
||||
|
||||
return self.scrolledwindow
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
"""
|
||||
Specifies the UIManager XML code that defines the menus and buttons
|
||||
associated with the interface.
|
||||
@ -866,29 +884,6 @@ class PedigreeView(NavigationView):
|
||||
self._config.save()
|
||||
NavigationView.on_delete(self)
|
||||
|
||||
def set_ident(self, ident):
|
||||
"""
|
||||
Set the id of the view. This is an unique ident
|
||||
We use this to create immediately the config file with this ident.
|
||||
"""
|
||||
NavigationView.set_ident(self, ident)
|
||||
|
||||
# Automatic resize
|
||||
self.force_size = self._config.get('interface.pedview-tree-size')
|
||||
# Nice tree
|
||||
self.tree_style = self._config.get('interface.pedview-layout')
|
||||
# Show photos of persons
|
||||
self.show_images = self._config.get('interface.pedview-show-images')
|
||||
# Hide marriage data by default
|
||||
self.show_marriage_data = self._config.get(
|
||||
'interface.pedview-show-marriage')
|
||||
# Tree draw direction
|
||||
self.tree_direction = self._config.get('interface.pedview-tree-direction')
|
||||
# Show on not unknown people.
|
||||
# Default - not show, for mo fast display hight tree
|
||||
self.show_unknown_people = self._config.get(
|
||||
'interface.pedview-show-unknown-people')
|
||||
|
||||
def goto_handle(self, handle=None):
|
||||
"""
|
||||
Rebuild the tree with the given person handle as the root.
|
||||
|
@ -53,7 +53,7 @@ class PersonListView(BasePersonView):
|
||||
"""
|
||||
A hierarchical view of the top three levels of places.
|
||||
"""
|
||||
def __init__(self, dbstate, uistate, wspace, nav_group=0):
|
||||
BasePersonView.__init__(self, dbstate, uistate,
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
BasePersonView.__init__(self, pdata, dbstate, uistate,
|
||||
_('Person View'), PersonListModel,
|
||||
nav_group=nav_group)
|
||||
|
@ -55,8 +55,8 @@ class PersonTreeView(BasePersonView):
|
||||
"""
|
||||
A hierarchical view of the top three levels of places.
|
||||
"""
|
||||
def __init__(self, dbstate, uistate, wspace, nav_group=0):
|
||||
BasePersonView.__init__(self, dbstate, uistate,
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
BasePersonView.__init__(self, pdata, dbstate, uistate,
|
||||
_('People Tree View'), PersonTreeModel,
|
||||
nav_group=nav_group)
|
||||
|
||||
@ -85,7 +85,7 @@ class PersonTreeView(BasePersonView):
|
||||
self.close_all_nodes),
|
||||
])
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
"""
|
||||
Defines the UI string for UIManager
|
||||
"""
|
||||
|
@ -47,7 +47,7 @@ class PlaceListView(PlaceBaseView):
|
||||
"""
|
||||
Flat place view. (Original code in PlaceBaseView).
|
||||
"""
|
||||
def __init__(self, dbstate, uistate, wspace):
|
||||
PlaceBaseView.__init__(self, dbstate, uistate,
|
||||
def __init__(self, pdata, dbstate, uistate):
|
||||
PlaceBaseView.__init__(self, pdata, dbstate, uistate,
|
||||
_('Place View'), PlaceListModel,
|
||||
nav_group=0)
|
||||
|
@ -93,8 +93,8 @@ class PlaceTreeView(PlaceBaseView):
|
||||
100, 150, 150, 100, 150])
|
||||
)
|
||||
|
||||
def __init__(self, dbstate, uistate, wspace):
|
||||
PlaceBaseView.__init__(self, dbstate, uistate,
|
||||
def __init__(self, pdata, dbstate, uistate):
|
||||
PlaceBaseView.__init__(self, pdata, dbstate, uistate,
|
||||
_('Place Tree View'), PlaceTreeModel,
|
||||
nav_group=0, markup=PlaceBaseView.MARKUP_COLS)
|
||||
|
||||
@ -125,7 +125,7 @@ class PlaceTreeView(PlaceBaseView):
|
||||
self._add_action('CloseAllNodes', None, _("Collapse all Nodes"),
|
||||
callback=self.close_all_nodes)
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
"""
|
||||
A user interface definition including tree specific actions.
|
||||
"""
|
||||
|
@ -130,9 +130,9 @@ class RelationshipView(NavigationView):
|
||||
('preferences.releditbtn', True),
|
||||
)
|
||||
|
||||
def __init__(self, dbstate, uistate, wspace, nav_group=0):
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
NavigationView.__init__(self, _('Relationships'),
|
||||
dbstate, uistate,
|
||||
pdata, dbstate, uistate,
|
||||
dbstate.db.get_bookmarks(),
|
||||
Bookmarks.PersonBookmarks,
|
||||
nav_group)
|
||||
@ -152,6 +152,14 @@ class RelationshipView(NavigationView):
|
||||
self.reorder_sensitive = False
|
||||
self.collapsed_items = {}
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
|
||||
self.show_siblings = self._config.get('preferences.family-siblings')
|
||||
self.show_details = self._config.get('preferences.family-details')
|
||||
self.use_shade = self._config.get('preferences.relation-shade')
|
||||
self.theme = self._config.get('preferences.relation-display-theme')
|
||||
self.toolbar_visible = config.get('interface.toolbar-on')
|
||||
|
||||
def _connect_db_signals(self):
|
||||
"""
|
||||
implement from base class DbGUIElement
|
||||
@ -179,22 +187,6 @@ class RelationshipView(NavigationView):
|
||||
"""
|
||||
return True
|
||||
|
||||
def on_delete(self):
|
||||
self._config.save()
|
||||
NavigationView.on_delete(self)
|
||||
|
||||
def set_ident(self, ident):
|
||||
"""
|
||||
Set the id of the view. This is an unique ident
|
||||
We use this to create immediately the config file with this ident.
|
||||
"""
|
||||
NavigationView.set_ident(self, ident)
|
||||
self.show_siblings = self._config.get('preferences.family-siblings')
|
||||
self.show_details = self._config.get('preferences.family-details')
|
||||
self.use_shade = self._config.get('preferences.relation-shade')
|
||||
self.theme = self._config.get('preferences.relation-display-theme')
|
||||
self.toolbar_visible = config.get('interface.toolbar-on')
|
||||
|
||||
def goto_handle(self, handle):
|
||||
self.change_person(handle)
|
||||
|
||||
@ -331,7 +323,7 @@ class RelationshipView(NavigationView):
|
||||
container.show_all()
|
||||
return container
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
"""
|
||||
Specifies the UIManager XML code that defines the menus and buttons
|
||||
associated with the interface.
|
||||
|
@ -109,7 +109,7 @@ class RepositoryView(ListView):
|
||||
FILTER_TYPE = "Repository"
|
||||
QR_CATEGORY = CATEGORY_QR_REPOSITORY
|
||||
|
||||
def __init__(self, dbstate, uistate, wspace, nav_group=0):
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
|
||||
signal_map = {
|
||||
'repository-add' : self.row_add,
|
||||
@ -119,7 +119,7 @@ class RepositoryView(ListView):
|
||||
}
|
||||
|
||||
ListView.__init__(
|
||||
self, _('Repositories'), dbstate, uistate,
|
||||
self, _('Repositories'), pdata, dbstate, uistate,
|
||||
RepositoryView.COLUMN_NAMES, len(RepositoryView.COLUMN_NAMES),
|
||||
RepositoryModel, signal_map,
|
||||
dbstate.db.get_repo_bookmarks(),
|
||||
@ -132,6 +132,8 @@ class RepositoryView(ListView):
|
||||
'<CONTROL>BackSpace' : self.key_delete,
|
||||
})
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
|
||||
def navigation_type(self):
|
||||
return 'Repository'
|
||||
|
||||
@ -153,7 +155,7 @@ class RepositoryView(ListView):
|
||||
def get_stock(self):
|
||||
return 'gramps-repository'
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
return '''<ui>
|
||||
<menubar name="MenuBar">
|
||||
<menu action="FileMenu">
|
||||
|
@ -93,7 +93,7 @@ class SourceView(ListView):
|
||||
FILTER_TYPE = "Source"
|
||||
QR_CATEGORY = CATEGORY_QR_SOURCE
|
||||
|
||||
def __init__(self, dbstate, uistate, wspace, nav_group=0):
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
|
||||
signal_map = {
|
||||
'source-add' : self.row_add,
|
||||
@ -103,7 +103,7 @@ class SourceView(ListView):
|
||||
}
|
||||
|
||||
ListView.__init__(
|
||||
self, _('Sources'), dbstate, uistate,
|
||||
self, _('Sources'), pdata, dbstate, uistate,
|
||||
SourceView.COLUMN_NAMES, len(SourceView.COLUMN_NAMES),
|
||||
SourceModel, signal_map,
|
||||
dbstate.db.get_source_bookmarks(),
|
||||
@ -116,6 +116,8 @@ class SourceView(ListView):
|
||||
'<CONTROL>BackSpace' : self.key_delete,
|
||||
})
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
|
||||
def navigation_type(self):
|
||||
return 'Source'
|
||||
|
||||
@ -135,7 +137,7 @@ class SourceView(ListView):
|
||||
def get_stock(self):
|
||||
return 'gramps-source'
|
||||
|
||||
def ui_definition(self):
|
||||
def additional_ui(self):
|
||||
return '''<ui>
|
||||
<menubar name="MenuBar">
|
||||
<menu action="FileMenu">
|
||||
|
Loading…
x
Reference in New Issue
Block a user