* src/DataViews/_MediaView.py: cleanup and documentation

* src/DataViews/_RepositoryView.py: cleanup and documentation
	* src/DataViews/_SourceView.py: cleanup and documentation
	* src/DataViews/_EventView.py: cleanup and documentation
	* src/DataViews/_FamilyList.py: cleanup and documentation
	* src/DataViews/_PedigreeView.py: cleanup and documentation
	* src/DataViews/_PlaceView.py: cleanup and documentation
	* src/DataViews/_NoteView.py: cleanup and documentation
	* src/DataViews/_PersonView.py: cleanup and documentation
	* src/DataViews/_MapView.py: cleanup and documentation
	* src/DataViews/_RelationView.py: cleanup and documentation
	* src/PageView.py: cleanup and documentation
	
2007-09-12  Don Allingham  <don@gramps-project.org>


svn: r8969
This commit is contained in:
Don Allingham 2007-09-13 04:20:24 +00:00
parent ca2942e133
commit dd42d5b11f
13 changed files with 156 additions and 114 deletions

View File

@ -1,3 +1,17 @@
2007-09-12 Don Allingham <don@gramps-project.org>
* src/DataViews/_MediaView.py: cleanup and documentation
* src/DataViews/_RepositoryView.py: cleanup and documentation
* src/DataViews/_SourceView.py: cleanup and documentation
* src/DataViews/_EventView.py: cleanup and documentation
* src/DataViews/_FamilyList.py: cleanup and documentation
* src/DataViews/_PedigreeView.py: cleanup and documentation
* src/DataViews/_PlaceView.py: cleanup and documentation
* src/DataViews/_NoteView.py: cleanup and documentation
* src/DataViews/_PersonView.py: cleanup and documentation
* src/DataViews/_MapView.py: cleanup and documentation
* src/DataViews/_RelationView.py: cleanup and documentation
* src/PageView.py: cleanup and documentation
2007-09-12 Don Allingham <don@gramps-project.org>
* src/DataViews/_MediaView.py: update thumbnail on data update (#1226)

View File

@ -167,7 +167,7 @@ class EventView(PageView.ListView):
def define_actions(self):
PageView.ListView.define_actions(self)
self.add_action('FilterEdit', None, _('Event Filter Editor'),
self._add_action('FilterEdit', None, _('Event Filter Editor'),
callback=self.filter_editor,)
def get_handle_from_gramps_id(self, gid):
@ -177,7 +177,7 @@ class EventView(PageView.ListView):
else:
return None
def column_editor(self, obj):
def _column_editor(self, obj):
"""
returns a tuple indicating the column order
"""

View File

@ -96,7 +96,7 @@ class FamilyListView(PageView.ListView):
def column_order(self):
return self.dbstate.db.get_family_list_column_order()
def column_editor(self, obj):
def _column_editor(self, obj):
import ColumnOrder
ColumnOrder.ColumnOrder(
@ -161,10 +161,10 @@ class FamilyListView(PageView.ListView):
"""
PageView.ListView.define_actions(self)
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self.column_editor)
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self._column_editor)
self.add_action('FilterEdit', None, _('Family Filter Editor'),
self._add_action('FilterEdit', None, _('Family Filter Editor'),
callback=self.filter_editor,)
self.all_action = gtk.ActionGroup(self.title + "/FamilyAll")
@ -172,7 +172,7 @@ class FamilyListView(PageView.ListView):
('QuickReport', None, _("Quick Report"), None, None, None),
('Dummy', None, ' ', None, None, self.dummy_report),
])
self.add_action_group(self.all_action)
self._add_action_group(self.all_action)
def get_bookmarks(self):
return self.dbstate.db.get_family_bookmarks()

View File

@ -627,18 +627,18 @@ class MapView(PageView.PageView):
return PageView.NAVIGATION_NONE
def define_actions(self):
self.add_action('ZoomIn',gtk.STOCK_ZOOM_IN,
_("Zoom _In"),tip=_("Zoom in by a factor of 2"),
callback=self.zoom_in_cb)
self.add_action('ZoomOut',gtk.STOCK_ZOOM_OUT,
_("Zoom _Out"),tip=_("Zoom out by a factor of 2"),
callback=self.zoom_out_cb)
self.add_action('ZoomNormal',gtk.STOCK_ZOOM_100,
_("_Normal Size"), tip=_("Return to normal size"),
callback=self.zoom_100_cb)
self.add_action('ZoomFit',gtk.STOCK_ZOOM_FIT,
_("Best _Fit"),
tip=_("Produce the best fit of the map in the window"),
self._add_action('ZoomIn',gtk.STOCK_ZOOM_IN,
_("Zoom _In"),tip=_("Zoom in by a factor of 2"),
callback=self.zoom_in_cb)
self._add_action('ZoomOut',gtk.STOCK_ZOOM_OUT,
_("Zoom _Out"),tip=_("Zoom out by a factor of 2"),
callback=self.zoom_out_cb)
self._add_action('ZoomNormal',gtk.STOCK_ZOOM_100,
_("_Normal Size"), tip=_("Return to normal size"),
callback=self.zoom_100_cb)
self._add_action('ZoomFit',gtk.STOCK_ZOOM_FIT,
_("Best _Fit"),
tip=_("Produce the best fit of the map in the window"),
callback=self.zoom_fit_cb)
def get_stock(self):

View File

@ -211,13 +211,13 @@ class MediaView(PageView.ListView):
"""
PageView.ListView.define_actions(self)
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self.column_editor)
self.add_action('FilterEdit', None, _('Media Filter Editor'),
callback=self.filter_editor)
self.add_action('OpenMedia', 'gramps-viewmedia', _('View'),
tip=_("View in the default viewer"),
callback=self.view_media)
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self._column_editor)
self._add_action('FilterEdit', None, _('Media Filter Editor'),
callback=self.filter_editor)
self._add_action('OpenMedia', 'gramps-viewmedia', _('View'),
tip=_("View in the default viewer"),
callback=self.view_media)
def view_media(self, obj):
"""
@ -237,7 +237,7 @@ class MediaView(PageView.ListView):
_("GRAMPS cannot find an application that can view "
"a file type of %s.") % mime_type)
def column_editor(self, obj):
def _column_editor(self, obj):
"""
Start the column editor dialog
"""

View File

@ -164,10 +164,10 @@ class NoteView(PageView.ListView):
def define_actions(self):
PageView.ListView.define_actions(self)
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self.column_editor)
self.add_action('FilterEdit', None, _('Note Filter Editor'),
callback=self.filter_editor,)
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self._column_editor)
self._add_action('FilterEdit', None, _('Note Filter Editor'),
callback=self.filter_editor,)
def get_handle_from_gramps_id(self, gid):
obj = self.dbstate.db.get_note_from_gramps_id(gid)
@ -176,7 +176,7 @@ class NoteView(PageView.ListView):
else:
return None
def column_editor(self, obj):
def _column_editor(self, obj):
"""
returns a tuple indicating the column order
"""

View File

@ -593,7 +593,7 @@ class PedigreeView(PageView.PersonNavView):
"""
PageView.PersonNavView.define_actions(self)
# self.add_action('HomePerson',gtk.STOCK_HOME,_("_Home"),
# self._add_action('HomePerson',gtk.STOCK_HOME,_("_Home"),
# tip=_("Go to the default person"), callback=self.home)
def build_tree(self):

View File

@ -163,7 +163,7 @@ class PersonView(PageView.PersonNavView):
('Remove', gtk.STOCK_REMOVE, _("_Remove"), "<control>Delete",
_("Remove the selected person"), self.remove),
('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor'), None,
None, self.column_editor),
None, self._column_editor),
('CmpMerge', None, _('_Compare and merge'), None, None,
self.cmp_merge),
('FastMerge', None, _('_Fast merge'), None, None,
@ -171,8 +171,8 @@ class PersonView(PageView.PersonNavView):
('ExportTab', None, _('Export view'), None, None, self.export),
])
self.add_action_group(self.edit_action)
self.add_action_group(self.all_action)
self._add_action_group(self.edit_action)
self._add_action_group(self.all_action)
def enable_action_group(self, obj):
PageView.PersonNavView.enable_action_group(self, obj)
@ -234,7 +234,7 @@ class PersonView(PageView.PersonNavView):
"A second person can be selected by holding down the "
"control key while clicking on the desired person."))
def column_editor(self, obj):
def _column_editor(self, obj):
import ColumnOrder
ColumnOrder.ColumnOrder(
@ -282,7 +282,7 @@ class PersonView(PageView.PersonNavView):
self.tree.set_rules_hint(True)
self.tree.set_headers_visible(True)
self.tree.set_fixed_height_mode(True)
self.tree.connect('key-press-event', self.key_press)
self.tree.connect('key-press-event', self._key_press)
self.tree.connect('start-interactive-search',self.open_all_nodes)
scrollwindow = gtk.ScrolledWindow()
@ -302,7 +302,7 @@ class PersonView(PageView.PersonNavView):
self.setup_filter()
self.build_columns()
self.tree.connect('button-press-event', self.button_press)
self.tree.connect('button-press-event', self._button_press)
self.tree.connect('drag_data_get', self.drag_data_get)
self.tree.connect('drag_begin', self.drag_begin)
@ -819,7 +819,7 @@ class PersonView(PageView.PersonNavView):
elif row == 0 and self.model.on_get_iter(path):
self.selection.select_path(path)
def button_press(self, obj, event):
def _button_press(self, obj, event):
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
handle = self.first_selected()
person = self.dbstate.db.get_person_from_handle(handle)
@ -860,7 +860,7 @@ class PersonView(PageView.PersonNavView):
return True
return False
def key_press(self,obj,event):
def _key_press(self,obj,event):
if not event.state or event.state in (gtk.gdk.MOD2_MASK,):
if event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):
if self.dbstate.active:

View File

@ -114,15 +114,15 @@ class PlaceView(PageView.ListView):
def define_actions(self):
PageView.ListView.define_actions(self)
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self.column_editor)
self.add_action('FastMerge', None, _('_Merge'),
callback=self.fast_merge)
self.add_action('GoogleMaps', gtk.STOCK_JUMP_TO, _('_Google Maps'),
callback=self.google,
tip=_("Attempt to map location on Google Maps"))
self.add_action('FilterEdit', None, _('Place Filter Editor'),
callback=self.filter_editor,)
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self._column_editor)
self._add_action('FastMerge', None, _('_Merge'),
callback=self.fast_merge)
self._add_action('GoogleMaps', gtk.STOCK_JUMP_TO, _('_Google Maps'),
callback=self.google,
tip=_("Attempt to map location on Google Maps"))
self._add_action('FilterEdit', None, _('Place Filter Editor'),
callback=self.filter_editor,)
def drag_info(self):
return DdTargets.PLACE_LINK
@ -151,7 +151,7 @@ class PlaceView(PageView.ListView):
path = "http://maps.google.com/maps?q=%s" % '+'.join(descr.split())
GrampsDisplay.url(path)
def column_editor(self, obj):
def _column_editor(self, obj):
import ColumnOrder
ColumnOrder.ColumnOrder(

View File

@ -328,15 +328,15 @@ class RelationshipView(PageView.PersonNavView):
_("Adds an existing set of parents"), self.select_parents),
])
self.add_action_group(self.order_action)
self.add_action_group(self.family_action)
self._add_action_group(self.order_action)
self._add_action_group(self.family_action)
self.add_toggle_action('Details', None, _('Show details'),
None, None, self.details_toggle,
self.show_details)
self.add_toggle_action('Siblings', None, _('Show siblings'),
None, None, self.siblings_toggle,
self.show_siblings)
self._add_toggle_action('Details', None, _('Show details'),
None, None, self.details_toggle,
self.show_details)
self._add_toggle_action('Siblings', None, _('Show siblings'),
None, None, self.siblings_toggle,
self.show_siblings)
self.order_action.set_sensitive(self.reorder_sensitive)
self.family_action.set_sensitive(False)
@ -801,8 +801,8 @@ class RelationshipView(PageView.PersonNavView):
initial_name = False
if handle:
name = self.get_name(handle, True)
link_label = GrampsWidgets.LinkLabel(name,
self.button_press, handle)
link_label = GrampsWidgets.LinkLabel(
name, self._button_press, handle)
if self.use_shade:
link_label.modify_bg(gtk.STATE_NORMAL, self.color)
if Config.get(Config.RELEDITBTN):
@ -841,8 +841,8 @@ class RelationshipView(PageView.PersonNavView):
if handle:
name = self.get_name(handle, True)
link_label = GrampsWidgets.LinkLabel(name,
self.button_press, handle)
link_label = GrampsWidgets.LinkLabel(
name, self._button_press, handle)
if self.use_shade:
link_label.modify_bg(gtk.STATE_NORMAL, self.color)
if Config.get(Config.RELEDITBTN):
@ -891,7 +891,7 @@ class RelationshipView(PageView.PersonNavView):
else:
format = 'underline="single"'
link_label = GrampsWidgets.LinkLabel(self.get_name(handle, True),
self.button_press, handle, format)
self._button_press, handle, format)
if self.use_shade:
link_label.modify_bg(gtk.STATE_NORMAL, self.color)
link_label.set_padding(3, 0)
@ -974,7 +974,7 @@ class RelationshipView(PageView.PersonNavView):
self.collapsed_items[person.handle] = [handle]
self.redraw()
def button_press(self, obj, event, handle):
def _button_press(self, obj, event, handle):
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:
self.dbstate.change_active_handle(handle)
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:

View File

@ -117,12 +117,12 @@ class RepositoryView(PageView.ListView):
def define_actions(self):
PageView.ListView.define_actions(self)
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self.column_editor)
self.add_action('FilterEdit', None, _('Repository Filter Editor'),
callback=self.filter_editor,)
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self._column_editor)
self._add_action('FilterEdit', None, _('Repository Filter Editor'),
callback=self.filter_editor,)
def column_editor(self, obj):
def _column_editor(self, obj):
import ColumnOrder
ColumnOrder.ColumnOrder(

View File

@ -110,14 +110,14 @@ class SourceView(PageView.ListView):
def define_actions(self):
PageView.ListView.define_actions(self)
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self.column_editor)
self.add_action('FastMerge', None, _('_Merge'),
callback=self.fast_merge)
self.add_action('FilterEdit', None, _('Source Filter Editor'),
callback=self.filter_editor,)
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self._column_editor)
self._add_action('FastMerge', None, _('_Merge'),
callback=self.fast_merge)
self._add_action('FilterEdit', None, _('Source Filter Editor'),
callback=self.filter_editor,)
def column_editor(self, obj):
def _column_editor(self, obj):
import ColumnOrder
ColumnOrder.ColumnOrder(

View File

@ -26,7 +26,7 @@ Provide the base classes for GRAMPS' DataView classes
#----------------------------------------------------------------
#
# python
# python modules
#
#----------------------------------------------------------------
from gettext import gettext as _
@ -39,7 +39,6 @@ import cPickle as pickle
#----------------------------------------------------------------
import gtk
import pango
from gtk.gdk import ACTION_COPY, BUTTON1_MASK
#----------------------------------------------------------------
#
@ -209,24 +208,47 @@ class PageView:
if len(self.action_toggle_list) > 0:
self.action_group.add_toggle_actions(self.action_toggle_list)
def add_action(self, name, stock_icon, label, accel=None, tip=None,
def _add_action(self, name, stock_icon, label, accel=None, tip=None,
callback=None):
"""
Adds an action to the action list for the current view.
"""
self.action_list.append((name, stock_icon, label, accel, tip, callback))
def add_toggle_action(self, name, stock_icon, label, accel=None,
tip=None, callback=None, value=False):
def _add_toggle_action(self, name, stock_icon, label, accel=None,
tip=None, callback=None, value=False):
"""
Adds a toggle action to the action list for the current view.
"""
self.action_toggle_list.append((name, stock_icon, label, accel,
tip, callback, value))
def get_actions(self):
"""
Returns the actions that should be used for the view. This includes the
standard action group (which handles the main toolbar), along with
additional action groups.
If the action group is not defined, we build it the first time. This
allows us to delay the intialization until it is really needed.
The ViewManager uses this function to extract the actions to install
into the UIManager.
"""
if not self.action_group:
self.__build_action_group()
return [self.action_group] + self.additional_action_groups
def add_action_group(self, group):
def _add_action_group(self, group):
"""
Allows additional action groups to be added to the view.
"""
self.additional_action_groups.append(group)
def change_page(self):
"""
Called when the page changes.
"""
self.uistate.clear_filter_results()
def edit(self, obj):
@ -247,7 +269,7 @@ class PageView:
"""
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
if not event.state or event.state in (gtk.gdk.MOD2_MASK, ):
if event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):
@ -321,13 +343,14 @@ class BookMarkView(PageView):
def define_actions(self):
self.book_action = gtk.ActionGroup(self.title + '/Bookmark')
self.book_action.add_actions([
('AddBook', 'gramps-bookmark-new', _('_Add bookmark'), '<control>d', None,
self.add_bookmark),
('EditBook', 'gramps-bookmark-edit', _('_Edit bookmarks'), '<control>b', None,
('AddBook', 'gramps-bookmark-new', _('_Add bookmark'),
'<control>d', None, self.add_bookmark),
('EditBook', 'gramps-bookmark-edit', _('_Edit bookmarks'),
'<control>b', None,
self.edit_bookmarks),
])
self.add_action_group(self.book_action)
self._add_action_group(self.book_action)
#----------------------------------------------------------------
#
@ -364,10 +387,10 @@ class PersonNavView(BookMarkView):
self.back_clicked)
])
self.add_action('HomePerson', gtk.STOCK_HOME, _("_Home"),
accel="<Alt>Home",
tip=_("Go to the default person"), callback=self.home)
self.add_action('FilterEdit', None, _('Person Filter Editor'),
self._add_action('HomePerson', gtk.STOCK_HOME, _("_Home"),
accel="<Alt>Home",
tip=_("Go to the default person"), callback=self.home)
self._add_action('FilterEdit', None, _('Person Filter Editor'),
callback=self.filter_editor)
self.other_action = gtk.ActionGroup(self.title + '/PersonOther')
@ -376,9 +399,9 @@ class PersonNavView(BookMarkView):
None, self.set_default_person),
])
self.add_action_group(self.back_action)
self.add_action_group(self.fwd_action)
self.add_action_group(self.other_action)
self._add_action_group(self.back_action)
self._add_action_group(self.fwd_action)
self._add_action_group(self.other_action)
def disable_action_group(self):
"""
@ -419,7 +442,8 @@ class PersonNavView(BookMarkView):
dialog = gtk.Dialog(_('Jump to by GRAMPS ID'), None,
gtk.DIALOG_NO_SEPARATOR)
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)
dialog.vbox.add(label)
dialog.vbox.set_spacing(10)
@ -654,8 +678,8 @@ class ListView(BookMarkView):
self.list.set_headers_visible(True)
self.list.set_headers_clickable(True)
self.list.set_fixed_height_mode(True)
self.list.connect('button-press-event', self.button_press)
self.list.connect('key-press-event', self.key_press)
self.list.connect('button-press-event', self._button_press)
self.list.connect('key-press-event', self._key_press)
if self.drag_info():
self.list.connect('drag_data_get', self.drag_data_get)
self.list.connect('drag_begin', self.drag_begin)
@ -699,9 +723,9 @@ class ListView(BookMarkView):
selected_ids = self.selected_handles()
if len(selected_ids) == 1:
self.list.drag_source_set(BUTTON1_MASK,
self.list.drag_source_set(gtk.gdk.BUTTON1_MASK,
[self.drag_info().target()],
ACTION_COPY)
gtk.gdk.ACTION_COPY)
def drag_data_get(self, widget, context, sel_data, info, time):
selected_ids = self.selected_handles()
@ -787,13 +811,13 @@ class ListView(BookMarkView):
for pair in [pair for pair in self.column_order() if pair[0]]:
name = self.colinfo[pair[1]]
if self.model and self.model.__dict__.has_key('marker_color_column'):
if self.model and self.model.__dict__.has_key('marker_color_column'):
mcol = self.model.marker_color_column
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1],
foreground=mcol)
else:
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1])
column.connect('clicked', self.column_clicked, index)
column.set_resizable(True)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
@ -898,24 +922,28 @@ class ListView(BookMarkView):
('Remove', gtk.STOCK_REMOVE, _("_Remove"), "<control>Delete",
self.DEL_MSG, self.remove),
('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor'),
None, None, self.column_editor),
None, None, self._column_editor),
('ExportTab', None, _('Export view'), None, None, self.export),
])
self.add_action_group(self.edit_action)
self._add_action_group(self.edit_action)
self.add_action('Edit', gtk.STOCK_EDIT, _("_Edit"),
accel="<control>Return",
tip=self.EDIT_MSG,
callback=self.edit)
self._add_action('Edit', gtk.STOCK_EDIT, _("_Edit"),
accel="<control>Return",
tip=self.EDIT_MSG,
callback=self.edit)
self.add_toggle_action('Filter', None, _('_Filter'),
callback=self.filter_toggle_action)
self._add_toggle_action('Filter', None, _('_Filter'),
callback=self.filter_toggle_action)
def column_editor(self, obj):
raise NotImplementedError
def _column_editor(self, obj):
"""
Causes the View to display a column editor. This should be overridden
by any class that provides columns (such as a list based view)
"""
return
def button_press(self, obj, event):
def _button_press(self, obj, event):
from QuickReports import create_quickreport_menu
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
self.edit(obj)
@ -947,7 +975,7 @@ class ListView(BookMarkView):
return False
def key_press(self, obj, event):
def _key_press(self, obj, event):
if not event.state or event.state in (gtk.gdk.MOD2_MASK, ):
if event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):
self.edit(obj)