Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2007-08-28 12:15:51 (GMT)
committer Simon Schampijer <simon@schampijer.de>2007-08-28 12:15:51 (GMT)
commitc30bb01b0e37f26190835ed6fd42b68a8a2e2ad8 (patch)
tree519f5670021d2c22bd4e6407a2e05bea122089d1 /shell
parent44d2bb6ffbf12febadd7d1025d15ab6f69298e79 (diff)
Usage of the tray widget to display activity icons
ActivitiesBox patch for ticket #2713.
Diffstat (limited to 'shell')
-rw-r--r--shell/view/frame/ActivitiesBox.py32
-rw-r--r--shell/view/frame/Makefile.am1
-rw-r--r--shell/view/frame/activitybutton.py60
3 files changed, 75 insertions, 18 deletions
diff --git a/shell/view/frame/ActivitiesBox.py b/shell/view/frame/ActivitiesBox.py
index 78d7a45..affd34d 100644
--- a/shell/view/frame/ActivitiesBox.py
+++ b/shell/view/frame/ActivitiesBox.py
@@ -20,27 +20,13 @@ import logging
from sugar.graphics.palette import Palette
from sugar.graphics.xocolor import XoColor
from sugar.graphics.iconbutton import IconButton
+from sugar.graphics.tray import HTray
from sugar.graphics import style
from sugar import profile
from sugar import activity
from frameinvoker import FrameCanvasInvoker
-
-class ActivityButton(IconButton):
- def __init__(self, activity_info):
- IconButton.__init__(self, file_name=activity_info.icon,
- stroke_color=style.COLOR_WHITE.get_svg(),
- fill_color=style.COLOR_TRANSPARENT.get_svg())
-
- palette = Palette(activity_info.name)
- palette.props.invoker = FrameCanvasInvoker(self)
- palette.set_group_id('frame')
- self.set_palette(palette)
-
- self._activity_info = activity_info
-
- def get_bundle_id(self):
- return self._activity_info.service_name
+from activitybutton import ActivityButton
class InviteButton(IconButton):
def __init__(self, activity_model, invite):
@@ -67,6 +53,10 @@ class ActivitiesBox(hippo.CanvasBox):
self._invite_to_item = {}
self._invites = self._shell_model.get_invites()
+ self.tray = HTray()
+ self.append(hippo.CanvasWidget(widget=self.tray))
+ self.tray.show()
+
registry = activity.get_registry()
registry.get_activities_async(reply_handler=self._get_activities_cb)
@@ -96,13 +86,19 @@ class ActivitiesBox(hippo.CanvasBox):
def _invite_removed_cb(self, invites, invite):
self.remove_invite(invite)
+ def _activity_removed_cb(self, item):
+ index = self.tray.get_item_index(item)
+ self.tray.remove_item(index)
+
def _activity_added_cb(self, activity_registry, activity_info):
self.add_activity(activity_info)
def add_activity(self, activity_info):
item = ActivityButton(activity_info)
- item.connect('activated', self._activity_clicked_cb)
- self.append(item, 0)
+ item.connect('clicked', self._activity_clicked_cb)
+ item.connect('remove_activity', self._activity_removed_cb)
+ self.tray.add_item(item, -1)
+ item.show()
def add_invite(self, invite):
mesh = self._shell_model.get_mesh()
diff --git a/shell/view/frame/Makefile.am b/shell/view/frame/Makefile.am
index 4a7083b..e40219e 100644
--- a/shell/view/frame/Makefile.am
+++ b/shell/view/frame/Makefile.am
@@ -2,6 +2,7 @@ sugardir = $(pkgdatadir)/shell/view/frame
sugar_PYTHON = \
__init__.py \
ActivitiesBox.py \
+ activitybutton.py \
clipboardbox.py \
clipboardpanelwindow.py \
frameinvoker.py \
diff --git a/shell/view/frame/activitybutton.py b/shell/view/frame/activitybutton.py
new file mode 100644
index 0000000..f3e2b7e
--- /dev/null
+++ b/shell/view/frame/activitybutton.py
@@ -0,0 +1,60 @@
+# 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.
+
+import gtk
+import os
+import gobject
+
+from sugar.graphics.palette import Palette
+from sugar.graphics.tray import TrayButton
+from sugar.graphics.icon import Icon
+from sugar.graphics import style
+
+from gettext import gettext as _
+
+class ActivityButton(TrayButton, gobject.GObject):
+ __gtype_name__ = 'SugarActivityButton'
+ __gsignals__ = {
+ 'remove_activity': (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE, ([]))
+ }
+
+ def __init__(self, activity_info):
+ TrayButton.__init__(self)
+ icon = Icon(file=activity_info.icon,
+ stroke_color=style.COLOR_WHITE.get_svg(),
+ fill_color=style.COLOR_TRANSPARENT.get_svg())
+ self.set_icon_widget(icon)
+ icon.show()
+
+ self._activity_info = activity_info
+ self.setup_rollover_options()
+
+ def get_bundle_id(self):
+ return self._activity_info.service_name
+
+ def setup_rollover_options(self):
+ palette = Palette(self._activity_info.name)
+ self.set_palette(palette)
+
+ menu_item = gtk.MenuItem(_('Remove'))
+ menu_item.connect('activate', self.item_remove_cb)
+ palette.menu.append(menu_item)
+ menu_item.show()
+
+ def item_remove_cb(self, widget):
+ self.emit('remove_activity')