From 5a6a0d2d7d13613b2cb312bca41c36dc608ea032 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 28 Sep 2006 15:52:56 -0400 Subject: [PATCH] Start making activity chat work; hit F9 to activate --- shell/view/ActivityHost.py | 37 +++++++++++++++++++++++++++++++++++++ shell/view/Shell.py | 11 +++++++++++ 2 files changed, 48 insertions(+) diff --git a/shell/view/ActivityHost.py b/shell/view/ActivityHost.py index 08454483..4524f563 100644 --- a/shell/view/ActivityHost.py +++ b/shell/view/ActivityHost.py @@ -7,10 +7,26 @@ from sugar.presence import PresenceService from sugar.canvas.IconColor import IconColor from sugar.p2p import Stream from sugar.p2p import network +from sugar.chat import ActivityChat + +class ActivityChatWindow(gtk.Window): + def __init__(self, gdk_window, chat_widget): + gtk.Window.__init__(self) + + self.set_decorated(False) + self.realize() + self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) + self.window.set_accept_focus(True) + self.window.set_transient_for(gdk_window) + + self.add(chat_widget) class ActivityHost: def __init__(self, shell, window): self._shell = shell + self._shell.connect('activity-changed', self._activity_changed_cb) + self._shell.connect('activity-closed', self._activity_closed_cb) + self._window = window self._xid = window.get_xid() self._pservice = PresenceService.get_instance() @@ -28,6 +44,9 @@ class ActivityHost: info = registry.get_activity(self._type) self._icon_name = info.get_icon() + self._chat_widget = ActivityChat.ActivityChat(self) + self._chat_window = ActivityChatWindow(self._gdk_window, self._chat_widget) + def get_id(self): return self._id @@ -76,3 +95,21 @@ class ActivityHost: def show_dialog(self, dialog): dialog.show() dialog.window.set_transient_for(self._gdk_window) + + def chat_show(self): + self._chat_window.show_all() + + def chat_hide(self): + self._chat_window.hide() + + def is_chat_visible(self): + return self._chat_window.get_property('visible') + + def _activity_changed_cb(self, shell, activity): + if activity != self: + self.chat_hide() + + def _activity_closed_cb(self, shell, activity): + if activity == self: + self.chat_hide() + diff --git a/shell/view/Shell.py b/shell/view/Shell.py index 0b54e19b..e5274b80 100644 --- a/shell/view/Shell.py +++ b/shell/view/Shell.py @@ -41,6 +41,7 @@ class Shell(gobject.GObject): self._key_grabber.grab('F4') self._key_grabber.grab('F5') self._key_grabber.grab('F6') + self._key_grabber.grab('F9') self._home_window = HomeWindow(self) self._home_window.show() @@ -67,6 +68,8 @@ class Shell(gobject.GObject): self._frame.notify_key_press() elif key == 'F6': self.start_activity('org.sugar.Terminal') + elif key == 'F9': + self._show_hide_activity_chat() def __global_key_released_cb(self, grabber, key): if key == 'F5': @@ -147,3 +150,11 @@ class Shell(gobject.GObject): if host.get_id() == activity_id: return host return None + + def _show_hide_activity_chat(self): + act = self.get_current_activity() + if act: + if act.is_chat_visible(): + act.chat_hide() + else: + act.chat_show()