diff --git a/shell/view/Shell.py b/shell/view/Shell.py index 69dc90d3..9b14b69c 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 2533fd50..1aaabd6b 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/eventframe.py b/shell/view/frame/eventframe.py new file mode 100644 index 00000000..8155c679 --- /dev/null +++ b/shell/view/frame/eventframe.py @@ -0,0 +1,136 @@ +# 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 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_() diff --git a/shell/view/frame/Frame.py b/shell/view/frame/frame.py similarity index 66% rename from shell/view/frame/Frame.py rename to shell/view/frame/frame.py index 01791159..d08d4d2c 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,123 +32,6 @@ 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_() - class Frame: INACTIVE = 0 TEMPORARY = 1