Abstract activity on the shell side into an ActivityHost object.
Comment out/fix more ps borkage.
This commit is contained in:
parent
53947aaaf2
commit
87cb115aa0
30
shell/ActivityHost.py
Normal file
30
shell/ActivityHost.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import gtk
|
||||||
|
import dbus
|
||||||
|
|
||||||
|
from sugar.activity import Activity
|
||||||
|
|
||||||
|
class ActivityHost:
|
||||||
|
def __init__(self, xid):
|
||||||
|
self._xid = xid
|
||||||
|
|
||||||
|
bus = dbus.SessionBus()
|
||||||
|
service = Activity.ACTIVITY_SERVICE_NAME + "%s" % xid
|
||||||
|
path = Activity.ACTIVITY_SERVICE_PATH + "/%s" % xid
|
||||||
|
proxy_obj = bus.get_object(service, path)
|
||||||
|
|
||||||
|
self._activity = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Activity')
|
||||||
|
self._id = self._activity.get_id()
|
||||||
|
self._window = gtk.gdk.window_foreign_new(xid)
|
||||||
|
|
||||||
|
def get_id(self):
|
||||||
|
return self._id
|
||||||
|
|
||||||
|
def publish(self):
|
||||||
|
self._activity.publish()
|
||||||
|
|
||||||
|
def get_shared(self):
|
||||||
|
return self._activity.get_shared()
|
||||||
|
|
||||||
|
def show_dialog(self, dialog):
|
||||||
|
dialog.show()
|
||||||
|
dialog.window.set_transient_for(self._window)
|
@ -20,12 +20,9 @@ class PresenceView(gtk.VBox):
|
|||||||
self._activity = None
|
self._activity = None
|
||||||
self._shell = shell
|
self._shell = shell
|
||||||
|
|
||||||
self._pservice = PresenceService.get_instance()
|
self._pservice = PresenceService()
|
||||||
self._pservice.connect("buddy-appeared", self._on_buddy_appeared_cb)
|
self._pservice.connect("BuddyAppeared", self._on_buddy_appeared_cb)
|
||||||
self._pservice.connect("buddy-disappeared", self._on_buddy_disappeared_cb)
|
self._pservice.connect("BuddyDisappeared", self._on_buddy_disappeared_cb)
|
||||||
self._pservice.start()
|
|
||||||
|
|
||||||
self._pservice.track_service_type(BuddyChat.SERVICE_TYPE)
|
|
||||||
|
|
||||||
self._setup_ui()
|
self._setup_ui()
|
||||||
|
|
||||||
|
@ -11,10 +11,10 @@ from ActivityRegistry import ActivityRegistry
|
|||||||
from HomeWindow import HomeWindow
|
from HomeWindow import HomeWindow
|
||||||
from sugar import keybindings
|
from sugar import keybindings
|
||||||
from sugar import env
|
from sugar import env
|
||||||
from sugar.activity import Activity
|
|
||||||
from PeopleWindow import PeopleWindow
|
from PeopleWindow import PeopleWindow
|
||||||
from Owner import ShellOwner
|
from Owner import ShellOwner
|
||||||
from PresenceService import PresenceService
|
from PresenceService import PresenceService
|
||||||
|
from ActivityHost import ActivityHost
|
||||||
|
|
||||||
class ShellDbusService(dbus.service.Object):
|
class ShellDbusService(dbus.service.Object):
|
||||||
def __init__(self, shell, bus_name):
|
def __init__(self, shell, bus_name):
|
||||||
@ -66,40 +66,29 @@ class Shell:
|
|||||||
else:
|
else:
|
||||||
window.show()
|
window.show()
|
||||||
|
|
||||||
def get_activity_from_xid(self, xid):
|
def get_current_activity(self):
|
||||||
bus = dbus.SessionBus()
|
window = self._screen.get_active_window()
|
||||||
service = Activity.ACTIVITY_SERVICE_NAME + "%s" % xid
|
if window and window.get_window_type() == wnck.WINDOW_NORMAL:
|
||||||
path = Activity.ACTIVITY_SERVICE_PATH + "/%s" % xid
|
return ActivityHost(window.get_xid())
|
||||||
proxy_obj = bus.get_object(service, path)
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
return dbus.Interface(proxy_obj, 'com.redhat.Sugar.Activity')
|
def __people_dialog_delete_cb(self, window, event):
|
||||||
|
|
||||||
def get_activity_window(self):
|
|
||||||
return self._screen.get_active_window()
|
|
||||||
|
|
||||||
def __people_window_delete_cb(self, window, event):
|
|
||||||
window.hide()
|
window.hide()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def show_people(self):
|
def show_people(self):
|
||||||
activity_window = self.get_activity_window()
|
activity = self.get_current_activity()
|
||||||
if activity_window:
|
if activity:
|
||||||
xid = activity_window.get_xid()
|
if not self._people_windows.has_key(activity.get_id()):
|
||||||
activity = self.get_activity_from_xid(xid)
|
dialog = PeopleWindow(self, activity)
|
||||||
activity_id = activity.get_id()
|
dialog.connect('delete-event', self.__people_dialog_delete_cb)
|
||||||
|
keybindings.setup_global_keys(dialog, self)
|
||||||
if not self._people_windows.has_key(activity_id):
|
self._people_windows[activity.get_id()] = dialog
|
||||||
window = PeopleWindow(self, activity)
|
|
||||||
window.connect('delete-event', self.__people_window_delete_cb)
|
|
||||||
keybindings.setup_global_keys(window, self)
|
|
||||||
self._people_windows[activity_id] = window
|
|
||||||
else:
|
else:
|
||||||
window = self._people_windows[activity_id]
|
dialog = self._people_windows[activity.get_id()]
|
||||||
|
|
||||||
window.show()
|
activity.show_dialog(dialog)
|
||||||
|
|
||||||
foreign_activity_win = gtk.gdk.window_foreign_new(xid)
|
|
||||||
window.window.set_transient_for(foreign_activity_win)
|
|
||||||
|
|
||||||
def toggle_console(self):
|
def toggle_console(self):
|
||||||
self._toggle_window_visibility(self._console.get_window())
|
self._toggle_window_visibility(self._console.get_window())
|
||||||
|
@ -10,13 +10,13 @@ class ActivityChat(GroupChat):
|
|||||||
self._chat_service = None
|
self._chat_service = None
|
||||||
|
|
||||||
self._activity = activity
|
self._activity = activity
|
||||||
self._pservice.connect('service-appeared', self._service_appeared_cb)
|
self._pservice.connect('ServiceAppeared', self._service_appeared_cb)
|
||||||
self._pservice.track_service_type(ActivityChat.SERVICE_TYPE)
|
|
||||||
|
|
||||||
# Find an existing activity chat to latch onto
|
# Find an existing activity chat to latch onto
|
||||||
service = self._pservice.get_activity_service(activity, ActivityChat.SERVICE_TYPE)
|
#activity_ps = self._pservice.getActivity(activity.get_id())
|
||||||
if service is not None:
|
#service = activity.getServiceOfType(ActivityChat.SERVICE_TYPE)
|
||||||
self._service_appeared_cb(self._pservice, None, service)
|
#if service is not None:
|
||||||
|
# self._service_appeared_cb(self._pservice, None, service)
|
||||||
|
|
||||||
def _service_appeared_cb(self, pservice, buddy, service):
|
def _service_appeared_cb(self, pservice, buddy, service):
|
||||||
if service.get_activity_id() != self._activity.get_id():
|
if service.get_activity_id() != self._activity.get_id():
|
||||||
|
@ -28,8 +28,7 @@ class Chat(gtk.VBox):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
gtk.VBox.__init__(self, False, 6)
|
gtk.VBox.__init__(self, False, 6)
|
||||||
|
|
||||||
self._pservice = PresenceService.get_instance()
|
self._pservice = PresenceService()
|
||||||
self._pservice.start()
|
|
||||||
|
|
||||||
self._stream_writer = None
|
self._stream_writer = None
|
||||||
self.set_border_width(12)
|
self.set_border_width(12)
|
||||||
|
Loading…
Reference in New Issue
Block a user