Get tasks adding to work
This commit is contained in:
parent
e5ed8275a1
commit
fb829989c7
@ -1,5 +1,6 @@
|
|||||||
import gtk
|
import gtk
|
||||||
import goocanvas
|
import goocanvas
|
||||||
|
import wnck
|
||||||
|
|
||||||
from sugar.canvas.IconItem import IconItem
|
from sugar.canvas.IconItem import IconItem
|
||||||
from sugar.canvas.DonutItem import DonutItem
|
from sugar.canvas.DonutItem import DonutItem
|
||||||
@ -7,10 +8,32 @@ from sugar.canvas.DonutItem import DonutItem
|
|||||||
class TasksItem(DonutItem):
|
class TasksItem(DonutItem):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
DonutItem.__init__(self, 200)
|
DonutItem.__init__(self, 200)
|
||||||
self.add_piece(30)
|
|
||||||
self.add_piece(30)
|
self._items = {}
|
||||||
self.add_piece(30)
|
|
||||||
self.add_piece(10)
|
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)
|
||||||
|
|
||||||
|
def __window_opened_cb(self, screen, window):
|
||||||
|
if not window.is_skip_tasklist():
|
||||||
|
self._add(window)
|
||||||
|
|
||||||
|
def __window_closed_cb(self, screen, window):
|
||||||
|
if not window.is_skip_tasklist():
|
||||||
|
self._remove(window)
|
||||||
|
|
||||||
|
def _remove(self, window):
|
||||||
|
item = self._items[window.get_xid()]
|
||||||
|
self.remove_child(item)
|
||||||
|
del self._items[window.get_xid()]
|
||||||
|
|
||||||
|
def _add(self, window):
|
||||||
|
item = self.add_piece(100 / 8)
|
||||||
|
self._items[window.get_xid()] = item
|
||||||
|
|
||||||
class ActivityItem(IconItem):
|
class ActivityItem(IconItem):
|
||||||
def __init__(self, activity):
|
def __init__(self, activity):
|
||||||
|
@ -25,8 +25,6 @@ class PieceItem(goocanvas.Path):
|
|||||||
|
|
||||||
data += 'z'
|
data += 'z'
|
||||||
|
|
||||||
print data
|
|
||||||
|
|
||||||
self.set_property('data', data)
|
self.set_property('data', data)
|
||||||
|
|
||||||
class DonutItem(goocanvas.Group):
|
class DonutItem(goocanvas.Group):
|
||||||
@ -45,5 +43,11 @@ class DonutItem(goocanvas.Group):
|
|||||||
self.add_child(piece_item)
|
self.add_child(piece_item)
|
||||||
piece_item.construct()
|
piece_item.construct()
|
||||||
|
|
||||||
|
return piece_item
|
||||||
|
|
||||||
|
def remove_piece(self, piece_item):
|
||||||
|
index = self.find(piece_item)
|
||||||
|
self.remove_child(index)
|
||||||
|
|
||||||
def get_radius(self):
|
def get_radius(self):
|
||||||
return self._radius
|
return self._radius
|
||||||
|
Loading…
Reference in New Issue
Block a user