From 72562502b9e28eebe7884eb8f4f911a9e842ebea Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 29 Sep 2006 13:35:48 -0400 Subject: [PATCH 1/3] Add composited overlay window underneath chat --- shell/view/ActivityHost.py | 15 ++++++++++++++- shell/view/OverlayWindow.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 shell/view/OverlayWindow.py diff --git a/shell/view/ActivityHost.py b/shell/view/ActivityHost.py index a9d55ea7..259f3fb1 100644 --- a/shell/view/ActivityHost.py +++ b/shell/view/ActivityHost.py @@ -8,12 +8,14 @@ from sugar.canvas.IconColor import IconColor from sugar.p2p import Stream from sugar.p2p import network from sugar.chat import ActivityChat +import OverlayWindow class ActivityChatWindow(gtk.Window): def __init__(self, gdk_window, chat_widget): gtk.Window.__init__(self) self.realize() + self.set_decorated(False) self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) self.window.set_accept_focus(True) self.window.set_transient_for(gdk_window) @@ -43,8 +45,15 @@ class ActivityHost: info = registry.get_activity(self._type) self._icon_name = info.get_icon() + try: + self._overlay_window = OverlayWindow.OverlayWindow(self._gdk_window) + win = self._overlay_window.window + except RuntimeError: + self._overlay_window = None + win = self._gdk_window + self._chat_widget = ActivityChat.ActivityChat(self) - self._chat_window = ActivityChatWindow(self._gdk_window, self._chat_widget) + self._chat_window = ActivityChatWindow(win, self._chat_widget) self._frame_was_visible = False self._shell.connect('activity-changed', self._activity_changed_cb) @@ -101,11 +110,15 @@ class ActivityHost: dialog.window.set_transient_for(self._gdk_window) def chat_show(self, frame_was_visible): + if self._overlay_window: + self._overlay_window.show_all() self._chat_window.show_all() self._frame_was_visible = frame_was_visible def chat_hide(self): self._chat_window.hide() + if self._overlay_window: + self._overlay_window.hide() wasvis = self._frame_was_visible self._frame_was_visible = False return wasvis diff --git a/shell/view/OverlayWindow.py b/shell/view/OverlayWindow.py new file mode 100644 index 00000000..13353606 --- /dev/null +++ b/shell/view/OverlayWindow.py @@ -0,0 +1,34 @@ +import gtk +import cairo + + +class OverlayWindow(gtk.Window): + def __init__(self, lower_window): + gtk.Window.__init__(self) + + colormap = self.get_screen().get_rgba_colormap() + colormap=None + if not colormap: + raise RuntimeError("The window manager doesn't support compositing.") + self.set_colormap(colormap) + + self.realize() + + self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) + self.window.set_accept_focus(False) + self.window.set_transient_for(lower_window) + + self.set_decorated(False) + self.set_position(gtk.WIN_POS_CENTER_ALWAYS) + self.set_default_size(gtk.gdk.screen_width(), gtk.gdk.screen_height()) + self.set_app_paintable(True) + + self.connect('expose-event', self._expose_cb) + + def _expose_cb(self, widget, event): + cr = widget.window.cairo_create() + cr.set_source_rgba(0.0, 0.0, 0.0, 0.4) # Transparent + cr.set_operator(cairo.OPERATOR_SOURCE) + cr.paint() + return False + From ca56406aa4f352f889dae70187e89e1d7acd4f7a Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 29 Sep 2006 16:46:12 -0400 Subject: [PATCH 2/3] Add OverlayWindow to makefile --- shell/view/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/view/Makefile.am b/shell/view/Makefile.am index e932ff06..e1db8698 100644 --- a/shell/view/Makefile.am +++ b/shell/view/Makefile.am @@ -9,4 +9,5 @@ sugar_PYTHON = \ FirstTimeDialog.py \ BuddyIcon.py \ BuddyMenu.py \ + OverlayWindow.py \ Shell.py From fc9c923da9338f47987377a69b60d7b7f8ce2e32 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 29 Sep 2006 16:53:42 -0400 Subject: [PATCH 3/3] Ignore local name collisions again --- services/presence/Service.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/services/presence/Service.py b/services/presence/Service.py index 1d70baa0..2f0e22fa 100644 --- a/services/presence/Service.py +++ b/services/presence/Service.py @@ -397,10 +397,14 @@ class Service(gobject.GObject): logging.debug("Will register service with name='%s', stype='%s'," \ " domain='%s', address='%s', port=%d, info='%s'" % (self._full_name, self._stype, self._domain, self._address, self._port, info)) - self._avahi_entry_group.AddService(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, 0, - dbus.String(self._full_name), dbus.String(self._stype), - dbus.String(self._domain), dbus.String(""), # let Avahi figure the 'host' out - dbus.UInt16(self._port), info) + try: + self._avahi_entry_group.AddService(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, 0, + dbus.String(self._full_name), dbus.String(self._stype), + dbus.String(self._domain), dbus.String(""), # let Avahi figure the 'host' out + dbus.UInt16(self._port), info) + except dbus.DBusException, exc: + # Local name collision and stuff + pass self._avahi_entry_group.connect_to_signal('StateChanged', self.__entry_group_changed_cb) self._avahi_entry_group.Commit()