sugar-toolkit-gtk3/shell/home/HomeGroup.py

78 lines
2.0 KiB
Python
Raw Normal View History

2006-07-08 11:56:13 +02:00
import gtk
import goocanvas
2006-08-17 12:09:45 +02:00
import wnck
from sugar.canvas.IconItem import IconItem
2006-08-23 21:03:17 +02:00
from sugar.canvas.IconColor import IconColor
2006-08-26 11:47:02 +02:00
from home.DonutItem import DonutItem
2006-08-25 00:49:39 +02:00
import sugar.conf
2006-08-17 11:47:41 +02:00
2006-08-23 14:13:15 +02:00
import Theme
2006-08-17 11:47:41 +02:00
class TasksItem(DonutItem):
def __init__(self, shell):
2006-08-17 13:16:48 +02:00
DonutItem.__init__(self, 250)
2006-08-17 12:09:45 +02:00
self._items = {}
2006-08-29 16:29:56 +02:00
self._shell = shell
self._shell.connect('activity_opened', self.__activity_opened_cb)
self._shell.connect('activity_closed', self.__activity_closed_cb)
2006-08-17 12:09:45 +02:00
def __activity_opened_cb(self, shell, activity):
self._add(activity)
2006-08-17 12:09:45 +02:00
def __activity_closed_cb(self, shell, activity):
self._remove(activity)
2006-08-17 12:09:45 +02:00
def _remove(self, activity):
item = self._items[activity.get_id()]
self.remove_piece(item)
del self._items[activity.get_id()]
2006-08-17 12:09:45 +02:00
def _add(self, activity):
icon_name = activity.get_icon_name()
2006-08-26 14:17:55 +02:00
icon_color = activity.get_icon_color()
2006-08-29 16:29:56 +02:00
item = self.add_piece(100 / 8, icon_name, icon_color)
item.get_icon().connect('clicked',
self.__activity_icon_clicked_cb,
activity)
self._items[activity.get_id()] = item
2006-08-29 16:29:56 +02:00
def __activity_icon_clicked_cb(self, item, activity):
activity.present()
2006-08-29 14:39:34 +02:00
class HomeGroup(goocanvas.Group):
WIDTH = 1200.0
HEIGHT = 900.0
def __init__(self, shell):
goocanvas.Group.__init__(self)
2006-08-23 14:13:15 +02:00
self._theme = Theme.get_instance()
self._theme.connect("theme-changed", self.__theme_changed_cb)
2006-08-16 22:01:43 +02:00
color = self._theme.get_home_activities_color()
2006-08-29 14:39:34 +02:00
self._home_rect = goocanvas.Rect(width=HomeGroup.WIDTH,
height=HomeGroup.HEIGHT,
line_width=0, fill_color=color,
radius_x=30, radius_y=30)
2006-08-23 14:06:45 +02:00
self.add_child(self._home_rect)
2006-08-16 22:01:43 +02:00
tasks = TasksItem(shell)
2006-08-17 11:47:41 +02:00
tasks.translate(600, 450)
self.add_child(tasks)
2006-08-17 11:47:41 +02:00
2006-08-25 00:49:39 +02:00
profile = sugar.conf.get_profile()
me = IconItem(icon_name = 'stock-buddy',
color = profile.get_color(), size = 150)
2006-08-19 13:39:13 +02:00
me.translate(600 - (me.get_property('width') / 2),
450 - (me.get_property('height') / 2))
self.add_child(me)
2006-08-29 14:39:34 +02:00
def __theme_changed_cb(self, theme):
color = self._theme.get_home_activities_color()
self._home_rect.set_property("fill-color", color)