diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 5286ec9e8..3801242f3 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,15 @@ +2006-02-08 Richard Taylor + * src/ObjectSelector/_FamilyPreviewFrame.py: use new baseclass + * src/ObjectSelector/_FamilyTreeFrame.py: use new baseclass + * src/ObjectSelector/_FilterSpec.py: removed + * src/ObjectSelector/_ObjectSelectorResult.py: removed + * src/ObjectSelector/_PersonPreviewFrame.py: use new baseclass + * src/ObjectSelector/_PersonTreeFrame.py: use new baseclass + * src/ObjectSelector/_PreviewFrameBase.py: added + * src/ObjectSelector/_TreeFrameBase.py: added + * src/ObjectSelector/__init__.py: added some documentation + + 2006-02-08 Don Allingham * src/DisplayTabs.py: reordering items in a Gallery diff --git a/gramps2/src/ObjectSelector/_FamilyPreviewFrame.py b/gramps2/src/ObjectSelector/_FamilyPreviewFrame.py index 538f70907..2d54d4c42 100644 --- a/gramps2/src/ObjectSelector/_FamilyPreviewFrame.py +++ b/gramps2/src/ObjectSelector/_FamilyPreviewFrame.py @@ -29,7 +29,9 @@ log = getLogger(".ObjectSelector") import ImgManip import const -class FamilyPreviewFrame(gtk.Frame): +from _PreviewFrameBase import PreviewFrameBase + +class FamilyPreviewFrame(PreviewFrameBase): __gproperties__ = {} @@ -39,7 +41,7 @@ class FamilyPreviewFrame(gtk.Frame): __default_border_width = 5 def __init__(self,dbstate,label="Preview"): - gtk.Frame.__init__(self,label) + PreviewFrameBase.__init__(self,label) self._dbstate = dbstate diff --git a/gramps2/src/ObjectSelector/_FamilyTreeFrame.py b/gramps2/src/ObjectSelector/_FamilyTreeFrame.py index ed0de0f61..76e8e573a 100644 --- a/gramps2/src/ObjectSelector/_FamilyTreeFrame.py +++ b/gramps2/src/ObjectSelector/_FamilyTreeFrame.py @@ -25,7 +25,9 @@ import gobject from DisplayModels import FamilyModel -class FamilyTreeFrame(gtk.Frame): +from _TreeFrameBase import TreeFrameBase + +class FamilyTreeFrame(TreeFrameBase): __gproperties__ = {} @@ -36,7 +38,7 @@ class FamilyTreeFrame(gtk.Frame): def __init__(self,dbstate): - gtk.Frame.__init__(self) + TreeFrameBase.__init__(self) self._selection = None self._model = None diff --git a/gramps2/src/ObjectSelector/_ObjectSelectorResult.py b/gramps2/src/ObjectSelector/_ObjectSelectorResult.py deleted file mode 100644 index fbf159d55..000000000 --- a/gramps2/src/ObjectSelector/_ObjectSelectorResult.py +++ /dev/null @@ -1,68 +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 _Constants import ObjectTypes - -class ObjectSelectorResult(object): - - def __init__(self): - self._gramps_id = None - self._object_type = None - - def __str__(self): - return "Object Type = %s\n"\ - "Gramps ID = %s" % (str(self._object_type), - str(self._gramps_id)) - - def set_gramps_id(self,id): - self._gramps_id = id - - def get_gramps_id(self): - return self._gramps_id - - def set_object_type(self,object_type): - self._object_type = object_type - - def get_object_type(self,object_type): - return self._object_type - - def is_person(self): - return self._object_type == ObjectTypes.PERSON - - def is_family(self): - return self._object_type == ObjectTypes.FAMILY - - def is_event(self): - return self._object_type == ObjectTypes.EVENT - - def is_source(self): - return self._object_type == ObjectTypes.SOURCE - - def is_repository(self): - return self._object_type == ObjectTypes.REPOSITORY - - def is_media(self): - return self._object_type == ObjectTypes.MEDIA - - def is_place(self): - return self._object_type == ObjectTypes.PLACE diff --git a/gramps2/src/ObjectSelector/_PersonPreviewFrame.py b/gramps2/src/ObjectSelector/_PersonPreviewFrame.py index 0b9c02193..94f37e7e3 100644 --- a/gramps2/src/ObjectSelector/_PersonPreviewFrame.py +++ b/gramps2/src/ObjectSelector/_PersonPreviewFrame.py @@ -34,13 +34,15 @@ import const from ToolTips import PersonTip import DateHandler +from _PreviewFrameBase import PreviewFrameBase + def short(val,size=60): if len(val) > size: return "%s..." % val[0:size] else: return val -class PersonPreviewFrame(gtk.Frame): +class PersonPreviewFrame(PreviewFrameBase): __gproperties__ = {} @@ -50,7 +52,7 @@ class PersonPreviewFrame(gtk.Frame): __default_border_width = 5 def __init__(self,dbstate,label="Preview"): - gtk.Frame.__init__(self,label) + PreviewFrameBase.__init__(self,label) self._dbstate = dbstate diff --git a/gramps2/src/ObjectSelector/_PersonTreeFrame.py b/gramps2/src/ObjectSelector/_PersonTreeFrame.py index 5df33e68b..4c339a6b3 100644 --- a/gramps2/src/ObjectSelector/_PersonTreeFrame.py +++ b/gramps2/src/ObjectSelector/_PersonTreeFrame.py @@ -25,11 +25,12 @@ from gettext import gettext as _ import gtk import gobject -#from PeopleModel import PeopleModel from TreeViews import PersonTreeView import NameDisplay +from _TreeFrameBase import TreeFrameBase + column_names = [ _('Name'), _('ID') , @@ -44,7 +45,7 @@ column_names = [ ] -class PersonTreeFrame(gtk.Frame): +class PersonTreeFrame(TreeFrameBase): __gproperties__ = {} @@ -55,7 +56,7 @@ class PersonTreeFrame(gtk.Frame): def __init__(self,dbstate): - gtk.Frame.__init__(self) + TreeFrameBase.__init__(self) self._dbstate = dbstate self._selection = None diff --git a/gramps2/src/ObjectSelector/_FilterSpec.py b/gramps2/src/ObjectSelector/_PreviewFrameBase.py similarity index 72% rename from gramps2/src/ObjectSelector/_FilterSpec.py rename to gramps2/src/ObjectSelector/_PreviewFrameBase.py index f5f065e7c..2c7a775a1 100644 --- a/gramps2/src/ObjectSelector/_FilterSpec.py +++ b/gramps2/src/ObjectSelector/_PreviewFrameBase.py @@ -20,17 +20,17 @@ # $Id$ +import gtk -class FilterSpecBase(object): +class PreviewFrameBase(gtk.Frame): + + __gproperties__ = {} - def __init__(self): - self._gramps_id = None + __gsignals__ = { + } - def set_gramps_id(self,gramps_id): - self._gramps_id = gramps_id + def __init__(self,label): + gtk.Frame.__init__(self,label) - def get_gramps_id(self): - return self._gramps_id - - def include_gramps_id(self): - return self._gramps_id is not None + def set_object(self,person): + raise NotImplementedError("Subclasses of PreviewFrameBase must implement set_object") diff --git a/gramps2/src/ObjectSelector/_TreeFrameBase.py b/gramps2/src/ObjectSelector/_TreeFrameBase.py new file mode 100644 index 000000000..50341c81b --- /dev/null +++ b/gramps2/src/ObjectSelector/_TreeFrameBase.py @@ -0,0 +1,43 @@ + +# 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$ + +import gtk + +class TreeFrameBase(gtk.Frame): + + __gproperties__ = {} + + __gsignals__ = { + } + + def __init__(self): + gtk.Frame.__init__(self) + + def set_model(self,data_filter=None): + raise NotImplementedError("Subclasses of TreeFrameBase must implement set_model") + + def get_selection(self): + raise NotImplementedError("Subclasses of TreeFrameBase must implement get_selection") + + def get_tree(self): + raise NotImplementedError("Subclasses of TreeFrameBase must implement get_tree") + diff --git a/gramps2/src/ObjectSelector/__init__.py b/gramps2/src/ObjectSelector/__init__.py index f6e97e3a3..6c8809763 100644 --- a/gramps2/src/ObjectSelector/__init__.py +++ b/gramps2/src/ObjectSelector/__init__.py @@ -20,6 +20,79 @@ # $Id$ +""" +ObjectSelector provides a collection of widgets that can be used to select +any of the Primary objects in the database. + +The class hierachy is currently this: + + gtk.Window + ObjectSelectorWindow + PersonSelector + + gtk.Frame + FilterFrameBase + PersonFilterFrame + FamilyFilterFrame + ObjectFrameBase + FamilyFrame + PersonFrame + PreviewFrameBase + FamilyPreviewFrame + PersonPreviewFrame + TreeFrameBase + FamilyTreeFrame + PersonTreeFrame + + FilterSpecBase + PersonFilterSpec + + ObjectFrameFactory + +To implement a selector for a new Primary RelLib type you need to implement a new +subclass of each of: + + FilterFrameBase + ObjectFrameBase + PreviewFrameBase + TreeFrameBase + +You must then extend ObjectFrameFactory so that it know how to create the new selector +type. The new type should also be added to the OBJECT_LIST in _ObjectSelectorWindow.py +so that it shows up in the selector. A subclass of ObjectSelectorWindow can be added to +this file as a convienience for starting a selector for just the new type. + +At runtime Object selector is constructed from these widgets in the following structure: + + +------------------------------------------------------------------------------- +| ObjectSelectorWindow | +| +| --------------------------------------------------------------------------- | +| | Subclass of ObjectFrameBase | | +| | | | +| | ----------------------------- ---------------------------------------- | | +| | | Subclass of TreeFrameBase | | Subclass of PreviewFrameBase | | | +| | | | | | | | +| | | | | | | | +| | | | | | | | +| | | | | | | | +| | | | | | | | +| | | | | | | | +| | | | ---------------------------------------- | | +| | | | ---------------------------------------- | | +| | | | | Subclass of FilterFrameBase | | | +| | | | | | | | +| | | | | | | | +| | | | | | | | +| | | | | | | | +| | | | | | | | +| | | | | | | | +| | ----------------------------- ---------------------------------------- | | +| --------------------------------------------------------------------------- | +------------------------------------------------------------------------------- + +""" from gettext import gettext as _ from _ObjectSelectorWindow import ObjectSelectorWindow