1,293 bytes added
, 11:05, 5 August 2011
=Summary=
There are a lot of code copy/pasted in the activities, and we can provide a easier API to new/occasional developers.
Would be good use the change to GTK3 to improve our small sugar-toolkit/sugar APIs
This pages is right now, to discuss ideas, and collect useful information.
=Owner=
The Activity Team
=Ideas=
== Toolbar items factory methods ==
Walter use in his activities factory methods to create buttons, separators, entry, etc.
This remove a lot of duplicated code.
Example:
def _label_factory(label, toolbar):
''' Factory for adding a label to a toolbar '''
my_label = gtk.Label(label)
my_label.set_line_wrap(True)
my_label.show()
_toolitem = gtk.ToolItem()
_toolitem.add(my_label)
toolbar.insert(_toolitem, -1)
_toolitem.show()
return my_label
def _entry_factory(length, toolbar, callback):
''' Factory for adding a text enrty to a toolbar '''
my_entry = gtk.Entry()
my_entry.set_max_length(length)
my_entry.set_width_chars(length)
my_entry.connect('changed', callback)
my_entry.show()
_toolitem = gtk.ToolItem()
_toolitem.add(my_entry)
toolbar.insert(_toolitem, -1)
_toolitem.show()
return my_entry
We can add methods like create_button, create_label and create_entry to the toolbar