Add icon for activity to the donut.
Add signals in the shell for window open/close and use them in the task view.
This commit is contained in:
@@ -20,9 +20,15 @@ class ActivityHost:
|
||||
self._gdk_window = gtk.gdk.window_foreign_new(self._xid)
|
||||
self._people_window = PeopleWindow(shell, self)
|
||||
|
||||
info = self._shell.get_registry().get_activity(self._default_type)
|
||||
self._icon_name = info.get_icon()
|
||||
|
||||
def get_id(self):
|
||||
return self._id
|
||||
|
||||
def get_icon_name(self):
|
||||
return self._icon_name
|
||||
|
||||
def share(self):
|
||||
self._people_window.share()
|
||||
self._activity.share()
|
||||
|
||||
@@ -13,7 +13,8 @@ class ChatController:
|
||||
|
||||
self._shell.connect('activity-closed', self.__activity_closed_cb)
|
||||
|
||||
def __activity_closed_cb(self, shell, activity_id):
|
||||
def __activity_closed_cb(self, shell, activity):
|
||||
activity_id = activity.get_id()
|
||||
if self._id_to_name.has_key(activity_id):
|
||||
name = self._id_to_name[activity_id]
|
||||
del self._name_to_chat[name]
|
||||
|
||||
+18
-23
@@ -7,35 +7,30 @@ from sugar.canvas.DonutItem import DonutItem
|
||||
from sugar.canvas.DonutItem import PieceItem
|
||||
|
||||
class TasksItem(DonutItem):
|
||||
def __init__(self):
|
||||
def __init__(self, shell):
|
||||
DonutItem.__init__(self, 250)
|
||||
|
||||
self._items = {}
|
||||
|
||||
screen = wnck.screen_get_default()
|
||||
for window in screen.get_windows():
|
||||
if not window.is_skip_tasklist():
|
||||
self._add(window)
|
||||
screen.connect('window_opened', self.__window_opened_cb)
|
||||
screen.connect('window_closed', self.__window_closed_cb)
|
||||
shell.connect('activity_opened', self.__activity_opened_cb)
|
||||
shell.connect('activity_closed', self.__activity_closed_cb)
|
||||
|
||||
def __window_opened_cb(self, screen, window):
|
||||
if not window.is_skip_tasklist():
|
||||
self._add(window)
|
||||
def __activity_opened_cb(self, shell, activity):
|
||||
self._add(activity)
|
||||
|
||||
def __window_closed_cb(self, screen, window):
|
||||
if not window.is_skip_tasklist():
|
||||
self._remove(window)
|
||||
def __activity_closed_cb(self, shell, activity):
|
||||
self._remove(activity)
|
||||
|
||||
def _remove(self, window):
|
||||
item = self._items[window.get_xid()]
|
||||
def _remove(self, activity):
|
||||
item = self._items[activity.get_id()]
|
||||
self.remove_child(item)
|
||||
del self._items[window.get_xid()]
|
||||
del self._items[activity.get_id()]
|
||||
|
||||
def _add(self, window):
|
||||
item = self.add_piece(100 / 8)
|
||||
item.set_data('window', window)
|
||||
self._items[window.get_xid()] = item
|
||||
def _add(self, activity):
|
||||
icon_name = activity.get_icon_name()
|
||||
item = self.add_piece(100 / 8, icon_name, 'blue')
|
||||
item.set_data('activity', activity)
|
||||
self._items[activity.get_id()] = item
|
||||
|
||||
class ActivityItem(IconItem):
|
||||
def __init__(self, activity):
|
||||
@@ -91,7 +86,7 @@ class Model(goocanvas.CanvasModelSimple):
|
||||
activity_bar.translate(50, 860)
|
||||
root.add_child(activity_bar)
|
||||
|
||||
tasks = TasksItem()
|
||||
tasks = TasksItem(shell)
|
||||
tasks.translate(600, 450)
|
||||
root.add_child(tasks)
|
||||
|
||||
@@ -130,8 +125,8 @@ class HomeWindow(gtk.Window):
|
||||
self._shell.start_activity(activity_id)
|
||||
|
||||
def __task_button_press_cb(self, view, target, event):
|
||||
window = view.get_item().get_data('window')
|
||||
window.activate(gtk.get_current_event_time())
|
||||
activity = view.get_item().get_data('activity')
|
||||
activity.present()
|
||||
|
||||
def __realize_cb(self, window):
|
||||
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DESKTOP)
|
||||
|
||||
+9
-4
@@ -39,7 +39,10 @@ class ShellDbusService(dbus.service.Object):
|
||||
|
||||
class Shell(gobject.GObject):
|
||||
__gsignals__ = {
|
||||
'activity-closed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([str]))
|
||||
'activity-opened': (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])),
|
||||
'activity-closed': (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT]))
|
||||
}
|
||||
|
||||
def __init__(self, registry):
|
||||
@@ -71,14 +74,16 @@ class Shell(gobject.GObject):
|
||||
|
||||
def __window_opened_cb(self, screen, window):
|
||||
if window.get_window_type() == wnck.WINDOW_NORMAL:
|
||||
self._hosts[window.get_xid()] = ActivityHost(self, window)
|
||||
host = ActivityHost(self, window)
|
||||
self._hosts[window.get_xid()] = host
|
||||
self.emit('activity-opened', host)
|
||||
|
||||
def __window_closed_cb(self, screen, window):
|
||||
if window.get_window_type() == wnck.WINDOW_NORMAL:
|
||||
xid = window.get_xid()
|
||||
|
||||
activity = self._hosts[xid]
|
||||
self.emit('activity-closed', activity.get_id())
|
||||
host = self._hosts[xid]
|
||||
self.emit('activity-closed', host)
|
||||
|
||||
del self._hosts[xid]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user