Move the zoom levels inside the model
This commit is contained in:
parent
59bf818e99
commit
7024f93a43
@ -10,6 +10,6 @@ sugar_PYTHON = \
|
|||||||
Invites.py \
|
Invites.py \
|
||||||
Owner.py \
|
Owner.py \
|
||||||
MeshModel.py \
|
MeshModel.py \
|
||||||
ShellModel.py \
|
shellmodel.py \
|
||||||
homeactivity.py \
|
homeactivity.py \
|
||||||
homemodel.py
|
homemodel.py
|
||||||
|
@ -31,6 +31,11 @@ class ShellModel(gobject.GObject):
|
|||||||
STATE_RUNNING = 1
|
STATE_RUNNING = 1
|
||||||
STATE_SHUTDOWN = 2
|
STATE_SHUTDOWN = 2
|
||||||
|
|
||||||
|
ZOOM_MESH = 0
|
||||||
|
ZOOM_FRIENDS = 1
|
||||||
|
ZOOM_HOME = 2
|
||||||
|
ZOOM_ACTIVITY = 3
|
||||||
|
|
||||||
__gproperties__ = {
|
__gproperties__ = {
|
||||||
'state' : (int, None, None,
|
'state' : (int, None, None,
|
||||||
0, 2, STATE_RUNNING,
|
0, 2, STATE_RUNNING,
|
@ -35,7 +35,7 @@ logger.start('shell')
|
|||||||
sys.path.insert(0, env.get_shell_path())
|
sys.path.insert(0, env.get_shell_path())
|
||||||
|
|
||||||
from view.Shell import Shell
|
from view.Shell import Shell
|
||||||
from model.ShellModel import ShellModel
|
from model.shellmodel import ShellModel
|
||||||
from shellservice import ShellService
|
from shellservice import ShellService
|
||||||
from intro import intro
|
from intro import intro
|
||||||
|
|
||||||
|
@ -29,14 +29,13 @@ from sugar.activity.activityhandle import ActivityHandle
|
|||||||
from sugar.activity import activityfactory
|
from sugar.activity import activityfactory
|
||||||
from sugar.datastore import datastore
|
from sugar.datastore import datastore
|
||||||
from sugar import profile
|
from sugar import profile
|
||||||
import sugar
|
|
||||||
|
|
||||||
from view.ActivityHost import ActivityHost
|
from view.ActivityHost import ActivityHost
|
||||||
from view.frame.frame import Frame
|
from view.frame.frame import Frame
|
||||||
from view.keyhandler import KeyHandler
|
from view.keyhandler import KeyHandler
|
||||||
from view.home.HomeWindow import HomeWindow
|
from view.home.HomeWindow import HomeWindow
|
||||||
from model import bundleregistry
|
from model import bundleregistry
|
||||||
|
from model.shellmodel import ShellModel
|
||||||
from hardware import hardwaremanager
|
from hardware import hardwaremanager
|
||||||
|
|
||||||
class Shell(gobject.GObject):
|
class Shell(gobject.GObject):
|
||||||
@ -58,7 +57,7 @@ class Shell(gobject.GObject):
|
|||||||
self._home_window = HomeWindow(self)
|
self._home_window = HomeWindow(self)
|
||||||
self._home_window.show()
|
self._home_window.show()
|
||||||
|
|
||||||
self._zoom_level = sugar.ZOOM_HOME
|
self._zoom_level = ShellModel.ZOOM_HOME
|
||||||
|
|
||||||
home_model = self._model.get_home()
|
home_model = self._model.get_home()
|
||||||
home_model.connect('activity-started', self._activity_started_cb)
|
home_model.connect('activity-started', self._activity_started_cb)
|
||||||
@ -102,9 +101,9 @@ class Shell(gobject.GObject):
|
|||||||
|
|
||||||
if self._current_host:
|
if self._current_host:
|
||||||
self._current_host.set_active(True)
|
self._current_host.set_active(True)
|
||||||
self.set_zoom_level(sugar.ZOOM_ACTIVITY)
|
self.set_zoom_level(ShellModel.ZOOM_ACTIVITY)
|
||||||
else:
|
else:
|
||||||
self.set_zoom_level(sugar.ZOOM_HOME)
|
self.set_zoom_level(ShellModel.ZOOM_HOME)
|
||||||
|
|
||||||
def get_model(self):
|
def get_model(self):
|
||||||
return self._model
|
return self._model
|
||||||
@ -134,7 +133,7 @@ class Shell(gobject.GObject):
|
|||||||
|
|
||||||
def notify_launch(self, bundle_id, activity_id):
|
def notify_launch(self, bundle_id, activity_id):
|
||||||
# Zoom to Home for launch feedback
|
# Zoom to Home for launch feedback
|
||||||
self.set_zoom_level(sugar.ZOOM_HOME)
|
self.set_zoom_level(ShellModel.ZOOM_HOME)
|
||||||
|
|
||||||
home_model = self._model.get_home()
|
home_model = self._model.get_home()
|
||||||
home_model.notify_activity_launch(activity_id, bundle_id)
|
home_model.notify_activity_launch(activity_id, bundle_id)
|
||||||
@ -154,18 +153,18 @@ class Shell(gobject.GObject):
|
|||||||
def set_zoom_level(self, level):
|
def set_zoom_level(self, level):
|
||||||
if self._zoom_level == level:
|
if self._zoom_level == level:
|
||||||
return
|
return
|
||||||
if len(self._hosts) == 0 and level == sugar.ZOOM_ACTIVITY:
|
if len(self._hosts) == 0 and level == ShellModel.ZOOM_ACTIVITY:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._zoom_level = level
|
self._zoom_level = level
|
||||||
|
|
||||||
if self._zoom_level == sugar.ZOOM_ACTIVITY:
|
if self._zoom_level == ShellModel.ZOOM_ACTIVITY:
|
||||||
self._screen.toggle_showing_desktop(False)
|
self._screen.toggle_showing_desktop(False)
|
||||||
else:
|
else:
|
||||||
self._screen.toggle_showing_desktop(True)
|
self._screen.toggle_showing_desktop(True)
|
||||||
self._home_window.set_zoom_level(self._zoom_level)
|
self._home_window.set_zoom_level(self._zoom_level)
|
||||||
|
|
||||||
if self._zoom_level == sugar.ZOOM_HOME:
|
if self._zoom_level == ShellModel.ZOOM_HOME:
|
||||||
self._frame.show()
|
self._frame.show()
|
||||||
else:
|
else:
|
||||||
self._frame.hide()
|
self._frame.hide()
|
||||||
|
@ -18,7 +18,8 @@ import hippo
|
|||||||
|
|
||||||
from sugar.graphics import color
|
from sugar.graphics import color
|
||||||
from sugar.graphics.iconbutton import IconButton
|
from sugar.graphics.iconbutton import IconButton
|
||||||
import sugar
|
|
||||||
|
from model.shellmodel import ShellModel
|
||||||
|
|
||||||
class ZoomBox(hippo.CanvasBox):
|
class ZoomBox(hippo.CanvasBox):
|
||||||
def __init__(self, shell):
|
def __init__(self, shell):
|
||||||
@ -29,25 +30,33 @@ class ZoomBox(hippo.CanvasBox):
|
|||||||
icon = IconButton(icon_name='theme:stock-zoom-mesh',
|
icon = IconButton(icon_name='theme:stock-zoom-mesh',
|
||||||
stroke_color=color.BLACK,
|
stroke_color=color.BLACK,
|
||||||
fill_color=color.WHITE)
|
fill_color=color.WHITE)
|
||||||
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_MESH)
|
icon.connect('activated',
|
||||||
|
self._level_clicked_cb,
|
||||||
|
ShellModel.ZOOM_MESH)
|
||||||
self.append(icon)
|
self.append(icon)
|
||||||
|
|
||||||
icon = IconButton(icon_name='theme:stock-zoom-friends',
|
icon = IconButton(icon_name='theme:stock-zoom-friends',
|
||||||
stroke_color=color.BLACK,
|
stroke_color=color.BLACK,
|
||||||
fill_color=color.WHITE)
|
fill_color=color.WHITE)
|
||||||
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_FRIENDS)
|
icon.connect('activated',
|
||||||
|
self._level_clicked_cb,
|
||||||
|
ShellModel.ZOOM_FRIENDS)
|
||||||
self.append(icon)
|
self.append(icon)
|
||||||
|
|
||||||
icon = IconButton(icon_name='theme:stock-zoom-home',
|
icon = IconButton(icon_name='theme:stock-zoom-home',
|
||||||
stroke_color=color.BLACK,
|
stroke_color=color.BLACK,
|
||||||
fill_color=color.WHITE)
|
fill_color=color.WHITE)
|
||||||
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_HOME)
|
icon.connect('activated',
|
||||||
|
self._level_clicked_cb,
|
||||||
|
ShellModel.ZOOM_HOME)
|
||||||
self.append(icon)
|
self.append(icon)
|
||||||
|
|
||||||
icon = IconButton(icon_name='theme:stock-zoom-activity',
|
icon = IconButton(icon_name='theme:stock-zoom-activity',
|
||||||
stroke_color=color.BLACK,
|
stroke_color=color.BLACK,
|
||||||
fill_color=color.WHITE)
|
fill_color=color.WHITE)
|
||||||
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_ACTIVITY)
|
icon.connect('activated',
|
||||||
|
self._level_clicked_cb,
|
||||||
|
ShellModel.ZOOM_ACTIVITY)
|
||||||
self.append(icon)
|
self.append(icon)
|
||||||
|
|
||||||
def _level_clicked_cb(self, item, level):
|
def _level_clicked_cb(self, item, level):
|
||||||
|
@ -27,7 +27,7 @@ from view.frame.overlaybox import OverlayBox
|
|||||||
from view.frame.FriendsBox import FriendsBox
|
from view.frame.FriendsBox import FriendsBox
|
||||||
from view.frame.framewindow import FrameWindow
|
from view.frame.framewindow import FrameWindow
|
||||||
from view.frame.clipboardpanelwindow import ClipboardPanelWindow
|
from view.frame.clipboardpanelwindow import ClipboardPanelWindow
|
||||||
from model.ShellModel import ShellModel
|
from model.shellmodel import ShellModel
|
||||||
from sugar.graphics import animator
|
from sugar.graphics import animator
|
||||||
from sugar.graphics import units
|
from sugar.graphics import units
|
||||||
from sugar.clipboard import clipboardservice
|
from sugar.clipboard import clipboardservice
|
||||||
|
@ -34,7 +34,7 @@ from sugar import env
|
|||||||
from view.home.activitiesdonut import ActivitiesDonut
|
from view.home.activitiesdonut import ActivitiesDonut
|
||||||
from view.devices import deviceview
|
from view.devices import deviceview
|
||||||
from view.home.MyIcon import MyIcon
|
from view.home.MyIcon import MyIcon
|
||||||
from model.ShellModel import ShellModel
|
from model.shellmodel import ShellModel
|
||||||
|
|
||||||
class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||||
__gtype_name__ = 'SugarHomeBox'
|
__gtype_name__ = 'SugarHomeBox'
|
||||||
|
@ -19,12 +19,12 @@ import hippo
|
|||||||
import cairo
|
import cairo
|
||||||
|
|
||||||
from sugar.graphics import units
|
from sugar.graphics import units
|
||||||
import sugar
|
|
||||||
|
|
||||||
from view.home.MeshBox import MeshBox
|
from view.home.MeshBox import MeshBox
|
||||||
from view.home.HomeBox import HomeBox
|
from view.home.HomeBox import HomeBox
|
||||||
from view.home.FriendsBox import FriendsBox
|
from view.home.FriendsBox import FriendsBox
|
||||||
from view.home.transitionbox import TransitionBox
|
from view.home.transitionbox import TransitionBox
|
||||||
|
from model.shellmodel import ShellModel
|
||||||
|
|
||||||
_HOME_PAGE = 0
|
_HOME_PAGE = 0
|
||||||
_FRIENDS_PAGE = 1
|
_FRIENDS_PAGE = 1
|
||||||
@ -37,7 +37,7 @@ class HomeWindow(gtk.Window):
|
|||||||
|
|
||||||
self._shell = shell
|
self._shell = shell
|
||||||
self._active = False
|
self._active = False
|
||||||
self._level = sugar.ZOOM_HOME
|
self._level = ShellModel.ZOOM_HOME
|
||||||
|
|
||||||
self._canvas = hippo.Canvas()
|
self._canvas = hippo.Canvas()
|
||||||
self.add(self._canvas)
|
self.add(self._canvas)
|
||||||
@ -94,7 +94,7 @@ class HomeWindow(gtk.Window):
|
|||||||
self._home_box.release()
|
self._home_box.release()
|
||||||
|
|
||||||
def _update_mesh_state(self):
|
def _update_mesh_state(self):
|
||||||
if self._active and self._level == sugar.ZOOM_MESH:
|
if self._active and self._level == ShellModel.ZOOM_MESH:
|
||||||
self._mesh_box.resume()
|
self._mesh_box.resume()
|
||||||
else:
|
else:
|
||||||
self._mesh_box.suspend()
|
self._mesh_box.suspend()
|
||||||
@ -112,21 +112,21 @@ class HomeWindow(gtk.Window):
|
|||||||
|
|
||||||
self._canvas.set_root(self._transition_box)
|
self._canvas.set_root(self._transition_box)
|
||||||
|
|
||||||
if level == sugar.ZOOM_HOME:
|
if level == ShellModel.ZOOM_HOME:
|
||||||
scale = units.XLARGE_ICON_SCALE
|
scale = units.XLARGE_ICON_SCALE
|
||||||
elif level == sugar.ZOOM_FRIENDS:
|
elif level == ShellModel.ZOOM_FRIENDS:
|
||||||
scale = units.LARGE_ICON_SCALE
|
scale = units.LARGE_ICON_SCALE
|
||||||
elif level == sugar.ZOOM_MESH:
|
elif level == ShellModel.ZOOM_MESH:
|
||||||
scale = units.STANDARD_ICON_SCALE
|
scale = units.STANDARD_ICON_SCALE
|
||||||
|
|
||||||
self._transition_box.set_scale(scale)
|
self._transition_box.set_scale(scale)
|
||||||
|
|
||||||
def _transition_completed_cb(self, transition_box):
|
def _transition_completed_cb(self, transition_box):
|
||||||
if self._level == sugar.ZOOM_HOME:
|
if self._level == ShellModel.ZOOM_HOME:
|
||||||
self._canvas.set_root(self._home_box)
|
self._canvas.set_root(self._home_box)
|
||||||
elif self._level == sugar.ZOOM_FRIENDS:
|
elif self._level == ShellModel.ZOOM_FRIENDS:
|
||||||
self._canvas.set_root(self._friends_box)
|
self._canvas.set_root(self._friends_box)
|
||||||
elif self._level == sugar.ZOOM_MESH:
|
elif self._level == ShellModel.ZOOM_MESH:
|
||||||
self._canvas.set_root(self._mesh_box)
|
self._canvas.set_root(self._mesh_box)
|
||||||
|
|
||||||
self._update_mesh_state()
|
self._update_mesh_state()
|
||||||
|
@ -24,9 +24,8 @@ import gtk
|
|||||||
|
|
||||||
from sugar import env
|
from sugar import env
|
||||||
from hardware import hardwaremanager
|
from hardware import hardwaremanager
|
||||||
from model.ShellModel import ShellModel
|
from model.shellmodel import ShellModel
|
||||||
from sugar._sugarext import KeyGrabber
|
from sugar._sugarext import KeyGrabber
|
||||||
import sugar
|
|
||||||
|
|
||||||
_actions_table = {
|
_actions_table = {
|
||||||
'F1' : 'zoom_mesh',
|
'F1' : 'zoom_mesh',
|
||||||
@ -90,16 +89,16 @@ class KeyHandler(object):
|
|||||||
hw_manager.set_display_mode(mode)
|
hw_manager.set_display_mode(mode)
|
||||||
|
|
||||||
def handle_zoom_mesh(self):
|
def handle_zoom_mesh(self):
|
||||||
self._shell.set_zoom_level(sugar.ZOOM_MESH)
|
self._shell.set_zoom_level(ShellModel.ZOOM_MESH)
|
||||||
|
|
||||||
def handle_zoom_friends(self):
|
def handle_zoom_friends(self):
|
||||||
self._shell.set_zoom_level(sugar.ZOOM_FRIENDS)
|
self._shell.set_zoom_level(ShellModel.ZOOM_FRIENDS)
|
||||||
|
|
||||||
def handle_zoom_home(self):
|
def handle_zoom_home(self):
|
||||||
self._shell.set_zoom_level(sugar.ZOOM_HOME)
|
self._shell.set_zoom_level(ShellModel.ZOOM_HOME)
|
||||||
|
|
||||||
def handle_zoom_activity(self):
|
def handle_zoom_activity(self):
|
||||||
self._shell.set_zoom_level(sugar.ZOOM_ACTIVITY)
|
self._shell.set_zoom_level(ShellModel.ZOOM_ACTIVITY)
|
||||||
|
|
||||||
def handle_brightness_1(self):
|
def handle_brightness_1(self):
|
||||||
self._set_display_brightness(0)
|
self._set_display_brightness(0)
|
||||||
|
@ -21,10 +21,5 @@ import os
|
|||||||
|
|
||||||
from sugar import ltihooks
|
from sugar import ltihooks
|
||||||
|
|
||||||
ZOOM_MESH = 0
|
|
||||||
ZOOM_FRIENDS = 1
|
|
||||||
ZOOM_HOME = 2
|
|
||||||
ZOOM_ACTIVITY = 3
|
|
||||||
|
|
||||||
if os.path.isfile(os.path.join(os.path.dirname(__file__), 'Makefile.am')):
|
if os.path.isfile(os.path.join(os.path.dirname(__file__), 'Makefile.am')):
|
||||||
ltihooks.install()
|
ltihooks.install()
|
||||||
|
Loading…
Reference in New Issue
Block a user