Implement close button for the activity.

Some fixes.
This commit is contained in:
Marco Pesenti Gritti 2006-09-18 11:56:53 +02:00
parent 1f3187e0b5
commit 180c65e81c
4 changed files with 22 additions and 7 deletions

View File

@ -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)

View File

@ -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()

View File

@ -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)

View File

@ -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()
if action == ActivityMenu.ACTION_CLOSE:
activity.close()
class TopPanel(goocanvas.Group):
def __init__(self, shell):