Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2006-06-16 05:43:42 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2006-06-16 05:43:42 (GMT)
commitbdce0eb48c1b96a8ee5bc4303266cda4eb6e0375 (patch)
tree248450401abfb40c63e4a226a777de3e138c07d7 /sugar
parent20afcfa47569d10adf7522ff025e7f9b67f6432e (diff)
Get activities sharing sort of working
Diffstat (limited to 'sugar')
-rw-r--r--sugar/browser/BrowserActivity.py7
-rw-r--r--sugar/browser/BrowserShell.py6
-rw-r--r--sugar/browser/NavigationToolbar.py14
-rw-r--r--sugar/shell/StartPage.py36
-rw-r--r--sugar/shell/activity.py13
-rwxr-xr-xsugar/shell/shell.py16
6 files changed, 57 insertions, 35 deletions
diff --git a/sugar/browser/BrowserActivity.py b/sugar/browser/BrowserActivity.py
index 371a62e..840a25b 100644
--- a/sugar/browser/BrowserActivity.py
+++ b/sugar/browser/BrowserActivity.py
@@ -29,7 +29,7 @@ class BrowserActivity(activity.Activity):
self._pservice.track_service_type(_BROWSER_ACTIVITY_TYPE)
self._share_service = None
self._model = None
-
+
def _update_shared_location(self):
address = self.embed.get_address()
self._model.set_value('address', address)
@@ -93,13 +93,10 @@ class BrowserActivity(activity.Activity):
self._setup_shared(self.uri)
- def publish(self):
- print 'Publish %s' % self.get_id()
-
def get_embed(self):
return self.embed
- def share(self):
+ def publish(self):
escaped_title = urllib.quote(self.embed.get_title())
escaped_url = urllib.quote(self.embed.get_address())
diff --git a/sugar/browser/BrowserShell.py b/sugar/browser/BrowserShell.py
index 5e07327..d49a7cc 100644
--- a/sugar/browser/BrowserShell.py
+++ b/sugar/browser/BrowserShell.py
@@ -34,3 +34,9 @@ class BrowserShell(dbus.service.Object):
browser = BrowserActivity(uri)
self.__browsers.append(browser)
browser.connect_to_shell()
+
+ @dbus.service.method('com.redhat.Sugar.BrowserShell')
+ def open_browser_with_id(self, uri, activity_id):
+ browser = BrowserActivity(uri)
+ self.__browsers.append(browser)
+ browser.connect_to_shell(activity_id)
diff --git a/sugar/browser/NavigationToolbar.py b/sugar/browser/NavigationToolbar.py
index 2063c20..e9cc1c5 100644
--- a/sugar/browser/NavigationToolbar.py
+++ b/sugar/browser/NavigationToolbar.py
@@ -33,17 +33,6 @@ class NavigationToolbar(gtk.Toolbar):
separator = gtk.SeparatorToolItem()
self.insert(separator, -1)
separator.show()
-
- share = gtk.ToolButton(None, "Share")
- share.set_icon_name('stock_shared-by-me')
- share.set_is_important(True)
- share.connect("clicked", self.__share_cb)
- self.insert(share, -1)
- share.show()
-
- separator = gtk.SeparatorToolItem()
- self.insert(separator, -1)
- separator.show()
address_item = AddressItem(self.__open_address_cb)
self.insert(address_item, -1)
@@ -66,9 +55,6 @@ class NavigationToolbar(gtk.Toolbar):
def __reload_cb(self, button):
self._embed.reload()
- def __share_cb(self, button):
- self._browser.share()
-
def __location_changed(self, embed):
self._update_sensitivity()
diff --git a/sugar/shell/StartPage.py b/sugar/shell/StartPage.py
index f51b566..1a388cd 100644
--- a/sugar/shell/StartPage.py
+++ b/sugar/shell/StartPage.py
@@ -4,6 +4,7 @@ import gtk
import pango
import dbus
import cgi
+import urllib
import google
from sugar.presence.PresenceService import PresenceService
@@ -12,14 +13,21 @@ from sugar.browser import BrowserActivity
class ActivitiesModel(gtk.ListStore):
def __init__(self):
- gtk.ListStore.__init__(self, str, str)
+ gtk.ListStore.__init__(self, str, str, str, str)
def add_web_page(self, title, address):
- self.append([ title, address ])
+ self.append([ title, address, None, None ])
+
+ def add_activity(self, buddy, service):
+ (uid, stype) = service.get_activity_uid()
+ title = service.get_one_property('Title')
+ address = urllib.unquote(service.get_one_property('URI'))
+ subtitle = 'Shared by %s' % buddy.get_nick_name()
+ self.append([ title, address, subtitle, uid ])
class ActivitiesView(gtk.TreeView):
def __init__(self):
- gtk.TreeView.__init__(self)
+ gtk.TreeView.__init__(self, model = ActivitiesModel())
self.set_headers_visible(False)
@@ -34,23 +42,32 @@ class ActivitiesView(gtk.TreeView):
def _cell_data_func(self, column, cell, model, it):
title = model.get_value(it, 0)
- address = model.get_value(it, 1)
-
- markup = '<big><b>' + title + '</b></big>' + '\n' + address
+ subtitle = model.get_value(it, 2)
+ if subtitle is None:
+ subtitle = model.get_value(it, 1)
+
+ markup = '<big><b>' + title + '</b></big>' + '\n' + subtitle
markup = cgi.escape(markup) # escape the markup
cell.set_property('markup', markup)
cell.set_property('ellipsize', pango.ELLIPSIZE_END)
- def _row_activated_cb(self, treeview, path, column):
+ def _row_activated_cb(self, treeview, path, column):
bus = dbus.SessionBus()
proxy_obj = bus.get_object('com.redhat.Sugar.Browser', '/com/redhat/Sugar/Browser')
browser_shell = dbus.Interface(proxy_obj, 'com.redhat.Sugar.BrowserShell')
model = self.get_model()
address = model.get_value(model.get_iter(path), 1)
- browser_shell.open_browser(address, ignore_reply=True)
+ activity_id = model.get_value(model.get_iter(path), 3)
+ print 'Activated row %s %s' % (address, activity_id)
+
+ if activity_id is None:
+ browser_shell.open_browser(address, ignore_reply=True)
+ else:
+ browser_shell.open_browser_with_id(address, activity_id, ignore_reply=True)
+
class StartPage(gtk.HBox):
def __init__(self):
gtk.HBox.__init__(self)
@@ -104,8 +121,7 @@ class StartPage(gtk.HBox):
self._pservice.track_service_type(real_stype)
def _on_activity_announced_cb(self, pservice, service, buddy):
- (activity_uid, activity_stype) = service.get_activity_uid()
- print "::: %s announced activity UID %s of type %s" % (buddy.get_nick_name(), activity_uid, activity_stype)
+ self._activities.get_model().add_activity(buddy, service)
def _search_entry_activate_cb(self, entry):
self._search()
diff --git a/sugar/shell/activity.py b/sugar/shell/activity.py
index ce0d537..b7f84b3 100644
--- a/sugar/shell/activity.py
+++ b/sugar/shell/activity.py
@@ -68,7 +68,7 @@ class ActivityDbusService(dbus.service.Object):
if name in self._ALLOWED_CALLBACKS and self._callbacks[name]:
gobject.idle_add(self._call_callback_cb, self._callbacks[name], *args)
- def connect_to_shell(self):
+ def connect_to_shell(self, activity_id = None):
"""Register with the shell via dbus, getting an activity ID and
and XEMBED window ID in which to display the Activity."""
self._activity_container_object = self._bus.get_object(SHELL_SERVICE_NAME, \
@@ -76,7 +76,12 @@ class ActivityDbusService(dbus.service.Object):
self._activity_container = dbus.Interface(self._activity_container_object, \
SHELL_SERVICE_NAME + ".ActivityContainer")
- self._activity_id = self._activity_container.add_activity("")
+ if activity_id is None:
+ self._activity_id = self._activity_container.add_activity("")
+ else:
+ self._activity_id = activity_id
+ self._activity_container.add_activity_with_id("", activity_id)
+
self._object_path = SHELL_SERVICE_PATH + "/Activities/%s" % self._activity_id
print "ActivityDbusService: object path is '%s'" % self._object_path
@@ -172,10 +177,10 @@ class Activity(object):
"""Return whether or not this Activity is visible to the user."""
return self._has_focus
- def connect_to_shell(self):
+ def connect_to_shell(self, activity_id = None):
"""Called by our controller to tell us to initialize and connect
to the shell."""
- self._dbus_service.connect_to_shell()
+ self._dbus_service.connect_to_shell(activity_id)
def _internal_on_connected_to_shell_cb(self, activity_object, activity_id):
"""Callback when the dbus service object has connected to the shell."""
diff --git a/sugar/shell/shell.py b/sugar/shell/shell.py
index cb81154..5df7215 100755
--- a/sugar/shell/shell.py
+++ b/sugar/shell/shell.py
@@ -16,13 +16,16 @@ from sugar.chat.GroupChat import GroupChat
class ActivityHost(dbus.service.Object):
- def __init__(self, activity_container, activity_name):
+ def __init__(self, activity_container, activity_name, activity_id = None):
self.activity_name = activity_name
self.ellipsize_tab = False
self.activity_container = activity_container
- self.activity_id = sugar.util.unique_id()
+ if activity_id is None:
+ self.activity_id = sugar.util.unique_id()
+ else:
+ self.activity_id = activity_id
self.dbus_object_name = "/com/redhat/Sugar/Shell/Activities/%s" % self.activity_id
@@ -305,6 +308,15 @@ class ActivityContainer(dbus.service.Object):
#self.__print_activities()
return activity.get_host_activity_id()
+ @dbus.service.method("com.redhat.Sugar.Shell.ActivityContainer", \
+ in_signature="ss", \
+ out_signature="s", \
+ sender_keyword="sender")
+ def add_activity_with_id(self, activity_name, activity_id, sender):
+ activity = ActivityHost(self, activity_name, activity_id)
+ self.activities.append((sender, activity))
+ self.current_activity = activity
+
def __print_activities(self):
print "__print_activities: %d activities registered" % len(self.activities)
i = 0