Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
This commit is contained in:
+15
-2
@@ -57,6 +57,7 @@ class Shell(gobject.GObject):
|
||||
self._current_host = None
|
||||
self._pending_host = None
|
||||
self._screen_rotation = 0
|
||||
self._zoom_level = ShellModel.ZOOM_HOME
|
||||
|
||||
self._key_handler = KeyHandler(self)
|
||||
|
||||
@@ -73,6 +74,8 @@ class Shell(gobject.GObject):
|
||||
home_model.connect('pending-activity-changed',
|
||||
self._pending_activity_changed_cb)
|
||||
|
||||
self._model.connect('notify::zoom-level', self._zoom_level_changed_cb)
|
||||
|
||||
gobject.idle_add(self._start_journal_idle)
|
||||
|
||||
def _start_journal_idle(self):
|
||||
@@ -172,8 +175,7 @@ class Shell(gobject.GObject):
|
||||
activity.get_service().TakeScreenshot()
|
||||
|
||||
def set_zoom_level(self, level):
|
||||
old_level = self._model.get_zoom_level()
|
||||
if level == old_level:
|
||||
if level == self._zoom_level:
|
||||
return
|
||||
|
||||
self.take_activity_screenshot()
|
||||
@@ -187,6 +189,17 @@ class Shell(gobject.GObject):
|
||||
self._screen.toggle_showing_desktop(True)
|
||||
self._home_window.set_zoom_level(level)
|
||||
|
||||
def _zoom_level_changed_cb(self, model, pspec):
|
||||
new_level = model.props.zoom_level
|
||||
|
||||
if new_level == ShellModel.ZOOM_HOME:
|
||||
self._frame.show(Frame.MODE_HOME)
|
||||
|
||||
if self._zoom_level == ShellModel.ZOOM_HOME:
|
||||
self._frame.hide()
|
||||
|
||||
self._zoom_level = new_level
|
||||
|
||||
def toggle_activity_fullscreen(self):
|
||||
if self._model.get_zoom_level() == ShellModel.ZOOM_ACTIVITY:
|
||||
self.get_current_activity().toggle_fullscreen()
|
||||
|
||||
+29
-78
@@ -33,16 +33,11 @@ from view.frame.framewindow import FrameWindow
|
||||
from view.frame.clipboardpanelwindow import ClipboardPanelWindow
|
||||
from model.shellmodel import ShellModel
|
||||
|
||||
MODE_NONE = 0
|
||||
MODE_MOUSE = 1
|
||||
MODE_KEYBOARD = 2
|
||||
MODE_FORCE = 3
|
||||
|
||||
_FRAME_HIDING_DELAY = 500
|
||||
|
||||
class _Animation(animator.Animation):
|
||||
def __init__(self, frame, end):
|
||||
start = frame.get_current_position()
|
||||
start = frame.current_position
|
||||
animator.Animation.__init__(self, start, end)
|
||||
self._frame = frame
|
||||
|
||||
@@ -55,19 +50,16 @@ class _MouseListener(object):
|
||||
self._hide_sid = 0
|
||||
|
||||
def mouse_enter(self):
|
||||
if self._frame.mode == MODE_NONE or \
|
||||
self._frame.mode == MODE_MOUSE:
|
||||
self._show_frame()
|
||||
self._show_frame()
|
||||
|
||||
def mouse_leave(self):
|
||||
if self._frame.mode == MODE_MOUSE:
|
||||
if self._frame.mode == Frame.MODE_MOUSE:
|
||||
self._hide_frame()
|
||||
|
||||
def _show_frame(self):
|
||||
if self._hide_sid != 0:
|
||||
gobject.source_remove(self._hide_sid)
|
||||
self._frame.show()
|
||||
self._frame.mode = MODE_MOUSE
|
||||
self._frame.show(Frame.MODE_MOUSE)
|
||||
|
||||
def _hide_frame_timeout_cb(self):
|
||||
self._frame.hide()
|
||||
@@ -80,52 +72,23 @@ class _MouseListener(object):
|
||||
_FRAME_HIDING_DELAY, self._hide_frame_timeout_cb)
|
||||
|
||||
class _KeyListener(object):
|
||||
_HIDDEN = 1
|
||||
_SHOWN_PRESSED = 2
|
||||
_SHOWN_REPEAT = 3
|
||||
_SHOWN_RELEASED = 4
|
||||
|
||||
def __init__(self, frame):
|
||||
self._frame = frame
|
||||
self._state = _KeyListener._HIDDEN
|
||||
|
||||
def key_press(self):
|
||||
if self._frame.mode != MODE_NONE and \
|
||||
self._frame.mode != MODE_KEYBOARD:
|
||||
return
|
||||
|
||||
if self._frame.visible:
|
||||
self._frame.hide()
|
||||
if self._frame.mode == Frame.MODE_KEYBOARD:
|
||||
self._frame.hide()
|
||||
else:
|
||||
self._frame.show()
|
||||
self._frame.mode = MODE_KEYBOARD
|
||||
|
||||
"""
|
||||
if self._state == _KeyListener._HIDDEN:
|
||||
self._frame.show()
|
||||
self._frame.mode = MODE_KEYBOARD
|
||||
self._state = _KeyListener._SHOWN_PRESSED
|
||||
elif self._state == _KeyListener._SHOWN_PRESSED:
|
||||
self._state = _KeyListener._SHOWN_REPEAT
|
||||
elif self._state == _KeyListener._SHOWN_RELEASED:
|
||||
self._frame.hide()
|
||||
self._state = _KeyListener._HIDDEN
|
||||
"""
|
||||
|
||||
def key_release(self):
|
||||
pass
|
||||
"""
|
||||
if self._state == _KeyListener._SHOWN_PRESSED:
|
||||
self._state = _KeyListener._SHOWN_RELEASED
|
||||
elif self._state == _KeyListener._SHOWN_REPEAT:
|
||||
self._frame.hide()
|
||||
self._state = _KeyListener._HIDDEN
|
||||
"""
|
||||
self._frame.show(Frame.MODE_KEYBOARD)
|
||||
|
||||
class Frame(object):
|
||||
MODE_MOUSE = 0
|
||||
MODE_KEYBOARD = 1
|
||||
MODE_HOME = 2
|
||||
|
||||
def __init__(self, shell):
|
||||
self.mode = MODE_NONE
|
||||
self.visible = False
|
||||
self.mode = None
|
||||
|
||||
self._palette_group = palettegroup.get_group('frame')
|
||||
self._palette_group.connect('popdown', self._palette_group_popdown_cb)
|
||||
@@ -136,7 +99,7 @@ class Frame(object):
|
||||
self._bottom_panel = None
|
||||
|
||||
self._shell = shell
|
||||
self._current_position = 0.0
|
||||
self.current_position = 0.0
|
||||
self._animator = None
|
||||
|
||||
self._event_area = EventArea()
|
||||
@@ -157,9 +120,12 @@ class Frame(object):
|
||||
self._key_listener = _KeyListener(self)
|
||||
self._mouse_listener = _MouseListener(self)
|
||||
|
||||
def hide(self, force=False):
|
||||
if not self.visible:
|
||||
return
|
||||
self.move(1.0)
|
||||
|
||||
def is_visible(self):
|
||||
return self.current_position != 0.0
|
||||
|
||||
def hide(self):
|
||||
if self._animator:
|
||||
self._animator.stop()
|
||||
|
||||
@@ -169,16 +135,9 @@ class Frame(object):
|
||||
|
||||
self._event_area.show()
|
||||
|
||||
self.visible = False
|
||||
if force:
|
||||
self.mode = MODE_NONE
|
||||
else:
|
||||
self.mode = MODE_FORCE
|
||||
self._animator.connect('completed', self._hide_completed_cb)
|
||||
|
||||
def show(self):
|
||||
self.mode = MODE_FORCE
|
||||
self.mode = None
|
||||
|
||||
def show(self, mode):
|
||||
if self.visible:
|
||||
return
|
||||
if self._animator:
|
||||
@@ -186,19 +145,16 @@ class Frame(object):
|
||||
|
||||
self._shell.take_activity_screenshot()
|
||||
|
||||
self.mode = mode
|
||||
|
||||
self._animator = animator.Animator(0.5)
|
||||
self._animator.add(_Animation(self, 1.0))
|
||||
self._animator.start()
|
||||
|
||||
self._event_area.hide()
|
||||
|
||||
self.visible = True
|
||||
|
||||
def get_current_position(self):
|
||||
return self._current_position
|
||||
|
||||
def move(self, pos):
|
||||
self._current_position = pos
|
||||
self.current_position = pos
|
||||
self._update_position()
|
||||
|
||||
def _is_hover(self):
|
||||
@@ -266,21 +222,18 @@ class Frame(object):
|
||||
screen_h = gtk.gdk.screen_height()
|
||||
screen_w = gtk.gdk.screen_width()
|
||||
|
||||
self._move_panel(self._top_panel, self._current_position,
|
||||
self._move_panel(self._top_panel, self.current_position,
|
||||
0, - self._top_panel.size, 0, 0)
|
||||
|
||||
self._move_panel(self._bottom_panel, self._current_position,
|
||||
self._move_panel(self._bottom_panel, self.current_position,
|
||||
0, screen_h, 0, screen_h - self._bottom_panel.size)
|
||||
|
||||
self._move_panel(self._left_panel, self._current_position,
|
||||
self._move_panel(self._left_panel, self.current_position,
|
||||
- self._left_panel.size, 0, 0, 0)
|
||||
|
||||
self._move_panel(self._right_panel, self._current_position,
|
||||
self._move_panel(self._right_panel, self.current_position,
|
||||
screen_w, 0, screen_w - self._right_panel.size, 0)
|
||||
|
||||
def _hide_completed_cb(self, animator):
|
||||
self.mode = MODE_NONE
|
||||
|
||||
def _size_changed_cb(self, screen):
|
||||
self._update_position()
|
||||
|
||||
@@ -316,6 +269,4 @@ class Frame(object):
|
||||
def notify_key_press(self):
|
||||
self._key_listener.key_press()
|
||||
|
||||
def notify_key_release(self):
|
||||
self._key_listener.key_release()
|
||||
|
||||
visible = property(is_visible, None)
|
||||
|
||||
+11
-41
@@ -48,55 +48,17 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
|
||||
shell_model = shell.get_model()
|
||||
|
||||
top_box = hippo.CanvasBox(yalign=hippo.ALIGNMENT_START,
|
||||
box_height=style.GRID_CELL_SIZE,
|
||||
orientation=hippo.ORIENTATION_HORIZONTAL)
|
||||
self.append(top_box, hippo.PACK_EXPAND)
|
||||
|
||||
nw_arrow = CanvasIcon(icon_name='arrow_NW',
|
||||
xalign=hippo.ALIGNMENT_START)
|
||||
top_box.append(nw_arrow)
|
||||
|
||||
arrows_separator = hippo.CanvasBox()
|
||||
top_box.append(arrows_separator, hippo.PACK_EXPAND)
|
||||
|
||||
ne_arrow = CanvasIcon(icon_name='arrow_NE',
|
||||
xalign=hippo.ALIGNMENT_END)
|
||||
top_box.append(ne_arrow)
|
||||
|
||||
self._donut = ActivitiesDonut(shell)
|
||||
self.append(self._donut)
|
||||
|
||||
bottom_box = hippo.CanvasBox(yalign=hippo.ALIGNMENT_END,
|
||||
box_height=style.GRID_CELL_SIZE,
|
||||
orientation=hippo.ORIENTATION_HORIZONTAL)
|
||||
self.append(bottom_box, hippo.PACK_EXPAND)
|
||||
self.append(self._donut, hippo.PACK_FIXED)
|
||||
|
||||
self._my_icon = _MyIcon(shell, style.XLARGE_ICON_SIZE)
|
||||
self.append(self._my_icon, hippo.PACK_FIXED)
|
||||
|
||||
sw_arrow = CanvasIcon(icon_name='arrow_SW',
|
||||
xalign=hippo.ALIGNMENT_START)
|
||||
bottom_box.append(sw_arrow)
|
||||
|
||||
devices_box = _DevicesBox(shell_model.get_devices())
|
||||
bottom_box.append(devices_box, hippo.PACK_EXPAND)
|
||||
|
||||
se_arrow = CanvasIcon(icon_name='arrow_SE',
|
||||
xalign=hippo.ALIGNMENT_END)
|
||||
bottom_box.append(se_arrow)
|
||||
|
||||
self._arrows = [ nw_arrow, ne_arrow, sw_arrow, se_arrow ]
|
||||
self._devices_box = _DevicesBox(shell_model.get_devices())
|
||||
self.append(self._devices_box, hippo.PACK_FIXED)
|
||||
|
||||
shell_model.connect('notify::state',
|
||||
self._shell_state_changed_cb)
|
||||
shell_model.connect('notify::zoom-level',
|
||||
self._shell_zoom_level_changed_cb)
|
||||
|
||||
def _shell_zoom_level_changed_cb(self, model, pspec):
|
||||
for arrow in self._arrows:
|
||||
arrow.destroy()
|
||||
self._arrows = []
|
||||
|
||||
def _shell_state_changed_cb(self, model, pspec):
|
||||
# FIXME implement this
|
||||
@@ -106,9 +68,17 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
def do_allocate(self, width, height, origin_changed):
|
||||
hippo.CanvasBox.do_allocate(self, width, height, origin_changed)
|
||||
|
||||
[donut_width, donut_height] = self._donut.get_allocation()
|
||||
self.set_position(self._donut, (width - donut_width) / 2,
|
||||
(height - donut_height) / 2)
|
||||
|
||||
[icon_width, icon_height] = self._my_icon.get_allocation()
|
||||
self.set_position(self._my_icon, (width - icon_width) / 2,
|
||||
(height - icon_height) / 2)
|
||||
|
||||
[box_width, box_height] = self._devices_box.get_allocation()
|
||||
self.set_position(self._devices_box, (width - icon_width) / 2,
|
||||
height - style.GRID_CELL_SIZE * 3)
|
||||
|
||||
_REDRAW_TIMEOUT = 5 * 60 * 1000 # 5 minutes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user