Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-01-26 14:18:53 (GMT)
committer Dan Williams <dcbw@redhat.com>2007-01-26 14:18:53 (GMT)
commitd35413d8b04d6bd565b8980d101125dbf9c9460c (patch)
tree758ccb7d44113d5518c6115d557d82774151829c /shell
parent89e10838d3199e6f52508c72ee0aa904cbf235d4 (diff)
parent8a0728b169535e83ba1c1540cd6ddc42d24f16e3 (diff)
Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
Diffstat (limited to 'shell')
-rw-r--r--shell/view/Shell.py2
-rw-r--r--shell/view/frame/Makefile.am7
-rw-r--r--shell/view/frame/PanelWindow.py3
-rw-r--r--shell/view/frame/ZoomBox.py2
-rw-r--r--shell/view/frame/clipboardpanelwindow.py4
-rw-r--r--shell/view/frame/eventframe.py141
-rw-r--r--shell/view/frame/frame.py (renamed from shell/view/frame/Frame.py)234
-rw-r--r--shell/view/keyhandler.py4
8 files changed, 222 insertions, 175 deletions
diff --git a/shell/view/Shell.py b/shell/view/Shell.py
index 69dc90d..9b14b69 100644
--- a/shell/view/Shell.py
+++ b/shell/view/Shell.py
@@ -25,7 +25,7 @@ from view.home.HomeWindow import HomeWindow
from sugar.presence import PresenceService
from view.ActivityHost import ActivityHost
from sugar.activity import ActivityFactory
-from view.frame.Frame import Frame
+from view.frame.frame import Frame
from view.keyhandler import KeyHandler
from view.hardwaremanager import HardwareManager
from _sugar import AudioManager
diff --git a/shell/view/frame/Makefile.am b/shell/view/frame/Makefile.am
index 2533fd5..1aaabd6 100644
--- a/shell/view/frame/Makefile.am
+++ b/shell/view/frame/Makefile.am
@@ -5,8 +5,9 @@ sugar_PYTHON = \
clipboardbox.py \
clipboardpanelwindow.py \
FriendsBox.py \
- PanelWindow.py \
- Frame.py \
+ eventframe.py \
+ frame.py \
ZoomBox.py \
notificationtray.py \
- overlaybox.py
+ overlaybox.py \
+ PanelWindow.py
diff --git a/shell/view/frame/PanelWindow.py b/shell/view/frame/PanelWindow.py
index a690b80..0260313 100644
--- a/shell/view/frame/PanelWindow.py
+++ b/shell/view/frame/PanelWindow.py
@@ -20,7 +20,7 @@ import hippo
from sugar.graphics.menushell import MenuShell
class PanelWindow(gtk.Window):
- def __init__(self, x, y, width, height):
+ def __init__(self, width, height):
gtk.Window.__init__(self)
self.set_decorated(False)
@@ -36,7 +36,6 @@ class PanelWindow(gtk.Window):
self._menu_shell = MenuShell(canvas)
- self.move(x, y)
self.resize(width, height)
def get_menu_shell(self):
diff --git a/shell/view/frame/ZoomBox.py b/shell/view/frame/ZoomBox.py
index ed10374..7e14212 100644
--- a/shell/view/frame/ZoomBox.py
+++ b/shell/view/frame/ZoomBox.py
@@ -113,7 +113,7 @@ class ZoomBox(hippo.CanvasBox):
if home_activity:
icon = ActivityIcon(self._shell, self._menu_shell, home_activity)
style.apply_stylesheet(icon, 'frame.ZoomIcon')
- self.append(icon, 0)
+ self.append(icon)
self._activity_icon = icon
else:
self._activity_icon = None
diff --git a/shell/view/frame/clipboardpanelwindow.py b/shell/view/frame/clipboardpanelwindow.py
index f001476..2f63106 100644
--- a/shell/view/frame/clipboardpanelwindow.py
+++ b/shell/view/frame/clipboardpanelwindow.py
@@ -8,8 +8,8 @@ from sugar.clipboard import clipboardservice
from sugar import util
class ClipboardPanelWindow(PanelWindow):
- def __init__(self, frame, x, y, width, height):
- PanelWindow.__init__(self, x, y, width, height)
+ def __init__(self, frame, width, height):
+ PanelWindow.__init__(self, width, height)
self._frame = frame
diff --git a/shell/view/frame/eventframe.py b/shell/view/frame/eventframe.py
new file mode 100644
index 0000000..0537df3
--- /dev/null
+++ b/shell/view/frame/eventframe.py
@@ -0,0 +1,141 @@
+# Copyright (C) 2006, Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import logging
+
+import gtk
+import gobject
+import wnck
+
+class EventFrame(gobject.GObject):
+ __gsignals__ = {
+ 'enter-edge': (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE, ([])),
+ 'enter-corner': (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE, ([])),
+ 'leave': (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE, ([]))
+ }
+
+ HOVER_NONE = 0
+ HOVER_CORNER = 1
+ HOVER_EDGE = 2
+
+ def __init__(self):
+ gobject.GObject.__init__(self)
+
+ self._windows = []
+ self._hover = EventFrame.HOVER_NONE
+ self._active = False
+
+ invisible = self._create_invisible(0, 0, gtk.gdk.screen_width(), 6)
+ self._windows.append(invisible)
+
+ invisible = self._create_invisible(0, 0, 6, gtk.gdk.screen_height())
+ self._windows.append(invisible)
+
+ invisible = self._create_invisible(gtk.gdk.screen_width() - 6, 0,
+ gtk.gdk.screen_width(),
+ gtk.gdk.screen_height())
+ self._windows.append(invisible)
+
+ invisible = self._create_invisible(0, gtk.gdk.screen_height() - 6,
+ gtk.gdk.screen_width(),
+ gtk.gdk.screen_height())
+ self._windows.append(invisible)
+
+ screen = wnck.screen_get_default()
+ screen.connect('active-window-changed',
+ self._active_window_changed_cb)
+
+ def _create_invisible(self, x, y, width, height):
+ invisible = gtk.Invisible()
+ invisible.connect('motion-notify-event', self._motion_notify_cb)
+ invisible.connect('enter-notify-event', self._enter_notify_cb)
+ invisible.connect('leave-notify-event', self._leave_notify_cb)
+
+ invisible.drag_dest_set(0, [], 0)
+ invisible.connect('drag_motion', self._drag_motion_cb)
+ invisible.connect('drag_leave', self._drag_leave_cb)
+
+ invisible.realize()
+ invisible.window.set_events(gtk.gdk.POINTER_MOTION_MASK |
+ gtk.gdk.ENTER_NOTIFY_MASK |
+ gtk.gdk.LEAVE_NOTIFY_MASK)
+ invisible.window.move_resize(x, y, width, height)
+
+ return invisible
+
+ def _enter_notify_cb(self, widget, event):
+ self._notify_enter(event.x, event.y)
+ logging.debug('EventFrame._enter_notify_cb ' + str(self._hover))
+
+ def _motion_notify_cb(self, widget, event):
+ self._notify_enter(event.x, event.y)
+ logging.debug('EventFrame._motion_notify_cb ' + str(self._hover))
+
+ def _drag_motion_cb(self, widget, drag_context, x, y, timestamp):
+ drag_context.drag_status(0, timestamp);
+ self._notify_enter(x, y)
+ logging.debug('EventFrame._drag_motion_cb ' + str(self._hover))
+ return True
+
+ def _notify_enter(self, x, y):
+ screen_w = gtk.gdk.screen_width()
+ screen_h = gtk.gdk.screen_height()
+
+ if (x == 0 and y == 0) or \
+ (x == 0 and y == screen_h - 1) or \
+ (x == screen_w - 1 and y == 0) or \
+ (x == screen_w - 1 and y == screen_h - 1):
+ if self._hover != EventFrame.HOVER_CORNER:
+ self._hover = EventFrame.HOVER_CORNER
+ self.emit('enter-corner')
+ else:
+ if self._hover != EventFrame.HOVER_EDGE:
+ self._hover = EventFrame.HOVER_EDGE
+ self.emit('enter-edge')
+
+ def _leave_notify_cb(self, widget, event):
+ self._notify_leave()
+ logging.debug('EventFrame._leave_notify_cb ' + str(self._hover))
+
+ def _drag_leave_cb(self, widget, drag_context, timestamp):
+ self._notify_leave()
+ logging.debug('EventFrame._drag_leave_cb ' + str(self._hover))
+ return True
+
+ def _notify_leave(self):
+ self._hover = EventFrame.HOVER_NONE
+ if self._active:
+ self.emit('leave')
+
+ def show(self):
+ self._active = True
+ for window in self._windows:
+ window.show()
+
+ def hide(self):
+ self._active = False
+ for window in self._windows:
+ window.hide()
+
+ def _active_window_changed_cb(self, screen):
+ for window in self._windows:
+ window.window.raise_()
+
+ def is_visible(self):
+ return self._windows[0].props.visible
diff --git a/shell/view/frame/Frame.py b/shell/view/frame/frame.py
index 0179115..1e92180 100644
--- a/shell/view/frame/Frame.py
+++ b/shell/view/frame/frame.py
@@ -18,8 +18,8 @@ import logging
import gtk
import gobject
import hippo
-import wnck
+from view.frame.eventframe import EventFrame
from view.frame.ActivitiesBox import ActivitiesBox
from view.frame.ZoomBox import ZoomBox
from view.frame.overlaybox import OverlayBox
@@ -32,122 +32,7 @@ from sugar.graphics.timeline import Timeline
from sugar.graphics.grid import Grid
from sugar.graphics.menushell import MenuShell
-class EventFrame(gobject.GObject):
- __gsignals__ = {
- 'enter-edge': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE, ([])),
- 'enter-corner': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE, ([])),
- 'leave': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE, ([]))
- }
-
- HOVER_NONE = 0
- HOVER_CORNER = 1
- HOVER_EDGE = 2
-
- def __init__(self):
- gobject.GObject.__init__(self)
-
- self._windows = []
- self._hover = EventFrame.HOVER_NONE
- self._active = False
-
- invisible = self._create_invisible(0, 0, gtk.gdk.screen_width(), 6)
- self._windows.append(invisible)
-
- invisible = self._create_invisible(0, 0, 6, gtk.gdk.screen_height())
- self._windows.append(invisible)
-
- invisible = self._create_invisible(gtk.gdk.screen_width() - 6, 0,
- gtk.gdk.screen_width(),
- gtk.gdk.screen_height())
- self._windows.append(invisible)
-
- invisible = self._create_invisible(0, gtk.gdk.screen_height() - 6,
- gtk.gdk.screen_width(),
- gtk.gdk.screen_height())
- self._windows.append(invisible)
-
- screen = wnck.screen_get_default()
- screen.connect('active-window-changed',
- self._active_window_changed_cb)
-
- def _create_invisible(self, x, y, width, height):
- invisible = gtk.Invisible()
- invisible.connect('motion-notify-event', self._motion_notify_cb)
- invisible.connect('enter-notify-event', self._enter_notify_cb)
- invisible.connect('leave-notify-event', self._leave_notify_cb)
-
- invisible.drag_dest_set(0, [], 0)
- invisible.connect('drag_motion', self._drag_motion_cb)
- invisible.connect('drag_leave', self._drag_leave_cb)
-
- invisible.realize()
- invisible.window.set_events(gtk.gdk.POINTER_MOTION_MASK |
- gtk.gdk.ENTER_NOTIFY_MASK |
- gtk.gdk.LEAVE_NOTIFY_MASK)
- invisible.window.move_resize(x, y, width, height)
-
- return invisible
-
- def _enter_notify_cb(self, widget, event):
- self._notify_enter(event.x, event.y)
- logging.debug('EventFrame._enter_notify_cb ' + str(self._hover))
-
- def _motion_notify_cb(self, widget, event):
- self._notify_enter(event.x, event.y)
- logging.debug('EventFrame._motion_notify_cb ' + str(self._hover))
-
- def _drag_motion_cb(self, widget, drag_context, x, y, timestamp):
- drag_context.drag_status(0, timestamp);
- self._notify_enter(x, y)
- logging.debug('EventFrame._drag_motion_cb ' + str(self._hover))
- return True
-
- def _notify_enter(self, x, y):
- screen_w = gtk.gdk.screen_width()
- screen_h = gtk.gdk.screen_height()
-
- if (x == 0 and y == 0) or \
- (x == 0 and y == screen_h - 1) or \
- (x == screen_w - 1 and y == 0) or \
- (x == screen_w - 1 and y == screen_h - 1):
- if self._hover != EventFrame.HOVER_CORNER:
- self._hover = EventFrame.HOVER_CORNER
- self.emit('enter-corner')
- else:
- if self._hover != EventFrame.HOVER_EDGE:
- self._hover = EventFrame.HOVER_EDGE
- self.emit('enter-edge')
-
- def _leave_notify_cb(self, widget, event):
- self._notify_leave()
- logging.debug('EventFrame._leave_notify_cb ' + str(self._hover))
-
- def _drag_leave_cb(self, widget, drag_context, timestamp):
- self._notify_leave()
- logging.debug('EventFrame._drag_leave_cb ' + str(self._hover))
- return True
-
- def _notify_leave(self):
- self._hover = EventFrame.HOVER_NONE
- if self._active:
- self.emit('leave')
-
- def show(self):
- self._active = True
- for window in self._windows:
- window.show()
-
- def hide(self):
- self._active = False
- for window in self._windows:
- window.hide()
-
- def _active_window_changed_cb(self, screen):
- for window in self._windows:
- window.window.raise_()
+_ANIMATION = False
class Frame:
INACTIVE = 0
@@ -157,10 +42,15 @@ class Frame:
AUTOMATIC = 4
def __init__(self, shell):
- self._windows = []
+ self._left_panel = None
+ self._right_panel = None
+ self._top_panel = None
+ self._bottom_panel = None
+
self._hover_frame = False
self._shell = shell
self._mode = Frame.INACTIVE
+ self._grid = Grid()
self._timeline = Timeline(self)
self._timeline.add_tag('slide_in', 18, 24)
@@ -173,92 +63,100 @@ class Frame:
self._event_frame.connect('leave', self._event_frame_leave_cb)
self._event_frame.show()
- grid = Grid()
+ self._create_top_panel()
+ self._create_bottom_panel()
+ self._create_left_panel()
+ self._create_right_panel()
- # Top panel
- panel = self._create_panel(grid, 0, 0, 16, 1)
- menu_shell = panel.get_menu_shell()
- root = panel.get_root()
+ shell.get_model().connect('notify::state',
+ self._shell_state_changed_cb)
+
+ def _create_top_panel(self):
+ self._top_panel = self._create_panel(16, 1)
+ menu_shell = self._top_panel.get_menu_shell()
+ root = self._top_panel.get_root()
menu_shell.set_position(MenuShell.BOTTOM)
box = ZoomBox(self._shell, menu_shell)
- [x, y] = grid.point(1, 0)
+ [x, y] = self._grid.point(1, 0)
root.append(box, hippo.PACK_FIXED)
root.set_position(box, x, y)
tray = NotificationTray()
- tray_box = hippo.CanvasBox(box_width=grid.dimension(1),
- box_height=grid.dimension(1),
+ tray_box = hippo.CanvasBox(box_width=self._grid.dimension(1),
+ box_height=self._grid.dimension(1),
xalign=hippo.ALIGNMENT_END)
tray_widget = hippo.CanvasWidget()
tray_widget.props.widget = tray
tray_box.append(tray_widget, gtk.EXPAND)
- [x, y] = grid.point(13, 0)
+ [x, y] = self._grid.point(13, 0)
root.append(tray_box, hippo.PACK_FIXED)
root.set_position(tray_box, x, y)
box = OverlayBox(self._shell)
- [x, y] = grid.point(14, 0)
+ [x, y] = self._grid.point(14, 0)
root.append(box, hippo.PACK_FIXED)
root.set_position(box, x, y)
- # Bottom panel
- panel = self._create_panel(grid, 0, 11, 16, 1)
- menu_shell = panel.get_menu_shell()
- root = panel.get_root()
+ def _create_bottom_panel(self):
+ self._bottom_panel = self._create_panel(16, 1)
+ menu_shell = self._bottom_panel.get_menu_shell()
+ root = self._bottom_panel.get_root()
menu_shell.set_position(MenuShell.TOP)
box = ActivitiesBox(self._shell)
root.append(box, hippo.PACK_FIXED)
- [x, y] = grid.point(1, 0)
+ [x, y] = self._grid.point(1, 0)
root.set_position(box, x, y)
- # Right panel
- panel = self._create_panel(grid, 15, 1, 1, 10)
- menu_shell = panel.get_menu_shell()
- root = panel.get_root()
+ def _create_right_panel(self):
+ self._right_panel = self._create_panel(1, 10)
+ menu_shell = self._right_panel.get_menu_shell()
+ root = self._right_panel.get_root()
menu_shell.set_position(MenuShell.LEFT)
box = FriendsBox(self._shell, menu_shell)
root.append(box)
- # Left panel
- panel = self._create_clipboard_panel(grid, 0, 1, 1, 10)
+ def _create_left_panel(self):
+ self._left_panel = ClipboardPanelWindow(
+ self, self._grid.dimension(1), self._grid.dimension(10))
- shell.get_model().connect('notify::state',
- self._shell_state_changed_cb)
+ self._connect_to_panel(self._left_panel)
+ self._left_panel.connect('drag-motion', self._drag_motion_cb)
+ self._left_panel.connect('drag-leave', self._drag_leave_cb)
def _shell_state_changed_cb(self, model, pspec):
if model.props.state == ShellModel.STATE_SHUTDOWN:
self._timeline.goto('slide_out', True)
- def _create_clipboard_panel(self, grid, x, y, width, height):
- [x, y, width, height] = grid.rectangle(x, y, width, height)
- panel = ClipboardPanelWindow(self, x, y, width, height)
-
+ def _create_panel(self, width, height):
+ panel = PanelWindow(self._grid.dimension(width),
+ self._grid.dimension(height))
self._connect_to_panel(panel)
- panel.connect('drag-motion', self._drag_motion_cb)
- panel.connect('drag-leave', self._drag_leave_cb)
-
- self._windows.append(panel)
return panel
- def _create_panel(self, grid, x, y, width, height):
- [x, y, width, height] = grid.rectangle(x, y, width, height)
- panel = PanelWindow(x, y, width, height)
- self._connect_to_panel(panel)
- self._windows.append(panel)
+ def _move_panel(self, panel, x1, y1, x2, y2, pos):
+ [screen_x1, screen_y1] = self._grid.point(x1, y1)
+ [screen_x2, screen_y2] = self._grid.point(x2, y2)
- return panel
+ screen_x = (screen_x2 - screen_x1) * pos + screen_x1
+ screen_y = (screen_y2 - screen_y1) * pos + screen_y1
+
+ panel.move(int(screen_x), int(screen_y))
+
+ # FIXME we should hide and show as necessary to free memory
+ if not panel.props.visible:
+ panel.show()
def _connect_to_panel(self, panel):
panel.connect('enter-notify-event', self._enter_notify_cb)
@@ -341,19 +239,27 @@ class Frame:
if self._mode == Frame.TEMPORARY:
self._timeline.play('before_slide_out', 'slide_out')
+ def _move(self, pos):
+ self._move_panel(self._top_panel, 0, -1, 0, 0, pos)
+ self._move_panel(self._bottom_panel, 0, 12, 0, 11, pos)
+ self._move_panel(self._left_panel, -1, 1, 0, 1, pos)
+ self._move_panel(self._right_panel, 16, 1, 15, 1, pos)
+
def do_slide_in(self, current=0, n_frames=0):
- if not self._windows[0].props.visible:
- for panel in self._windows:
- panel.show()
+ if _ANIMATION:
+ self._move(float(current + 1) / float(n_frames))
+ elif current == 0:
+ self._move(1)
+ if self._event_frame.is_visible():
self._event_frame.hide()
def do_slide_out(self, current=0, n_frames=0):
- if self._windows[0].props.visible:
- for panel in self._windows:
- panel.hide()
+ if _ANIMATION:
+ self._move(1 - (float(current + 1) / float(n_frames)))
+ elif current == 0:
+ self._move(0)
+ if not self._event_frame.is_visible():
self._event_frame.show()
def is_visible(self):
- if self._windows[0].props.visible:
- return True
- return False
+ return self._top_panel.props.visible
diff --git a/shell/view/keyhandler.py b/shell/view/keyhandler.py
index c5f9eff..870adb9 100644
--- a/shell/view/keyhandler.py
+++ b/shell/view/keyhandler.py
@@ -80,10 +80,10 @@ class KeyHandler(object):
self._audio_manager.set_volume(0)
def handle_volume_2(self):
- self._audio_manager.set_volume(40)
+ self._audio_manager.set_volume(50)
def handle_volume_3(self):
- self._audio_manager.set_volume(75)
+ self._audio_manager.set_volume(80)
def handle_volume_4(self):
self._audio_manager.set_volume(100)