From 180c65e81c80bd48362a30719502c688ab660985 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 18 Sep 2006 11:56:53 +0200 Subject: [PATCH] Implement close button for the activity. Some fixes. --- shell/view/ActivityHost.py | 3 +++ shell/view/Shell.py | 3 +-- shell/view/frame/RightPanel.py | 7 +++++-- shell/view/frame/TopPanel.py | 16 +++++++++++++--- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/shell/view/ActivityHost.py b/shell/view/ActivityHost.py index 0e81acd3..08454483 100644 --- a/shell/view/ActivityHost.py +++ b/shell/view/ActivityHost.py @@ -70,6 +70,9 @@ class ActivityHost: def present(self): self._window.activate(gtk.get_current_event_time()) + def close(self): + self._window.close(gtk.get_current_event_time()) + def show_dialog(self, dialog): dialog.show() dialog.window.set_transient_for(self._gdk_window) diff --git a/shell/view/Shell.py b/shell/view/Shell.py index f56f62df..821442c1 100644 --- a/shell/view/Shell.py +++ b/shell/view/Shell.py @@ -77,8 +77,7 @@ class Shell(gobject.GObject): if window == None: self._model.set_current_activity(None) self.emit('activity-changed', None) - - if window.get_window_type() == wnck.WINDOW_NORMAL: + elif window.get_window_type() == wnck.WINDOW_NORMAL: activity_host = self._hosts[window.get_xid()] current = self._model.get_current_activity() diff --git a/shell/view/frame/RightPanel.py b/shell/view/frame/RightPanel.py index 14120590..3cc2935c 100644 --- a/shell/view/frame/RightPanel.py +++ b/shell/view/frame/RightPanel.py @@ -70,8 +70,11 @@ class RightPanel(CanvasBox): 'buddy-left', self.__buddy_left_cb) def __activity_changed_cb(self, group, activity): - activity_ps = self._pservice.get_activity(activity.get_id()) - self._set_activity_ps(activity_ps) + if activity: + ps = self._pservice.get_activity(activity.get_id()) + self._set_activity_ps(ps) + else: + self._set_activity_ps(None) def __buddy_joined_cb(self, activity, buddy): self.add(buddy) diff --git a/shell/view/frame/TopPanel.py b/shell/view/frame/TopPanel.py index 188a7d7e..35df67fa 100644 --- a/shell/view/frame/TopPanel.py +++ b/shell/view/frame/TopPanel.py @@ -9,6 +9,7 @@ import sugar class ActivityMenu(Menu): ACTION_SHARE = 1 + ACTION_CLOSE = 2 def __init__(self, grid, activity_host): title = activity_host.get_title() @@ -17,6 +18,9 @@ class ActivityMenu(Menu): icon = IconItem(icon_name='stock-share') self.add_action(icon, ActivityMenu.ACTION_SHARE) + icon = IconItem(icon_name='stock-close-activity') + self.add_action(icon, ActivityMenu.ACTION_CLOSE) + class ActivityIcon(MenuIcon): def __init__(self, shell, activity_host): self._shell = shell @@ -36,10 +40,16 @@ class ActivityIcon(MenuIcon): return menu def _action_cb(self, menu, action): + self.popdown() + + activity = self._shell.get_current_activity() + if activity == None: + return + if action == ActivityMenu.ACTION_SHARE: - activity = shell.get_current_activity() - if activity != None: - activity.share() + activity.share() + if action == ActivityMenu.ACTION_CLOSE: + activity.close() class TopPanel(goocanvas.Group): def __init__(self, shell):