Add fg and bg circles, fill the paths
This commit is contained in:
parent
fb829989c7
commit
10f356cb22
@ -4,10 +4,11 @@ import wnck
|
||||
|
||||
from sugar.canvas.IconItem import IconItem
|
||||
from sugar.canvas.DonutItem import DonutItem
|
||||
from sugar.canvas.DonutItem import PieceItem
|
||||
|
||||
class TasksItem(DonutItem):
|
||||
def __init__(self):
|
||||
DonutItem.__init__(self, 200)
|
||||
DonutItem.__init__(self, 250)
|
||||
|
||||
self._items = {}
|
||||
|
||||
@ -33,6 +34,7 @@ class TasksItem(DonutItem):
|
||||
|
||||
def _add(self, window):
|
||||
item = self.add_piece(100 / 8)
|
||||
item.set_data('window', window)
|
||||
self._items[window.get_xid()] = item
|
||||
|
||||
class ActivityItem(IconItem):
|
||||
@ -120,9 +122,16 @@ class HomeWindow(gtk.Window):
|
||||
item_view.connect("button_press_event",
|
||||
self.__activity_button_press_cb,
|
||||
item.get_activity_id())
|
||||
elif isinstance(item, PieceItem):
|
||||
item_view.connect("button_press_event",
|
||||
self.__task_button_press_cb)
|
||||
|
||||
def __activity_button_press_cb(self, view, target, event, activity_id):
|
||||
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())
|
||||
|
||||
def __realize_cb(self, window):
|
||||
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DESKTOP)
|
||||
|
@ -8,6 +8,10 @@ class PieceItem(goocanvas.Path):
|
||||
self._angle_start = angle_start
|
||||
self._angle_end = angle_end
|
||||
|
||||
self.set_property('fill-color', '#e8e8e8')
|
||||
self.set_property('stroke-color', '#d8d8d8')
|
||||
self.set_property('line-width', 4)
|
||||
|
||||
def construct(self):
|
||||
r = self.get_parent().get_radius()
|
||||
|
||||
@ -33,6 +37,15 @@ class DonutItem(goocanvas.Group):
|
||||
self._radius = radius
|
||||
self._angle_start = 0
|
||||
|
||||
bg = goocanvas.Ellipse(radius_x=radius, radius_y=radius,
|
||||
fill_color='#c2c3c5', line_width=0)
|
||||
self.add_child(bg)
|
||||
|
||||
fg_radius = radius / 2
|
||||
fg = goocanvas.Ellipse(radius_x=fg_radius, radius_y=fg_radius,
|
||||
fill_color='#d8d8d8', line_width=0)
|
||||
self.add_child(fg)
|
||||
|
||||
def add_piece(self, perc):
|
||||
angle_end = self._angle_start + perc * 2 * math.pi / 100
|
||||
piece_item = PieceItem(self._angle_start, angle_end)
|
||||
@ -40,7 +53,7 @@ class DonutItem(goocanvas.Group):
|
||||
|
||||
# FIXME can't override set_parent on the
|
||||
# PieceItem and there is no signal.
|
||||
self.add_child(piece_item)
|
||||
self.add_child(piece_item, 1)
|
||||
piece_item.construct()
|
||||
|
||||
return piece_item
|
||||
|
Loading…
Reference in New Issue
Block a user