4 from gazpacho.widgets.base.base
import SimpleContainerAdaptor
44 __gtype_name__ =
'HIGContainer'
48 'title': (str,
'Group Title',
'the group title',
49 '', gobject.PARAM_READWRITE|gobject.PARAM_CONSTRUCT),
55 @param self: this object
59 gtk.widget_push_composite_child()
60 self.
__title = gobject.new(gtk.Label, visible=
True, xalign=0, yalign=0.5)
61 self.
__indent = gobject.new(gtk.Label, visible=
True, label=
' ')
62 gtk.widget_pop_composite_child()
63 gtk.Bin.__init__(self)
64 self.__title.set_parent(self)
65 self.__indent.set_parent(self)
67 self.props.title = title
73 @param self: this object
74 @param requisition: requisition
77 title_req = gtk.gdk.Rectangle(0, 0, *self.__title.size_request())
78 indent_req = gtk.gdk.Rectangle(0, 0, *self.__indent.size_request())
79 if self.child
is None:
80 child_req = gtk.gdk.Rectangle()
82 child_req = gtk.gdk.Rectangle(0, 0, *self.child.size_request())
83 requisition.height = (title_req.height + 6 +
84 max(child_req.height, indent_req.height))
85 requisition.width =
max(title_req.width, indent_req.width + child_req.width)
89 Allocate size function
91 @param self: this object
92 @param allocation: allocation
95 self.allocation = allocation
98 title_req = gtk.gdk.Rectangle(0, 0, *self.__title.get_child_requisition())
99 title_alloc = gtk.gdk.Rectangle()
100 title_alloc.x = allocation.x
101 title_alloc.y = allocation.y
102 title_alloc.width =
min(title_req.width, allocation.width)
103 title_alloc.height =
min(title_req.height, allocation.height)
104 self.__title.size_allocate(title_alloc)
107 if self.child
is None:
109 indent_req = gtk.gdk.Rectangle(0, 0, *self.__indent.get_child_requisition())
110 child_req = gtk.gdk.Rectangle(0, 0, *self.child.get_child_requisition())
111 child_alloc = gtk.gdk.Rectangle()
112 child_alloc.x = allocation.x + indent_req.width
113 child_alloc.y = allocation.y + title_alloc.height + 6
114 child_alloc.width = allocation.width - indent_req.width
115 child_alloc.height = allocation.height - 6 - title_alloc.height
116 self.child.size_allocate(child_alloc)
122 @param self: this object
123 @param internal: internal
124 @param callback: callback
131 if self.child
is not None:
132 callback(self.child, data)
136 Set property function
138 @param self: this object
139 @param pspec: internal
140 @param value: callback
141 @return AttributeError if unknown property
143 if pspec.name ==
'title':
144 self.__title.set_markup(
'<span weight="bold">%s</span>' %
145 gobject.markup_escape_text(value))
148 raise AttributeError,
'unknown property %s' % pspec.name
152 Set property function
154 @param self: this object
155 @param pspec: internal
158 if pspec.name ==
'title':
161 raise AttributeError,
'unknown property %s' % pspec.name
163 if __name__ ==
'__main__':
165 group = gobject.new(HIGContainer, title=
"Hello")
167 check = gtk.CheckButton(
"foobar")
172 w.connect(
"destroy",
lambda w: gtk.main_quit())
def do_size_request(self, requisition)
Size request function.
def do_forall(self, internal, callback, data)
For all function.
def do_get_property(self, pspec)
Set property function.
def do_set_property(self, pspec, value)
Set property function.
def do_size_allocate(self, allocation)
Allocate size function.