From 58f7dca355a53a9e8593d492c9807c75903c5f0d Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Thu, 18 Oct 2007 23:56:58 +0200 Subject: [PATCH] Fullscreen support and tray support in activity window Fullscreen mode hides toolbox and tray --- NEWS | 3 ++ lib/sugar/graphics/window.py | 63 ++++++++++++++++++++++++++++-------- shell/kbdconfig | 1 + 3 files changed, 53 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index 6f6ff784..3ef0933c 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +* Fullscreen support (hide toolbar and tray) and tray support in activity +window (erikos) + Snapshot 276e1ee517 * #4266 Avoid misleading warning every time an activity starts (smcv) diff --git a/lib/sugar/graphics/window.py b/lib/sugar/graphics/window.py index e6081feb..e55199f5 100644 --- a/lib/sugar/graphics/window.py +++ b/lib/sugar/graphics/window.py @@ -16,60 +16,95 @@ # Boston, MA 02111-1307, USA. import gtk -import hippo class Window(gtk.Window): def __init__(self): gtk.Window.__init__(self) - self.connect('realize', self._window_realize_cb) - + self.connect('realize', self.__window_realize_cb) + self.connect('window-state-event', self.__window_state_event_cb) + self.toolbox = None self._alerts = [] - self.alert_position = -1 self.canvas = None - + self.tray = None + self._vbox = gtk.VBox() + self._hbox = gtk.HBox() + self._vbox.pack_start(self._hbox) + self._hbox.show() + self.add(self._vbox) self._vbox.show() def set_canvas(self, canvas): if self.canvas: - self._vbox.remove(self.canvas) + self._hbox.remove(self.canvas) - self._vbox.pack_start(canvas) - self._vbox.reorder_child(canvas, -1) + self._hbox.pack_start(canvas) self.canvas = canvas def set_toolbox(self, toolbox): if self.toolbox: self._vbox.remove(self.toolbox) - + self._vbox.pack_start(toolbox, False) self._vbox.reorder_child(toolbox, 0) self.toolbox = toolbox + def set_tray(self, tray, position): + if self.tray: + box = self.tray.get_parent() + box.remove(self.tray) + + if position == gtk.POS_LEFT: + self._hbox.pack_start(tray, False) + elif position == gtk.POS_RIGHT: + self._hbox.pack_end(tray, False) + elif position == gtk.POS_BOTTOM: + self._vbox.pack_end(tray, False) + + self.tray = tray + def add_alert(self, alert): self._alerts.append(alert) if len(self._alerts) == 1: self._vbox.pack_start(alert, False) - self._vbox.reorder_child(alert, self.alert_position) - + if self.toolbox is not None: + self._vbox.reorder_child(alert, 1) + else: + self._vbox.reorder_child(alert, 0) + def remove_alert(self, alert): if alert in self._alerts: self._alerts.remove(alert) self._vbox.remove(alert) if len(self._alerts) >= 1: self._vbox.pack_start(self._alerts[0], False) - self._vbox.reorder_child(self._alerts[0], self.alert_position) - - def _window_realize_cb(self, window): + if self.toolbox is not None: + self._vbox.reorder_child(self._alerts[0], 1) + else: + self._vbox.reorder_child(self._alert[0], 0) + + def __window_realize_cb(self, window): group = gtk.Window() group.realize() window.window.set_group(group.window) + def __window_state_event_cb(self, window, event): + if event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN: + if self.toolbox is not None: + self.toolbox.hide() + if self.tray is not None: + self.tray.hide() + elif event.new_window_state == 0: + if self.toolbox is not None: + self.toolbox.show() + if self.tray is not None: + self.tray.show() + def get_canvas_screenshot(self): if not self.canvas: return None diff --git a/shell/kbdconfig b/shell/kbdconfig index 415c69ff..eb912c58 100644 --- a/shell/kbdconfig +++ b/shell/kbdconfig @@ -5,3 +5,4 @@ n=next p=prev c=close +return=fullscreen