Bunch of fixes, sharing should be back to work
This commit is contained in:
parent
db08c3795f
commit
21b46a0022
@ -77,7 +77,7 @@ class BrowserActivity(Activity):
|
|||||||
if service.get_activity_id() != self._activity_id:
|
if service.get_activity_id() != self._activity_id:
|
||||||
return
|
return
|
||||||
|
|
||||||
if service.get_type() == _BROWSER_ACTIVITY_TYPE:
|
if service.get_type() == self._default_type:
|
||||||
self._notif_service = service
|
self._notif_service = service
|
||||||
elif service.get_type() == LocalModel.SERVICE_TYPE:
|
elif service.get_type() == LocalModel.SERVICE_TYPE:
|
||||||
if self._mode != BrowserActivity.LEADING:
|
if self._mode != BrowserActivity.LEADING:
|
||||||
@ -102,7 +102,6 @@ class BrowserActivity(Activity):
|
|||||||
self._update_shared_location()
|
self._update_shared_location()
|
||||||
elif action_id == 'goto_shared_location':
|
elif action_id == 'goto_shared_location':
|
||||||
address = self._model.get_value("address")
|
address = self._model.get_value("address")
|
||||||
print address
|
|
||||||
self.embed.load_address(address)
|
self.embed.load_address(address)
|
||||||
self._notif_bar.hide()
|
self._notif_bar.hide()
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import xml.sax.saxutils
|
||||||
|
|
||||||
import gobject
|
import gobject
|
||||||
|
|
||||||
from sugar.presence.PresenceService import PresenceService
|
from sugar.presence.PresenceService import PresenceService
|
||||||
@ -7,11 +9,18 @@ class ActivityInfo:
|
|||||||
self._service = service
|
self._service = service
|
||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
activity_id = service.get_one_property('activity_id')
|
activity_id = self._service.get_one_property('activity_id')
|
||||||
|
|
||||||
|
def get_type(self):
|
||||||
|
return self._service.get_type()
|
||||||
|
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
escaped_title = service.get_one_property('Title')
|
escaped_title = self._service.get_one_property('Title')
|
||||||
title = xml.sax.saxutils.unescape(escaped_title)
|
title = xml.sax.saxutils.unescape(escaped_title)
|
||||||
|
return title
|
||||||
|
|
||||||
|
def get_service(self):
|
||||||
|
return self._service
|
||||||
|
|
||||||
class ActivitiesModel(gobject.GObject):
|
class ActivitiesModel(gobject.GObject):
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
@ -44,4 +53,6 @@ class ActivitiesModel(gobject.GObject):
|
|||||||
self._pservice.track_service_type(short_stype)
|
self._pservice.track_service_type(short_stype)
|
||||||
|
|
||||||
def _on_activity_announced_cb(self, pservice, service, buddy):
|
def _on_activity_announced_cb(self, pservice, service, buddy):
|
||||||
self.add_activity(buddy, service)
|
# FIXME We should not hard code activity types here
|
||||||
|
if service.get_type() == "_web_olpc._udp":
|
||||||
|
self.add_activity(service)
|
||||||
|
@ -44,6 +44,13 @@ class ActivityRegistry:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._activities = []
|
self._activities = []
|
||||||
|
|
||||||
|
def get_activity(self, default_type):
|
||||||
|
"""Returns an activity given his default type"""
|
||||||
|
for activity in self._activities:
|
||||||
|
if activity.get_default_type() == default_type:
|
||||||
|
return activity
|
||||||
|
return None
|
||||||
|
|
||||||
def scan_directory(self, path):
|
def scan_directory(self, path):
|
||||||
"""Scan a directory for activities and add them to the registry."""
|
"""Scan a directory for activities and add them to the registry."""
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
|
@ -39,9 +39,10 @@ class Toolbar(gtk.Toolbar):
|
|||||||
new_activity_button.show()
|
new_activity_button.show()
|
||||||
|
|
||||||
class ActivitiesGrid(gtk.VBox):
|
class ActivitiesGrid(gtk.VBox):
|
||||||
def __init__(self, model):
|
def __init__(self, shell, model):
|
||||||
gtk.VBox.__init__(self)
|
gtk.VBox.__init__(self, shell)
|
||||||
|
|
||||||
|
self._shell = shell
|
||||||
self._buttons = {}
|
self._buttons = {}
|
||||||
|
|
||||||
for activity in model:
|
for activity in model:
|
||||||
@ -60,15 +61,16 @@ class ActivitiesGrid(gtk.VBox):
|
|||||||
self.remove(button)
|
self.remove(button)
|
||||||
|
|
||||||
def _add(self, activity):
|
def _add(self, activity):
|
||||||
button = gtk.Button(window.get_title())
|
button = gtk.Button(activity.get_title())
|
||||||
button.connect('clicked', self.__button_clicked_cb, window)
|
button.connect('clicked', self.__button_clicked_cb, activity)
|
||||||
self.pack_start(button, False)
|
self.pack_start(button, False)
|
||||||
button.show()
|
button.show()
|
||||||
|
|
||||||
self._buttons[activity.get_id()] = button
|
self._buttons[activity.get_id()] = button
|
||||||
|
|
||||||
def __button_clicked_cb(self, button, window):
|
def __button_clicked_cb(self, button, info):
|
||||||
self._home.activate(window)
|
activity = self._shell.get_registry().get_activity(info.get_type())
|
||||||
|
Activity.create(activity.get_id(), info.get_service())
|
||||||
|
|
||||||
class TasksGrid(gtk.VBox):
|
class TasksGrid(gtk.VBox):
|
||||||
def __init__(self, home):
|
def __init__(self, home):
|
||||||
@ -137,7 +139,7 @@ class HomeWindow(gtk.Window):
|
|||||||
label.show()
|
label.show()
|
||||||
|
|
||||||
model = ActivitiesModel()
|
model = ActivitiesModel()
|
||||||
grid = ActivitiesGrid(model)
|
grid = ActivitiesGrid(shell, model)
|
||||||
vbox.pack_start(grid)
|
vbox.pack_start(grid)
|
||||||
grid.show()
|
grid.show()
|
||||||
|
|
||||||
|
@ -4,17 +4,13 @@ import imp
|
|||||||
import dbus
|
import dbus
|
||||||
import dbus.service
|
import dbus.service
|
||||||
import dbus.glib
|
import dbus.glib
|
||||||
import pygtk
|
import gtk
|
||||||
pygtk.require('2.0')
|
import gobject
|
||||||
import gtk, gobject
|
|
||||||
|
|
||||||
from sugar.LogWriter import LogWriter
|
from sugar.LogWriter import LogWriter
|
||||||
from sugar import keybindings
|
from sugar import keybindings
|
||||||
import sugar.util
|
import sugar.util
|
||||||
|
|
||||||
SHELL_SERVICE_NAME = "caom.redhat.Sugar.Shell"
|
|
||||||
SHELL_SERVICE_PATH = "/com/redhat/Sugar/Shell"
|
|
||||||
|
|
||||||
ACTIVITY_SERVICE_NAME = "com.redhat.Sugar.Activity"
|
ACTIVITY_SERVICE_NAME = "com.redhat.Sugar.Activity"
|
||||||
ACTIVITY_SERVICE_PATH = "/com/redhat/Sugar/Activity"
|
ACTIVITY_SERVICE_PATH = "/com/redhat/Sugar/Activity"
|
||||||
|
|
||||||
@ -84,7 +80,6 @@ def create(activity_name, service = None, args = None):
|
|||||||
def register_factory(name, activity_class, default_type=None):
|
def register_factory(name, activity_class, default_type=None):
|
||||||
"""Register the activity factory."""
|
"""Register the activity factory."""
|
||||||
factory = ActivityFactory(name, activity_class, default_type)
|
factory = ActivityFactory(name, activity_class, default_type)
|
||||||
|
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
|
||||||
class ActivityDbusService(dbus.service.Object):
|
class ActivityDbusService(dbus.service.Object):
|
||||||
@ -186,6 +181,7 @@ class Activity(gtk.Window):
|
|||||||
|
|
||||||
def set_default_type(self, default_type):
|
def set_default_type(self, default_type):
|
||||||
self._default_type = default_type
|
self._default_type = default_type
|
||||||
|
print self._default_type
|
||||||
|
|
||||||
def get_default_type(self):
|
def get_default_type(self):
|
||||||
return self._default_type
|
return self._default_type
|
||||||
@ -194,7 +190,6 @@ class Activity(gtk.Window):
|
|||||||
"""Mark the activity as 'shared'."""
|
"""Mark the activity as 'shared'."""
|
||||||
if not self._shared:
|
if not self._shared:
|
||||||
self._shared = True
|
self._shared = True
|
||||||
self._dbus_service.ActivityShared()
|
|
||||||
|
|
||||||
def get_shared(self):
|
def get_shared(self):
|
||||||
return self._shared
|
return self._shared
|
||||||
|
@ -489,7 +489,7 @@ class PresenceService(gobject.GObject):
|
|||||||
port = random.randint(5000, 65535)
|
port = random.randint(5000, 65535)
|
||||||
|
|
||||||
# Mark the activity as shared
|
# Mark the activity as shared
|
||||||
if stype == activity.default_type():
|
if stype == activity.get_default_type():
|
||||||
activity.set_shared()
|
activity.set_shared()
|
||||||
|
|
||||||
logging.debug('Share activity %s, type %s, address %s, port %d, properties %s' % (actid, stype, address, port, properties))
|
logging.debug('Share activity %s, type %s, address %s, port %d, properties %s' % (actid, stype, address, port, properties))
|
||||||
|
Loading…
Reference in New Issue
Block a user