diff options
author | Daniel Francis <francis@sugarlabs.org> | 2012-07-01 17:01:31 (GMT) |
---|---|---|
committer | Rafael Ortiz <rafael@activitycentral.com> | 2012-07-03 05:29:31 (GMT) |
commit | 6b9ff449e17cc7ac7327138234a72b1066202c18 (patch) | |
tree | e7746f077b65a16c2af61eb42e129ccef3d63ed6 /toolitem.py | |
parent | 4e2df4e10931eac04393c3cc8abe99953b17dcc6 (diff) |
Migrating from the early toolbarbox-toolkit modules to Sugar Toolkit
This little patch is the second step in the Gtk3 migration.
Here I remove some few unnecesary files always when it was possible, and use Sugar Toolkit.
The purpose is to prevent a headache at the time of porting to Gtk3 the activity, and of course remove some useless kilobytes and not having written the same code twice.
I also modified the .gitignore file, I didn't type 'git add .gitignore' previous than my commit so I didn't expect it would appear in my patch, I think git has its own life :) , but anyway, is better having a correct .gitignore .
Signed-off-by: Daniel Francis <francis@sugarlabs.org>
Diffstat (limited to 'toolitem.py')
-rw-r--r-- | toolitem.py | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/toolitem.py b/toolitem.py new file mode 100644 index 0000000..1f4ee49 --- /dev/null +++ b/toolitem.py @@ -0,0 +1,77 @@ +# Copyright (C) 2009, Aleksey Lim +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +"""A set of toolitem widets""" + +import gtk +import gobject + +from sugar.graphics import style + + +class ToolWidget(gtk.ToolItem): + + def __init__(self, **kwargs): + self._widget = None + self._label = None + self._label_text = None + self._box = gtk.HBox(False, style.DEFAULT_SPACING) + + gobject.GObject.__init__(self, **kwargs) + self.props.border_width = style.DEFAULT_PADDING + + self._box.show() + self.add(self._box) + + if self.label is None: + self.label = gtk.Label() + + def get_label_text(self): + return self._label_text + + def set_label_text(self, value): + self._label_text = value + if self.label is not None and value: + self.label.set_text(self._label_text) + + label_text = gobject.property(getter=get_label_text, setter=set_label_text) + + def get_label(self): + return self._label + + def set_label(self, label): + if self._label is not None: + self._box.remove(self._label) + self._label = label + self._box.pack_start(label, False) + self._box.reorder_child(label, 0) + label.show() + self.set_label_text(self._label_text) + + label = gobject.property(getter=get_label, setter=set_label) + + def get_widget(self): + return self._widget + + def set_widget(self, widget): + if self._widget is not None: + self._box.remove(self._widget) + self._widget = widget + self._box.pack_end(widget) + widget.show() + + widget = gobject.property(getter=get_widget, setter=set_widget) |