refactored object frame in object selector
svn: r5760
This commit is contained in:
parent
3bf46f706e
commit
0186f296d6
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2006-01-16 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||
* src/ObjectSelector/_Factories.py: refactored object frame
|
||||
* src/ObjectSelector/_FamilyFrame.py: refactored object frame
|
||||
* src/ObjectSelector/_ObjectFrameBase.py: refactored object frame
|
||||
* src/ObjectSelector/_ObjectSelectorWindow.py: refactored object frame
|
||||
* src/ObjectSelector/_PersonFilterFrame.py: refactored object frame
|
||||
* src/ObjectSelector/_PersonFrame.py: refactored object frame
|
||||
* src/ObjectSelector/_PersonSearchCriteriaWidget.py: renamed file
|
||||
|
||||
|
||||
2006-01-14 Don Allingham <don@gramps-project.org>
|
||||
* src/DisplayTabs.py: add button control class
|
||||
* src/EditFamily.py: add icons
|
||||
|
@ -1,36 +1,15 @@
|
||||
from _Constants import ObjectTypes
|
||||
|
||||
from _PersonSearchCriteriaWidget import PersonSearchCriteriaWidget
|
||||
from _PersonPreviewFrame import PersonPreviewFrame
|
||||
from _PersonTreeFrame import PersonTreeFrame
|
||||
from _PersonFrame import PersonFrame
|
||||
|
||||
from _FamilyFilterFrame import FamilyFilterFrame
|
||||
from _FamilyPreviewFrame import FamilyPreviewFrame
|
||||
from _FamilyTreeFrame import FamilyTreeFrame
|
||||
from _FamilyFrame import FamilyFrame
|
||||
|
||||
|
||||
class FilterFactory(object):
|
||||
|
||||
__frame_creators = {ObjectTypes.PERSON: PersonSearchCriteriaWidget,
|
||||
ObjectTypes.FAMILY: FamilyFilterFrame}
|
||||
class ObjectFrameFactory(object):
|
||||
__frame_creators = {ObjectTypes.PERSON: PersonFrame,
|
||||
ObjectTypes.FAMILY: FamilyFrame}
|
||||
|
||||
def get_frame(self,object_type,dbstate):
|
||||
return self.__class__.__frame_creators[object_type](dbstate)
|
||||
|
||||
|
||||
class PreviewFactory(object):
|
||||
|
||||
__frame_creators = {ObjectTypes.PERSON: PersonPreviewFrame,
|
||||
ObjectTypes.FAMILY: FamilyPreviewFrame}
|
||||
|
||||
def get_frame(self,object_type,dbstate):
|
||||
return self.__class__.__frame_creators[object_type](dbstate)
|
||||
|
||||
class TreeFactory(object):
|
||||
|
||||
__frame_creators = {ObjectTypes.PERSON: PersonTreeFrame,
|
||||
ObjectTypes.FAMILY: FamilyTreeFrame}
|
||||
|
||||
def get_frame(self,object_type,dbstate):
|
||||
return self.__class__.__frame_creators[object_type](dbstate)
|
||||
|
||||
|
36
src/ObjectSelector/_FamilyFrame.py
Normal file
36
src/ObjectSelector/_FamilyFrame.py
Normal file
@ -0,0 +1,36 @@
|
||||
#for debug, remove later
|
||||
import sys
|
||||
sys.path.append("..")
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
from _ObjectFrameBase import ObjectFrameBase
|
||||
from _FamilyFilterFrame import FamilyFilterFrame
|
||||
from _FamilyPreviewFrame import FamilyPreviewFrame
|
||||
from _FamilyTreeFrame import FamilyTreeFrame
|
||||
|
||||
class FamilyFrame(ObjectFrameBase):
|
||||
|
||||
__gproperties__ = {}
|
||||
|
||||
__gsignals__ = {}
|
||||
|
||||
__default_border_width = 5
|
||||
|
||||
def __init__(self,
|
||||
dbstate):
|
||||
|
||||
ObjectFrameBase.__init__(self,
|
||||
dbstate=dbstate,
|
||||
filter_frame = FamilyFilterFrame(dbstate),
|
||||
preview_frame = FamilyPreviewFrame(dbstate),
|
||||
tree_frame = FamilyTreeFrame(dbstate))
|
||||
|
||||
|
||||
|
||||
if gtk.pygtk_version < (2,8,0):
|
||||
gobject.type_register(FamilyFrame)
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
63
src/ObjectSelector/_ObjectFrameBase.py
Normal file
63
src/ObjectSelector/_ObjectFrameBase.py
Normal file
@ -0,0 +1,63 @@
|
||||
#for debug, remove later
|
||||
import sys
|
||||
sys.path.append("..")
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
class ObjectFrameBase(gtk.Frame):
|
||||
|
||||
__gproperties__ = {}
|
||||
|
||||
__gsignals__ = {}
|
||||
|
||||
__default_border_width = 5
|
||||
|
||||
def __init__(self,
|
||||
dbstate,
|
||||
filter_frame,
|
||||
preview_frame,
|
||||
tree_frame):
|
||||
|
||||
gtk.Frame.__init__(self)
|
||||
|
||||
self._dbstate = dbstate
|
||||
self._filter_frame = filter_frame
|
||||
self._preview_frame = preview_frame
|
||||
self._tree_frame = tree_frame
|
||||
|
||||
# Create the widgets for each of the object types
|
||||
|
||||
vbox = gtk.VBox()
|
||||
vbox.show()
|
||||
|
||||
vbox2 = gtk.VBox()
|
||||
vbox2.show()
|
||||
|
||||
pane = gtk.HPaned()
|
||||
pane.show()
|
||||
|
||||
vbox.pack_start(self._preview_frame,True,True)
|
||||
vbox.pack_start(self._filter_frame,True,True)
|
||||
vbox2.pack_start(self._tree_frame,True,True)
|
||||
|
||||
pane.pack1(vbox2,True,False)
|
||||
pane.pack2(vbox,False,True)
|
||||
|
||||
pane_align = gtk.Alignment()
|
||||
pane_align.add(pane)
|
||||
pane_align.set_padding(self.__class__.__default_border_width,
|
||||
self.__class__.__default_border_width,
|
||||
self.__class__.__default_border_width,
|
||||
self.__class__.__default_border_width)
|
||||
pane_align.set(0.5,0.5,1,1)
|
||||
pane_align.show()
|
||||
|
||||
self.add(pane_align)
|
||||
|
||||
|
||||
if gtk.pygtk_version < (2,8,0):
|
||||
gobject.type_register(PersonFrame)
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
@ -7,25 +7,17 @@ import gobject
|
||||
|
||||
import _Factories
|
||||
from _Constants import ObjectTypes
|
||||
from _PersonSearchCriteriaWidget import PersonSearchCriteriaWidget
|
||||
from _PersonPreviewFrame import PersonPreviewFrame
|
||||
|
||||
class _ObjectTypeWidgets(object):
|
||||
|
||||
def __init__(self):
|
||||
self.filter_frame = None
|
||||
self.preview_frame = None
|
||||
self.tree_frame = None
|
||||
self.frame = None
|
||||
|
||||
def show(self):
|
||||
self.filter_frame.show_all()
|
||||
self.preview_frame.show_all()
|
||||
self.tree_frame.show_all()
|
||||
self.frame.show_all()
|
||||
|
||||
def hide(self):
|
||||
self.filter_frame.hide_all()
|
||||
self.preview_frame.hide_all()
|
||||
self.tree_frame.hide_all()
|
||||
self.frame.hide_all()
|
||||
|
||||
OBJECT_LIST = [ObjectTypes.PERSON, ObjectTypes.FAMILY,
|
||||
ObjectTypes.SOURCE, ObjectTypes.EVENT,
|
||||
@ -117,53 +109,23 @@ class ObjectSelectorWindow(gtk.Window):
|
||||
|
||||
# Create the widgets for each of the object types
|
||||
|
||||
self._object_frames = {}
|
||||
|
||||
vbox = gtk.VBox()
|
||||
vbox.show()
|
||||
# Object frame box
|
||||
|
||||
vbox2 = gtk.VBox()
|
||||
vbox2.show()
|
||||
frame_box = gtk.HBox()
|
||||
frame_box.show()
|
||||
|
||||
pane = gtk.HPaned()
|
||||
pane.show()
|
||||
self._object_frames = {}
|
||||
|
||||
for object_type in object_list:
|
||||
self._object_frames[object_type] = _ObjectTypeWidgets()
|
||||
|
||||
# Filters
|
||||
self._object_frames[object_type].frame = \
|
||||
_Factories.ObjectFrameFactory().get_frame(object_type,dbstate)
|
||||
|
||||
self._object_frames[object_type].filter_frame = _Factories.FilterFactory().get_frame(object_type,dbstate)
|
||||
|
||||
# Preview
|
||||
|
||||
self._object_frames[object_type].preview_frame = _Factories.PreviewFactory().get_frame(object_type,dbstate)
|
||||
|
||||
# Tree
|
||||
|
||||
self._object_frames[object_type].tree_frame = _Factories.TreeFactory().get_frame(object_type,dbstate)
|
||||
|
||||
|
||||
vbox.pack_start(self._object_frames[object_type].preview_frame,True,True)
|
||||
vbox.pack_start(self._object_frames[object_type].filter_frame,True,True)
|
||||
vbox2.pack_start(self._object_frames[object_type].tree_frame,True,True)
|
||||
frame_box.pack_start(self._object_frames[object_type].frame,True,True)
|
||||
|
||||
self._set_object_type(default_object_type)
|
||||
|
||||
pane.pack1(vbox2,True,False)
|
||||
pane.pack2(vbox,False,True)
|
||||
|
||||
pane_align = gtk.Alignment()
|
||||
pane_align.add(pane)
|
||||
pane_align.set_padding(self.__class__.__default_border_width,
|
||||
self.__class__.__default_border_width,
|
||||
self.__class__.__default_border_width,
|
||||
self.__class__.__default_border_width)
|
||||
pane_align.set(0.5,0.5,1,1)
|
||||
pane_align.show()
|
||||
|
||||
|
||||
|
||||
# Bottom buttons
|
||||
add_button = gtk.Button(stock=gtk.STOCK_ADD)
|
||||
add_button.set_sensitive(False)
|
||||
@ -184,7 +146,7 @@ class ObjectSelectorWindow(gtk.Window):
|
||||
|
||||
box = gtk.VBox()
|
||||
box.pack_start(top_box,False,False)
|
||||
box.pack_start(pane_align,True,True)
|
||||
box.pack_start(frame_box,True,True)
|
||||
box.pack_start(bottom_button_bar,False,False)
|
||||
box.show()
|
||||
|
||||
@ -231,7 +193,7 @@ if __name__ == "__main__":
|
||||
pass
|
||||
|
||||
db = GrampsDb.gramps_db_factory(const.app_gramps)()
|
||||
db.load("/home/gramps/lib/gramps.rjt/gramps2.grdb",
|
||||
db.load("/home/rtaylor/devel/Personal/gramps/test/Untitled_1.grdb",
|
||||
cb, # callback
|
||||
"w")
|
||||
class D:
|
||||
@ -242,7 +204,7 @@ if __name__ == "__main__":
|
||||
|
||||
|
||||
w = ObjectSelectorWindow(dbstate=dbstate,
|
||||
default_object_type = ObjectTypes.FAMILY,
|
||||
default_object_type = ObjectTypes.PERSON,
|
||||
object_list=[ObjectTypes.PERSON,ObjectTypes.FAMILY])
|
||||
w.show()
|
||||
w.connect("destroy", gtk.main_quit)
|
||||
|
@ -3,7 +3,7 @@ import gobject
|
||||
|
||||
from _IntEdit import IntEdit
|
||||
|
||||
class PersonSearchCriteriaWidget(gtk.Frame):
|
||||
class PersonFilterFrame(gtk.Frame):
|
||||
|
||||
__gproperties__ = {}
|
||||
|
||||
@ -207,12 +207,12 @@ class PersonSearchCriteriaWidget(gtk.Frame):
|
||||
|
||||
|
||||
if gtk.pygtk_version < (2,8,0):
|
||||
gobject.type_register(PersonSearchCriteriaWidget)
|
||||
gobject.type_register(PersonFilterFrame)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
w = gtk.Window()
|
||||
f = PersonSearchCriteriaWidget()
|
||||
f = PersonFilterFrame()
|
||||
w.add(f)
|
||||
w.show_all()
|
||||
|
36
src/ObjectSelector/_PersonFrame.py
Normal file
36
src/ObjectSelector/_PersonFrame.py
Normal file
@ -0,0 +1,36 @@
|
||||
#for debug, remove later
|
||||
import sys
|
||||
sys.path.append("..")
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
from _ObjectFrameBase import ObjectFrameBase
|
||||
from _PersonFilterFrame import PersonFilterFrame
|
||||
from _PersonPreviewFrame import PersonPreviewFrame
|
||||
from _PersonTreeFrame import PersonTreeFrame
|
||||
|
||||
class PersonFrame(ObjectFrameBase):
|
||||
|
||||
__gproperties__ = {}
|
||||
|
||||
__gsignals__ = {}
|
||||
|
||||
__default_border_width = 5
|
||||
|
||||
def __init__(self,
|
||||
dbstate):
|
||||
|
||||
ObjectFrameBase.__init__(self,
|
||||
dbstate=dbstate,
|
||||
filter_frame = PersonFilterFrame(dbstate),
|
||||
preview_frame = PersonPreviewFrame(dbstate),
|
||||
tree_frame = PersonTreeFrame(dbstate))
|
||||
|
||||
|
||||
|
||||
if gtk.pygtk_version < (2,8,0):
|
||||
gobject.type_register(PersonFrame)
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
Loading…
Reference in New Issue
Block a user