Start making activity chat work; hit F9 to activate

This commit is contained in:
Dan Williams 2006-09-28 15:52:56 -04:00
parent e95e6c2a4e
commit 5a6a0d2d7d
2 changed files with 48 additions and 0 deletions

View File

@ -7,10 +7,26 @@ from sugar.presence import PresenceService
from sugar.canvas.IconColor import IconColor from sugar.canvas.IconColor import IconColor
from sugar.p2p import Stream from sugar.p2p import Stream
from sugar.p2p import network 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: class ActivityHost:
def __init__(self, shell, window): def __init__(self, shell, window):
self._shell = shell 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._window = window
self._xid = window.get_xid() self._xid = window.get_xid()
self._pservice = PresenceService.get_instance() self._pservice = PresenceService.get_instance()
@ -28,6 +44,9 @@ class ActivityHost:
info = registry.get_activity(self._type) info = registry.get_activity(self._type)
self._icon_name = info.get_icon() 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): def get_id(self):
return self._id return self._id
@ -76,3 +95,21 @@ class ActivityHost:
def show_dialog(self, dialog): def show_dialog(self, dialog):
dialog.show() dialog.show()
dialog.window.set_transient_for(self._gdk_window) 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()

View File

@ -41,6 +41,7 @@ class Shell(gobject.GObject):
self._key_grabber.grab('F4') self._key_grabber.grab('F4')
self._key_grabber.grab('F5') self._key_grabber.grab('F5')
self._key_grabber.grab('F6') self._key_grabber.grab('F6')
self._key_grabber.grab('F9')
self._home_window = HomeWindow(self) self._home_window = HomeWindow(self)
self._home_window.show() self._home_window.show()
@ -67,6 +68,8 @@ class Shell(gobject.GObject):
self._frame.notify_key_press() self._frame.notify_key_press()
elif key == 'F6': elif key == 'F6':
self.start_activity('org.sugar.Terminal') self.start_activity('org.sugar.Terminal')
elif key == 'F9':
self._show_hide_activity_chat()
def __global_key_released_cb(self, grabber, key): def __global_key_released_cb(self, grabber, key):
if key == 'F5': if key == 'F5':
@ -147,3 +150,11 @@ class Shell(gobject.GObject):
if host.get_id() == activity_id: if host.get_id() == activity_id:
return host return host
return None 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()