GEPS 014: Plugin registration and management

Also views are now plugins belonging to view category


svn: r13528
This commit is contained in:
Benny Malengier 2009-11-08 16:41:49 +00:00
parent eea7ba35c7
commit 19522ec975
51 changed files with 588 additions and 354 deletions

View File

@ -199,7 +199,14 @@ src/gui/views/pageview.py
# gui/views/treemodels - the GUI views package
src/gui/views/treemodels/__init__.py
src/gui/views/treemodels/eventmodel.py
src/gui/views/treemodels/familymodel.py
src/gui/views/treemodels/flatbasemodel.py
src/gui/views/treemodels/mediamodel.py
src/gui/views/treemodels/peoplemodel.py
src/gui/views/treemodels/placemodel.py
src/gui/views/treemodels/repomodel.py
src/gui/views/treemodels/sourcemodel.py
src/gui/views/treemodels/treebasemodel.py
# Simple API
@ -218,21 +225,6 @@ src/Merge/_MergePerson.py
src/Merge/_MergePlace.py
src/Merge/_MergeSource.py
# DataViews package
src/DataViews/EventView.py
src/DataViews/FamilyList.py
src/DataViews/GeoView.py
src/DataViews/__init__.py
src/DataViews/MediaView.py
src/DataViews/GrampletView.py
src/DataViews/NoteView.py
src/DataViews/PedigreeView.py
src/DataViews/PersonView.py
src/DataViews/PlaceView.py
src/DataViews/RelationView.py
src/DataViews/RepositoryView.py
src/DataViews/SourceView.py
# DateHandler package
src/DateHandler/_Date_cs.py
src/DateHandler/_Date_de.py
@ -259,16 +251,6 @@ src/docgen/OpenSpreadSheet.py
src/docgen/SpreadSheetDoc.py
src/docgen/TextBufDoc.py
# DisplayModels package
src/DisplayModels/_EventModel.py
src/DisplayModels/_FamilyModel.py
src/DisplayModels/_MediaModel.py
src/DisplayModels/_PeopleModel.py
src/DisplayModels/_PlaceModel.py
src/DisplayModels/_RepositoryModel.py
src/DisplayModels/_SourceModel.py
src/DisplayModels/__init__.py
# DisplayTabs package
src/DisplayTabs/_AddrEmbedList.py
src/DisplayTabs/_AddressModel.py
@ -546,6 +528,23 @@ src/plugins/tool/SoundGen.py
src/plugins/tool/tools.gpr.py
src/plugins/tool/Verify.py
#plugins/view directory
src/plugins/view/eventview.py
src/plugins/view/familyview.py
src/plugins/view/geoview.py
src/plugins/view/geoview.gpr.py
src/plugins/view/grampletview.py
src/plugins/view/htmlrenderer
src/plugins/view/mediaview.py
src/plugins/view/noteview.py
src/plugins/view/pedigreeview.py
src/plugins/view/personview.py
src/plugins/view/placeview.py
src/plugins/view/relview.py
src/plugins/view/repoview.py
src/plugins/view/sourceview.py
src/plugins/view/view.gpr.py
# plugins/webreport directory
src/plugins/webreport/NarrativeWeb.py
src/plugins/webreport/WebCal.py

View File

@ -1,36 +0,0 @@
# This is the src/DataViews level Makefile for Gramps
# We could use GNU make's ':=' syntax for nice wildcard use,
# but that is not necessarily portable.
# If not using GNU make, then list all .py files individually
pkgdatadir = $(datadir)/@PACKAGE@/DataViews
pkgdata_PYTHON = \
__init__.py\
EventView.py\
FamilyList.py\
GeoView.py\
GrampletView.py\
MediaView.py\
NoteView.py\
PedigreeView.py\
PersonView.py\
PlaceView.py\
RelationView.py\
RepositoryView.py\
SourceView.py
pkgpyexecdir = @pkgpyexecdir@/DataViews
pkgpythondir = @pkgpythondir@/DataViews
# Clean up all the byte-compiled files
MOSTLYCLEANFILES = *pyc *pyo
GRAMPS_PY_MODPATH = "../"
pycheck:
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
pychecker $(pkgdata_PYTHON));
pylint:
PYTHONPATH=$(GRAMPS_PY_MODPATH) pylint $(pkgdata_PYTHON) > pylint.out

View File

@ -1,82 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2001-2005 Donald N. Allingham
#
# 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$
"""
Package init for the DataViews package.
"""
from GrampletView import GrampletView
from PersonView import PersonView
from RelationView import RelationshipView
from FamilyList import FamilyListView
from PedigreeView import PedigreeView
from EventView import EventView
from SourceView import SourceView
from PlaceView import PlaceView
from MediaView import MediaView
from RepositoryView import RepositoryView
from NoteView import NoteView
geopresent = True
try:
from GeoView import HtmlView, GeoView
except:
geopresent = False
try:
import config
dv = config.get('interface.data-views') # list of strings
#remove GeoView so we do not try to eval it if import fails
if not geopresent and dv.count('GeoView') > 0:
dv.remove('GeoView')
DATA_VIEWS = [eval(view) for view in dv]
#add or remove GeoView if config says so
if geopresent and config.get('preferences.geoview') and \
not GeoView in DATA_VIEWS:
DATA_VIEWS.append(GeoView)
config.get('interface.data-views').append('GeoView')
elif geopresent and not config.get('preferences.geoview') and \
GeoView in DATA_VIEWS:
DATA_VIEWS.remove(GeoView)
config.get('interface.data-views').remove('GeoView')
except AttributeError:
# Fallback if bad config line, or if no Config system
DATA_VIEWS = [
GrampletView,
PersonView,
RelationshipView,
FamilyListView,
PedigreeView,
EventView,
SourceView,
PlaceView,
MediaView,
RepositoryView,
NoteView,
]
if geopresent:
DATA_VIEWS.append(GeoView)
def get_views():
"""
Return a list of PageView instances, in order
"""
return DATA_VIEWS

View File

@ -1,26 +0,0 @@
# This is the src/DisplayModels level Makefile for Gramps
pkgdatadir = $(datadir)/@PACKAGE@/DisplayModels
pkgdata_PYTHON = \
__init__.py \
_EventModel.py \
_FamilyModel.py \
_MediaModel.py \
_PeopleModel.py \
_PlaceModel.py \
_RepositoryModel.py \
_NoteModel.py \
_SourceModel.py
pkgpyexecdir = @pkgpyexecdir@/DisplayModels
pkgpythondir = @pkgpythondir@/DisplayModels
# Clean up all the byte-compiled files
MOSTLYCLEANFILES = *pyc *pyo
GRAMPS_PY_MODPATH = "../"
pycheck:
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
pychecker $(pkgdata_PYTHON));

View File

@ -1,29 +0,0 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2006 Donald N. Allingham
#
# 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$
from _PeopleModel import PeopleModel
from _FamilyModel import FamilyModel
from _EventModel import EventModel
from _SourceModel import SourceModel
from _PlaceModel import PlaceModel
from _MediaModel import MediaModel
from _RepositoryModel import RepositoryModel
from _NoteModel import NoteModel

View File

@ -151,10 +151,6 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
MarkupLabel(_('Researcher')))
panel.append_page(self.add_color_panel(),
MarkupLabel(_('Marker Colors')))
import DataViews
if DataViews.geopresent:
panel.append_page(self.add_geoview_panel(),
MarkupLabel(_('Internet Maps')))
self.window.show_all()
self.show()
@ -261,32 +257,6 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
for widget in [self.comp_color, self.todo_color, self.custom_color]:
widget.emit('color-set')
def add_geoview_panel(self):
table = gtk.Table(3, 8)
table.set_border_width(12)
table.set_col_spacings(12)
table.set_row_spacings(6)
self.add_text(
table, _('You need a broadband internet connection to use '
'Internet mapping applications from within GRAMPS')
, 0)
self.add_checkbox(
table, _('Add GeoView to GRAMPS showing internet maps based on '
'your data.'),
1, 'preferences.geoview')
self.add_text(
table, _('GeoView uses OpenStreetMap and Google maps provider.'),
2)
self.add_text(
table, _('You need to restart GRAMPS for above settings to take'
' effect'), 5)
return table
def add_name_panel(self):
"""
Name format settings panel

View File

@ -5,10 +5,8 @@ SUBDIRS = \
BasicUtils \
cli \
data \
DataViews \
DateHandler \
DisplayTabs \
DisplayModels \
docgen \
Editors \
Filters \

View File

@ -33,7 +33,7 @@ from gettext import gettext as _
# gramps modules
#
#-------------------------------------------------------------------------
from DisplayModels import EventModel
from gui.views.treemodels import EventModel
from _BaseSelector import BaseSelector
import config

View File

@ -33,7 +33,7 @@ from gettext import gettext as _
# gramps modules
#
#-------------------------------------------------------------------------
from DisplayModels import FamilyModel
from gui.views.treemodels import FamilyModel
from _BaseSelector import BaseSelector
import config

View File

@ -36,7 +36,7 @@ from gettext import gettext as _
# GRAMPS Modules
#
#-------------------------------------------------------------------------
from DisplayModels import NoteModel
from gui.views.treemodels import NoteModel
from _BaseSelector import BaseSelector
import config

View File

@ -47,7 +47,7 @@ import gtk
import const
from Utils import media_path_full
import ThumbNails
from DisplayModels import MediaModel
from gui.views.treemodels import MediaModel
from _BaseSelector import BaseSelector
import config

View File

@ -34,7 +34,7 @@ import gtk
# gramps modules
#
#-------------------------------------------------------------------------
from DisplayModels import PeopleModel
from gui.views.treemodels import PeopleModel
from _BaseSelector import BaseSelector
import config

View File

@ -33,7 +33,7 @@ from gettext import gettext as _
# gramps modules
#
#-------------------------------------------------------------------------
from DisplayModels import PlaceModel
from gui.views.treemodels import PlaceModel
from _BaseSelector import BaseSelector
import config

View File

@ -33,7 +33,7 @@ from gettext import gettext as _
# gramps modules
#
#-------------------------------------------------------------------------
from DisplayModels import RepositoryModel
from gui.views.treemodels import RepositoryModel
from _BaseSelector import BaseSelector
import config

View File

@ -33,7 +33,7 @@ from gettext import gettext as _
# gramps modules
#
#-------------------------------------------------------------------------
from DisplayModels import SourceModel
from gui.views.treemodels import SourceModel
from _BaseSelector import BaseSelector
import config

View File

@ -612,11 +612,10 @@ register('preferences.family-details', True)
register('preferences.family-siblings', True)
register('preferences.family-warn', True)
register('preferences.fprefix', 'F%04d')
register('preferences.geoview', False)
register('preferences.hide-ep-msg', False)
register('preferences.invalid-date-format', "<b>%s</b>")
register('preferences.iprefix', 'I%04d')
register('preferences.last-view', 0)
register('preferences.last-view', '')
register('preferences.name-format', 1)
register('preferences.no-given-text', "[%s]" % _("Missing Given Name"))
register('preferences.no-record-text', "[%s]" % _("Missing Record"))

View File

@ -29,7 +29,11 @@ from _pluginreg import (PluginData, PluginRegister, REPORT, TOOL,
TOOL_UTILS, CATEGORY_QR_MISC, CATEGORY_QR_PERSON,
CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_NOTE,
CATEGORY_QR_DATE, PTYPE_STR )
CATEGORY_QR_DATE, PTYPE_STR,
VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY, VIEW_EVENT,
VIEW_PLACE, VIEW_SOURCE, VIEW_REPO, VIEW_MEDIA, VIEW_NOTE,
VIEW_GEO
)
from _manager import BasePluginManager
from _import import ImportPlugin
from _export import ExportPlugin

View File

@ -225,6 +225,11 @@ class BasePluginManager(object):
"""
return self.__pgr.quickreport_plugins()
def get_reg_views(self):
""" Return list of registered views
"""
return self.__pgr.view_plugins()
def get_reg_mapservices(self):
""" Return list of registered mapservices
"""

View File

@ -102,6 +102,22 @@ TOOL_UTILS = 4
TOOL_CAT = [ TOOL_DEBUG, TOOL_ANAL, TOOL_DBPROC, TOOL_DBFIX, TOOL_REVCTL,
TOOL_UTILS]
#possible view categories
VIEW_MISC = 0
VIEW_PERSON = 1
VIEW_REL = 2
VIEW_FAMILY = 3
VIEW_EVENT = 4
VIEW_PLACE = 5
VIEW_SOURCE = 6
VIEW_REPO = 7
VIEW_MEDIA = 8
VIEW_NOTE = 9
VIEW_GEO = 10
VIEW_CAT = [VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY, VIEW_EVENT,
VIEW_PLACE, VIEW_SOURCE, VIEW_REPO, VIEW_MEDIA, VIEW_NOTE,
VIEW_GEO]
#possible quickreport categories
CATEGORY_QR_MISC = -1
CATEGORY_QR_PERSON = 0
@ -178,11 +194,12 @@ class PluginData(object):
.. attribute:: report_modes
The report modes: list of REPORT_MODE_GUI ,REPORT_MODE_BKI,REPORT_MODE_CLI
Attributes for REPORT and TOOL and QUICKREPORT plugins
Attributes for REPORT and TOOL and QUICKREPORT and VIEW plugins
.. attribute:: category
Or the report category the plugin belongs to, default=CATEGORY_TEXT
or the tool category a plugin belongs to, default=TOOL_UTILS
or the quickreport category a plugin belongs to, default=CATEGORY_QR_PERSON
or the view category a plugin belongs to, default=VIEW_MISC
Attributes for REPORT and TOOL plugins
.. attribute:: optionclass
@ -243,6 +260,11 @@ class PluginData(object):
Title to use for the gramplet, default = 'Gramplet'
.. attribute:: help_url
The URL where documentation for the URL can be found
Attributes for VIEW plugins
.. attribute:: viewclass
A class of type ViewCreator that holds the needed info of the
view to be created: icon, viewclass that derives from pageview, ...
"""
def __init__(self):
@ -296,6 +318,8 @@ class PluginData(object):
self._expand = False
self._gramplet_title = _('Gramplet')
self._help_url = None
#VIEW attr
self._viewclass = None
def _set_id(self, id):
self._id = id
@ -353,6 +377,8 @@ class PluginData(object):
self._category = TOOL_UTILS
elif self._ptype == QUICKREPORT:
self._category = CATEGORY_QR_PERSON
elif self._ptype == VIEW:
self._category = VIEW_MISC
#if self._ptype == DOCGEN:
# self._load_on_reg = True
@ -463,8 +489,9 @@ class PluginData(object):
#REPORT OR TOOL OR QUICKREPORT attributes
def _set_category(self, category):
if not (self._ptype == REPORT or self._ptype == TOOL or
self._ptype == QUICKREPORT):
raise ValueError, 'category may only be set for REPORT/TOOL plugins'
self._ptype == QUICKREPORT or self._ptype == VIEW):
raise ValueError, 'category may only be set for ' \
'REPORT/TOOL/QUICKREPORT/VIEW plugins'
self._category = category
def _get_category(self):
@ -690,6 +717,16 @@ class PluginData(object):
gramplet_title = property(_get_gramplet_title, _set_gramplet_title)
help_url = property(_get_help_url, _set_help_url)
def _set_viewclass(self, viewclass):
if not self._ptype == VIEW:
raise ValueError, 'viewclass may only be set for VIEW plugins'
self._viewclass = viewclass
def _get_viewclass(self):
return self._viewclass
viewclass = property(_get_viewclass, _set_viewclass)
def newplugin():
"""
Function to create a new plugindata object, add it to list of
@ -808,6 +845,17 @@ class PluginRegister(object):
'TOOL_DBFIX': TOOL_DBFIX,
'TOOL_REVCTL': TOOL_REVCTL,
'TOOL_UTILS': TOOL_UTILS,
'VIEW_MISC': VIEW_MISC,
'VIEW_PERSON': VIEW_PERSON,
'VIEW_REL': VIEW_REL,
'VIEW_FAMILY': VIEW_FAMILY,
'VIEW_EVENT': VIEW_EVENT,
'VIEW_PLACE': VIEW_PLACE,
'VIEW_SOURCE': VIEW_SOURCE,
'VIEW_REPO': VIEW_REPO,
'VIEW_MEDIA': VIEW_MEDIA,
'VIEW_NOTE': VIEW_NOTE,
'VIEW_GEO': VIEW_GEO,
'CATEGORY_QR_MISC': CATEGORY_QR_MISC,
'CATEGORY_QR_PERSON': CATEGORY_QR_PERSON,
'CATEGORY_QR_FAMILY': CATEGORY_QR_FAMILY,

View File

@ -61,7 +61,14 @@ import gobject
from QuestionDialog import ErrorDialog
import config
import Utils
from gui.pluginmanager import GuiPluginManager
from gen.plug import (VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY,
VIEW_EVENT, VIEW_PLACE, VIEW_SOURCE, VIEW_REPO, VIEW_MEDIA,
VIEW_NOTE, VIEW_GEO)
DEFAULT_SIDEBAR_ORDER = (VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY,
VIEW_EVENT, VIEW_PLACE, VIEW_SOURCE, VIEW_REPO, VIEW_MEDIA,
VIEW_NOTE, VIEW_GEO)
#-------------------------------------------------------------------------
#
# Functions
@ -221,6 +228,41 @@ def _display_welcome_message():
# config.set('behavior.betawarn', True)
config.set('behavior.betawarn', config.get('behavior.betawarn'))
def construct_view_order():
"""
Query the views and determine what views to show and in which order
:Returns: a list of lists containing tuples (view_id, viewclass)
"""
pmgr = GuiPluginManager.get_instance()
view_list = pmgr.get_reg_views()
viewstoshow = {}
for pdata in view_list:
mod = pmgr.load_plugin(pdata)
if not mod:
#import of plugin failed
ErrorDialog(
_('Failed Loading View'),
_('The view %(name)s did not load. See Help Menu, Plugin Status'
' for more info.\nUse http://bugs.gramps-project.org to'
' submit bugs of official views, contact the view '
'author (%(firstauthoremail)s) otherwise. ') % {
'name': pdata.name,
'firstauthoremail': pdata.authors_email[0] if
pdata.authors_email else '...'})
continue
viewclass = eval('mod.' + pdata.viewclass)
if pdata.category in viewstoshow:
viewstoshow[pdata.category].append((pdata.id, viewclass))
else:
viewstoshow[pdata.category] = [(pdata.id, viewclass)]
resultorder = []
for item in DEFAULT_SIDEBAR_ORDER:
if item in viewstoshow:
resultorder.append(viewstoshow[item])
return resultorder
#-------------------------------------------------------------------------
#
# Main Gramps class
@ -237,18 +279,18 @@ class Gramps(object):
def __init__(self, argparser):
import DbState
from viewmanager import ViewManager
import DataViews
from cli.arghandler import ArgHandler
import TipOfDay
register_stock_icons()
dbstate = DbState.DbState()
self.vm = ViewManager(dbstate)
for view in DataViews.get_views():
self.vm.register_view(view)
self.vm = ViewManager(dbstate, DEFAULT_SIDEBAR_ORDER)
self.vm.init_interface()
#now we determine which views are present, which to show, and we
#instruct the viewmanager to show them
vieworder = construct_view_order()
self.vm.init_interface(vieworder)
#act based on the given arguments
ah = ArgHandler(dbstate, argparser, self.vm, self.argerrorfunc,

View File

@ -144,6 +144,12 @@ class GuiPluginManager(gen.utils.Callback):
"""
return [plg for plg in self.basemgr.get_reg_tools(gui)
if plg.id not in self.__hidden_plugins]
def get_reg_views(self):
""" Return list of non hidden registered views
"""
return [plg for plg in self.basemgr.get_reg_views()
if plg.id not in self.__hidden_plugins]
def get_reg_quick_reports(self):
""" Return list of non hidden registered quick reports

View File

@ -199,10 +199,15 @@ class ViewManager(CLIManager):
into the gtk.UIManager to control all menus and actions.
The ViewManager controls the various Views within the GRAMPS programs.
Views are organised in categories. The categories can be accessed via
a sidebar. Within a category, the different views are accesible via the
toolbar of view menu.
A View is a particular way of looking a information in the GRAMPS main
window. Each view is separate from the others, and has no knowledge of
the others. All Views are held in the DisplayViews module. Examples of
current views include:
the others.
Examples of current views include:
- Person View
- Relationship View
@ -212,11 +217,17 @@ class ViewManager(CLIManager):
The View Manager does not have to know the number of views, the type of
views, or any other details about the views. It simply provides the
method of containing each view, and switching between the views.
"""
def __init__(self, dbstate):
def __init__(self, dbstate, view_category_order):
"""
The viewmanager is initialiste with a dbstate on which GRAMPS is
working, and a fixed view_category_order, which is the order in which
the view categories are accessible in the sidebar.
"""
CLIManager.__init__(self, dbstate, False)
self.view_category_order = view_category_order
#set pluginmanager to GUI one
self._pmgr = GuiPluginManager.get_instance()
self.page_is_changing = False
@ -277,6 +288,7 @@ class ViewManager(CLIManager):
self.notebook.set_scrollable(True)
self.notebook.set_show_tabs(False)
self.notebook.show()
self.notebook_cat = []
self.__init_lists()
self.__build_ui_manager()
@ -546,10 +558,11 @@ class ViewManager(CLIManager):
else:
self.notebook.set_current_page(new_page)
def init_interface(self):
def init_interface(self, vieworder):
"""
Initialize the interface, creating the pages
Initialize the interface, creating the pages as given in vieworder
"""
self.views = vieworder
self.__init_lists()
self.__create_pages()
@ -799,12 +812,6 @@ class ViewManager(CLIManager):
config.set('interface.fullscreen', False)
config.save()
def register_view(self, view):
"""
Allow other objects to register a view with the View Manager
"""
self.views.append(view)
def __switch_page_on_dnd(self, widget, context, xpos, ypos, time, page_no):
"""
Switches the page based on drag and drop
@ -818,8 +825,9 @@ class ViewManager(CLIManager):
"""
Calls on_delete() for each view
"""
for page in self.pages:
page.on_delete()
for pages in self.pages:
for page in pages:
page.on_delete()
def __create_pages(self):
"""
@ -831,55 +839,87 @@ class ViewManager(CLIManager):
use_text = config.get('interface.sidebar-text')
index = 0
for page_def in self.views:
page = page_def(self.dbstate, self.uistate)
page_title = page.get_title()
page_stock = page.get_stock()
for cat_views in self.views:
#for every category, we create a button in the sidebar and a main
#workspace in which to show the view
first = True
nr_views = len(cat_views)
self.pages.append([])
for id, page_def in cat_views:
page = page_def(self.dbstate, self.uistate)
page_title = page.get_title()
page_stock = page.get_stock()
if first:
#the first page of this category, used to obtain
#category workspace notebook
notebook = gtk.Notebook()
notebook.set_scrollable(False)
notebook.set_show_tabs(False)
notebook.show()
self.notebook_cat.append(notebook)
# create icon/label for workspace notebook
hbox = gtk.HBox()
image = gtk.Image()
image.set_from_stock(page_stock, gtk.ICON_SIZE_MENU)
hbox.pack_start(image, False)
hbox.add(gtk.Label(page_title))
hbox.show_all()
page_cat = self.notebook.append_page(notebook, hbox)
# Enable view switching during DnD
hbox.drag_dest_set(0, [], 0)
hbox.connect('drag_motion', self.__switch_page_on_dnd,
page_cat)
# create icon/label for notebook
hbox = gtk.HBox()
image = gtk.Image()
image.set_from_stock(page_stock, gtk.ICON_SIZE_MENU)
hbox.pack_start(image, False)
hbox.add(gtk.Label(page_title))
hbox.show_all()
# create the button and add it to the sidebar
button = self.__make_sidebar_button(use_text, index,
page_title, page_stock)
# create notebook page and add to notebook
page.define_actions()
page_display = page.get_display()
page_display.show_all()
page.post()
page_no = self.notebook.append_page(page_display, hbox)
self.pages.append(page)
# Enable view switching during DnD
hbox.drag_dest_set(0, [], 0)
hbox.connect('drag_motion', self.__switch_page_on_dnd, page_no)
index += 1
self.bbox.pack_start(button, False)
self.buttons.append(button)
# Enable view switching during DnD
button.drag_dest_set(0, [], 0)
button.connect('drag_motion', self.__switch_page_on_dnd,
page_cat)
# create the button and add it to the sidebar
button = self.__make_sidebar_button(use_text, index,
page_title, page_stock)
# create view page and add to category notebook
page.define_actions()
page_display = page.get_display()
page_display.show_all()
page.post()
page_no = self.notebook_cat[-1].append_page(page_display,
gtk.Label(page_title))
self.pages[-1].append(page)
index += 1
self.bbox.pack_start(button, False)
self.buttons.append(button)
# Enable view switching during DnD
button.drag_dest_set(0, [], 0)
button.connect('drag_motion', self.__switch_page_on_dnd, page_no)
first = False
current_cat = 0
current_cat_view = 0
use_current = config.get('preferences.use-last-view')
if use_current:
current_page = config.get('preferences.last-view')
if current_page >= len(self.pages):
current_page = 0
else:
current_page = 0
current_page_id = config.get('preferences.last-view')
found = False
for cat_views in self.views:
current_cat_view = 0
for id, page_def in cat_views:
if id == current_page_id:
found = True
break
else:
current_cat_view += 1
if found:
break
current_cat += 1
if not found:
current_cat = 0
current_cat_view = 0
self.active_page = self.pages[current_page]
self.buttons[current_page].set_active(True)
self.active_page = self.pages[current_cat][current_cat_view]
self.buttons[current_cat].set_active(True)
self.active_page.set_active()
self.notebook.set_current_page(current_page)
self.notebook.set_current_page(current_cat)
self.notebook_cat[current_cat].set_current_page(current_cat_view)
def __make_sidebar_button(self, use_text, index, page_title, page_stock):
"""
@ -1018,18 +1058,18 @@ class ViewManager(CLIManager):
"""
if num == -1:
num = self.notebook.get_current_page()
num_view = self.notebook_cat[num].get_current_page()
# set button of current page active
self.__set_active_button(num)
if self.dbstate.open:
self.__disconnect_previous_page()
if len(self.pages) > 0:
self.active_page = self.pages[num]
self.active_page = self.pages[num][num_view]
self.active_page.set_active()
config.set('preferences.last-view', num)
config.set('preferences.last-view', self.views[num][num_view][0])
config.save()
self.__setup_navigation()
@ -1057,7 +1097,6 @@ class ViewManager(CLIManager):
InfoDialog(_('Import Statistics'), infotxt, self.window)
self.__post_load()
def __open_activate(self, obj):
"""
Called when the Open button is clicked, opens the DbManager

View File

@ -213,6 +213,9 @@ class ListView(NavigationView):
self.list.append_column(column)
index += 1
def __build_tree(self):
Utils.profile(self._build_tree)
def build_tree(self):
if self.active:
cput0 = time.clock()

View File

@ -7,7 +7,15 @@ pkgdatadir = $(datadir)/@PACKAGE@/gui/views/treemodels
pkgdata_PYTHON = \
__init__.py \
eventmodel.py \
familymodel.py \
flatbasemodel.py \
mediamodel.py \
notemodel.py \
peoplemodel.py \
placemodel.py \
repomodel.py \
sourcemodel.py \
treebasemodel.py
pkgpyexecdir = @pkgpyexecdir@/gui/views/treemodels

View File

@ -22,3 +22,12 @@
"""
Package init for the treemodels package.
"""
from peoplemodel import PeopleModel
from familymodel import FamilyModel
from eventmodel import EventModel
from sourcemodel import SourceModel
from placemodel import PlaceModel
from mediamodel import MediaModel
from repomodel import RepositoryModel
from notemodel import NoteModel

View File

@ -25,7 +25,7 @@
#
#-------------------------------------------------------------------------
import logging
_LOG = logging.getLogger(".DisplayModels.NoteModel")
_LOG = logging.getLogger(".gui.notemodel")
#-------------------------------------------------------------------------
#

View File

@ -16,6 +16,7 @@ SUBDIRS = \
rel \
textreport \
tool \
view \
webreport
pkgdatadir = $(datadir)/@PACKAGE@/plugins

View File

@ -44,7 +44,7 @@ import gtk
#-------------------------------------------------------------------------
from BasicUtils import name_displayer
import ManagedWindow
from DisplayModels import PeopleModel
from gui.views.treemodels import PeopleModel
import Relationship
from QuestionDialog import ErrorDialog

View File

@ -0,0 +1,35 @@
# This is the src/plugins/quickview level Makefile for Gramps
# We could use GNU make's ':=' syntax for nice wildcard use,
# but that is not necessarily portable.
# If not using GNU make, then list all .py files individually
pkgdatadir = $(datadir)/@PACKAGE@/plugins/view
pkgdata_PYTHON = \
eventview.py \
familyview.py \
geoview.py \
geoview.gpr.py \
grampletview.py \
htmlrenderer \
mediaview.py \
noteview.py \
pedigreeview.py \
personview.py \
placeview.py \
relview.py \
repoview.py \
sourceview.py \
view.gpr.py
pkgpyexecdir = @pkgpyexecdir@/plugins/view
pkgpythondir = @pkgpythondir@/plugins/view
# Clean up all the byte-compiled files
MOSTLYCLEANFILES = *pyc *pyo
GRAMPS_PY_MODPATH = "../../"
pycheck:
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
pychecker $(pkgdata_PYTHON));

View File

@ -24,6 +24,15 @@
Provide the event view.
"""
#-------------------------------------------------------------------------
#
# Standard python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
import logging
_LOG = logging.getLogger(".plugins.eventview")
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
@ -38,7 +47,7 @@ import gtk
#-------------------------------------------------------------------------
import gen.lib
from gui.views.listview import ListView
import DisplayModels
from gui.views.treemodels import EventModel
import Utils
import Errors
import Bookmarks
@ -48,14 +57,6 @@ from Editors import EditEvent, DelEventQuery
from Filters.SideBar import EventSidebarFilter
from gen.plug import CATEGORY_QR_EVENT
#-------------------------------------------------------------------------
#
# internationalization
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# EventView
@ -95,7 +96,7 @@ class EventView(ListView):
ListView.__init__(
self, _('Events'), dbstate, uistate,
EventView.COLUMN_NAMES, len(EventView.COLUMN_NAMES),
DisplayModels.EventModel,
EventModel,
signal_map, dbstate.db.get_event_bookmarks(),
Bookmarks.EventBookmarks,
multiple=True,

View File

@ -20,7 +20,7 @@
# $Id$
"""
FamilyList View.
Family View.
"""
#-------------------------------------------------------------------------
@ -29,7 +29,8 @@ FamilyList View.
#
#-------------------------------------------------------------------------
from gettext import gettext as _
import logging
_LOG = logging.getLogger(".plugins.eventview")
#-------------------------------------------------------------------------
#
# GNOME/GTK+ modules
@ -44,7 +45,7 @@ import gtk
#-------------------------------------------------------------------------
import gen.lib
from gui.views.listview import ListView
import DisplayModels
from gui.views.treemodels import FamilyModel
import Bookmarks
import Errors
import config
@ -53,10 +54,10 @@ from gen.plug import CATEGORY_QR_FAMILY
#-------------------------------------------------------------------------
#
# FamilyListView
# FamilyView
#
#-------------------------------------------------------------------------
class FamilyListView(ListView):
class FamilyView(ListView):
COLUMN_NAMES = [
_('ID'),
@ -84,8 +85,8 @@ class FamilyListView(ListView):
ListView.__init__(
self, _('Families'), dbstate, uistate,
FamilyListView.COLUMN_NAMES, len(FamilyListView.COLUMN_NAMES),
DisplayModels.FamilyModel,
FamilyView.COLUMN_NAMES, len(FamilyView.COLUMN_NAMES),
FamilyModel,
signal_map, dbstate.db.get_family_bookmarks(),
Bookmarks.FamilyBookmarks, filter_class=FamilySidebarFilter)
@ -110,7 +111,7 @@ class FamilyListView(ListView):
_('Select Family Columns'),
self.uistate,
self.dbstate.db.get_family_list_column_order(),
FamilyListView.COLUMN_NAMES,
FamilyView.COLUMN_NAMES,
self.set_column_order)
def get_stock(self):

View File

@ -0,0 +1,69 @@
# encoding:utf-8
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Benny Malengier
#
# 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$
#------------------------------------------------------------------------
#
# Geoview and HtmlView
#
#------------------------------------------------------------------------
TOOLKIT = NOWEB
try:
import webkit
TOOLKIT = WEBKIT
except:
try:
import gtkmozembed
TOOLKIT = MOZILLA
except:
pass
#no interfaces present, we do not register these plugins
if not (TOOLKIT == NOWEB):
register(VIEW,
id = 'geoview',
name = _("Geographic View"),
description = _("The view showing events on an interactive internet map "
"(internet connection needed"),
version = '1.0',
status = STABLE,
fname = 'geoview.py',
authors = [u"The GRAMPS project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_GEO,
viewclass = 'GeoView',
)
register(VIEW,
id = 'htmlview',
name = _("Html View"),
description = _("A view allowing to see html pages embedded in GRAMPS"),
version = '1.0',
status = UNSTABLE,
fname = 'htmlrenderer.py',
authors = [u"The GRAMPS project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_MISC,
viewclass = 'HtmlView',
)

View File

@ -61,11 +61,11 @@ from const import TEMP_DIR
#-------------------------------------------------------------------------
def get_identity():
if Utils.lin:
if Utils.lin():
platform = "X11"
elif Utils.win:
elif Utils.win():
platform = "Windows"
elif Utils.mac:
elif Utils.mac():
platform = "Macintosh"
else:
platform = "Unknown"
@ -112,7 +112,6 @@ except:
#no interfaces present, raise Error so that options for GeoView do not show
if TOOLKIT == NOWEB :
config.set('preferences.geoview', False)
raise ImportError, 'No GTK html plugin found'
#-------------------------------------------------------------------------

View File

@ -48,7 +48,7 @@ import gtk
#-------------------------------------------------------------------------
from gui.utils import open_file_with_default_application
from gui.views.listview import ListView
import DisplayModels
from gui.views.treemodels import MediaModel
import ThumbNails
import const
import config
@ -104,7 +104,7 @@ class MediaView(ListView):
ListView.__init__(
self, _('Media'), dbstate, uistate,
MediaView.COLUMN_NAMES, len(MediaView.COLUMN_NAMES),
DisplayModels.MediaModel,
MediaModel,
signal_map, dbstate.db.get_media_bookmarks(),
Bookmarks.MediaBookmarks, filter_class=MediaSidebarFilter,
multiple=True)

View File

@ -21,8 +21,16 @@
# $Id$
"""
Place View.
Note View.
"""
#-------------------------------------------------------------------------
#
# python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
import logging
_LOG = logging.getLogger(".plugins.noteview")
#-------------------------------------------------------------------------
#
@ -37,7 +45,7 @@ import gtk
#
#-------------------------------------------------------------------------
from gui.views.listview import ListView
import DisplayModels
from gui.views.treemodels import NoteModel
import Utils
import Errors
import Bookmarks
@ -48,14 +56,6 @@ from DdTargets import DdTargets
from Filters.SideBar import NoteSidebarFilter
from Editors import EditNote, DeleteNoteQuery
#-------------------------------------------------------------------------
#
# internationalization
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# NoteView
@ -91,7 +91,7 @@ class NoteView(ListView):
ListView.__init__(
self, _('Notes'), dbstate, uistate, NoteView.COLUMN_NAMES,
len(NoteView.COLUMN_NAMES), DisplayModels.NoteModel, signal_map,
len(NoteView.COLUMN_NAMES), NoteModel, signal_map,
dbstate.db.get_note_bookmarks(),
Bookmarks.NoteBookmarks,
filter_class=NoteSidebarFilter,

View File

@ -46,9 +46,9 @@ _LOG = logging.getLogger(".gui.personview")
#
#-------------------------------------------------------------------------
import gen.lib
import gui.views.pageview as PageView
from gui.views.pageview import NAVIGATION_PERSON
from gui.views.listview import ListView
import DisplayModels
from gui.views.treemodels import PeopleModel
import Utils
from BasicUtils import name_displayer
from QuestionDialog import ErrorDialog, QuestionDialog
@ -108,7 +108,7 @@ class PersonView(ListView):
ListView.__init__(
self, _('People'), dbstate, uistate,
PersonView.COLUMN_NAMES, len(PersonView.COLUMN_NAMES),
DisplayModels.PeopleModel,
PeopleModel,
signal_map, dbstate.db.get_bookmarks(),
Bookmarks.Bookmarks,
multiple=True,
@ -126,7 +126,7 @@ class PersonView(ListView):
self.dbstate.db.set_person_column_order(clist)
def navigation_type(self):
return PageView.NAVIGATION_PERSON
return NAVIGATION_PERSON
def get_bookmarks(self):
"""

View File

@ -45,7 +45,7 @@ import gtk
#-------------------------------------------------------------------------
import gen.lib
from gui.views.listview import ListView
import DisplayModels
from gui.views.treemodels import PlaceModel
from gui.utils import add_menuitem
import Errors
import Bookmarks
@ -111,7 +111,7 @@ class PlaceView(ListView):
ListView.__init__(
self, _('Places'), dbstate, uistate, PlaceView.COLUMN_NAMES,
len(PlaceView.COLUMN_NAMES),
DisplayModels.PlaceModel, signal_map,
PlaceModel, signal_map,
dbstate.db.get_place_bookmarks(),
Bookmarks.PlaceBookmarks,
multiple=True,

View File

@ -38,7 +38,7 @@ import gtk
#-------------------------------------------------------------------------
import gen.lib
from gui.views.listview import ListView
import DisplayModels
from gui.views.treemodels import RepositoryModel
import Utils
import Bookmarks
import Errors
@ -102,7 +102,7 @@ class RepositoryView(ListView):
ListView.__init__(
self, _('Repositories'), dbstate, uistate,
RepositoryView.COLUMN_NAMES, len(RepositoryView.COLUMN_NAMES),
DisplayModels.RepositoryModel, signal_map,
RepositoryModel, signal_map,
dbstate.db.get_repo_bookmarks(),
Bookmarks.RepoBookmarks, multiple=True,
filter_class=RepoSidebarFilter)

View File

@ -39,7 +39,7 @@ import gtk
import gen.lib
import config
from gui.views.listview import ListView
import DisplayModels
from gui.views.treemodels import SourceModel
import Utils
import Bookmarks
import Errors
@ -94,7 +94,7 @@ class SourceView(ListView):
ListView.__init__(
self, _('Sources'), dbstate, uistate,
SourceView.COLUMN_NAMES, len(SourceView.COLUMN_NAMES),
DisplayModels.SourceModel, signal_map,
SourceModel, signal_map,
dbstate.db.get_source_bookmarks(),
Bookmarks.SourceBookmarks, multiple=True,
filter_class=SourceSidebarFilter)

View File

@ -0,0 +1,171 @@
# encoding:utf-8
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Benny Malengier
#
# 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$
#------------------------------------------------------------------------
#
# default views of GRAMPS
#
#------------------------------------------------------------------------
register(VIEW,
id = 'eventview',
name = _("Event View"),
description = _("The view showing all the events"),
version = '1.0',
status = STABLE,
fname = 'eventview.py',
authors = [u"The GRAMPS project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_EVENT,
viewclass = 'EventView',
)
register(VIEW,
id = 'familyview',
name = _("Family View"),
description = _("The view showing all families"),
version = '1.0',
status = STABLE,
fname = 'familyview.py',
authors = [u"The GRAMPS project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_FAMILY,
viewclass = 'FamilyView',
)
register(VIEW,
id = 'grampletview',
name = _("Gramplet View"),
description = _("The view allowing to see Gramplets"),
version = '1.0',
status = STABLE,
fname = 'grampletview.py',
authors = [u"The GRAMPS project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_MISC,
viewclass = 'GrampletView',
)
register(VIEW,
id = 'mediaview',
name = _("Media View"),
description = _("The view showing all the media objects"),
version = '1.0',
status = STABLE,
fname = 'mediaview.py',
authors = [u"The GRAMPS project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_MEDIA,
viewclass = 'MediaView',
)
register(VIEW,
id = 'noteview',
name = _("Note View"),
description = _("The view showing all the notes"),
version = '1.0',
status = STABLE,
fname = 'noteview.py',
authors = [u"The GRAMPS project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_NOTE,
viewclass = 'NoteView',
)
register(VIEW,
id = 'relview',
name = _("Relationship View"),
description = _("The view showing all relationships of the selected person"),
version = '1.0',
status = STABLE,
fname = 'relview.py',
authors = [u"The GRAMPS project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_REL,
viewclass = 'RelationshipView',
)
register(VIEW,
id = 'pedigreeview',
name = _("Pedigree View"),
description = _("The view showing an ancestor pedigree of the selected person"),
version = '1.0',
status = STABLE,
fname = 'pedigreeview.py',
authors = [u"The GRAMPS project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_REL,
viewclass = 'PedigreeView',
)
register(VIEW,
id = 'personview',
name = _("Person View"),
description = _("The view showing all people in the family tree"),
version = '1.0',
status = STABLE,
fname = 'personview.py',
authors = [u"The GRAMPS project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_PERSON,
viewclass = 'PersonView',
)
register(VIEW,
id = 'placeview',
name = _("Place View"),
description = _("The view showing all the places of the family tree"),
version = '1.0',
status = STABLE,
fname = 'placeview.py',
authors = [u"The GRAMPS project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_PLACE,
viewclass = 'PlaceView',
)
register(VIEW,
id = 'repoview',
name = _("Repository View"),
description = _("The view showing all the repositories"),
version = '1.0',
status = STABLE,
fname = 'repoview.py',
authors = [u"The GRAMPS project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_REPO,
viewclass = 'RepositoryView',
)
register(VIEW,
id = 'sourceview',
name = _("Source View"),
description = _("The view showing all the sources"),
version = '1.0',
status = STABLE,
fname = 'sourceview.py',
authors = [u"The GRAMPS project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_SOURCE,
viewclass = 'SourceView',
)