3352: Confusion in creating multiple views of same type and selecting them; see tracker for more details

svn: r13705
This commit is contained in:
Doug Blank 2009-12-05 04:38:31 +00:00
parent e07455b891
commit 7fbdff5e0d
10 changed files with 89 additions and 82 deletions

View File

@ -526,10 +526,10 @@ register('interface.child-ref-width', 600)
register('interface.clipboard-height', 300)
register('interface.clipboard-width', 300)
register('interface.dont-ask', False)
register('interface.data-views',
['GrampletView', 'PersonView', 'RelationshipView',
'FamilyListView', 'PedigreeView', 'EventView', 'SourceView',
'PlaceView', 'MediaView', 'RepositoryView', 'NoteView'])
register('interface.view-categories',
["Gramplets", "People", "Relationships", "Families",
"Charts", "Events", "Places", "Geography", "Sources",
"Repositories", "Media", "Notes"])
register('interface.event-height', 450)
register('interface.event-ref-height', 450)
register('interface.event-ref-width', 600)

View File

@ -30,9 +30,6 @@ from _pluginreg import (PluginData, PluginRegister, REPORT, TOOL,
CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_NOTE,
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, VIEW_PEDI,
START, END
)
from _manager import BasePluginManager
@ -52,7 +49,4 @@ __all__ = [ "docbackend", "docgen", "menu", Plugin, PluginData,
CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_NOTE,
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, VIEW_PEDI,
START, END]

View File

@ -102,23 +102,6 @@ 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_PEDI = 4
VIEW_EVENT = 5
VIEW_PLACE = 6
VIEW_SOURCE = 7
VIEW_REPO = 8
VIEW_MEDIA = 9
VIEW_NOTE = 10
VIEW_GEO = 11
VIEW_CAT = [VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY, VIEW_EVENT,
VIEW_PEDI, VIEW_PLACE, VIEW_SOURCE, VIEW_REPO, VIEW_MEDIA,
VIEW_NOTE, VIEW_GEO]
#possible quickreport categories
CATEGORY_QR_MISC = -1
CATEGORY_QR_PERSON = 0
@ -204,7 +187,8 @@ class PluginData(object):
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
or the view category a plugin belongs to,
default=("Miscellaneous", _("Miscellaneous"))
Attributes for REPORT and TOOL plugins
.. attribute:: optionclass
@ -389,7 +373,7 @@ class PluginData(object):
elif self._ptype == QUICKREPORT:
self._category = CATEGORY_QR_PERSON
elif self._ptype == VIEW:
self._category = VIEW_MISC
self._category = ("Miscellaneous", _("Miscellaneous"))
#if self._ptype == DOCGEN:
# self._load_on_reg = True
@ -865,18 +849,6 @@ 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_PEDI': VIEW_PEDI,
'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

@ -62,13 +62,8 @@ 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_GEO, VIEW_SOURCE, VIEW_REPO,
VIEW_MEDIA, VIEW_PEDI, VIEW_NOTE, START, END)
from gen.plug import (START, END)
DEFAULT_SIDEBAR_ORDER = (VIEW_MISC, VIEW_PERSON, VIEW_REL, VIEW_FAMILY,
VIEW_PEDI, VIEW_EVENT, VIEW_PLACE, VIEW_GEO, VIEW_SOURCE,
VIEW_REPO, VIEW_MEDIA, VIEW_NOTE)
#-------------------------------------------------------------------------
#
# Functions
@ -256,20 +251,28 @@ def construct_view_order():
'firstauthoremail': pdata.authors_email[0] if
pdata.authors_email else '...'})
continue
viewclass = eval('mod.' + pdata.viewclass)
if pdata.category in viewstoshow:
viewclass = getattr(mod, pdata.viewclass)
# pdata.category is (string, trans-string):
if pdata.category[0] in viewstoshow:
if pdata.order == START:
viewstoshow[pdata.category].insert(0, ((pdata.id,
viewclass)))
viewstoshow[pdata.category[0]].insert(0, ((pdata, viewclass)))
else:
viewstoshow[pdata.category].append((pdata.id, viewclass))
viewstoshow[pdata.category[0]].append((pdata, viewclass))
else:
viewstoshow[pdata.category] = [(pdata.id, viewclass)]
viewstoshow[pdata.category[0]] = [(pdata, viewclass)]
resultorder = []
for item in DEFAULT_SIDEBAR_ORDER:
# First, get those in order defined, if exists:
for item in config.get("interface.view-categories"):
if item in viewstoshow:
resultorder.append(viewstoshow[item])
# Next, get the rest in some order:
viewstoshow_names = viewstoshow.keys()
viewstoshow_names.sort()
for item in viewstoshow_names:
if viewstoshow[item] in resultorder:
continue
resultorder.append(viewstoshow[item])
return resultorder
#-------------------------------------------------------------------------
@ -294,7 +297,7 @@ class Gramps(object):
register_stock_icons()
dbstate = DbState.DbState()
self.vm = ViewManager(dbstate, DEFAULT_SIDEBAR_ORDER)
self.vm = ViewManager(dbstate, config.get("interface.view-categories"))
#now we determine which views are present, which to show, and we
#instruct the viewmanager to show them

View File

@ -891,9 +891,13 @@ class ViewManager(CLIManager):
self.view_toggle_actions[index] = []
self.pages.append([])
nrpage = 0
for id, page_def in cat_views:
for pdata, page_def in cat_views:
page = page_def(self.dbstate, self.uistate)
# Category is (string, trans):
page.set_category(pdata.category)
page_title = page.get_title()
page_category = page.get_category()
page_translated_category = page.get_translated_category()
page_stock = page.get_stock()
if nrpage == 0:
#the first page of this category, used to obtain
@ -908,7 +912,7 @@ class ViewManager(CLIManager):
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.add(gtk.Label(page_translated_category))
hbox.show_all()
page_cat = self.notebook.append_page(notebook, hbox)
# Enable view switching during DnD
@ -918,7 +922,8 @@ class ViewManager(CLIManager):
# create the button and add it to the sidebar
button = self.__make_sidebar_button(use_text, index,
page_title, page_stock)
page_translated_category,
page_stock)
self.bbox.pack_start(button, False)
self.buttons.append(button)
@ -936,12 +941,13 @@ class ViewManager(CLIManager):
page_no = self.notebook_cat[-1].append_page(page_display,
gtk.Label(page_title))
self.pages[-1].append(page)
pageid = (id + '_%i' % nrpage)
pageid = (pdata.id + '_%i' % nrpage)
uimenuitems += '\n<menuitem action="%s"/>' % pageid
uitoolitems += '\n<toolitem action="%s"/>' % pageid
# id, stock, button text, UI, tooltip, page
self.view_toggle_actions[index].append((pageid,
page.get_viewtype_stock(),
page_title, '<CONTROL>%i' % (nrpage+1), page_title,
pdata.name, '<CONTROL>%i' % (nrpage+1), page_title,
nrpage))
nrpage += 1
@ -971,8 +977,8 @@ class ViewManager(CLIManager):
found = False
for cat_views in self.views:
current_cat_view = 0
for id, page_def in cat_views:
if id == current_page_id:
for pdata, page_def in cat_views:
if pdata.id == current_page_id:
found = True
break
else:
@ -1166,7 +1172,7 @@ class ViewManager(CLIManager):
self.active_page = self.pages[category_page][view_page]
self.active_page.set_active()
config.set('preferences.last-view',
self.views[category_page][view_page][0])
self.views[category_page][view_page][0].id)
config.save()
self.__setup_navigation()
@ -1605,14 +1611,14 @@ def run_plugin(pdata, dbstate, uistate):
if pdata.ptype == REPORT:
ReportBase.report(dbstate, uistate, dbstate.active,
eval('mod.' + pdata.reportclass),
eval('mod.' + pdata.optionclass),
getattr(mod, pdata.reportclass),
getattr(mod, pdata.optionclass),
pdata.name, pdata.id,
pdata.category, pdata.require_active)
else:
gui_tool(dbstate, uistate,
eval('mod.' + pdata.toolclass),
eval('mod.' + pdata.optionclass),
getattr(mod, pdata.toolclass),
getattr(mod, pdata.optionclass),
pdata.name, pdata.id, pdata.category,
dbstate.db.request_rebuild)

View File

@ -39,6 +39,7 @@ _LOG = logging.getLogger('.pageview')
#
#----------------------------------------------------------------
import gtk
from gettext import gettext as _
#----------------------------------------------------------------
#
@ -79,6 +80,8 @@ class PageView(DbGUIElement):
self.dirty = True
self.active = False
self.func_list = {}
self.category = "Miscellaneous"
self.translated_category = _("Miscellaneous")
self.dbstate.connect('no-database', self.disable_action_group)
self.dbstate.connect('database-changed', self.enable_action_group)
@ -180,6 +183,34 @@ class PageView(DbGUIElement):
"""
return self.title
def set_category(self, category):
"""
Set the category of the view. This is used to define the text for the
button, and for the tab label.
category - a tuple of the form (category, translated-category)
"""
if isinstance(category, tuple):
self.category = category[0]
self.translated_category = category[1]
else:
raise AttributeError("View category must be (name, translated-name)")
def get_category(self):
"""
Return the category name of the view. This is used to define
the text for the button, and for the tab label.
"""
return self.category
def get_translated_category(self):
"""
Return the translated category name of the view. This is used
to define the text for the button, and for the tab label.
"""
return self.translated_category
def get_display(self):
"""
Builds the graphical display, returning the top level widget.

View File

@ -1,12 +1,12 @@
register(VIEW,
id = 'fanchartview',
name = _("Fan Chart View"),
category = ("Charts", _("Charts")),
description = _("The view showing relations through a fanchart"),
version = '1.0',
status = UNSTABLE,
fname = 'fanchartview.py',
authors = [u"Douglas S. Blank"],
authors_email = ["doug.blank@gmail.com"],
category = VIEW_PEDI,
viewclass = 'FanChartView',
)

View File

@ -55,7 +55,7 @@ if not (TOOLKIT == NOWEB):
fname = 'geoview.py',
authors = [u"The Gramps project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_GEO,
category = ("Geography", _("Geography")),
viewclass = 'GeoView',
)
@ -68,6 +68,6 @@ if not (TOOLKIT == NOWEB):
fname = 'htmlrenderer.py',
authors = [u"The Gramps project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_MISC,
category = ("Web", _("Web")),
viewclass = 'HtmlView',
)

View File

@ -7,6 +7,6 @@ register(VIEW,
fname = 'placetreeview.py',
authors = [u"Donald N. Allingham", u"Gary Burton", u"Nick Hall"],
authors_email = [""],
category = VIEW_PLACE,
category = ("Places", _("Places")),
viewclass = 'PlaceTreeView',
)

View File

@ -36,7 +36,7 @@ status = STABLE,
fname = 'eventview.py',
authors = [u"The Gramps project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_EVENT,
category = ("Events", _("Events")),
viewclass = 'EventView',
order = START,
)
@ -50,7 +50,7 @@ status = STABLE,
fname = 'familyview.py',
authors = [u"The Gramps project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_FAMILY,
category = ("Families", _("Families")),
viewclass = 'FamilyView',
order = START,
)
@ -64,7 +64,7 @@ status = STABLE,
fname = 'grampletview.py',
authors = [u"The Gramps project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_MISC,
category = ("Gramplets", _("Gramplets")),
viewclass = 'GrampletView',
order = START,
)
@ -78,7 +78,7 @@ status = STABLE,
fname = 'mediaview.py',
authors = [u"The Gramps project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_MEDIA,
category = ("Media", _("Media")),
viewclass = 'MediaView',
order = START,
)
@ -92,7 +92,7 @@ status = STABLE,
fname = 'noteview.py',
authors = [u"The Gramps project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_NOTE,
category = ("Notes", _("Notes")),
viewclass = 'NoteView',
order = START,
)
@ -106,7 +106,7 @@ status = STABLE,
fname = 'relview.py',
authors = [u"The Gramps project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_REL,
category = ("Relationships", _("Relationships")),
viewclass = 'RelationshipView',
order = START,
)
@ -120,8 +120,9 @@ status = STABLE,
fname = 'pedigreeview.py',
authors = [u"The Gramps project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_PEDI,
category = ("Charts", _("Charts")),
viewclass = 'PedigreeView',
order = START,
)
register(VIEW,
@ -133,7 +134,7 @@ status = STABLE,
fname = 'personview.py',
authors = [u"The Gramps project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_PERSON,
category = ("People", _("People")),
viewclass = 'PersonView',
order = START,
)
@ -147,7 +148,7 @@ status = STABLE,
fname = 'placeview.py',
authors = [u"The Gramps project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_PLACE,
category = ("Places", _("Places")),
viewclass = 'PlaceView',
order = START,
)
@ -161,7 +162,7 @@ status = STABLE,
fname = 'repoview.py',
authors = [u"The Gramps project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_REPO,
category = ("Repositories", _("Repositories")),
viewclass = 'RepositoryView',
order = START,
)
@ -175,7 +176,7 @@ status = STABLE,
fname = 'sourceview.py',
authors = [u"The Gramps project"],
authors_email = ["http://gramps-project.org"],
category = VIEW_SOURCE,
category = ("Sources", _("Sources")),
viewclass = 'SourceView',
order = START,
)