2007-09-11 Don Allingham <don@gramps-project.org>
* src/PageView.py: add some documentation svn: r8962
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
2007-09-11 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/PageView.py: add some documentation
|
||||||
|
|
||||||
2007-09-08 Benny Malengier <benny.malengier@gramps-project.org>
|
2007-09-08 Benny Malengier <benny.malengier@gramps-project.org>
|
||||||
* src/PageView.py : cleanup
|
* src/PageView.py : cleanup
|
||||||
* src/QuickReports.py: fix error getting source handle
|
* src/QuickReports.py: fix error getting source handle
|
||||||
|
|||||||
120
src/PageView.py
120
src/PageView.py
@@ -20,6 +20,10 @@
|
|||||||
|
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
|
"""
|
||||||
|
Provide the base classes for GRAMPS' DataView classes
|
||||||
|
"""
|
||||||
|
|
||||||
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# python
|
# python
|
||||||
@@ -55,12 +59,17 @@ NAVIGATION_PERSON = 0
|
|||||||
|
|
||||||
EMPTY_SEARCH = (0, '', False)
|
EMPTY_SEARCH = (0, '', False)
|
||||||
|
|
||||||
#----------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# PageView
|
# PageView
|
||||||
#
|
#
|
||||||
#----------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
class PageView:
|
class PageView:
|
||||||
|
"""
|
||||||
|
The PageView class is the base class for all Data Views in GRAMPS. All
|
||||||
|
Views should derive from this class. The ViewManager understands the public
|
||||||
|
interface of this class
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, title, dbstate, uistate):
|
def __init__(self, title, dbstate, uistate):
|
||||||
self.title = title
|
self.title = title
|
||||||
@@ -73,21 +82,29 @@ class PageView:
|
|||||||
self.additional_uis = []
|
self.additional_uis = []
|
||||||
self.widget = None
|
self.widget = None
|
||||||
self.model = None
|
self.model = None
|
||||||
self.ui = '<ui></ui>'
|
self.ui_def = '<ui></ui>'
|
||||||
self.dbstate.connect('no-database', self.disable_action_group)
|
self.dbstate.connect('no-database', self.disable_action_group)
|
||||||
self.dbstate.connect('database-changed', self.enable_action_group)
|
self.dbstate.connect('database-changed', self.enable_action_group)
|
||||||
self.dirty = True
|
self.dirty = True
|
||||||
self.active = False
|
self.active = False
|
||||||
self.handle_col = 0
|
self.handle_col = 0
|
||||||
self.selection = None
|
self.selection = None
|
||||||
|
self.func_list = {}
|
||||||
|
|
||||||
def call_function(self, key):
|
def call_function(self, key):
|
||||||
|
"""
|
||||||
|
Calls the function associated with the key value
|
||||||
|
"""
|
||||||
self.func_list.get(key)()
|
self.func_list.get(key)()
|
||||||
|
|
||||||
def post(self):
|
def post(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def set_active(self):
|
def set_active(self):
|
||||||
|
"""
|
||||||
|
Called with the PageView is set as active. If the page is "dirty",
|
||||||
|
then we rebuild the data.
|
||||||
|
"""
|
||||||
self.active = True
|
self.active = True
|
||||||
if self.dirty:
|
if self.dirty:
|
||||||
self.uistate.set_busy_cursor(True)
|
self.uistate.set_busy_cursor(True)
|
||||||
@@ -95,49 +112,97 @@ class PageView:
|
|||||||
self.uistate.set_busy_cursor(False)
|
self.uistate.set_busy_cursor(False)
|
||||||
|
|
||||||
def set_inactive(self):
|
def set_inactive(self):
|
||||||
|
"""
|
||||||
|
Marks page as being active (currently displayed)
|
||||||
|
"""
|
||||||
self.active = False
|
self.active = False
|
||||||
|
|
||||||
def build_tree(self):
|
def build_tree(self):
|
||||||
pass
|
"""
|
||||||
|
Rebuilds the current display. This must be overridden by the derived
|
||||||
|
class.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def navigation_type(self):
|
def navigation_type(self):
|
||||||
|
"""
|
||||||
|
Indictates the navigation type. Currently, we only support navigation
|
||||||
|
for views that are Person centric.
|
||||||
|
"""
|
||||||
return NAVIGATION_NONE
|
return NAVIGATION_NONE
|
||||||
|
|
||||||
def ui_definition(self):
|
def ui_definition(self):
|
||||||
return self.ui
|
"""
|
||||||
|
returns the XML UI definition for the UIManager
|
||||||
|
"""
|
||||||
|
return self.ui_def
|
||||||
|
|
||||||
def additional_ui_definitions(self):
|
def additional_ui_definitions(self):
|
||||||
|
"""
|
||||||
|
Returns any additional interfaces for the UIManager that the view
|
||||||
|
needs to define.
|
||||||
|
"""
|
||||||
return self.additional_uis
|
return self.additional_uis
|
||||||
|
|
||||||
def disable_action_group(self):
|
def disable_action_group(self):
|
||||||
|
"""
|
||||||
|
Turns off the visibility of the View's action group, if defined
|
||||||
|
"""
|
||||||
if self.action_group:
|
if self.action_group:
|
||||||
self.action_group.set_visible(False)
|
self.action_group.set_visible(False)
|
||||||
|
|
||||||
def enable_action_group(self, obj):
|
def enable_action_group(self, obj):
|
||||||
|
"""
|
||||||
|
Turns on the visibility of the View's action group, if defined
|
||||||
|
"""
|
||||||
if self.action_group:
|
if self.action_group:
|
||||||
self.action_group.set_visible(True)
|
self.action_group.set_visible(True)
|
||||||
|
|
||||||
def get_stock(self):
|
def get_stock(self):
|
||||||
try:
|
"""
|
||||||
return gtk.STOCK_MEDIA_MISSING
|
Returns image associated with the view, which is used for the
|
||||||
except AttributeError:
|
icon for the button.
|
||||||
|
"""
|
||||||
return gtk.STOCK_MISSING_IMAGE
|
return gtk.STOCK_MISSING_IMAGE
|
||||||
|
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
|
"""
|
||||||
|
Returns the title of the view. This is used to define the text for the
|
||||||
|
button, and for the tab label.
|
||||||
|
"""
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
def get_display(self):
|
def get_display(self):
|
||||||
|
"""
|
||||||
|
Builds the graphical display, returning the top level widget.
|
||||||
|
"""
|
||||||
if not self.widget:
|
if not self.widget:
|
||||||
self.widget = self.build_widget()
|
self.widget = self.build_widget()
|
||||||
return self.widget
|
return self.widget
|
||||||
|
|
||||||
def build_widget(self):
|
def build_widget(self):
|
||||||
assert False
|
"""
|
||||||
|
Builds the container widget for the interface. Must be overridden by the
|
||||||
|
the base class. Returns a gtk container widget.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def define_actions(self):
|
def define_actions(self):
|
||||||
assert False
|
"""
|
||||||
|
Defines the UIManager actions. Called by the ViewManager to set up the
|
||||||
|
View. The user typically defines self.action_list and
|
||||||
|
self.action_toggle_list in this function.
|
||||||
|
|
||||||
def _build_action_group(self):
|
Derived classes must override this function.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def __build_action_group(self):
|
||||||
|
"""
|
||||||
|
Creates an UIManager ActionGroup from the values in self.action_list
|
||||||
|
and self.action_toggle_list. The user should define these in
|
||||||
|
self.define_actions
|
||||||
|
"""
|
||||||
self.action_group = gtk.ActionGroup(self.title)
|
self.action_group = gtk.ActionGroup(self.title)
|
||||||
if len(self.action_list) > 0:
|
if len(self.action_list) > 0:
|
||||||
self.action_group.add_actions(self.action_list)
|
self.action_group.add_actions(self.action_list)
|
||||||
@@ -155,7 +220,7 @@ class PageView:
|
|||||||
|
|
||||||
def get_actions(self):
|
def get_actions(self):
|
||||||
if not self.action_group:
|
if not self.action_group:
|
||||||
self._build_action_group()
|
self.__build_action_group()
|
||||||
return [self.action_group] + self.additional_action_groups
|
return [self.action_group] + self.additional_action_groups
|
||||||
|
|
||||||
def add_action_group(self, group):
|
def add_action_group(self, group):
|
||||||
@@ -165,13 +230,22 @@ class PageView:
|
|||||||
self.uistate.clear_filter_results()
|
self.uistate.clear_filter_results()
|
||||||
|
|
||||||
def edit(self, obj):
|
def edit(self, obj):
|
||||||
pass
|
"""
|
||||||
|
Template function to allow the editing of the selected object
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def remove(self, obj):
|
def remove(self, obj):
|
||||||
pass
|
"""
|
||||||
|
Template function to allow the removal of the selected object
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def add(self, obj):
|
def add(self, obj):
|
||||||
pass
|
"""
|
||||||
|
Template function to allow the adding of a new object
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def key_press(self, obj, event):
|
def key_press(self, obj, event):
|
||||||
#act if no modifier, and allow Num Lock as MOD2_MASK
|
#act if no modifier, and allow Num Lock as MOD2_MASK
|
||||||
@@ -181,8 +255,8 @@ class PageView:
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def blist(self,store,path,iter,sel_list):
|
def blist(self, store, path, node, sel_list):
|
||||||
handle = store.get_value(iter,self.handle_col)
|
handle = store.get_value(node, self.handle_col)
|
||||||
sel_list.append(handle)
|
sel_list.append(handle)
|
||||||
|
|
||||||
def selected_handles(self):
|
def selected_handles(self):
|
||||||
@@ -206,7 +280,7 @@ class BookMarkView(PageView):
|
|||||||
self.setup_bookmarks(bookmarks)
|
self.setup_bookmarks(bookmarks)
|
||||||
|
|
||||||
def goto_handle(self, obj):
|
def goto_handle(self, obj):
|
||||||
pass
|
raise NotImplementedError
|
||||||
|
|
||||||
def setup_bookmarks(self, bookmarks):
|
def setup_bookmarks(self, bookmarks):
|
||||||
self.bookmarks = self.bm_type(
|
self.bookmarks = self.bm_type(
|
||||||
@@ -379,7 +453,7 @@ class PersonNavView(BookMarkView):
|
|||||||
FilterEditor('Person', const.CUSTOM_FILTERS,
|
FilterEditor('Person', const.CUSTOM_FILTERS,
|
||||||
self.dbstate, self.uistate)
|
self.dbstate, self.uistate)
|
||||||
except Errors.WindowActiveError:
|
except Errors.WindowActiveError:
|
||||||
pass
|
return
|
||||||
|
|
||||||
def fwd_clicked(self, obj, step=1):
|
def fwd_clicked(self, obj, step=1):
|
||||||
hobj = self.uistate.phistory
|
hobj = self.uistate.phistory
|
||||||
@@ -523,7 +597,8 @@ class ListView(BookMarkView):
|
|||||||
dialog = gtk.Dialog(_('Jump to by GRAMPS ID'), None,
|
dialog = gtk.Dialog(_('Jump to by GRAMPS ID'), None,
|
||||||
gtk.DIALOG_NO_SEPARATOR)
|
gtk.DIALOG_NO_SEPARATOR)
|
||||||
dialog.set_border_width(12)
|
dialog.set_border_width(12)
|
||||||
label = gtk.Label('<span weight="bold" size="larger">%s</span>' % _('Jump to by GRAMPS ID'))
|
label = gtk.Label('<span weight="bold" size="larger">%s</span>' %
|
||||||
|
_('Jump to by GRAMPS ID'))
|
||||||
label.set_use_markup(True)
|
label.set_use_markup(True)
|
||||||
dialog.vbox.add(label)
|
dialog.vbox.add(label)
|
||||||
dialog.vbox.set_spacing(10)
|
dialog.vbox.set_spacing(10)
|
||||||
@@ -688,7 +763,6 @@ class ListView(BookMarkView):
|
|||||||
sort_map=self.column_order())
|
sort_map=self.column_order())
|
||||||
|
|
||||||
self.list.set_model(self.model)
|
self.list.set_model(self.model)
|
||||||
colmap = self.column_order()
|
|
||||||
|
|
||||||
if handle:
|
if handle:
|
||||||
path = self.model.on_get_path(handle)
|
path = self.model.on_get_path(handle)
|
||||||
@@ -770,7 +844,7 @@ class ListView(BookMarkView):
|
|||||||
FilterEditor(self.FILTER_TYPE , const.CUSTOM_FILTERS,
|
FilterEditor(self.FILTER_TYPE , const.CUSTOM_FILTERS,
|
||||||
self.dbstate, self.uistate)
|
self.dbstate, self.uistate)
|
||||||
except Errors.WindowActiveError:
|
except Errors.WindowActiveError:
|
||||||
pass
|
return
|
||||||
|
|
||||||
def change_db(self, db):
|
def change_db(self, db):
|
||||||
for sig in self.signal_map:
|
for sig in self.signal_map:
|
||||||
@@ -839,7 +913,7 @@ class ListView(BookMarkView):
|
|||||||
callback=self.filter_toggle_action)
|
callback=self.filter_toggle_action)
|
||||||
|
|
||||||
def column_editor(self, obj):
|
def column_editor(self, obj):
|
||||||
pass
|
raise NotImplementedError
|
||||||
|
|
||||||
def button_press(self, obj, event):
|
def button_press(self, obj, event):
|
||||||
from QuickReports import create_quickreport_menu
|
from QuickReports import create_quickreport_menu
|
||||||
|
|||||||
Reference in New Issue
Block a user