Some cleanups in the Shell. Add a way to save/restore the frame state.

This commit is contained in:
Marco Pesenti Gritti 2007-03-12 20:18:55 +01:00
parent 2bd609e5fd
commit bf80cb55b9
2 changed files with 25 additions and 7 deletions

View File

@ -38,11 +38,13 @@ class Shell(gobject.GObject):
self._current_host = None
self._screen_rotation = 0
self._key_handler = KeyHandler(self)
self._popup_context = PopupContext()
self._frame = Frame(self)
self._home_window = HomeWindow(self)
self._home_window.show()
self.set_zoom_level(sugar.ZOOM_HOME)
self._key_handler = KeyHandler(self)
self._zoom_level = sugar.ZOOM_HOME
home_model = self._model.get_home()
home_model.connect('activity-added', self._activity_added_cb)
@ -50,10 +52,6 @@ class Shell(gobject.GObject):
home_model.connect('active-activity-changed',
self._active_activity_changed_cb)
self._popup_context = PopupContext()
self._frame = Frame(self)
#self.start_activity('org.laptop.JournalActivity')
def _activity_added_cb(self, home_model, home_activity):
@ -137,6 +135,10 @@ class Shell(gobject.GObject):
self.set_zoom_level(sugar.ZOOM_HOME)
def set_zoom_level(self, level):
self._zoom_level = level
self._update_zoom_level()
def _update_zoom_level(self):
if level == sugar.ZOOM_ACTIVITY:
self._screen.toggle_showing_desktop(False)
else:

View File

@ -110,6 +110,11 @@ class _KeyListener(object):
self._hide_sid = gobject.timeout_add(
100, self._hide_frame_timeout_cb)
class _FrameState(object):
def __init__(self, visible, mode):
self.visible = visible
self.mode = mode
class Frame(object):
def __init__(self, shell):
self.mode = MODE_NONE
@ -124,6 +129,7 @@ class Frame(object):
self._current_position = 0.0
self._animator = None
self._hover = False
self._saved_state = None
self._event_frame = EventFrame()
self._event_frame.connect('enter-corner', self._enter_corner_cb)
@ -149,6 +155,16 @@ class Frame(object):
self._key_listener = _KeyListener(self)
self._mouse_listener = _MouseListener(self)
def save_state(self):
self._saved_state = _FrameState(self.visible, self.mode)
def restore_state(self):
if self.saved_state.visible:
self.show()
else:
self.hide()
self.mode = self._saved_state.mode
def hide(self, force=False):
if not self.visible:
return