From b097802fe653c515013e3475e54a523c639d02de Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 29 Apr 2007 21:10:58 +0200 Subject: [PATCH 1/3] Add ComboBox control. --- sugar/graphics/Makefile.am | 1 + sugar/graphics/combobox.py | 76 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 sugar/graphics/combobox.py diff --git a/sugar/graphics/Makefile.am b/sugar/graphics/Makefile.am index 36f9bf90..6756aa93 100644 --- a/sugar/graphics/Makefile.am +++ b/sugar/graphics/Makefile.am @@ -5,6 +5,7 @@ sugar_PYTHON = \ iconbutton.py \ canvasicon.py \ color.py \ + combobox.py \ font.py \ frame.py \ menu.py \ diff --git a/sugar/graphics/combobox.py b/sugar/graphics/combobox.py new file mode 100644 index 00000000..dec13802 --- /dev/null +++ b/sugar/graphics/combobox.py @@ -0,0 +1,76 @@ +# Copyright (C) 2007, One Laptop Per Child +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +import sys + +import gobject +import gtk + +class ComboBox(gtk.ComboBox): + __gtype_name__ = 'SugarComboBox' + + __gproperties__ = { + 'value' : (int, None, None, + 0, sys.maxint, 0, + gobject.PARAM_READABLE) + } + def __init__(self): + gtk.ComboBox.__init__(self) + + self._model = gtk.ListStore(gobject.TYPE_INT, + gobject.TYPE_STRING, + gobject.TYPE_STRING, + gobject.TYPE_BOOLEAN) + self.set_model(self._model) + + renderer = gtk.CellRendererPixbuf() + self.pack_start(renderer, False) + self.add_attribute(renderer, 'icon-name', 2) + + renderer = gtk.CellRendererText() + self.pack_start(renderer, True) + self.add_attribute(renderer, 'text', 1) + + self.set_row_separator_func(self._is_separator) + self.connect('realize', self._realize_cb) + + def do_get_property(self, pspec): + if pspec.name == 'value': + action_id, text, icon_name, is_separator = self.get_active_item() + return action_id + else: + return gtk.ComboBox.do_get_property(self, pspec) + + def _realize_cb(self, widget, data=None): + if self.get_active() == -1: + self.set_active(0) + + def append_item(self, action_id, text, icon_name=None): + self._model.append([action_id, text, icon_name, False]) + + def append_separator(self): + self._model.append([0, None, None, True]) + + def get_active_item(self): + index = self.get_active() + if index == -1: + index = 0 + + row = self._model.iter_nth_child(None, index) + return self._model[row] + + def _is_separator(self, model, row): + action_id, text, icon_name, is_separator = model[row] + return is_separator From d6445af2c8e403468e1f248a12af44d3a78fbacb Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 29 Apr 2007 21:11:59 +0200 Subject: [PATCH 2/3] Add method Toolbox.remove_toolbar(). --- sugar/graphics/toolbox.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sugar/graphics/toolbox.py b/sugar/graphics/toolbox.py index 94391208..441d157b 100644 --- a/sugar/graphics/toolbox.py +++ b/sugar/graphics/toolbox.py @@ -33,3 +33,6 @@ class Toolbox(gtk.VBox): def add_toolbar(self, name, toolbar): self._notebook.append_page(toolbar, gtk.Label(name)) + + def remove_toolbar(self, index): + self._notebook.remove_page(index) From b4f2016844c2b9c944cffefb316fd8d35e9456b2 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 29 Apr 2007 21:12:35 +0200 Subject: [PATCH 3/3] Launch the journal activity on startup again. --- shell/view/Shell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/view/Shell.py b/shell/view/Shell.py index 391657d5..0b6519ce 100644 --- a/shell/view/Shell.py +++ b/shell/view/Shell.py @@ -57,7 +57,7 @@ class Shell(gobject.GObject): home_model.connect('active-activity-changed', self._active_activity_changed_cb) - #self.start_activity('org.laptop.JournalActivity') + self.start_activity('org.laptop.JournalActivity') def _activity_added_cb(self, home_model, home_activity): activity_host = ActivityHost(home_activity)