diff --git a/lib/src/Makefile.am b/lib/src/Makefile.am index f7d0e171..407b4690 100644 --- a/lib/src/Makefile.am +++ b/lib/src/Makefile.am @@ -1,17 +1,18 @@ -libsugarprivate_la_CPPFLAGS = \ - $(WARN_CFLAGS) \ - $(LIB_CFLAGS) \ - $(GECKO_CFLAGS) \ - -I$(MOZILLA_INCLUDE_DIR)/dom \ - -I$(MOZILLA_INCLUDE_DIR)/exthandler \ - -I$(MOZILLA_INCLUDE_DIR)/gtkembedmoz \ - -I$(MOZILLA_INCLUDE_DIR)/mimetype \ - -I$(MOZILLA_INCLUDE_DIR)/necko \ - -I$(MOZILLA_INCLUDE_DIR)/pref \ - -I$(MOZILLA_INCLUDE_DIR)/uriloader \ - -I$(MOZILLA_INCLUDE_DIR)/webbrwsr \ +libsugarprivate_la_CPPFLAGS = \ + $(WARN_CFLAGS) \ + $(LIB_CFLAGS) \ + $(GECKO_CFLAGS) \ + -I$(MOZILLA_INCLUDE_DIR)/dom \ + -I$(MOZILLA_INCLUDE_DIR)/exthandler \ + -I$(MOZILLA_INCLUDE_DIR)/gtkembedmoz \ + -I$(MOZILLA_INCLUDE_DIR)/mimetype \ + -I$(MOZILLA_INCLUDE_DIR)/necko \ + -I$(MOZILLA_INCLUDE_DIR)/pref \ + -I$(MOZILLA_INCLUDE_DIR)/uriloader \ + -I$(MOZILLA_INCLUDE_DIR)/webbrwsr \ + -DPLUGIN_DIR=\"$(libdir)/mozilla/plugins\" \ -DSHARE_DIR=\"$(pkgdatadir)\" - + noinst_LTLIBRARIES = libsugarprivate.la libsugarprivate_la_LIBADD = \ diff --git a/lib/src/sugar-browser.cpp b/lib/src/sugar-browser.cpp index fe94378a..4bbbb62f 100644 --- a/lib/src/sugar-browser.cpp +++ b/lib/src/sugar-browser.cpp @@ -69,11 +69,28 @@ static const nsModuleComponentInfo sSugarComponents[] = { #endif +static void +setup_plugin_path () +{ + const char *user_path; + char *new_path; + + user_path = g_getenv ("MOZ_PLUGIN_PATH"); + new_path = g_strconcat (user_path ? user_path : "", + user_path ? ":" : "", + PLUGIN_DIR, + (char *) NULL); + g_setenv ("MOZ_PLUGIN_PATH", new_path, TRUE); + g_free (new_path); +} + gboolean sugar_browser_startup(const char *profile_path, const char *profile_name) { nsresult rv; + setup_plugin_path(); + gtk_moz_embed_set_profile_path(profile_path, profile_name); gtk_moz_embed_push_startup(); 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/PanelWindow.py b/shell/view/frame/PanelWindow.py index a690b80c..02603134 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 ed103744..7e14212d 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 f001476d..2f63106f 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 00000000..0537df3f --- /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 similarity index 52% rename from shell/view/frame/Frame.py rename to shell/view/frame/frame.py index 01791159..1e921803 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 c5f9eff9..870adb9c 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)