Split model/view in the activities donut.
Provide some infrastructure for Alt+Tab implementation.
This commit is contained in:
+8
-3
@@ -95,6 +95,7 @@ class Shell(gobject.GObject):
|
||||
self._key_grabber.grab('0xDC') # Camera key
|
||||
self._key_grabber.grab('0xE0') # Overlay key
|
||||
self._key_grabber.grab('0x93') # Frame key
|
||||
self._key_grabber.grab('<alt>Tab')
|
||||
|
||||
# For non-OLPC machines
|
||||
self._key_grabber.grab('<shft><alt>F9')
|
||||
@@ -127,6 +128,10 @@ class Shell(gobject.GObject):
|
||||
self.toggle_chat_visibility()
|
||||
elif key == '0x93': # Frame key
|
||||
self._frame.notify_key_press()
|
||||
elif key == '<alt>Tab':
|
||||
self.set_zoom_level(sugar.ZOOM_HOME)
|
||||
box = self._home_window.get_home_box()
|
||||
box.grab_and_rotate()
|
||||
|
||||
def _key_released_cb(self, grabber, key):
|
||||
if key == '<shft><alt>F9':
|
||||
@@ -202,7 +207,7 @@ class Shell(gobject.GObject):
|
||||
def join_activity(self, bundle_id, activity_id):
|
||||
pservice = PresenceService.get_instance()
|
||||
|
||||
activity = self._get_activity(activity_id)
|
||||
activity = self.get_activity(activity_id)
|
||||
if activity:
|
||||
activity.present()
|
||||
else:
|
||||
@@ -244,11 +249,11 @@ class Shell(gobject.GObject):
|
||||
def get_current_activity(self):
|
||||
activity_id = self._model.get_current_activity()
|
||||
if activity_id:
|
||||
return self._get_activity(activity_id)
|
||||
return self.get_activity(activity_id)
|
||||
else:
|
||||
return None
|
||||
|
||||
def _get_activity(self, activity_id):
|
||||
def get_activity(self, activity_id):
|
||||
for host in self._hosts.values():
|
||||
if host.get_id() == activity_id:
|
||||
return host
|
||||
|
||||
@@ -25,13 +25,12 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
__gtype_name__ = 'SugarHomeBox'
|
||||
|
||||
def __init__(self, shell):
|
||||
hippo.CanvasBox.__init__(self, background_color=0xe2e2e2ff,
|
||||
yalign=2)
|
||||
hippo.CanvasBox.__init__(self, background_color=0xe2e2e2ff, yalign=2)
|
||||
|
||||
grid = Grid()
|
||||
donut = ActivitiesDonut(shell, box_width=grid.dimension(7),
|
||||
box_height=grid.dimension(7))
|
||||
self.append(donut)
|
||||
self._donut = ActivitiesDonut(shell, box_width=grid.dimension(7),
|
||||
box_height=grid.dimension(7))
|
||||
self.append(self._donut)
|
||||
|
||||
self._my_icon = MyIcon()
|
||||
style.apply_stylesheet(self._my_icon, 'home.MyIcon')
|
||||
@@ -43,3 +42,15 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
[icon_width, icon_height] = self._my_icon.get_allocation()
|
||||
self.move(self._my_icon, (width - icon_width) / 2,
|
||||
(height - icon_height) / 2)
|
||||
|
||||
def has_activities(self):
|
||||
return self._donut.has_activities()
|
||||
|
||||
def grab_and_rotate(self):
|
||||
pass
|
||||
|
||||
def rotate(self):
|
||||
pass
|
||||
|
||||
def release(self):
|
||||
pass
|
||||
|
||||
@@ -34,6 +34,7 @@ class HomeWindow(gtk.Window):
|
||||
|
||||
self.realize()
|
||||
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DESKTOP)
|
||||
self.connect("key-release-event", self._key_release_cb)
|
||||
|
||||
self._nb = gtk.Notebook()
|
||||
self._nb.set_show_border(False)
|
||||
@@ -43,8 +44,8 @@ class HomeWindow(gtk.Window):
|
||||
self._nb.show()
|
||||
|
||||
canvas = hippo.Canvas()
|
||||
box = HomeBox(shell)
|
||||
canvas.set_root(box)
|
||||
self._home_box = HomeBox(shell)
|
||||
canvas.set_root(self._home_box)
|
||||
self._nb.append_page(canvas)
|
||||
canvas.show()
|
||||
|
||||
@@ -60,6 +61,11 @@ class HomeWindow(gtk.Window):
|
||||
self._nb.append_page(canvas)
|
||||
canvas.show()
|
||||
|
||||
def _key_release_cb(self, widget, event):
|
||||
keyname = gtk.gdk.keyval_name(event.keyval)
|
||||
if keyname == "Alt_L":
|
||||
self._home_box.release()
|
||||
|
||||
def set_zoom_level(self, level):
|
||||
if level == sugar.ZOOM_HOME:
|
||||
self._nb.set_current_page(0)
|
||||
@@ -67,3 +73,6 @@ class HomeWindow(gtk.Window):
|
||||
self._nb.set_current_page(1)
|
||||
elif level == sugar.ZOOM_MESH:
|
||||
self._nb.set_current_page(2)
|
||||
|
||||
def get_home_box(self):
|
||||
return self._home_box
|
||||
|
||||
@@ -19,6 +19,7 @@ import math
|
||||
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar.graphics import style
|
||||
from model.homemodel import HomeModel
|
||||
|
||||
class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
|
||||
__gtype_name__ = 'SugarActivitiesDonut'
|
||||
@@ -26,14 +27,16 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
|
||||
hippo.CanvasBox.__init__(self, **kwargs)
|
||||
|
||||
self._activities = {}
|
||||
self._shell = shell
|
||||
|
||||
shell.connect('activity_opened', self.__activity_opened_cb)
|
||||
shell.connect('activity_closed', self.__activity_closed_cb)
|
||||
self._model = HomeModel(shell)
|
||||
self._model.connect('activity-added', self._activity_added_cb)
|
||||
self._model.connect('activity-removed', self._activity_removed_cb)
|
||||
|
||||
def __activity_opened_cb(self, model, activity):
|
||||
def _activity_added_cb(self, model, activity):
|
||||
self._add_activity(activity)
|
||||
|
||||
def __activity_closed_cb(self, model, activity):
|
||||
def _activity_removed_cb(self, model, activity):
|
||||
self._remove_activity(activity)
|
||||
|
||||
def _remove_activity(self, activity):
|
||||
@@ -47,15 +50,17 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
|
||||
|
||||
icon = CanvasIcon(icon_name=icon_name, color=icon_color)
|
||||
style.apply_stylesheet(icon, 'ring.ActivityIcon')
|
||||
icon.connect('activated', self.__activity_icon_clicked_cb, activity)
|
||||
icon.connect('activated', self._activity_icon_clicked_cb, activity)
|
||||
self.append(icon, hippo.PACK_FIXED)
|
||||
|
||||
self._activities[activity.get_id()] = icon
|
||||
|
||||
self.emit_paint_needed(0, 0, -1, -1)
|
||||
|
||||
def __activity_icon_clicked_cb(self, item, activity):
|
||||
activity.present()
|
||||
def _activity_icon_clicked_cb(self, item, activity):
|
||||
activity_host = self._shell.get_activity(activity.get_id())
|
||||
if activity_host:
|
||||
activity_host.present()
|
||||
|
||||
def _get_angles(self, index):
|
||||
angle = 2 * math.pi / 8
|
||||
|
||||
Reference in New Issue
Block a user