From ddef3947d4b642978e4c603db4a2d4e93939cea3 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 28 Sep 2006 14:45:32 -0400 Subject: [PATCH 01/11] Import gobject --- shell/view/BuddyMenu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/view/BuddyMenu.py b/shell/view/BuddyMenu.py index 25d64d1b..3b8752a2 100644 --- a/shell/view/BuddyMenu.py +++ b/shell/view/BuddyMenu.py @@ -1,7 +1,7 @@ from sugar.canvas.Menu import Menu from sugar.canvas.IconItem import IconItem from sugar.presence import PresenceService -import gtk +import gtk, gobject import goocanvas _ICON_SIZE = 75 From e95e6c2a4e9a721b03e7ba16f9f14d8f00750005 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 28 Sep 2006 15:51:40 -0400 Subject: [PATCH 02/11] Import the PS correctly --- sugar/chat/Chat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sugar/chat/Chat.py b/sugar/chat/Chat.py index 058cac52..ba370f85 100644 --- a/sugar/chat/Chat.py +++ b/sugar/chat/Chat.py @@ -14,7 +14,7 @@ import logging from sugar.chat.Emoticons import Emoticons from sugar.chat.ChatToolbar import ChatToolbar from sugar.chat.ChatEditor import ChatEditor -from sugar.presence.PresenceService import PresenceService +from sugar.presence import PresenceService import richtext PANGO_SCALE = 1024 # Where is this defined? @@ -29,7 +29,7 @@ class Chat(gtk.VBox): def __init__(self): gtk.VBox.__init__(self, False, 6) - self._pservice = PresenceService() + self._pservice = PresenceService.get_instance() self._stream_writer = None self.set_border_width(12) From 5a6a0d2d7d13613b2cb312bca41c36dc608ea032 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 28 Sep 2006 15:52:56 -0400 Subject: [PATCH 03/11] 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() From a91738d3a9a85b46952995df12ed473692e5c2e6 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 28 Sep 2006 16:11:29 -0400 Subject: [PATCH 04/11] Default values for args for do_slide_in and do_slide_out, and add is_visisble() --- shell/view/frame/Frame.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shell/view/frame/Frame.py b/shell/view/frame/Frame.py index ef0077a6..0206080b 100644 --- a/shell/view/frame/Frame.py +++ b/shell/view/frame/Frame.py @@ -210,14 +210,19 @@ class Frame: if self._mode == Frame.TEMPORARY: self._timeline.play('before_slide_out', 'slide_out') - def do_slide_in(self, current, n_frames): + def do_slide_in(self, current=0, n_frames=0): if not self._windows[0].props.visible: for panel in self._windows: panel.show() self._event_frame.hide() - def do_slide_out(self, current, n_frames): + def do_slide_out(self, current=0, n_frames=0): if self._windows[0].props.visible: for panel in self._windows: panel.hide() self._event_frame.show() + + def is_visible(self): + if self._windows[0].props.visible: + return True + return False From ef539c50d9eadec934da5ba7b145c41f694518f1 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 28 Sep 2006 16:12:07 -0400 Subject: [PATCH 05/11] Fix frame behavior on chat; when we show the chat remember previous frame state and return to it when we hide chat --- shell/view/ActivityHost.py | 8 +++++++- shell/view/Shell.py | 16 +++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/shell/view/ActivityHost.py b/shell/view/ActivityHost.py index 4524f563..43ed38ce 100644 --- a/shell/view/ActivityHost.py +++ b/shell/view/ActivityHost.py @@ -96,11 +96,15 @@ class ActivityHost: dialog.show() dialog.window.set_transient_for(self._gdk_window) - def chat_show(self): + def chat_show(self, frame_was_visible): self._chat_window.show_all() + self._frame_was_visible = frame_was_visible def chat_hide(self): self._chat_window.hide() + wasvis = self._frame_was_visible + self._frame_was_visible = False + return wasvis def is_chat_visible(self): return self._chat_window.get_property('visible') @@ -108,8 +112,10 @@ class ActivityHost: def _activity_changed_cb(self, shell, activity): if activity != self: self.chat_hide() + self._frame_was_visible = False def _activity_closed_cb(self, shell, activity): if activity == self: self.chat_hide() + self._frame_was_visible = False diff --git a/shell/view/Shell.py b/shell/view/Shell.py index e5274b80..c9a2c4da 100644 --- a/shell/view/Shell.py +++ b/shell/view/Shell.py @@ -153,8 +153,14 @@ class Shell(gobject.GObject): 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() + if not act: + return + is_visible = self._frame.is_visible() + if act.is_chat_visible(): + frame_was_visible = act.chat_hide() + if not frame_was_visible: + self._frame.do_slide_out() + else: + if not is_visible: + self._frame.do_slide_in() + act.chat_show(is_visible) From e2225c443f263bffb5cb11e9eea30e8add860b0a Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 28 Sep 2006 16:13:48 -0400 Subject: [PATCH 06/11] Initialize _frame_was_visible, and move signal connections lower --- shell/view/ActivityHost.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shell/view/ActivityHost.py b/shell/view/ActivityHost.py index 43ed38ce..caf22b88 100644 --- a/shell/view/ActivityHost.py +++ b/shell/view/ActivityHost.py @@ -24,8 +24,6 @@ class ActivityChatWindow(gtk.Window): 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() @@ -47,6 +45,10 @@ class ActivityHost: self._chat_widget = ActivityChat.ActivityChat(self) self._chat_window = ActivityChatWindow(self._gdk_window, self._chat_widget) + self._frame_was_visible = False + self._shell.connect('activity-changed', self._activity_changed_cb) + self._shell.connect('activity-closed', self._activity_closed_cb) + def get_id(self): return self._id From a55242d798b98eabe21cba08632625851c98ab9a Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 28 Sep 2006 16:20:48 -0400 Subject: [PATCH 07/11] Center chat window, and give it a frame --- shell/view/ActivityHost.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/view/ActivityHost.py b/shell/view/ActivityHost.py index caf22b88..118b4161 100644 --- a/shell/view/ActivityHost.py +++ b/shell/view/ActivityHost.py @@ -13,11 +13,11 @@ 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.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.add(chat_widget) From 5db9888666078dddfe5f51b3c2b1e72de6eb2511 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 28 Sep 2006 17:00:03 -0400 Subject: [PATCH 08/11] Set default chat window size --- shell/view/ActivityHost.py | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/view/ActivityHost.py b/shell/view/ActivityHost.py index 118b4161..e03dc3a1 100644 --- a/shell/view/ActivityHost.py +++ b/shell/view/ActivityHost.py @@ -18,6 +18,7 @@ class ActivityChatWindow(gtk.Window): self.window.set_accept_focus(True) self.window.set_transient_for(gdk_window) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) + self.set_default_size(600, 450) self.add(chat_widget) From 8e7fe5dd659db80f6a09541379037d5237d92a30 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 28 Sep 2006 17:00:15 -0400 Subject: [PATCH 09/11] Deal with missing icons --- sugar/chat/ChatToolbar.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sugar/chat/ChatToolbar.py b/sugar/chat/ChatToolbar.py index b150fa61..70f0c2c7 100644 --- a/sugar/chat/ChatToolbar.py +++ b/sugar/chat/ChatToolbar.py @@ -83,8 +83,9 @@ class ChatToolbar(gtk.HBox): for name in Emoticons.get_instance().get_all(): icon_theme = gtk.icon_theme_get_default() pixbuf = icon_theme.load_icon(name, 16, 0) - model.append([pixbuf, name]) - + if pixbuf: + model.append([pixbuf, name]) + icon_view = gtk.IconView(model) icon_view.connect('selection-changed', self.__emoticon_selection_changed_cb) icon_view.set_pixbuf_column(0) From a09dc486692844a4c4e2bce74f3650da4fadd52d Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 28 Sep 2006 17:03:24 -0400 Subject: [PATCH 10/11] Fix missing icon check --- sugar/chat/ChatToolbar.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sugar/chat/ChatToolbar.py b/sugar/chat/ChatToolbar.py index 70f0c2c7..5d49e1f3 100644 --- a/sugar/chat/ChatToolbar.py +++ b/sugar/chat/ChatToolbar.py @@ -1,4 +1,4 @@ -import gtk +import gtk, gobject from sugar.chat.Emoticons import Emoticons from sugar.chat.sketchpad.Toolbox import Toolbox @@ -82,9 +82,11 @@ class ChatToolbar(gtk.HBox): for name in Emoticons.get_instance().get_all(): icon_theme = gtk.icon_theme_get_default() - pixbuf = icon_theme.load_icon(name, 16, 0) - if pixbuf: + try: + pixbuf = icon_theme.load_icon(name, 16, 0) model.append([pixbuf, name]) + except gobject.GError: + pass icon_view = gtk.IconView(model) icon_view.connect('selection-changed', self.__emoticon_selection_changed_cb) From ba05afdc535278101b134d6c1c66e8ab0fe482be Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 28 Sep 2006 17:08:42 -0400 Subject: [PATCH 11/11] Activate chat service when activity gets shared --- shell/view/ActivityHost.py | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/view/ActivityHost.py b/shell/view/ActivityHost.py index e03dc3a1..a9d55ea7 100644 --- a/shell/view/ActivityHost.py +++ b/shell/view/ActivityHost.py @@ -71,6 +71,7 @@ class ActivityHost: def share(self): self._activity.share() + self._chat_widget.share() def invite(self, buddy): if not self.get_shared():