tidied up the class strucand added documentation to ObjectSelector
svn: r5900
This commit is contained in:
parent
d4623258e8
commit
85b3909ae3
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
||||
2006-02-08 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||
* 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 <don@gramps-project.org>
|
||||
* src/DisplayTabs.py: reordering items in a Gallery
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -20,17 +20,17 @@
|
||||
|
||||
# $Id$
|
||||
|
||||
import gtk
|
||||
|
||||
class FilterSpecBase(object):
|
||||
class PreviewFrameBase(gtk.Frame):
|
||||
|
||||
def __init__(self):
|
||||
self._gramps_id = None
|
||||
__gproperties__ = {}
|
||||
|
||||
def set_gramps_id(self,gramps_id):
|
||||
self._gramps_id = gramps_id
|
||||
__gsignals__ = {
|
||||
}
|
||||
|
||||
def get_gramps_id(self):
|
||||
return self._gramps_id
|
||||
def __init__(self,label):
|
||||
gtk.Frame.__init__(self,label)
|
||||
|
||||
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")
|
43
src/ObjectSelector/_TreeFrameBase.py
Normal file
43
src/ObjectSelector/_TreeFrameBase.py
Normal file
@ -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")
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user