diff --git a/ChangeLog b/ChangeLog index b3f496d88..f236c1c40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-01-16 Richard Taylor + * 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 * src/DisplayTabs.py: add button control class * src/EditFamily.py: add icons diff --git a/src/ObjectSelector/_Factories.py b/src/ObjectSelector/_Factories.py index 24652ccf3..f8b9274b9 100644 --- a/src/ObjectSelector/_Factories.py +++ b/src/ObjectSelector/_Factories.py @@ -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) diff --git a/src/ObjectSelector/_FamilyFrame.py b/src/ObjectSelector/_FamilyFrame.py new file mode 100644 index 000000000..e5ab32028 --- /dev/null +++ b/src/ObjectSelector/_FamilyFrame.py @@ -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 diff --git a/src/ObjectSelector/_ObjectFrameBase.py b/src/ObjectSelector/_ObjectFrameBase.py new file mode 100644 index 000000000..d2f9a24fd --- /dev/null +++ b/src/ObjectSelector/_ObjectFrameBase.py @@ -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 diff --git a/src/ObjectSelector/_ObjectSelectorWindow.py b/src/ObjectSelector/_ObjectSelectorWindow.py index 5ab1b3616..f532929e5 100644 --- a/src/ObjectSelector/_ObjectSelectorWindow.py +++ b/src/ObjectSelector/_ObjectSelectorWindow.py @@ -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) diff --git a/src/ObjectSelector/_PersonSearchCriteriaWidget.py b/src/ObjectSelector/_PersonFilterFrame.py similarity index 98% rename from src/ObjectSelector/_PersonSearchCriteriaWidget.py rename to src/ObjectSelector/_PersonFilterFrame.py index 3ed4a2e70..7869ae26c 100644 --- a/src/ObjectSelector/_PersonSearchCriteriaWidget.py +++ b/src/ObjectSelector/_PersonFilterFrame.py @@ -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() diff --git a/src/ObjectSelector/_PersonFrame.py b/src/ObjectSelector/_PersonFrame.py new file mode 100644 index 000000000..83bc691a8 --- /dev/null +++ b/src/ObjectSelector/_PersonFrame.py @@ -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