initial outline of object selector
svn: r5729
This commit is contained in:
parent
f213a120a4
commit
ab51961c95
@ -1,3 +1,9 @@
|
|||||||
|
2006-01-12 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||||
|
* src/ObjectSelector/_ObjectSelectorWindow.py: initial outline of ObjectSelector
|
||||||
|
* src/ObjectSelector/_PersonPreviewFrame.py: initial outline of ObjectSelector
|
||||||
|
* src/ObjectSelector/_PersonSearchCriteriaWidget.py: initial outline of ObjectSelector
|
||||||
|
|
||||||
|
|
||||||
2006-01-12 Alex Roitman <shura@gramps-project.org>
|
2006-01-12 Alex Roitman <shura@gramps-project.org>
|
||||||
* src/ViewManager.py: Connect undo handler to the menu item.
|
* src/ViewManager.py: Connect undo handler to the menu item.
|
||||||
* src/GrampsDb/_GrampsBSDDB.py: Place reference_map under
|
* src/GrampsDb/_GrampsBSDDB.py: Place reference_map under
|
||||||
|
4
gramps2/src/ObjectSelector/.cvsignore
Normal file
4
gramps2/src/ObjectSelector/.cvsignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
164
gramps2/src/ObjectSelector/_ObjectSelectorWindow.py
Normal file
164
gramps2/src/ObjectSelector/_ObjectSelectorWindow.py
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
import gtk
|
||||||
|
import gobject
|
||||||
|
|
||||||
|
from _PersonSearchCriteriaWidget import PersonSearchCriteriaWidget
|
||||||
|
from _PersonPreviewFrame import PersonPreviewFrame
|
||||||
|
|
||||||
|
class ObjectSelectorWindow(gtk.Window):
|
||||||
|
|
||||||
|
__gproperties__ = {}
|
||||||
|
|
||||||
|
__gsignals__ = {
|
||||||
|
}
|
||||||
|
|
||||||
|
__default_border_width = 5
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
gtk.Window.__init__(self)
|
||||||
|
|
||||||
|
self.set_title("Add Person")
|
||||||
|
|
||||||
|
# Selected object label
|
||||||
|
label = gtk.Label("Selected:")
|
||||||
|
sel_label = gtk.Label("No Selected Object")
|
||||||
|
sel_frame = gtk.Frame()
|
||||||
|
sel_frame.set_shadow_type(gtk.SHADOW_IN)
|
||||||
|
sel_frame.set_border_width(self.__class__.__default_border_width*2)
|
||||||
|
sel_frame.add(sel_label)
|
||||||
|
|
||||||
|
label_box = gtk.HBox()
|
||||||
|
label_box.pack_start(label,False,False)
|
||||||
|
label_box.pack_start(sel_frame,True,True)
|
||||||
|
|
||||||
|
# Toolbar
|
||||||
|
|
||||||
|
# FIXME: This should be done somewhere central
|
||||||
|
factory = gtk.IconFactory()
|
||||||
|
|
||||||
|
pixbuf = gtk.gdk.pixbuf_new_from_file("person.svg")
|
||||||
|
iconset = gtk.IconSet(pixbuf)
|
||||||
|
factory.add('gramps-person', iconset)
|
||||||
|
|
||||||
|
pixbuf = gtk.gdk.pixbuf_new_from_file("flist.svg")
|
||||||
|
iconset = gtk.IconSet(pixbuf)
|
||||||
|
factory.add('gramps-family', iconset)
|
||||||
|
|
||||||
|
factory.add_default()
|
||||||
|
|
||||||
|
tips = gtk.Tooltips()
|
||||||
|
|
||||||
|
person_tool = gtk.ToolButton("gramps-person")
|
||||||
|
person_tool.set_tooltip(tips,"Show People")
|
||||||
|
|
||||||
|
family_tool = gtk.ToolButton("gramps-family")
|
||||||
|
family_tool.set_tooltip(tips,"Show Families")
|
||||||
|
|
||||||
|
event_tool = gtk.ToolButton("gramps-person")
|
||||||
|
event_tool.set_tooltip(tips,"Show Events")
|
||||||
|
|
||||||
|
toolbar = gtk.Toolbar()
|
||||||
|
toolbar.insert(person_tool,0)
|
||||||
|
toolbar.insert(family_tool,1)
|
||||||
|
toolbar.insert(event_tool,2)
|
||||||
|
|
||||||
|
# Top box
|
||||||
|
|
||||||
|
top_box = gtk.HBox()
|
||||||
|
top_box.pack_start(toolbar,True,True)
|
||||||
|
top_box.pack_start(label_box,True,True)
|
||||||
|
|
||||||
|
# Filters
|
||||||
|
|
||||||
|
person_filter = PersonSearchCriteriaWidget()
|
||||||
|
|
||||||
|
# Preview
|
||||||
|
|
||||||
|
person_preview_frame = PersonPreviewFrame("Preview")
|
||||||
|
|
||||||
|
# Trees
|
||||||
|
|
||||||
|
# dummy data for testing
|
||||||
|
self.treestore = gtk.TreeStore(str)
|
||||||
|
|
||||||
|
# we'll add some data now - 4 rows with 3 child rows each
|
||||||
|
for parent in range(4):
|
||||||
|
piter = self.treestore.append(None, ['parent %i' % parent])
|
||||||
|
for child in range(3):
|
||||||
|
self.treestore.append(piter, ['child %i of parent %i' %
|
||||||
|
(child, parent)])
|
||||||
|
|
||||||
|
self.person_tree = gtk.TreeView(self.treestore)
|
||||||
|
self.tvcolumn = gtk.TreeViewColumn('Column 0')
|
||||||
|
self.person_tree.append_column(self.tvcolumn)
|
||||||
|
self.cell = gtk.CellRendererText()
|
||||||
|
self.tvcolumn.pack_start(self.cell, True)
|
||||||
|
self.tvcolumn.add_attribute(self.cell, 'text', 0)
|
||||||
|
self.person_tree.set_search_column(0)
|
||||||
|
self.tvcolumn.set_sort_column_id(0)
|
||||||
|
self.person_tree.set_reorderable(True)
|
||||||
|
|
||||||
|
p_tree_frame = gtk.Frame()
|
||||||
|
p_tree_frame.add(self.person_tree)
|
||||||
|
p_tree_frame.set_shadow_type(gtk.SHADOW_IN)
|
||||||
|
|
||||||
|
# paned
|
||||||
|
|
||||||
|
vbox = gtk.VBox()
|
||||||
|
vbox.pack_start(person_preview_frame,True,True)
|
||||||
|
vbox.pack_start(person_filter,True,True)
|
||||||
|
|
||||||
|
pane = gtk.HPaned()
|
||||||
|
pane.pack1(p_tree_frame,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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Bottom buttons
|
||||||
|
add_button = gtk.Button(stock=gtk.STOCK_ADD)
|
||||||
|
add_button.set_sensitive(False)
|
||||||
|
|
||||||
|
cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL)
|
||||||
|
|
||||||
|
bottom_button_bar = gtk.HButtonBox()
|
||||||
|
bottom_button_bar.set_layout(gtk.BUTTONBOX_SPREAD)
|
||||||
|
bottom_button_bar.set_spacing(self.__class__.__default_border_width/2)
|
||||||
|
bottom_button_bar.set_border_width(self.__class__.__default_border_width)
|
||||||
|
bottom_button_bar.add(cancel_button)
|
||||||
|
bottom_button_bar.add(add_button)
|
||||||
|
|
||||||
|
|
||||||
|
box = gtk.VBox()
|
||||||
|
box.pack_start(top_box,False,False)
|
||||||
|
box.pack_start(pane_align,True,True)
|
||||||
|
box.pack_start(bottom_button_bar,False,False)
|
||||||
|
|
||||||
|
align = gtk.Alignment()
|
||||||
|
align.set_padding(self.__class__.__default_border_width,
|
||||||
|
self.__class__.__default_border_width,
|
||||||
|
self.__class__.__default_border_width,
|
||||||
|
self.__class__.__default_border_width)
|
||||||
|
align.set(0.5,0.5,1,1)
|
||||||
|
align.add(box)
|
||||||
|
|
||||||
|
self.add(align)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if gtk.pygtk_version < (2,8,0):
|
||||||
|
gobject.type_register(PersonSearchCriteriaWidget)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
w = ObjectSelectorWindow()
|
||||||
|
w.show_all()
|
||||||
|
|
||||||
|
gtk.main()
|
67
gramps2/src/ObjectSelector/_PersonPreviewFrame.py
Normal file
67
gramps2/src/ObjectSelector/_PersonPreviewFrame.py
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import gtk
|
||||||
|
import gobject
|
||||||
|
|
||||||
|
class PersonPreviewFrame(gtk.Frame):
|
||||||
|
|
||||||
|
__gproperties__ = {}
|
||||||
|
|
||||||
|
__gsignals__ = {
|
||||||
|
}
|
||||||
|
|
||||||
|
__default_border_width = 5
|
||||||
|
|
||||||
|
def __init__(self,label="Filter"):
|
||||||
|
gtk.Frame.__init__(self,label)
|
||||||
|
|
||||||
|
align = gtk.Alignment()
|
||||||
|
|
||||||
|
# Image
|
||||||
|
image = gtk.Image()
|
||||||
|
|
||||||
|
# test image
|
||||||
|
image.set_from_file("person.svg")
|
||||||
|
image_frame = gtk.Frame()
|
||||||
|
image_frame.add(image)
|
||||||
|
|
||||||
|
# Text
|
||||||
|
label = gtk.Label()
|
||||||
|
label.set_use_markup(True)
|
||||||
|
label.set_line_wrap(True)
|
||||||
|
label.set_justify(gtk.JUSTIFY_LEFT)
|
||||||
|
label.set_alignment(xalign=0.1,yalign=0.1)
|
||||||
|
label.set_markup("<b>Name:</b> Joe Blogs\n"
|
||||||
|
"<b>b:</b> 1906\n"
|
||||||
|
"<b>d:</b> 1937\n")
|
||||||
|
|
||||||
|
# box
|
||||||
|
box = gtk.VBox()
|
||||||
|
box.pack_start(image_frame)
|
||||||
|
box.pack_start(label)
|
||||||
|
|
||||||
|
|
||||||
|
# align
|
||||||
|
|
||||||
|
align.add(box)
|
||||||
|
align.set_padding(self.__class__.__default_border_width,
|
||||||
|
self.__class__.__default_border_width,
|
||||||
|
self.__class__.__default_border_width,
|
||||||
|
self.__class__.__default_border_width)
|
||||||
|
align.set(0.5,0.5,
|
||||||
|
1.0,1.0)
|
||||||
|
|
||||||
|
|
||||||
|
self.add(align)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if gtk.pygtk_version < (2,8,0):
|
||||||
|
gobject.type_register(PersonPreviewFrame)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
w = gtk.Window()
|
||||||
|
f = PersonPreviewFrame()
|
||||||
|
w.add(f)
|
||||||
|
w.show_all()
|
||||||
|
|
||||||
|
gtk.main()
|
229
gramps2/src/ObjectSelector/_PersonSearchCriteriaWidget.py
Normal file
229
gramps2/src/ObjectSelector/_PersonSearchCriteriaWidget.py
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
import gtk
|
||||||
|
import gobject
|
||||||
|
|
||||||
|
class PersonSearchCriteriaWidget(gtk.Frame):
|
||||||
|
|
||||||
|
__gproperties__ = {}
|
||||||
|
|
||||||
|
__gsignals__ = {
|
||||||
|
}
|
||||||
|
|
||||||
|
__default_border_width = 5
|
||||||
|
|
||||||
|
def __init__(self,label="Filter"):
|
||||||
|
gtk.Frame.__init__(self,label)
|
||||||
|
|
||||||
|
align = gtk.Alignment()
|
||||||
|
|
||||||
|
# Gramps ID
|
||||||
|
id_check = gtk.CheckButton()
|
||||||
|
id_label = gtk.Label("Gramps ID:")
|
||||||
|
id_label.set_sensitive(False)
|
||||||
|
id_label.set_alignment(xalign=0,yalign=0.5)
|
||||||
|
|
||||||
|
id_edit = gtk.Entry()
|
||||||
|
id_edit.set_sensitive(False)
|
||||||
|
|
||||||
|
id_box = gtk.HBox()
|
||||||
|
id_box.pack_start(id_label,False,False)
|
||||||
|
id_box.pack_start(id_edit,True,True)
|
||||||
|
|
||||||
|
id_check.connect('toggled',lambda b: id_edit.set_sensitive(id_check.get_active()))
|
||||||
|
id_check.connect('toggled',lambda b: id_label.set_sensitive(id_check.get_active()))
|
||||||
|
|
||||||
|
# Name
|
||||||
|
name_check = gtk.CheckButton()
|
||||||
|
name_label = gtk.Label("Name:")
|
||||||
|
name_label.set_sensitive(False)
|
||||||
|
name_label.set_alignment(xalign=0,yalign=0.5)
|
||||||
|
|
||||||
|
name_edit = gtk.Entry()
|
||||||
|
name_edit.set_sensitive(False)
|
||||||
|
|
||||||
|
name_box = gtk.HBox()
|
||||||
|
name_box.pack_start(name_label,False,False)
|
||||||
|
name_box.pack_start(name_edit,True,True)
|
||||||
|
|
||||||
|
name_check.connect('toggled',lambda b: name_edit.set_sensitive(name_check.get_active()))
|
||||||
|
name_check.connect('toggled',lambda b: name_label.set_sensitive(name_check.get_active()))
|
||||||
|
|
||||||
|
# Gender
|
||||||
|
gender_check = gtk.CheckButton()
|
||||||
|
gender_label = gtk.Label("Gender:")
|
||||||
|
gender_label.set_sensitive(False)
|
||||||
|
gender_label.set_alignment(xalign=0,yalign=0.5)
|
||||||
|
|
||||||
|
gender_combo = gtk.combo_box_new_text()
|
||||||
|
gender_combo.append_text("Male")
|
||||||
|
gender_combo.append_text("Female")
|
||||||
|
gender_combo.append_text("Unknown")
|
||||||
|
gender_combo.set_active(2)
|
||||||
|
gender_combo.set_sensitive(False)
|
||||||
|
|
||||||
|
|
||||||
|
gender_box = gtk.HBox()
|
||||||
|
gender_box.pack_start(gender_label,False,False)
|
||||||
|
gender_box.pack_start(gender_combo,True,True)
|
||||||
|
|
||||||
|
gender_check.connect('toggled',lambda b: gender_combo.set_sensitive(gender_check.get_active()))
|
||||||
|
gender_check.connect('toggled',lambda b: gender_label.set_sensitive(gender_check.get_active()))
|
||||||
|
|
||||||
|
# Birth
|
||||||
|
birth_check = gtk.CheckButton()
|
||||||
|
birth_check.set_alignment(xalign=0,yalign=0)
|
||||||
|
|
||||||
|
#birth_frame = gtk.Frame("Birth")
|
||||||
|
#birth_frame.set_sensitive(False)
|
||||||
|
|
||||||
|
#birth_check.connect('toggled',lambda b: birth_frame.set_sensitive(birth_check.get_active()))
|
||||||
|
|
||||||
|
birth_box = gtk.HBox()
|
||||||
|
birth_box.set_sensitive(False)
|
||||||
|
birth_check.connect('toggled',lambda b: birth_box.set_sensitive(birth_check.get_active()))
|
||||||
|
|
||||||
|
b_label = gtk.Label("Birth:")
|
||||||
|
b_label.set_alignment(xalign=0,yalign=0)
|
||||||
|
|
||||||
|
b_edit = gtk.Entry()
|
||||||
|
b_before = gtk.RadioButton(group=None,label="Before")
|
||||||
|
b_after = gtk.RadioButton(b_before,"After")
|
||||||
|
b_before.set_active(True)
|
||||||
|
b_unknown = gtk.CheckButton("Include Unknown")
|
||||||
|
b_unknown.set_active(True)
|
||||||
|
|
||||||
|
b_inner_box = gtk.HBox()
|
||||||
|
b_inner_box.pack_start(b_before)
|
||||||
|
b_inner_box.pack_start(b_after)
|
||||||
|
|
||||||
|
b_box = gtk.VBox()
|
||||||
|
b_box.pack_start(b_edit,True,True)
|
||||||
|
b_box.pack_start(b_inner_box,False)
|
||||||
|
b_box.pack_start(b_unknown,False)
|
||||||
|
|
||||||
|
b_align = gtk.Alignment()
|
||||||
|
b_align.set(0.5,0.5,1,1)
|
||||||
|
b_align.add(b_box)
|
||||||
|
|
||||||
|
#birth_frame.add(b_align)
|
||||||
|
birth_box.pack_start(b_label,False,False)
|
||||||
|
birth_box.pack_start(b_align,True,True)
|
||||||
|
|
||||||
|
# Death
|
||||||
|
|
||||||
|
death_check = gtk.CheckButton()
|
||||||
|
#death_frame = gtk.Frame("Death")
|
||||||
|
#death_frame.set_sensitive(False)
|
||||||
|
|
||||||
|
#death_check.connect('toggled',lambda b: death_frame.set_sensitive(death_check.get_active()))
|
||||||
|
|
||||||
|
death_box = gtk.HBox()
|
||||||
|
death_box.set_sensitive(False)
|
||||||
|
death_check.connect('toggled',lambda b: death_box.set_sensitive(death_check.get_active()))
|
||||||
|
|
||||||
|
d_label = gtk.Label("Death:")
|
||||||
|
d_label.set_alignment(xalign=0,yalign=0)
|
||||||
|
|
||||||
|
d_edit = gtk.Entry()
|
||||||
|
d_before = gtk.RadioButton(group=None,label="Before")
|
||||||
|
d_after = gtk.RadioButton(d_before,"After")
|
||||||
|
d_before.set_active(True)
|
||||||
|
d_unknown = gtk.CheckButton("Include Unknown")
|
||||||
|
d_unknown.set_active(True)
|
||||||
|
|
||||||
|
d_inner_box = gtk.HBox()
|
||||||
|
d_inner_box.pack_start(d_before)
|
||||||
|
d_inner_box.pack_start(d_after)
|
||||||
|
|
||||||
|
d_box = gtk.VBox()
|
||||||
|
d_box.pack_start(d_edit,True,True)
|
||||||
|
d_box.pack_start(d_inner_box,False)
|
||||||
|
d_box.pack_start(d_unknown,False)
|
||||||
|
|
||||||
|
d_align = gtk.Alignment()
|
||||||
|
b_align.set(0.5,0.5,1,1)
|
||||||
|
|
||||||
|
d_align.add(d_box)
|
||||||
|
|
||||||
|
#death_frame.add(d_align)
|
||||||
|
death_box.pack_start(d_label,False,False)
|
||||||
|
death_box.pack_start(d_align,True,True)
|
||||||
|
|
||||||
|
# Filter
|
||||||
|
filter_check = gtk.CheckButton()
|
||||||
|
filter_label = gtk.Label("Filter:")
|
||||||
|
filter_label.set_sensitive(False)
|
||||||
|
filter_label.set_alignment(xalign=0,yalign=0.5)
|
||||||
|
|
||||||
|
filter_combo = gtk.combo_box_new_text()
|
||||||
|
filter_combo.append_text("Male")
|
||||||
|
filter_combo.append_text("Female")
|
||||||
|
filter_combo.append_text("Unknown")
|
||||||
|
filter_combo.set_active(2)
|
||||||
|
filter_combo.set_sensitive(False)
|
||||||
|
|
||||||
|
|
||||||
|
filter_box = gtk.HBox()
|
||||||
|
filter_box.pack_start(filter_label,False,False)
|
||||||
|
filter_box.pack_start(filter_combo,True,True)
|
||||||
|
|
||||||
|
filter_check.connect('toggled',lambda b: filter_combo.set_sensitive(filter_check.get_active()))
|
||||||
|
filter_check.connect('toggled',lambda b: filter_label.set_sensitive(filter_check.get_active()))
|
||||||
|
|
||||||
|
# table layout
|
||||||
|
|
||||||
|
table = gtk.Table(2,6,False)
|
||||||
|
table.set_row_spacings(5)
|
||||||
|
table.set_col_spacings(5)
|
||||||
|
table.attach(id_check,0,1,0,1,xoptions=False,yoptions=False)
|
||||||
|
table.attach(id_box,1,2,0,1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
|
||||||
|
|
||||||
|
table.attach(name_check,0,1,1,2,xoptions=False,yoptions=False)
|
||||||
|
table.attach(name_box,1,2,1,2,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
|
||||||
|
|
||||||
|
table.attach(gender_check,0,1,2,3,xoptions=False,yoptions=False)
|
||||||
|
table.attach(gender_box,1,2,2,3,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
|
||||||
|
|
||||||
|
table.attach(birth_check,0,1,3,4,xoptions=False,yoptions=False)
|
||||||
|
table.attach(birth_box,1,2,3,4,xoptions=gtk.EXPAND|gtk.FILL,yoptions=gtk.EXPAND|gtk.FILL)
|
||||||
|
|
||||||
|
table.attach(death_check,0,1,4,5,xoptions=False,yoptions=False)
|
||||||
|
table.attach(death_box,1,2,4,5,xoptions=gtk.EXPAND|gtk.FILL,yoptions=gtk.EXPAND|gtk.FILL)
|
||||||
|
|
||||||
|
table.attach(filter_check,0,1,5,6,xoptions=False,yoptions=False)
|
||||||
|
table.attach(filter_box,1,2,5,6,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
|
||||||
|
|
||||||
|
# Apply
|
||||||
|
|
||||||
|
apply_button = gtk.Button(stock=gtk.STOCK_APPLY)
|
||||||
|
|
||||||
|
|
||||||
|
# Outer box
|
||||||
|
|
||||||
|
outer_box = gtk.VBox()
|
||||||
|
outer_box.pack_start(table,True,True)
|
||||||
|
outer_box.pack_start(apply_button,False,False)
|
||||||
|
outer_box.set_border_width(self.__class__.__default_border_width/2)
|
||||||
|
outer_box.set_spacing(self.__class__.__default_border_width/2)
|
||||||
|
|
||||||
|
align.add(outer_box)
|
||||||
|
align.set_padding(self.__class__.__default_border_width,
|
||||||
|
self.__class__.__default_border_width,
|
||||||
|
self.__class__.__default_border_width,
|
||||||
|
self.__class__.__default_border_width)
|
||||||
|
|
||||||
|
|
||||||
|
self.add(align)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if gtk.pygtk_version < (2,8,0):
|
||||||
|
gobject.type_register(PersonSearchCriteriaWidget)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
w = gtk.Window()
|
||||||
|
f = PersonSearchCriteriaWidget()
|
||||||
|
w.add(f)
|
||||||
|
w.show_all()
|
||||||
|
|
||||||
|
gtk.main()
|
Loading…
Reference in New Issue
Block a user