4 from gazpacho.widgets.base.base
import SimpleContainerAdaptor
12 __gtype_name__ =
'HIGContainer'
14 'title': (str,
'Group Title',
'the group title',
15 '', gobject.PARAM_READWRITE|gobject.PARAM_CONSTRUCT),
20 gtk.widget_push_composite_child()
21 self.
__title = gobject.new(gtk.Label, visible=
True, xalign=0, yalign=0.5)
22 self.
__indent = gobject.new(gtk.Label, visible=
True, label=
' ')
23 gtk.widget_pop_composite_child()
24 gtk.Bin.__init__(self)
25 self.__title.set_parent(self)
26 self.__indent.set_parent(self)
28 self.props.title = title
31 title_req = gtk.gdk.Rectangle(0, 0, *self.__title.size_request())
32 indent_req = gtk.gdk.Rectangle(0, 0, *self.__indent.size_request())
33 if self.child
is None:
34 child_req = gtk.gdk.Rectangle()
36 child_req = gtk.gdk.Rectangle(0, 0, *self.child.size_request())
37 requisition.height = (title_req.height + 6 +
38 max(child_req.height, indent_req.height))
39 requisition.width = max(title_req.width, indent_req.width + child_req.width)
42 self.allocation = allocation
45 title_req = gtk.gdk.Rectangle(0, 0, *self.__title.get_child_requisition())
46 title_alloc = gtk.gdk.Rectangle()
47 title_alloc.x = allocation.x
48 title_alloc.y = allocation.y
49 title_alloc.width = min(title_req.width, allocation.width)
50 title_alloc.height = min(title_req.height, allocation.height)
51 self.__title.size_allocate(title_alloc)
54 if self.child
is None:
56 indent_req = gtk.gdk.Rectangle(0, 0, *self.__indent.get_child_requisition())
57 child_req = gtk.gdk.Rectangle(0, 0, *self.child.get_child_requisition())
58 child_alloc = gtk.gdk.Rectangle()
59 child_alloc.x = allocation.x + indent_req.width
60 child_alloc.y = allocation.y + title_alloc.height + 6
61 child_alloc.width = allocation.width - indent_req.width
62 child_alloc.height = allocation.height - 6 - title_alloc.height
63 self.child.size_allocate(child_alloc)
69 if self.child
is not None:
70 callback(self.child, data)
73 if pspec.name ==
'title':
74 self.__title.set_markup(
'<span weight="bold">%s</span>' %
75 gobject.markup_escape_text(value))
78 raise AttributeError,
'unknown property %s' % pspec.name
81 if pspec.name ==
'title':
84 raise AttributeError,
'unknown property %s' % pspec.name
86 if __name__ ==
'__main__':
88 group = gobject.new(HIGContainer, title=
"Hello")
90 check = gtk.CheckButton(
"foobar")
95 w.connect(
"destroy",
lambda w: gtk.main_quit())