2006-07-20 11:34:06 +02:00
|
|
|
import gtk
|
|
|
|
import dbus
|
|
|
|
|
|
|
|
from sugar.activity import Activity
|
2006-07-26 12:57:54 +02:00
|
|
|
from PeopleWindow import PeopleWindow
|
2006-07-20 11:34:06 +02:00
|
|
|
|
|
|
|
class ActivityHost:
|
2006-08-09 18:29:33 +02:00
|
|
|
def __init__(self, shell, window):
|
2006-07-26 12:57:54 +02:00
|
|
|
self._shell = shell
|
2006-08-12 00:29:32 +02:00
|
|
|
self._window = window
|
|
|
|
self._xid = window.get_xid()
|
2006-08-09 18:29:33 +02:00
|
|
|
|
2006-07-20 11:34:06 +02:00
|
|
|
bus = dbus.SessionBus()
|
2006-08-12 00:29:32 +02:00
|
|
|
proxy_obj = bus.get_object(Activity.get_service_name(self._xid),
|
|
|
|
Activity.get_object_path(self._xid))
|
2006-07-20 11:34:06 +02:00
|
|
|
|
2006-08-09 12:57:42 +02:00
|
|
|
self._activity = dbus.Interface(proxy_obj, Activity.ACTIVITY_INTERFACE)
|
2006-07-20 11:34:06 +02:00
|
|
|
self._id = self._activity.get_id()
|
2006-07-20 12:13:47 +02:00
|
|
|
self._default_type = self._activity.get_default_type()
|
2006-08-12 00:29:32 +02:00
|
|
|
self._gdk_window = gtk.gdk.window_foreign_new(self._xid)
|
2006-07-26 12:57:54 +02:00
|
|
|
self._people_window = PeopleWindow(shell, self)
|
2006-07-20 11:34:06 +02:00
|
|
|
|
2006-08-17 14:23:52 +02:00
|
|
|
info = self._shell.get_registry().get_activity(self._default_type)
|
|
|
|
self._icon_name = info.get_icon()
|
|
|
|
|
2006-07-20 11:34:06 +02:00
|
|
|
def get_id(self):
|
|
|
|
return self._id
|
|
|
|
|
2006-08-17 14:23:52 +02:00
|
|
|
def get_icon_name(self):
|
|
|
|
return self._icon_name
|
|
|
|
|
2006-07-26 00:17:05 +02:00
|
|
|
def share(self):
|
2006-07-26 12:57:54 +02:00
|
|
|
self._people_window.share()
|
2006-07-26 00:17:05 +02:00
|
|
|
self._activity.share()
|
2006-07-20 11:34:06 +02:00
|
|
|
|
|
|
|
def get_shared(self):
|
|
|
|
return self._activity.get_shared()
|
|
|
|
|
2006-07-20 12:13:47 +02:00
|
|
|
def get_default_type(self):
|
|
|
|
return self._default_type
|
|
|
|
|
2006-07-26 12:57:54 +02:00
|
|
|
def show_people(self):
|
|
|
|
self.show_dialog(self._people_window)
|
|
|
|
|
2006-08-12 00:29:32 +02:00
|
|
|
def present(self):
|
|
|
|
self._window.activate(gtk.get_current_event_time())
|
|
|
|
|
2006-07-20 11:34:06 +02:00
|
|
|
def show_dialog(self, dialog):
|
|
|
|
dialog.show()
|
2006-08-12 00:29:32 +02:00
|
|
|
dialog.window.set_transient_for(self._gdk_window)
|