remove whitespace

svn: r16443
This commit is contained in:
Benny Malengier 2011-01-22 19:54:01 +00:00
parent 0127d56473
commit 0f15f446e9
2 changed files with 262 additions and 262 deletions

View File

@ -73,66 +73,66 @@ def register_stock_icons ():
factory. This allows all gramps modules to call up the icons by their name factory. This allows all gramps modules to call up the icons by their name
""" """
from gui.pluginmanager import base_reg_stock_icons from gui.pluginmanager import base_reg_stock_icons
#iconpath to the base image. The front of the list has highest priority #iconpath to the base image. The front of the list has highest priority
if constfunc.win(): if constfunc.win():
iconpaths = [ iconpaths = [
(os.path.join(const.IMAGE_DIR, '48x48'), '.png'), (os.path.join(const.IMAGE_DIR, '48x48'), '.png'),
(const.IMAGE_DIR, '.png'), (const.IMAGE_DIR, '.png'),
] ]
else : else :
iconpaths = [ iconpaths = [
(os.path.join(const.IMAGE_DIR, 'scalable'), '.svg'), (os.path.join(const.IMAGE_DIR, 'scalable'), '.svg'),
(const.IMAGE_DIR, '.svg'), (const.IMAGE_DIR, '.png'), (const.IMAGE_DIR, '.svg'), (const.IMAGE_DIR, '.png'),
] ]
#sizes: menu=16, small_toolbar=18, large_toolbar=24, #sizes: menu=16, small_toolbar=18, large_toolbar=24,
# button=20, dnd=32, dialog=48 # button=20, dnd=32, dialog=48
#add to the back of this list to overrule images set at beginning of list #add to the back of this list to overrule images set at beginning of list
extraiconsize = [ extraiconsize = [
(os.path.join(const.IMAGE_DIR, '22x22'), (os.path.join(const.IMAGE_DIR, '22x22'),
gtk.ICON_SIZE_LARGE_TOOLBAR), gtk.ICON_SIZE_LARGE_TOOLBAR),
(os.path.join(const.IMAGE_DIR, '16x16'), (os.path.join(const.IMAGE_DIR, '16x16'),
gtk.ICON_SIZE_MENU), gtk.ICON_SIZE_MENU),
(os.path.join(const.IMAGE_DIR, '22x22'), (os.path.join(const.IMAGE_DIR, '22x22'),
gtk.ICON_SIZE_BUTTON), gtk.ICON_SIZE_BUTTON),
] ]
items = [ items = [
('gramps-db', _('Family Trees'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-db', _('Family Trees'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-address', _('Address'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-address', _('Address'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-attribute', _('Attribute'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-attribute', _('Attribute'), gtk.gdk.CONTROL_MASK, 0, ''),
#('gramps-bookmark', _('Bookmarks'), gtk.gdk.CONTROL_MASK, 0, ''), #('gramps-bookmark', _('Bookmarks'), gtk.gdk.CONTROL_MASK, 0, ''),
#('gramps-bookmark-delete', _('Delete bookmark'), gtk.gdk.CONTROL_MASK, 0, ''), #('gramps-bookmark-delete', _('Delete bookmark'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-bookmark-new', _('_Add bookmark'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-bookmark-new', _('_Add bookmark'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-bookmark-edit', _('Organize Bookmarks'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-bookmark-edit', _('Organize Bookmarks'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-config', _('Configure'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-config', _('Configure'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-date', _('Date'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-date', _('Date'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-date-edit', _('Edit Date'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-date-edit', _('Edit Date'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-event', _('Events'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-event', _('Events'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-family', _('Family'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-family', _('Family'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-fanchart', _('Fan Chart'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-fanchart', _('Fan Chart'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-font', _('Font'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-font', _('Font'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-font-color', _('Font Color'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-font-color', _('Font Color'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-font-bgcolor', _('Font Background Color'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-font-bgcolor', _('Font Background Color'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-gramplet', _('Gramplets'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-gramplet', _('Gramplets'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-geo', _('GeoView'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-geo', _('GeoView'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-geo-mainmap', _('GeoView'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-geo-mainmap', _('GeoView'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-geo-altmap', _('GeoView'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-geo-altmap', _('GeoView'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-lock', _('Public'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-lock', _('Public'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-media', _('Media'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-media', _('Media'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-merge', _('Merge'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-merge', _('Merge'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-notes', _('Notes'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-notes', _('Notes'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-parents', _('Parents'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-parents', _('Parents'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-parents-add', _('Add Parents'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-parents-add', _('Add Parents'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-parents-open', _('Select Parents'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-parents-open', _('Select Parents'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-pedigree', _('Pedigree'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-pedigree', _('Pedigree'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-person', _('Person'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-person', _('Person'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-place', _('Places'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-place', _('Places'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-relation', _('Relationships'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-relation', _('Relationships'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-reports', _('Reports'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-reports', _('Reports'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-repository', _('Repositories'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-repository', _('Repositories'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-source', _('Sources'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-source', _('Sources'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-spouse', _('Add Spouse'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-spouse', _('Add Spouse'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-tag', _('Tag'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-tag', _('Tag'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-tag-new', _('New Tag'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-tag-new', _('New Tag'), gtk.gdk.CONTROL_MASK, 0, ''),
@ -140,23 +140,23 @@ def register_stock_icons ():
('gramps-tree-group', _('Grouped List'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-tree-group', _('Grouped List'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-tree-list', _('List'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-tree-list', _('List'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-tree-select', _('Select'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-tree-select', _('Select'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-unlock', _('Private'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-unlock', _('Private'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-view', _('View'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-view', _('View'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-viewmedia', _('View'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-viewmedia', _('View'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-zoom-in', _('Zoom In'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-zoom-in', _('Zoom In'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-zoom-out', _('Zoom Out'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-zoom-out', _('Zoom Out'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-zoom-fit-width', _('Fit Width'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-zoom-fit-width', _('Fit Width'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-zoom-best-fit', _('Fit Page'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-zoom-best-fit', _('Fit Page'), gtk.gdk.CONTROL_MASK, 0, ''),
] ]
# the following icons are not yet in new directory structure # the following icons are not yet in new directory structure
# they should be ported in the near future # they should be ported in the near future
items_legacy = [ items_legacy = [
('gramps-export', _('Export'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-export', _('Export'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-import', _('Import'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-import', _('Import'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-undo-history', _('Undo History'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-undo-history', _('Undo History'), gtk.gdk.CONTROL_MASK, 0, ''),
('gramps-url', _('URL'), gtk.gdk.CONTROL_MASK, 0, ''), ('gramps-url', _('URL'), gtk.gdk.CONTROL_MASK, 0, ''),
] ]
base_reg_stock_icons(iconpaths, extraiconsize, items+items_legacy) base_reg_stock_icons(iconpaths, extraiconsize, items+items_legacy)
def _display_welcome_message(): def _display_welcome_message():
@ -166,7 +166,7 @@ def _display_welcome_message():
if not config.get('behavior.betawarn'): if not config.get('behavior.betawarn'):
from QuestionDialog import WarningDialog from QuestionDialog import WarningDialog
WarningDialog( WarningDialog(
_('Danger: This is unstable code!'), _('Danger: This is unstable code!'),
_("This Gramps 3.x-trunk is a development release. " _("This Gramps 3.x-trunk is a development release. "
"This version is not meant for normal usage. Use " "This version is not meant for normal usage. Use "
"at your own risk.\n" "at your own risk.\n"
@ -185,7 +185,7 @@ def _display_welcome_message():
config.set('behavior.autoload', False) config.set('behavior.autoload', False)
# config.set('behavior.betawarn', True) # config.set('behavior.betawarn', True)
config.set('behavior.betawarn', config.get('behavior.betawarn')) config.set('behavior.betawarn', config.get('behavior.betawarn'))
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Main Gramps class # Main Gramps class
@ -198,21 +198,21 @@ class Gramps(object):
There can be only one instance of this class per gramps application There can be only one instance of this class per gramps application
process. It may spawn several windows and control several databases. process. It may spawn several windows and control several databases.
""" """
def __init__(self, argparser): def __init__(self, argparser):
import DbState import DbState
from viewmanager import ViewManager from viewmanager import ViewManager
from cli.arghandler import ArgHandler from cli.arghandler import ArgHandler
import TipOfDay import TipOfDay
register_stock_icons() register_stock_icons()
dbstate = DbState.DbState() dbstate = DbState.DbState()
self.vm = ViewManager(dbstate, config.get("interface.view-categories")) self.vm = ViewManager(dbstate, config.get("interface.view-categories"))
self.vm.init_interface() self.vm.init_interface()
#act based on the given arguments #act based on the given arguments
ah = ArgHandler(dbstate, argparser, self.vm, self.argerrorfunc, ah = ArgHandler(dbstate, argparser, self.vm, self.argerrorfunc,
gui=True) gui=True)
ah.handle_args_gui() ah.handle_args_gui()
if ah.open or ah.imp_db_path: if ah.open or ah.imp_db_path:
@ -257,12 +257,12 @@ def __startgramps(errors, argparser):
ErrorDialog(errors[0], errors[1]) ErrorDialog(errors[0], errors[1])
gtk.main_quit() gtk.main_quit()
sys.exit(1) sys.exit(1)
if argparser.errors: if argparser.errors:
ErrorDialog(argparser.errors[0], argparser.errors[1]) ErrorDialog(argparser.errors[0], argparser.errors[1])
gtk.main_quit() gtk.main_quit()
sys.exit(1) sys.exit(1)
# add gui logger # add gui logger
from GrampsLogger import RotateHandler, GtkHandler from GrampsLogger import RotateHandler, GtkHandler
form = logging.Formatter(fmt="%(relativeCreated)d: %(levelname)s: " form = logging.Formatter(fmt="%(relativeCreated)d: %(levelname)s: "
@ -280,7 +280,7 @@ def __startgramps(errors, argparser):
l.addHandler(gtkh) l.addHandler(gtkh)
# start GRAMPS, errors stop the gtk loop # start GRAMPS, errors stop the gtk loop
try: try:
quit_now = False quit_now = False
exit_code = 0 exit_code = 0
if constfunc.has_display(): if constfunc.has_display():
@ -314,7 +314,7 @@ def __startgramps(errors, argparser):
#stop gtk loop and quit #stop gtk loop and quit
gtk.main_quit() gtk.main_quit()
sys.exit(exit_code) sys.exit(exit_code)
#function finished, return False to stop the timeout_add function calls #function finished, return False to stop the timeout_add function calls
return False return False
@ -322,6 +322,6 @@ def startgtkloop(errors, argparser):
""" We start the gtk loop and run the function to start up GRAMPS """ We start the gtk loop and run the function to start up GRAMPS
""" """
gobject.threads_init() gobject.threads_init()
gobject.timeout_add(100, __startgramps, errors, argparser, priority=100) gobject.timeout_add(100, __startgramps, errors, argparser, priority=100)
gtk.main() gtk.main()

View File

@ -12,7 +12,7 @@
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
@ -39,7 +39,7 @@ import os
import time import time
import datetime import datetime
from gen.ggettext import sgettext as _ from gen.ggettext import sgettext as _
from gen.ggettext import ngettext from gen.ggettext import ngettext
from cStringIO import StringIO from cStringIO import StringIO
from collections import defaultdict from collections import defaultdict
import sys import sys
@ -80,7 +80,7 @@ import const
import constfunc import constfunc
import config import config
import Errors import Errors
from QuestionDialog import (ErrorDialog, WarningDialog, QuestionDialog2, from QuestionDialog import (ErrorDialog, WarningDialog, QuestionDialog2,
InfoDialog) InfoDialog)
from gui import widgets from gui import widgets
import UndoHistory import UndoHistory
@ -143,7 +143,7 @@ UIDEFAULT = '''<ui>
<menu action="ViewMenu"> <menu action="ViewMenu">
<menuitem action="ConfigView"/> <menuitem action="ConfigView"/>
<menuitem action="Navigator"/> <menuitem action="Navigator"/>
<menuitem action="Toolbar"/> <menuitem action="Toolbar"/>
<placeholder name="Bars"/> <placeholder name="Bars"/>
<menuitem action="Fullscreen"/> <menuitem action="Fullscreen"/>
<separator/> <separator/>
@ -255,7 +255,7 @@ class ViewManager(CLIManager):
Overview Overview
======== ========
The ViewManager is the session manager of the program. The ViewManager is the session manager of the program.
Specifically, it manages the main window of the program. It is closely tied Specifically, it manages the main window of the program. It is closely tied
into the gtk.UIManager to control all menus and actions. into the gtk.UIManager to control all menus and actions.
@ -263,11 +263,11 @@ class ViewManager(CLIManager):
Views are organised in categories. The categories can be accessed via Views are organised in categories. The categories can be accessed via
a sidebar. Within a category, the different views are accesible via the a sidebar. Within a category, the different views are accesible via the
toolbar of view menu. toolbar of view menu.
A View is a particular way of looking a information in the GRAMPS main 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 window. Each view is separate from the others, and has no knowledge of
the others. the others.
Examples of current views include: Examples of current views include:
- Person View - Person View
@ -276,15 +276,15 @@ class ViewManager(CLIManager):
- Source View - Source View
The View Manager does not have to know the number of views, the type of 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 views, or any other details about the views. It simply provides the
method of containing each view, and has methods for creating, deleting and method of containing each view, and has methods for creating, deleting and
switching between the views. switching between the views.
""" """
def __init__(self, dbstate, view_category_order): def __init__(self, dbstate, view_category_order):
""" """
The viewmanager is initialised with a dbstate on which GRAMPS is The viewmanager is initialised with a dbstate on which GRAMPS is
working, and a fixed view_category_order, which is the order in which working, and a fixed view_category_order, which is the order in which
the view categories are accessible in the sidebar. the view categories are accessible in the sidebar.
""" """
@ -293,7 +293,7 @@ class ViewManager(CLIManager):
self.macapp = QuartzApp.OSXApplication() self.macapp = QuartzApp.OSXApplication()
self.view_category_order = view_category_order self.view_category_order = view_category_order
#set pluginmanager to GUI one #set pluginmanager to GUI one
self._pmgr = GuiPluginManager.get_instance() self._pmgr = GuiPluginManager.get_instance()
self.merge_ids = [] self.merge_ids = []
@ -316,7 +316,7 @@ class ViewManager(CLIManager):
self.__connect_signals() self.__connect_signals()
if _GTKOSXAPPLICATION: if _GTKOSXAPPLICATION:
self.macapp.ready() self.macapp.ready()
self.do_reg_plugins(self.dbstate, self.uistate) self.do_reg_plugins(self.dbstate, self.uistate)
#plugins loaded now set relationship class #plugins loaded now set relationship class
self.rel_class = Relationship.get_relationship_calculator() self.rel_class = Relationship.get_relationship_calculator()
@ -333,7 +333,7 @@ class ViewManager(CLIManager):
if force: if force:
update = True update = True
elif howoften != 0: # update never if zero elif howoften != 0: # update never if zero
y,m,d = map(int, y,m,d = map(int,
config.get("behavior.last-check-for-updates").split("/")) config.get("behavior.last-check-for-updates").split("/"))
days = (datetime.date.today() - datetime.date(y, m, d)).days days = (datetime.date.today() - datetime.date(y, m, d)).days
if howoften == 1 and days >= 30: # once a month if howoften == 1 and days >= 30: # once a month
@ -379,19 +379,19 @@ class ViewManager(CLIManager):
id = plugin_dict["i"] id = plugin_dict["i"]
plugin = self._pmgr.get_plugin(id) plugin = self._pmgr.get_plugin(id)
if plugin: if plugin:
LOG.debug("Comparing %s > %s" % LOG.debug("Comparing %s > %s" %
(version_str_to_tup(plugin_dict["v"], 3), (version_str_to_tup(plugin_dict["v"], 3),
version_str_to_tup(plugin.version, 3))) version_str_to_tup(plugin.version, 3)))
if (version_str_to_tup(plugin_dict["v"], 3) > if (version_str_to_tup(plugin_dict["v"], 3) >
version_str_to_tup(plugin.version, 3)): version_str_to_tup(plugin.version, 3)):
LOG.debug(" Downloading '%s'..." % plugin_dict["z"]) LOG.debug(" Downloading '%s'..." % plugin_dict["z"])
if "update" in whattypes: if "update" in whattypes:
if ((not config.get('behavior.do-not-show-previously-seen-updates')) or if ((not config.get('behavior.do-not-show-previously-seen-updates')) or
(config.get('behavior.do-not-show-previously-seen-updates') and (config.get('behavior.do-not-show-previously-seen-updates') and
plugin_dict["i"] not in config.get('behavior.previously-seen-updates'))): plugin_dict["i"] not in config.get('behavior.previously-seen-updates'))):
addon_update_list.append(("Updated", addon_update_list.append(("Updated",
"%s/download/%s" % "%s/download/%s" %
(ADDONS_URL, (ADDONS_URL,
plugin_dict["z"]), plugin_dict["z"]),
plugin_dict)) plugin_dict))
else: else:
@ -402,12 +402,12 @@ class ViewManager(CLIManager):
if ((not config.get('behavior.do-not-show-previously-seen-updates')) or if ((not config.get('behavior.do-not-show-previously-seen-updates')) or
(config.get('behavior.do-not-show-previously-seen-updates') and (config.get('behavior.do-not-show-previously-seen-updates') and
plugin_dict["i"] not in config.get('behavior.previously-seen-updates'))): plugin_dict["i"] not in config.get('behavior.previously-seen-updates'))):
addon_update_list.append(("New", addon_update_list.append(("New",
"%s/download/%s" % "%s/download/%s" %
(ADDONS_URL, (ADDONS_URL,
plugin_dict["z"]), plugin_dict["z"]),
plugin_dict)) plugin_dict))
config.set("behavior.last-check-for-updates", config.set("behavior.last-check-for-updates",
datetime.date.today().strftime("%Y/%m/%d")) datetime.date.today().strftime("%Y/%m/%d"))
count += 1 count += 1
if fp: if fp:
@ -417,9 +417,9 @@ class ViewManager(CLIManager):
self.update_addons(addon_update_list) self.update_addons(addon_update_list)
elif force: elif force:
from QuestionDialog import OkDialog from QuestionDialog import OkDialog
OkDialog(_("There are no available addons of this type"), OkDialog(_("There are no available addons of this type"),
_("Checked for '%s'") % _("Checked for '%s'") %
_("' and '").join(config.get('behavior.check-for-update-types')), _("' and '").join(config.get('behavior.check-for-update-types')),
self.window) self.window)
def update_addons(self, addon_update_list): def update_addons(self, addon_update_list):
@ -428,7 +428,7 @@ class ViewManager(CLIManager):
from ListModel import ListModel, NOSORT, TOGGLE from ListModel import ListModel, NOSORT, TOGGLE
glade = Glade("updateaddons.glade") glade = Glade("updateaddons.glade")
self.update_dialog = glade.toplevel self.update_dialog = glade.toplevel
ManagedWindow.set_titles(self.update_dialog, ManagedWindow.set_titles(self.update_dialog,
glade.get_object('title'), glade.get_object('title'),
_('Available Gramps Updates for Addons')) _('Available Gramps Updates for Addons'))
apply_button = glade.get_object('apply') apply_button = glade.get_object('apply')
@ -438,14 +438,14 @@ class ViewManager(CLIManager):
select_none = glade.get_object('select_none') select_none = glade.get_object('select_none')
select_none.connect("clicked", self.select_none_clicked) select_none.connect("clicked", self.select_none_clicked)
apply_button.connect("clicked", self.install_addons) apply_button.connect("clicked", self.install_addons)
cancel_button.connect("clicked", cancel_button.connect("clicked",
lambda obj: self.update_dialog.destroy()) lambda obj: self.update_dialog.destroy())
self.list = ListModel(glade.get_object("list"), [ self.list = ListModel(glade.get_object("list"), [
# name, click?, width, toggle # name, click?, width, toggle
{"name": _('Select'), {"name": _('Select'),
"sort_id": NOSORT, "sort_id": NOSORT,
"width": 60, "width": 60,
"type": TOGGLE, "type": TOGGLE,
"visible_col": 6, "visible_col": 6,
"editable": True}, # 0 selected? "editable": True}, # 0 selected?
(_('Type'), 1, 180), # 1 new gramplet (_('Type'), 1, 180), # 1 new gramplet
@ -460,8 +460,8 @@ class ViewManager(CLIManager):
last_category = None last_category = None
for (status,plugin_url,plugin_dict) in addon_update_list: for (status,plugin_url,plugin_dict) in addon_update_list:
count = get_count(addon_update_list, plugin_dict["t"]) count = get_count(addon_update_list, plugin_dict["t"])
category = "%s %s" % (_(status), ngettext(plugin_dict["t"], category = "%s %s" % (_(status), ngettext(plugin_dict["t"],
plugin_dict["t"] + "s", plugin_dict["t"] + "s",
count)) count))
if last_category != category: if last_category != category:
last_category = category last_category = category
@ -469,7 +469,7 @@ class ViewManager(CLIManager):
category, category,
"", "",
"", "",
"", "",
"", "",
False]) # checkbox visible? False]) # checkbox visible?
iter = self.list.add([False, # initially selected? iter = self.list.add([False, # initially selected?
@ -477,7 +477,7 @@ class ViewManager(CLIManager):
"%s (%s)" % (plugin_dict["n"], "%s (%s)" % (plugin_dict["n"],
plugin_dict["v"]), plugin_dict["v"]),
plugin_dict["d"], plugin_dict["d"],
plugin_url, plugin_url,
plugin_dict["i"], plugin_dict["i"],
True], node=node) True], node=node)
if pos is None: if pos is None:
@ -499,7 +499,7 @@ class ViewManager(CLIManager):
""" """
self.list.model.foreach(update_rows, False) self.list.model.foreach(update_rows, False)
self.list.tree.expand_all() self.list.tree.expand_all()
def install_addons(self, obj): def install_addons(self, obj):
""" """
Process all of the selected addons. Process all of the selected addons.
@ -514,10 +514,10 @@ class ViewManager(CLIManager):
if iter: if iter:
length += self.list.model.iter_n_children(iter) length += self.list.model.iter_n_children(iter)
longop = LongOpStatus( longop = LongOpStatus(
_("Downloading and installing selected addons..."), _("Downloading and installing selected addons..."),
length, 1, # total, increment-by length, 1, # total, increment-by
can_cancel=True) can_cancel=True)
pm = ProgressMonitor(GtkProgressDialog, pm = ProgressMonitor(GtkProgressDialog,
("Title", self.window, gtk.DIALOG_MODAL)) ("Title", self.window, gtk.DIALOG_MODAL))
pm.add_op(longop) pm.add_op(longop)
count = 0 count = 0
@ -534,7 +534,7 @@ class ViewManager(CLIManager):
self.list.model.get_value(child, 3), self.list.model.get_value(child, 3),
self.list.model.get_value(child, 4), self.list.model.get_value(child, 4),
self.list.model.get_value(child, 5),] self.list.model.get_value(child, 5),]
if longop.should_cancel(): if longop.should_cancel():
break break
elif row[0]: # toggle on elif row[0]: # toggle on
load_addon_file(row[4], callback=LOG.debug) load_addon_file(row[4], callback=LOG.debug)
@ -549,26 +549,26 @@ class ViewManager(CLIManager):
longop.end() longop.end()
if count: if count:
self.do_reg_plugins(self.dbstate, self.uistate) self.do_reg_plugins(self.dbstate, self.uistate)
OkDialog(_("Done downloading and installing addons"), OkDialog(_("Done downloading and installing addons"),
"%s %s" % (ngettext("%d addon was installed.", "%s %s" % (ngettext("%d addon was installed.",
"%d addons were installed.", "%d addons were installed.",
count) % count, count) % count,
_("You need to restart Gramps to see new views.")), _("You need to restart Gramps to see new views.")),
self.window) self.window)
else: else:
OkDialog(_("Done downloading and installing addons"), OkDialog(_("Done downloading and installing addons"),
_("No addons were installed."), _("No addons were installed."),
self.window) self.window)
self.update_dialog.destroy() self.update_dialog.destroy()
def _errordialog(title, errormessage): def _errordialog(title, errormessage):
""" """
Show the error. Show the error.
In the GUI, the error is shown, and a return happens In the GUI, the error is shown, and a return happens
""" """
ErrorDialog(title, errormessage) ErrorDialog(title, errormessage)
return 1 return 1
def __build_main_window(self): def __build_main_window(self):
""" """
Builds the GTK interface Builds the GTK interface
@ -584,7 +584,7 @@ class ViewManager(CLIManager):
self.window.add(vbox) self.window.add(vbox)
hpane = gtk.HPaned() hpane = gtk.HPaned()
self.ebox = gtk.EventBox() self.ebox = gtk.EventBox()
self.navigator = Navigator(self) self.navigator = Navigator(self)
self.ebox.add(self.navigator.get_top()) self.ebox.add(self.navigator.get_top())
hpane.add1(self.ebox) hpane.add1(self.ebox)
@ -610,7 +610,7 @@ class ViewManager(CLIManager):
GtkProgressDialog, ("", self.window)) GtkProgressDialog, ("", self.window))
self.uistate = DisplayState.DisplayState( self.uistate = DisplayState.DisplayState(
self.window, self.statusbar, self.progress, self.warnbtn, self.window, self.statusbar, self.progress, self.warnbtn,
self.uimanager, self.progress_monitor, self) self.uimanager, self.progress_monitor, self)
self.dbstate.connect('database-changed', self.uistate.db_changed) self.dbstate.connect('database-changed', self.uistate.db_changed)
@ -620,7 +620,7 @@ class ViewManager(CLIManager):
self.sidebar_menu = self.uimanager.get_widget( self.sidebar_menu = self.uimanager.get_widget(
'/MenuBar/ViewMenu/Sidebar/') '/MenuBar/ViewMenu/Sidebar/')
# handle OPEN button, insert it into the toolbar. Unfortunately, # handle OPEN button, insert it into the toolbar. Unfortunately,
# UIManager has no built in support for and Open Recent button # UIManager has no built in support for and Open Recent button
openbtn = self.__build_open_button() openbtn = self.__build_open_button()
@ -655,10 +655,10 @@ class ViewManager(CLIManager):
for pdata in self._pmgr.get_reg_sidebars(): for pdata in self._pmgr.get_reg_sidebars():
module = self._pmgr.load_plugin(pdata) module = self._pmgr.load_plugin(pdata)
if not module: if not module:
print("Error loading sidebar '%s': skipping content" print("Error loading sidebar '%s': skipping content"
% pdata.name) % pdata.name)
continue continue
sidebar_class = getattr(module, pdata.sidebarclass) sidebar_class = getattr(module, pdata.sidebarclass)
sidebar_page = sidebar_class(self.dbstate, self.uistate) sidebar_page = sidebar_class(self.dbstate, self.uistate)
self.navigator.add(pdata.menu_label, sidebar_page, pdata.order) self.navigator.add(pdata.menu_label, sidebar_page, pdata.order)
@ -687,7 +687,7 @@ class ViewManager(CLIManager):
def __setup_navigator(self): def __setup_navigator(self):
""" """
If we have enabled te sidebar, show it, and turn off the tabs. If If we have enabled te sidebar, show it, and turn off the tabs. If
disabled, hide the sidebar and turn on the tabs. disabled, hide the sidebar and turn on the tabs.
""" """
if self.show_navigator: if self.show_navigator:
@ -721,124 +721,124 @@ class ViewManager(CLIManager):
Initialize the actions lists for the UIManager Initialize the actions lists for the UIManager
""" """
self._file_action_list = [ self._file_action_list = [
('FileMenu', None, _('_Family Trees')), ('FileMenu', None, _('_Family Trees')),
('Open', 'gramps-db', _('_Manage Family Trees...'), "<control>o", ('Open', 'gramps-db', _('_Manage Family Trees...'), "<control>o",
_("Manage databases"), self.__open_activate), _("Manage databases"), self.__open_activate),
('OpenRecent', None, _('Open _Recent'), None, ('OpenRecent', None, _('Open _Recent'), None,
_("Open an existing database")), _("Open an existing database")),
('Quit', gtk.STOCK_QUIT, _('_Quit'), "<control>q", None, ('Quit', gtk.STOCK_QUIT, _('_Quit'), "<control>q", None,
self.quit), self.quit),
('ViewMenu', None, _('_View')), ('ViewMenu', None, _('_View')),
('EditMenu', None, _('_Edit')), ('EditMenu', None, _('_Edit')),
('Preferences', gtk.STOCK_PREFERENCES, _('_Preferences...'), None, ('Preferences', gtk.STOCK_PREFERENCES, _('_Preferences...'), None,
None, self.preferences_activate), None, self.preferences_activate),
('HelpMenu', None, _('_Help')), ('HelpMenu', None, _('_Help')),
('HomePage', None, _('Gramps _Home Page'), None, None, ('HomePage', None, _('Gramps _Home Page'), None, None,
home_page_activate), home_page_activate),
('MailingLists', None, _('Gramps _Mailing Lists'), None, None, ('MailingLists', None, _('Gramps _Mailing Lists'), None, None,
mailing_lists_activate), mailing_lists_activate),
('ReportBug', None, _('_Report a Bug'), None, None, ('ReportBug', None, _('_Report a Bug'), None, None,
report_bug_activate), report_bug_activate),
('ExtraPlugins', None, _('_Extra Reports/Tools'), None, None, ('ExtraPlugins', None, _('_Extra Reports/Tools'), None, None,
extra_plugins_activate), extra_plugins_activate),
('About', gtk.STOCK_ABOUT, _('_About'), None, None, ('About', gtk.STOCK_ABOUT, _('_About'), None, None,
display_about_box), display_about_box),
('PluginStatus', None, _('_Plugin Manager'), None, None, ('PluginStatus', None, _('_Plugin Manager'), None, None,
self.__plugin_status), self.__plugin_status),
('FAQ', None, _('_FAQ'), None, None, faq_activate), ('FAQ', None, _('_FAQ'), None, None, faq_activate),
('KeyBindings', None, _('_Key Bindings'), None, None, key_bindings), ('KeyBindings', None, _('_Key Bindings'), None, None, key_bindings),
('UserManual', gtk.STOCK_HELP, _('_User Manual'), 'F1', None, ('UserManual', gtk.STOCK_HELP, _('_User Manual'), 'F1', None,
manual_activate), manual_activate),
('TipOfDay', None, _('Tip of the Day'), None, None, ('TipOfDay', None, _('Tip of the Day'), None, None,
self.tip_of_day_activate), self.tip_of_day_activate),
] ]
self._readonly_action_list = [ self._readonly_action_list = [
('Export', 'gramps-export', _('_Export...'), "<control>e", None, ('Export', 'gramps-export', _('_Export...'), "<control>e", None,
self.export_data), self.export_data),
('Backup', None, _("Make Backup..."), None, ('Backup', None, _("Make Backup..."), None,
_("Make a Gramps XML backup of the database"), self.quick_backup), _("Make a Gramps XML backup of the database"), self.quick_backup),
('Abandon', gtk.STOCK_REVERT_TO_SAVED, ('Abandon', gtk.STOCK_REVERT_TO_SAVED,
_('_Abandon Changes and Quit'), None, None, self.abort), _('_Abandon Changes and Quit'), None, None, self.abort),
('Reports', 'gramps-reports', _('_Reports'), None, ('Reports', 'gramps-reports', _('_Reports'), None,
_("Open the reports dialog"), self.reports_clicked), _("Open the reports dialog"), self.reports_clicked),
('GoMenu', None, _('_Go')), ('GoMenu', None, _('_Go')),
('ReportsMenu', None, _('_Reports')), ('ReportsMenu', None, _('_Reports')),
('WindowsMenu', None, _('_Windows')), ('WindowsMenu', None, _('_Windows')),
('F2', None, 'F2', "F2", None, self.__keypress), ('F2', None, 'F2', "F2", None, self.__keypress),
('F3', None, 'F3', "F3", None, self.__keypress), ('F3', None, 'F3', "F3", None, self.__keypress),
('F4', None, 'F4', "F4", None, self.__keypress), ('F4', None, 'F4', "F4", None, self.__keypress),
('F5', None, 'F5', "F5", None, self.__keypress), ('F5', None, 'F5', "F5", None, self.__keypress),
('F6', None, 'F6', "F6", None, self.__keypress), ('F6', None, 'F6', "F6", None, self.__keypress),
('F7', None, 'F7', "F7", None, self.__keypress), ('F7', None, 'F7', "F7", None, self.__keypress),
('F8', None, 'F9', "F8", None, self.__keypress), ('F8', None, 'F9', "F8", None, self.__keypress),
('F9', None, 'F9', "F9", None, self.__keypress), ('F9', None, 'F9', "F9", None, self.__keypress),
('F11', None, 'F11', "F11", None, self.__keypress), ('F11', None, 'F11', "F11", None, self.__keypress),
('<CONTROL>BackSpace', None, '<CONTROL>BackSpace', ('<CONTROL>BackSpace', None, '<CONTROL>BackSpace',
"<CONTROL>BackSpace", None, self.__keypress), "<CONTROL>BackSpace", None, self.__keypress),
('<CONTROL>Delete', None, '<CONTROL>Delete', ('<CONTROL>Delete', None, '<CONTROL>Delete',
"<CONTROL>Delete", None, self.__keypress), "<CONTROL>Delete", None, self.__keypress),
('<CONTROL>Insert', None, '<CONTROL>Insert', ('<CONTROL>Insert', None, '<CONTROL>Insert',
"<CONTROL>Insert", None, self.__keypress), "<CONTROL>Insert", None, self.__keypress),
('F12', None, 'F12', "F12", None, self.__keypress), ('F12', None, 'F12', "F12", None, self.__keypress),
('<CONTROL>J', None, '<CONTROL>J', ('<CONTROL>J', None, '<CONTROL>J',
"<CONTROL>J", None, self.__keypress), "<CONTROL>J", None, self.__keypress),
('<CONTROL>N', None, '<CONTROL>N', "<CONTROL>N", None, ('<CONTROL>N', None, '<CONTROL>N', "<CONTROL>N", None,
self.__next_view), self.__next_view),
('<CONTROL>P', None, '<CONTROL>P', "<CONTROL>P", None, ('<CONTROL>P', None, '<CONTROL>P', "<CONTROL>P", None,
self.__prev_view), self.__prev_view),
] ]
self._action_action_list = [ self._action_action_list = [
('ScratchPad', gtk.STOCK_PASTE, _('Clip_board'), "<control>b", ('ScratchPad', gtk.STOCK_PASTE, _('Clip_board'), "<control>b",
_("Open the Clipboard dialog"), self.scratchpad), _("Open the Clipboard dialog"), self.scratchpad),
('Import', 'gramps-import', _('_Import...'), "<control>i", None, ('Import', 'gramps-import', _('_Import...'), "<control>i", None,
self.import_data), self.import_data),
('Tools', 'gramps-tools', _('_Tools'), None, ('Tools', 'gramps-tools', _('_Tools'), None,
_("Open the tools dialog"), self.tools_clicked), _("Open the tools dialog"), self.tools_clicked),
('EditMenu', None, _('_Edit')), ('EditMenu', None, _('_Edit')),
('BookMenu', None, _('_Bookmarks')), ('BookMenu', None, _('_Bookmarks')),
('ToolsMenu', None, _('_Tools')), ('ToolsMenu', None, _('_Tools')),
('ConfigView', 'gramps-config', _('_Configure View...'), ('ConfigView', 'gramps-config', _('_Configure View...'),
'<shift><control>c', _('Configure the active view'), '<shift><control>c', _('Configure the active view'),
self.config_view), self.config_view),
] ]
self._file_toggle_action_list = [ self._file_toggle_action_list = [
('Navigator', None, _('_Navigator'), None, None, ('Navigator', None, _('_Navigator'), None, None,
self.navigator_toggle, self.show_navigator ), self.navigator_toggle, self.show_navigator ),
('Toolbar', None, _('_Toolbar'), None, None, self.toolbar_toggle, ('Toolbar', None, _('_Toolbar'), None, None, self.toolbar_toggle,
self.show_toolbar ), self.show_toolbar ),
('Fullscreen', None, _('F_ull Screen'), "F11", None, ('Fullscreen', None, _('F_ull Screen'), "F11", None,
self.fullscreen_toggle, self.fullscreen), self.fullscreen_toggle, self.fullscreen),
] ]
self._undo_action_list = [ self._undo_action_list = [
('Undo', gtk.STOCK_UNDO, _('_Undo'), '<control>z', None, ('Undo', gtk.STOCK_UNDO, _('_Undo'), '<control>z', None,
self.undo), self.undo),
] ]
self._redo_action_list = [ self._redo_action_list = [
('Redo', gtk.STOCK_REDO, _('_Redo'), '<shift><control>z', None, ('Redo', gtk.STOCK_REDO, _('_Redo'), '<shift><control>z', None,
self.redo), self.redo),
] ]
self._undo_history_action_list = [ self._undo_history_action_list = [
('UndoHistory', 'gramps-undo-history', ('UndoHistory', 'gramps-undo-history',
_('Undo History...'), "<control>H", None, self.undo_history), _('Undo History...'), "<control>H", None, self.undo_history),
] ]
def __keypress(self, action): def __keypress(self, action):
""" """
Callback that is called on a keypress. It works by extracting the Callback that is called on a keypress. It works by extracting the
name of the associated action, and passes that to the active page name of the associated action, and passes that to the active page
(current view) so that it can take the associated action. (current view) so that it can take the associated action.
""" """
name = action.get_name() name = action.get_name()
try: try:
self.active_page.call_function(name) self.active_page.call_function(name)
except Exception: except Exception:
self.uistate.push_message(self.dbstate, self.uistate.push_message(self.dbstate,
_("Key %s is not bound") % name) _("Key %s is not bound") % name)
def __next_view(self, action): def __next_view(self, action):
@ -885,7 +885,7 @@ class ViewManager(CLIManager):
self.fileactions.set_sensitive(False) self.fileactions.set_sensitive(False)
self.__build_tools_menu(self._pmgr.get_reg_tools()) self.__build_tools_menu(self._pmgr.get_reg_tools())
self.__build_report_menu(self._pmgr.get_reg_reports()) self.__build_report_menu(self._pmgr.get_reg_reports())
self._pmgr.connect('plugins-reloaded', self._pmgr.connect('plugins-reloaded',
self.__rebuild_report_and_tool_menus) self.__rebuild_report_and_tool_menus)
self.fileactions.set_sensitive(True) self.fileactions.set_sensitive(True)
self.uistate.widget.set_sensitive(True) self.uistate.widget.set_sensitive(True)
@ -908,7 +908,7 @@ class ViewManager(CLIManager):
def do_load_plugins(self): def do_load_plugins(self):
""" """
Loads the plugins at initialization time. The plugin status window is Loads the plugins at initialization time. The plugin status window is
opened on an error if the user has requested. opened on an error if the user has requested.
""" """
# load plugins # load plugins
@ -920,10 +920,10 @@ class ViewManager(CLIManager):
self.__plugin_status() self.__plugin_status()
self.uistate.push_message(self.dbstate, _('Ready')) self.uistate.push_message(self.dbstate, _('Ready'))
def do_reg_plugins(self, dbstate, uistate): def do_reg_plugins(self, dbstate, uistate):
""" """
Register the plugins at initialization time. The plugin status window Register the plugins at initialization time. The plugin status window
is opened on an error if the user has requested. is opened on an error if the user has requested.
""" """
# registering plugins # registering plugins
@ -949,7 +949,7 @@ class ViewManager(CLIManager):
# have each page save anything, if they need to: # have each page save anything, if they need to:
self.__delete_pages() self.__delete_pages()
# save the current window size # save the current window size
(width, height) = self.window.get_size() (width, height) = self.window.get_size()
config.set('interface.width', width) config.set('interface.width', width)
@ -979,10 +979,10 @@ class ViewManager(CLIManager):
if self.dbstate.db.abort_possible: if self.dbstate.db.abort_possible:
dialog = QuestionDialog2( dialog = QuestionDialog2(
_("Abort changes?"), _("Abort changes?"),
_("Aborting changes will return the database to the state " _("Aborting changes will return the database to the state "
"is was before you started this editing session."), "is was before you started this editing session."),
_("Abort changes"), _("Abort changes"),
_("Cancel")) _("Cancel"))
if dialog.run(): if dialog.run():
@ -992,7 +992,7 @@ class ViewManager(CLIManager):
self.quit() self.quit()
else: else:
WarningDialog( WarningDialog(
_("Cannot abandon session's changes"), _("Cannot abandon session's changes"),
_('Changes cannot be completely abandoned because the ' _('Changes cannot be completely abandoned because the '
'number of changes made in the session exceeded the ' 'number of changes made in the session exceeded the '
'limit.')) 'limit.'))
@ -1024,7 +1024,7 @@ class ViewManager(CLIManager):
self.undohistoryactions = self.__init_action_group( self.undohistoryactions = self.__init_action_group(
'UndoHistory', self._undo_history_action_list) 'UndoHistory', self._undo_history_action_list)
self.fileactions = self.__init_action_group( self.fileactions = self.__init_action_group(
'FileWindow', self._file_action_list, 'FileWindow', self._file_action_list,
toggles=self._file_toggle_action_list) toggles=self._file_toggle_action_list)
self.undoactions = self.__init_action_group( self.undoactions = self.__init_action_group(
'Undo', self._undo_action_list, sensitive=False) 'Undo', self._undo_action_list, sensitive=False)
@ -1071,7 +1071,7 @@ class ViewManager(CLIManager):
def navigator_toggle(self, obj): def navigator_toggle(self, obj):
""" """
Set the sidebar based on the value of the toggle button. Save the Set the sidebar based on the value of the toggle button. Save the
results in the configuration settings results in the configuration settings
""" """
if obj.get_active(): if obj.get_active():
@ -1086,7 +1086,7 @@ class ViewManager(CLIManager):
def toolbar_toggle(self, obj): def toolbar_toggle(self, obj):
""" """
Set the toolbar based on the value of the toggle button. Save the Set the toolbar based on the value of the toggle button. Save the
results in the configuration settings results in the configuration settings
""" """
if obj.get_active(): if obj.get_active():
@ -1109,13 +1109,13 @@ class ViewManager(CLIManager):
self.window.unfullscreen() self.window.unfullscreen()
config.set('interface.fullscreen', False) config.set('interface.fullscreen', False)
config.save() config.save()
def get_views(self): def get_views(self):
""" """
Return the view definitions. Return the view definitions.
""" """
return self.views return self.views
def goto_page(self, cat_num, view_num): def goto_page(self, cat_num, view_num):
""" """
Create the page if it doesn't exist and make it the current page. Create the page if it doesn't exist and make it the current page.
@ -1131,10 +1131,10 @@ class ViewManager(CLIManager):
page_num = self.notebook.get_n_pages() page_num = self.notebook.get_n_pages()
self.page_lookup[(cat_num, view_num)] = page_num self.page_lookup[(cat_num, view_num)] = page_num
self.__create_page(page_def[0], page_def[1]) self.__create_page(page_def[0], page_def[1])
self.notebook.set_current_page(page_num) self.notebook.set_current_page(page_num)
return self.pages[page_num] return self.pages[page_num]
def get_category(self, cat_name): def get_category(self, cat_name):
""" """
Return the category number from the given category name. Return the category number from the given category name.
@ -1143,7 +1143,7 @@ class ViewManager(CLIManager):
if cat_name == cat_views[0][0].category[1]: if cat_name == cat_views[0][0].category[1]:
return cat_num return cat_num
return None return None
def __create_page(self, pdata, page_def): def __create_page(self, pdata, page_def):
""" """
Create a new page and set it as the current page. Create a new page and set it as the current page.
@ -1155,7 +1155,7 @@ class ViewManager(CLIManager):
LOG.warn("View '%s' failed to load." % pdata.id) LOG.warn("View '%s' failed to load." % pdata.id)
traceback.print_exc() traceback.print_exc()
return return
try: try:
page_display = page.get_display() page_display = page.get_display()
except: except:
@ -1167,7 +1167,7 @@ class ViewManager(CLIManager):
page.post() page.post()
self.pages.append(page) self.pages.append(page)
# create icon/label for notebook tab (useful for debugging) # create icon/label for notebook tab (useful for debugging)
hbox = gtk.HBox() hbox = gtk.HBox()
image = gtk.Image() image = gtk.Image()
@ -1176,7 +1176,7 @@ class ViewManager(CLIManager):
hbox.add(gtk.Label(pdata.name)) hbox.add(gtk.Label(pdata.name))
hbox.show_all() hbox.show_all()
page_num = self.notebook.append_page(page.get_display(), hbox) page_num = self.notebook.append_page(page.get_display(), hbox)
def view_changed(self, notebook, page, page_num): def view_changed(self, notebook, page, page_num):
""" """
Called when the notebook page is changed. Called when the notebook page is changed.
@ -1194,7 +1194,7 @@ class ViewManager(CLIManager):
if len(last_views) != len(self.views): if len(last_views) != len(self.views):
# If the number of categories has changed then reset the defaults # If the number of categories has changed then reset the defaults
last_views = [''] * len(self.views) last_views = [''] * len(self.views)
last_views[cat_num] = view_id last_views[cat_num] = view_id
config.set('preferences.last-views', last_views) config.set('preferences.last-views', last_views)
config.save() config.save()
@ -1209,11 +1209,11 @@ class ViewManager(CLIManager):
return return
self.__disconnect_previous_page() self.__disconnect_previous_page()
self.active_page = self.pages[page_num] self.active_page = self.pages[page_num]
self.active_page.set_active() self.active_page.set_active()
self.__connect_active_page(page_num) self.__connect_active_page(page_num)
self.uimanager.ensure_update() self.uimanager.ensure_update()
if _GTKOSXAPPLICATION: if _GTKOSXAPPLICATION:
self.macapp.sync_menubar() self.macapp.sync_menubar()
@ -1236,12 +1236,12 @@ class ViewManager(CLIManager):
and removes the old UI components. and removes the old UI components.
""" """
map(self.uimanager.remove_ui, self.merge_ids) map(self.uimanager.remove_ui, self.merge_ids)
if self.active_page: if self.active_page:
self.active_page.set_inactive() self.active_page.set_inactive()
groups = self.active_page.get_actions() groups = self.active_page.get_actions()
for grp in groups: for grp in groups:
if grp in self.uimanager.get_action_groups(): if grp in self.uimanager.get_action_groups():
self.uimanager.remove_action_group(grp) self.uimanager.remove_action_group(grp)
def __connect_active_page(self, page_num): def __connect_active_page(self, page_num):
@ -1258,7 +1258,7 @@ class ViewManager(CLIManager):
for uidef in self.active_page.additional_ui_definitions(): for uidef in self.active_page.additional_ui_definitions():
mergeid = self.uimanager.add_ui_from_string(uidef) mergeid = self.uimanager.add_ui_from_string(uidef)
self.merge_ids.append(mergeid) self.merge_ids.append(mergeid)
configaction = self.actiongroup.get_action('ConfigView') configaction = self.actiongroup.get_action('ConfigView')
if self.active_page.can_configure(): if self.active_page.can_configure():
configaction.set_sensitive(True) configaction.set_sensitive(True)
@ -1275,7 +1275,7 @@ class ViewManager(CLIManager):
if infotxt: if infotxt:
InfoDialog(_('Import Statistics'), infotxt, self.window) InfoDialog(_('Import Statistics'), infotxt, self.window)
self.__post_load() self.__post_load()
def __open_activate(self, obj): def __open_activate(self, obj):
""" """
Called when the Open button is clicked, opens the DbManager Called when the Open button is clicked, opens the DbManager
@ -1305,12 +1305,12 @@ class ViewManager(CLIManager):
def _post_load_newdb(self, filename, filetype, title=None): def _post_load_newdb(self, filename, filetype, title=None):
""" """
The method called after load of a new database. The method called after load of a new database.
Inherit CLI method to add GUI part Inherit CLI method to add GUI part
""" """
self._post_load_newdb_nongui(filename, title) self._post_load_newdb_nongui(filename, title)
self._post_load_newdb_gui(filename, filetype, title) self._post_load_newdb_gui(filename, filetype, title)
def _post_load_newdb_gui(self, filename, filetype, title=None): def _post_load_newdb_gui(self, filename, filetype, title=None):
""" """
Called after a new database is loaded to do GUI stuff Called after a new database is loaded to do GUI stuff
@ -1335,9 +1335,9 @@ class ViewManager(CLIManager):
self.__change_page(self.notebook.get_current_page()) self.__change_page(self.notebook.get_current_page())
self.actiongroup.set_visible(True) self.actiongroup.set_visible(True)
self.readonlygroup.set_visible(True) self.readonlygroup.set_visible(True)
self.recent_manager.build() self.recent_manager.build()
# Call common __post_load method for GUI update after a change # Call common __post_load method for GUI update after a change
self.__post_load() self.__post_load()
@ -1352,7 +1352,7 @@ class ViewManager(CLIManager):
('Undo', gtk.STOCK_UNDO, label, '<control>z', None, self.undo)]) ('Undo', gtk.STOCK_UNDO, label, '<control>z', None, self.undo)])
else: else:
self.undoactions.add_actions([ self.undoactions.add_actions([
('Undo', gtk.STOCK_UNDO, _('_Undo'), ('Undo', gtk.STOCK_UNDO, _('_Undo'),
'<control>z', None, self.undo)]) '<control>z', None, self.undo)])
self.undoactions.set_sensitive(False) self.undoactions.set_sensitive(False)
self.uimanager.insert_action_group(self.undoactions, 1) self.uimanager.insert_action_group(self.undoactions, 1)
@ -1365,11 +1365,11 @@ class ViewManager(CLIManager):
self.redoactions = gtk.ActionGroup('Redo') self.redoactions = gtk.ActionGroup('Redo')
if label: if label:
self.redoactions.add_actions([ self.redoactions.add_actions([
('Redo', gtk.STOCK_REDO, label, '<shift><control>z', ('Redo', gtk.STOCK_REDO, label, '<shift><control>z',
None, self.redo)]) None, self.redo)])
else: else:
self.redoactions.add_actions([ self.redoactions.add_actions([
('Redo', gtk.STOCK_UNDO, _('_Redo'), ('Redo', gtk.STOCK_UNDO, _('_Redo'),
'<shift><control>z', None, self.redo)]) '<shift><control>z', None, self.redo)])
self.redoactions.set_sensitive(False) self.redoactions.set_sensitive(False)
self.uimanager.insert_action_group(self.redoactions, 1) self.uimanager.insert_action_group(self.redoactions, 1)
@ -1398,12 +1398,12 @@ class ViewManager(CLIManager):
except AttributeError: except AttributeError:
# Let it go: history window does not exist # Let it go: history window does not exist
return return
def quick_backup(self, obj): def quick_backup(self, obj):
""" """
Make a quick XML back with or without media. Make a quick XML back with or without media.
""" """
window = gtk.Dialog(_("Gramps XML Backup"), window = gtk.Dialog(_("Gramps XML Backup"),
self.uistate.window, self.uistate.window,
gtk.DIALOG_DESTROY_WITH_PARENT, None) gtk.DIALOG_DESTROY_WITH_PARENT, None)
window.set_size_request(400, -1) window.set_size_request(400, -1)
@ -1424,7 +1424,7 @@ class ViewManager(CLIManager):
hbox.pack_start(path_entry, True) hbox.pack_start(path_entry, True)
file_entry = gtk.Entry() file_entry = gtk.Entry()
button = gtk.Button() button = gtk.Button()
button.connect("clicked", button.connect("clicked",
lambda widget: self.select_backup_path(widget, path_entry)) lambda widget: self.select_backup_path(widget, path_entry))
image = gtk.Image() image = gtk.Image()
image.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON) image.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON)
@ -1439,7 +1439,7 @@ class ViewManager(CLIManager):
label.set_alignment(0, .5) label.set_alignment(0, .5)
hbox.pack_start(label, False) hbox.pack_start(label, False)
struct_time = time.localtime() struct_time = time.localtime()
file_entry.set_text(config.get('paths.quick-backup-filename') % file_entry.set_text(config.get('paths.quick-backup-filename') %
{"filename": self.dbstate.db.get_dbname(), {"filename": self.dbstate.db.get_dbname(),
"year": struct_time.tm_year, "year": struct_time.tm_year,
"month": struct_time.tm_mon, "month": struct_time.tm_mon,
@ -1470,7 +1470,7 @@ class ViewManager(CLIManager):
label.set_size_request(90, -1) label.set_size_request(90, -1)
label.set_alignment(0, .5) label.set_alignment(0, .5)
hbox.pack_start(label, False) hbox.pack_start(label, False)
include = gtk.RadioButton(None, "%s (%s %s)" % (_("Include"), include = gtk.RadioButton(None, "%s (%s %s)" % (_("Include"),
mbytes, _("Megabyte|MB"))) mbytes, _("Megabyte|MB")))
exclude = gtk.RadioButton(include, _("Exclude")) exclude = gtk.RadioButton(include, _("Exclude"))
include.connect("toggled", lambda widget: self.media_toggle(widget, file_entry)) include.connect("toggled", lambda widget: self.media_toggle(widget, file_entry))
@ -1491,17 +1491,17 @@ class ViewManager(CLIManager):
filename = filename.encode(sys.getfilesystemencoding()) filename = filename.encode(sys.getfilesystemencoding())
if include.get_active(): if include.get_active():
from ExportPkg import PackageWriter from ExportPkg import PackageWriter
writer = PackageWriter(self.dbstate.db, filename, writer = PackageWriter(self.dbstate.db, filename,
msg_callback=lambda m1, m2: ErrorDialog(m1[0], m1[1]), msg_callback=lambda m1, m2: ErrorDialog(m1[0], m1[1]),
callback=self.pulse_progressbar) callback=self.pulse_progressbar)
writer.export() writer.export()
else: else:
from ExportXml import XmlWriter from ExportXml import XmlWriter
writer = XmlWriter(self.dbstate.db, writer = XmlWriter(self.dbstate.db,
msg_callback=lambda m1, m2: ErrorDialog(m1[0], m1[1]), msg_callback=lambda m1, m2: ErrorDialog(m1[0], m1[1]),
callback=self.pulse_progressbar, callback=self.pulse_progressbar,
strip_photos=0, compress=1) strip_photos=0, compress=1)
writer.write(filename) writer.write(filename)
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(0)
self.uistate.progress.hide() self.uistate.progress.hide()
filename = Utils.get_unicode_path_from_env_var(filename) filename = Utils.get_unicode_path_from_env_var(filename)
@ -1576,7 +1576,7 @@ class ViewManager(CLIManager):
try: try:
ToolPluginDialog(self.dbstate, self.uistate, []) ToolPluginDialog(self.dbstate, self.uistate, [])
except Errors.WindowActiveError: except Errors.WindowActiveError:
return return
def scratchpad(self, obj): def scratchpad(self, obj):
""" """
@ -1615,7 +1615,7 @@ class ViewManager(CLIManager):
Displays the Undo history window Displays the Undo history window
""" """
try: try:
self.undo_history_window = UndoHistory.UndoHistory(self.dbstate, self.undo_history_window = UndoHistory.UndoHistory(self.dbstate,
self.uistate) self.uistate)
except Errors.WindowActiveError: except Errors.WindowActiveError:
return return
@ -1654,7 +1654,7 @@ class ViewManager(CLIManager):
self.tool_menu_ui_id = self.uistate.uimanager.add_ui_from_string(uidef) self.tool_menu_ui_id = self.uistate.uimanager.add_ui_from_string(uidef)
self.uimanager.insert_action_group(self.toolactions, 1) self.uimanager.insert_action_group(self.toolactions, 1)
self.uistate.uimanager.ensure_update() self.uistate.uimanager.ensure_update()
def __build_report_menu(self, report_menu_list): def __build_report_menu(self, report_menu_list):
""" """
Builds a new reports menu Builds a new reports menu
@ -1664,7 +1664,7 @@ class ViewManager(CLIManager):
self.uistate.uimanager.remove_ui(self.report_menu_ui_id) self.uistate.uimanager.remove_ui(self.report_menu_ui_id)
self.reportactions = gtk.ActionGroup('ReportWindow') self.reportactions = gtk.ActionGroup('ReportWindow')
(uidef, actions) = self.build_plugin_menu( (uidef, actions) = self.build_plugin_menu(
'ReportsMenu', report_menu_list, standalone_categories, 'ReportsMenu', report_menu_list, standalone_categories,
make_plugin_callback) make_plugin_callback)
self.reportactions.add_actions(actions) self.reportactions.add_actions(actions)
self.report_menu_ui_id = self.uistate.uimanager.add_ui_from_string(uidef) self.report_menu_ui_id = self.uistate.uimanager.add_ui_from_string(uidef)
@ -1678,7 +1678,7 @@ class ViewManager(CLIManager):
actions = [] actions = []
ofile = StringIO() ofile = StringIO()
ofile.write('<ui><menubar name="MenuBar"><menu action="%s">' % text) ofile.write('<ui><menubar name="MenuBar"><menu action="%s">' % text)
menu = gtk.Menu() menu = gtk.Menu()
menu.show() menu.show()
@ -1704,7 +1704,7 @@ class ViewManager(CLIManager):
new_key = pdata.id.replace(' ', '-') new_key = pdata.id.replace(' ', '-')
menu_name = ("%s...") % pdata.name menu_name = ("%s...") % pdata.name
ofile.write('<menuitem action="%s"/>' % new_key) ofile.write('<menuitem action="%s"/>' % new_key)
actions.append((new_key, None, menu_name, None, None, actions.append((new_key, None, menu_name, None, None,
func(pdata, self.dbstate, self.uistate))) func(pdata, self.dbstate, self.uistate)))
ofile.write('</menu>') ofile.write('</menu>')
@ -1720,7 +1720,7 @@ class ViewManager(CLIManager):
new_key = pdata.id.replace(' ', '-') new_key = pdata.id.replace(' ', '-')
menu_name = ("%s...") % pdata.name menu_name = ("%s...") % pdata.name
ofile.write('<menuitem action="%s"/>' % new_key) ofile.write('<menuitem action="%s"/>' % new_key)
actions.append((new_key, None, menu_name, None, None, actions.append((new_key, None, menu_name, None, None,
func(pdata, self.dbstate, self.uistate))) func(pdata, self.dbstate, self.uistate)))
ofile.write('</menu>') ofile.write('</menu>')
@ -1791,18 +1791,18 @@ def run_plugin(pdata, dbstate, uistate):
if not mod: if not mod:
#import of plugin failed #import of plugin failed
ErrorDialog( ErrorDialog(
_('Failed Loading Plugin'), _('Failed Loading Plugin'),
_('The plugin did not load. See Help Menu, Plugin Manager' _('The plugin did not load. See Help Menu, Plugin Manager'
' for more info.\nUse http://bugs.gramps-project.org to' ' for more info.\nUse http://bugs.gramps-project.org to'
' submit bugs of official plugins, contact the plugin ' ' submit bugs of official plugins, contact the plugin '
'author otherwise. ')) 'author otherwise. '))
return return
if pdata.ptype == REPORT: if pdata.ptype == REPORT:
report(dbstate, uistate, uistate.get_active('Person'), report(dbstate, uistate, uistate.get_active('Person'),
getattr(mod, pdata.reportclass), getattr(mod, pdata.reportclass),
getattr(mod, pdata.optionclass), getattr(mod, pdata.optionclass),
pdata.name, pdata.id, pdata.name, pdata.id,
pdata.category, pdata.require_active, pdata.category, pdata.require_active,
) )
else: else:
@ -1821,7 +1821,7 @@ def make_plugin_callback(pdata, dbstate, uistate):
def get_available_views(): def get_available_views():
""" """
Query the views and determine what views to show and in which order Query the views and determine what views to show and in which order
:Returns: a list of lists containing tuples (view_id, viewclass) :Returns: a list of lists containing tuples (view_id, viewclass)
""" """
pmgr = GuiPluginManager.get_instance() pmgr = GuiPluginManager.get_instance()
@ -1832,13 +1832,13 @@ def get_available_views():
if not mod or not hasattr(mod, pdata.viewclass): if not mod or not hasattr(mod, pdata.viewclass):
#import of plugin failed #import of plugin failed
ErrorDialog( ErrorDialog(
_('Failed Loading View'), _('Failed Loading View'),
_('The view %(name)s did not load. See Help Menu, Plugin Manager' _('The view %(name)s did not load. See Help Menu, Plugin Manager'
' for more info.\nUse http://bugs.gramps-project.org to' ' for more info.\nUse http://bugs.gramps-project.org to'
' submit bugs of official views, contact the view ' ' submit bugs of official views, contact the view '
'author (%(firstauthoremail)s) otherwise. ') % { 'author (%(firstauthoremail)s) otherwise. ') % {
'name': pdata.name, 'name': pdata.name,
'firstauthoremail': pdata.authors_email[0] if 'firstauthoremail': pdata.authors_email[0] if
pdata.authors_email else '...'}) pdata.authors_email else '...'})
continue continue
viewclass = getattr(mod, pdata.viewclass) viewclass = getattr(mod, pdata.viewclass)
@ -1848,7 +1848,7 @@ def get_available_views():
viewstoshow[pdata.category[0]].insert(0, (pdata, viewclass) ) viewstoshow[pdata.category[0]].insert(0, (pdata, viewclass) )
else: else:
viewstoshow[pdata.category[0]].append( (pdata, viewclass) ) viewstoshow[pdata.category[0]].append( (pdata, viewclass) )
# First, get those in order defined, if exists: # First, get those in order defined, if exists:
resultorder = [viewstoshow[cat] resultorder = [viewstoshow[cat]
for cat in config.get("interface.view-categories") for cat in config.get("interface.view-categories")
@ -1864,7 +1864,7 @@ def views_to_show(views, use_last=True):
""" """
Determine based on preference setting which views should be shown Determine based on preference setting which views should be shown
""" """
current_cat = 0 current_cat = 0
current_cat_view = 0 current_cat_view = 0
default_cat_views = [0] * len(views) default_cat_views = [0] * len(views)
if use_last: if use_last:
@ -1885,6 +1885,6 @@ def views_to_show(views, use_last=True):
default_cat_views[indexcat] = cat_view default_cat_views[indexcat] = cat_view
cat_view += 1 cat_view += 1
if not found: if not found:
current_cat = 0 current_cat = 0
current_cat_view = 0 current_cat_view = 0
return current_cat, current_cat_view, default_cat_views return current_cat, current_cat_view, default_cat_views