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>
|
2006-01-14 Don Allingham <don@gramps-project.org>
|
||||||
* src/DisplayTabs.py: add button control class
|
* src/DisplayTabs.py: add button control class
|
||||||
* src/EditFamily.py: add icons
|
* src/EditFamily.py: add icons
|
||||||
|
@ -1,36 +1,15 @@
|
|||||||
from _Constants import ObjectTypes
|
from _Constants import ObjectTypes
|
||||||
|
|
||||||
from _PersonSearchCriteriaWidget import PersonSearchCriteriaWidget
|
from _PersonFrame import PersonFrame
|
||||||
from _PersonPreviewFrame import PersonPreviewFrame
|
|
||||||
from _PersonTreeFrame import PersonTreeFrame
|
|
||||||
|
|
||||||
from _FamilyFilterFrame import FamilyFilterFrame
|
from _FamilyFrame import FamilyFrame
|
||||||
from _FamilyPreviewFrame import FamilyPreviewFrame
|
|
||||||
from _FamilyTreeFrame import FamilyTreeFrame
|
|
||||||
|
|
||||||
|
|
||||||
class FilterFactory(object):
|
class ObjectFrameFactory(object):
|
||||||
|
__frame_creators = {ObjectTypes.PERSON: PersonFrame,
|
||||||
__frame_creators = {ObjectTypes.PERSON: PersonSearchCriteriaWidget,
|
ObjectTypes.FAMILY: FamilyFrame}
|
||||||
ObjectTypes.FAMILY: FamilyFilterFrame}
|
|
||||||
|
|
||||||
def get_frame(self,object_type,dbstate):
|
def get_frame(self,object_type,dbstate):
|
||||||
return self.__class__.__frame_creators[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
|
import _Factories
|
||||||
from _Constants import ObjectTypes
|
from _Constants import ObjectTypes
|
||||||
from _PersonSearchCriteriaWidget import PersonSearchCriteriaWidget
|
|
||||||
from _PersonPreviewFrame import PersonPreviewFrame
|
|
||||||
|
|
||||||
class _ObjectTypeWidgets(object):
|
class _ObjectTypeWidgets(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.filter_frame = None
|
self.frame = None
|
||||||
self.preview_frame = None
|
|
||||||
self.tree_frame = None
|
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
self.filter_frame.show_all()
|
self.frame.show_all()
|
||||||
self.preview_frame.show_all()
|
|
||||||
self.tree_frame.show_all()
|
|
||||||
|
|
||||||
def hide(self):
|
def hide(self):
|
||||||
self.filter_frame.hide_all()
|
self.frame.hide_all()
|
||||||
self.preview_frame.hide_all()
|
|
||||||
self.tree_frame.hide_all()
|
|
||||||
|
|
||||||
OBJECT_LIST = [ObjectTypes.PERSON, ObjectTypes.FAMILY,
|
OBJECT_LIST = [ObjectTypes.PERSON, ObjectTypes.FAMILY,
|
||||||
ObjectTypes.SOURCE, ObjectTypes.EVENT,
|
ObjectTypes.SOURCE, ObjectTypes.EVENT,
|
||||||
@ -117,53 +109,23 @@ class ObjectSelectorWindow(gtk.Window):
|
|||||||
|
|
||||||
# Create the widgets for each of the object types
|
# Create the widgets for each of the object types
|
||||||
|
|
||||||
self._object_frames = {}
|
# Object frame box
|
||||||
|
|
||||||
vbox = gtk.VBox()
|
|
||||||
vbox.show()
|
|
||||||
|
|
||||||
vbox2 = gtk.VBox()
|
frame_box = gtk.HBox()
|
||||||
vbox2.show()
|
frame_box.show()
|
||||||
|
|
||||||
pane = gtk.HPaned()
|
self._object_frames = {}
|
||||||
pane.show()
|
|
||||||
|
|
||||||
for object_type in object_list:
|
for object_type in object_list:
|
||||||
self._object_frames[object_type] = _ObjectTypeWidgets()
|
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)
|
frame_box.pack_start(self._object_frames[object_type].frame,True,True)
|
||||||
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
self._set_object_type(default_object_type)
|
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
|
# Bottom buttons
|
||||||
add_button = gtk.Button(stock=gtk.STOCK_ADD)
|
add_button = gtk.Button(stock=gtk.STOCK_ADD)
|
||||||
add_button.set_sensitive(False)
|
add_button.set_sensitive(False)
|
||||||
@ -184,7 +146,7 @@ class ObjectSelectorWindow(gtk.Window):
|
|||||||
|
|
||||||
box = gtk.VBox()
|
box = gtk.VBox()
|
||||||
box.pack_start(top_box,False,False)
|
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.pack_start(bottom_button_bar,False,False)
|
||||||
box.show()
|
box.show()
|
||||||
|
|
||||||
@ -231,7 +193,7 @@ if __name__ == "__main__":
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
db = GrampsDb.gramps_db_factory(const.app_gramps)()
|
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
|
cb, # callback
|
||||||
"w")
|
"w")
|
||||||
class D:
|
class D:
|
||||||
@ -242,7 +204,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
|
|
||||||
w = ObjectSelectorWindow(dbstate=dbstate,
|
w = ObjectSelectorWindow(dbstate=dbstate,
|
||||||
default_object_type = ObjectTypes.FAMILY,
|
default_object_type = ObjectTypes.PERSON,
|
||||||
object_list=[ObjectTypes.PERSON,ObjectTypes.FAMILY])
|
object_list=[ObjectTypes.PERSON,ObjectTypes.FAMILY])
|
||||||
w.show()
|
w.show()
|
||||||
w.connect("destroy", gtk.main_quit)
|
w.connect("destroy", gtk.main_quit)
|
||||||
|
@ -3,7 +3,7 @@ import gobject
|
|||||||
|
|
||||||
from _IntEdit import IntEdit
|
from _IntEdit import IntEdit
|
||||||
|
|
||||||
class PersonSearchCriteriaWidget(gtk.Frame):
|
class PersonFilterFrame(gtk.Frame):
|
||||||
|
|
||||||
__gproperties__ = {}
|
__gproperties__ = {}
|
||||||
|
|
||||||
@ -207,12 +207,12 @@ class PersonSearchCriteriaWidget(gtk.Frame):
|
|||||||
|
|
||||||
|
|
||||||
if gtk.pygtk_version < (2,8,0):
|
if gtk.pygtk_version < (2,8,0):
|
||||||
gobject.type_register(PersonSearchCriteriaWidget)
|
gobject.type_register(PersonFilterFrame)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
w = gtk.Window()
|
w = gtk.Window()
|
||||||
f = PersonSearchCriteriaWidget()
|
f = PersonFilterFrame()
|
||||||
w.add(f)
|
w.add(f)
|
||||||
w.show_all()
|
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