From a09a786ff7a2ccc5657ac2708e048a183c90360c Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Sun, 02 Sep 2007 23:48:03 +0000 Subject: Use Tray also for the frame friends view. Drop the deprecated IconButton. --- (limited to 'sugar') diff --git a/sugar/graphics/Makefile.am b/sugar/graphics/Makefile.am index cf19379..53e05aa 100644 --- a/sugar/graphics/Makefile.am +++ b/sugar/graphics/Makefile.am @@ -6,7 +6,6 @@ sugar_PYTHON = \ combobox.py \ entry.py \ icon.py \ - iconbutton.py \ iconentry.py \ menuitem.py \ notebook.py \ diff --git a/sugar/graphics/iconbutton.py b/sugar/graphics/iconbutton.py deleted file mode 100644 index fd977f6..0000000 --- a/sugar/graphics/iconbutton.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright (C) 2007, One Laptop Per Child -# -# 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. - -# -# DEPRECATED. Do not use in new code. We will reimplement it in gtk -# - -import sys - -import gobject -import hippo - -from sugar.graphics.icon import CanvasIcon -from sugar.graphics import style - -class IconButton(CanvasIcon, hippo.CanvasItem): - __gtype_name__ = 'SugarIconButton' - - def __init__(self, **kwargs): - CanvasIcon.__init__(self, **kwargs) - - if not self.props.fill_color and not self.props.stroke_color: - self.props.fill_color = style.Color("#404040").get_svg() - self.props.stroke_color = style.Color("#FFFFFF").get_svg() - - self.connect('activated', self._icon_clicked_cb) - - self.props.box_width = style.GRID_CELL_SIZE - self.props.box_height = style.GRID_CELL_SIZE - self.props.size = style.STANDARD_ICON_SIZE - - def _icon_clicked_cb(self, button): - if self._palette: - self._palette.popdown(True) diff --git a/sugar/graphics/tray.py b/sugar/graphics/tray.py index 1845d33..e865db6 100644 --- a/sugar/graphics/tray.py +++ b/sugar/graphics/tray.py @@ -19,6 +19,7 @@ import gobject import gtk from sugar.graphics import style +from sugar.graphics.palette import Palette, ToolInvoker from sugar.graphics.toolbutton import ToolButton from sugar.graphics.icon import Icon @@ -145,6 +146,9 @@ class HTray(gtk.HBox): scroll_left.viewport = self._viewport scroll_right.viewport = self._viewport + def get_children(self): + return self._viewport.traybar.get_children() + def add_item(self, item, index=-1): self._viewport.traybar.insert(item, index) @@ -173,6 +177,9 @@ class VTray(gtk.VBox): scroll_left.viewport = self._viewport scroll_right.viewport = self._viewport + def get_children(self): + return self._viewport.traybar.get_children() + def add_item(self, item, index=-1): self._viewport.traybar.insert(item, index) @@ -185,3 +192,24 @@ class VTray(gtk.VBox): class TrayButton(ToolButton): def __init__(self, **kwargs): ToolButton.__init__(self, **kwargs) + +class TrayIcon(gtk.ToolItem): + def __init__(self, icon_name=None, xo_color=None): + gtk.ToolItem.__init__(self) + + event_box = gtk.EventBox() + + icon = Icon(icon_name=icon_name, xo_color=xo_color, + icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) + event_box.add(icon) + icon.show() + + self.add(event_box) + event_box.show() + + def set_palette(self, palette): + self._palette = palette + self._palette.props.invoker = ToolInvoker(self.child) + + def set_tooltip(self, text): + self.set_palette(Palette(text)) -- cgit v0.9.1