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-13 18:49:01 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2006-06-13 18:49:01 (GMT)
commit9ebcd656595f64e93616b579b348a586749a834e (patch)
tree16d239f626ed363a8440b466672fcccd6ce1ee3f /sugar
parent2415fee0ed5cbd6a1092090f69e115a3cfb1d9ff (diff)
Implement the share button on the presence window
Diffstat (limited to 'sugar')
-rw-r--r--sugar/browser/BrowserActivity.py3
-rw-r--r--sugar/shell/PresenceWindow.py12
-rw-r--r--sugar/shell/activity.py16
-rwxr-xr-xsugar/shell/shell.py9
4 files changed, 36 insertions, 4 deletions
diff --git a/sugar/browser/BrowserActivity.py b/sugar/browser/BrowserActivity.py
index 2e379ad..b01a8a4 100644
--- a/sugar/browser/BrowserActivity.py
+++ b/sugar/browser/BrowserActivity.py
@@ -84,6 +84,9 @@ class BrowserActivity(activity.Activity):
self._setup_shared(self.uri)
+ def publish(self):
+ print 'Publish %s' % self.activity_get_id()
+
def get_embed(self):
return self.embed
diff --git a/sugar/shell/PresenceWindow.py b/sugar/shell/PresenceWindow.py
index d5eddc2..9d21a7e 100644
--- a/sugar/shell/PresenceWindow.py
+++ b/sugar/shell/PresenceWindow.py
@@ -11,8 +11,10 @@ class PresenceWindow(gtk.Window):
_MODEL_COL_ICON = 1
_MODEL_COL_BUDDY = 2
- def __init__(self):
+ def __init__(self, activity_container):
gtk.Window.__init__(self)
+
+ self._activity_container = activity_container
self._pservice = PresenceService.get_instance()
self._pservice.connect("buddy-appeared", self._on_buddy_appeared_cb)
@@ -63,9 +65,17 @@ class PresenceWindow(gtk.Window):
vbox.pack_start(sw)
sw.show()
+ share_button = gtk.Button('Share')
+ share_button.connect('clicked', self._share_button_clicked_cb)
+ vbox.pack_start(share_button)
+ share_button.show()
+
self.add(vbox)
vbox.show()
+ def _share_button_clicked_cb(self, button):
+ self._activity_container.current_activity.publish()
+
def _on_buddyList_buddy_selected(self, widget, *args):
(model, aniter) = widget.get_selection().get_selected()
name = self._buddy_list_model.get(aniter, self._MODEL_COL_NICK)
diff --git a/sugar/shell/activity.py b/sugar/shell/activity.py
index 84296bd..d0cfacb 100644
--- a/sugar/shell/activity.py
+++ b/sugar/shell/activity.py
@@ -19,6 +19,7 @@ ON_RECONNECTED_TO_SHELL_CB = "reconnected_to_shell"
ON_CLOSE_FROM_USER_CB = "close_from_user"
ON_LOST_FOCUS_CB = "lost_focus"
ON_GOT_FOCUS_CB = "got_focus"
+ON_PUBLISH_CB = "publish"
class ActivityDbusService(dbus.service.Object):
"""Base dbus service object that each Activity uses to export dbus methods.
@@ -28,7 +29,7 @@ class ActivityDbusService(dbus.service.Object):
_ALLOWED_CALLBACKS = [ON_CONNECTED_TO_SHELL_CB, ON_DISCONNECTED_FROM_SHELL_CB, \
ON_RECONNECTED_TO_SHELL_CB, ON_CLOSE_FROM_USER_CB, ON_LOST_FOCUS_CB, \
- ON_GOT_FOCUS_CB]
+ ON_GOT_FOCUS_CB, ON_PUBLISH_CB]
def __init__(self, activity):
self._activity = activity
@@ -123,6 +124,10 @@ class ActivityDbusService(dbus.service.Object):
"""Called by the shell to notify us that the user closed us."""
self._call_callback(ON_CLOSE_FROM_USER_CB)
+ @dbus.service.method(ACTIVITY_SERVICE_NAME)
+ def publish(self):
+ """Called by the shell to request the activity to publish itself on the network."""
+ self._call_callback(ON_PUBLISH_CB)
class Activity(object):
"""Base Activity class that all other Activities derive from."""
@@ -133,6 +138,7 @@ class Activity(object):
self._dbus_service.register_callback(ON_DISCONNECTED_FROM_SHELL_CB, self._internal_on_disconnected_from_shell_cb)
self._dbus_service.register_callback(ON_RECONNECTED_TO_SHELL_CB, self._internal_on_reconnected_to_shell_cb)
self._dbus_service.register_callback(ON_CLOSE_FROM_USER_CB, self._internal_on_close_from_user_cb)
+ self._dbus_service.register_callback(ON_PUBLISH_CB, self._internal_on_publish_cb)
self._dbus_service.register_callback(ON_LOST_FOCUS_CB, self._internal_on_lost_focus_cb)
self._dbus_service.register_callback(ON_GOT_FOCUS_CB, self._internal_on_got_focus_cb)
self._has_focus = False
@@ -187,6 +193,10 @@ class Activity(object):
self.shutdown()
self.on_close_from_user()
+ def _internal_on_publish_cb(self):
+ """Callback when the dbus service object tells us the user has closed our activity."""
+ self.publish()
+
def _internal_on_lost_focus_cb(self):
"""Callback when the dbus service object tells us we have lost focus."""
self._has_focus = False
@@ -262,6 +272,10 @@ class Activity(object):
# Pure Virtual methods that subclasses may/may not implement
#############################################################
+ def publish(self):
+ """Called to request the activity to publish itself on the network."""
+ pass
+
def on_lost_focus(self):
"""Triggered when this Activity loses focus."""
pass
diff --git a/sugar/shell/shell.py b/sugar/shell/shell.py
index 72b3ad3..aaf1569 100755
--- a/sugar/shell/shell.py
+++ b/sugar/shell/shell.py
@@ -73,7 +73,10 @@ class ActivityHost(dbus.service.Object):
def __close_button_clicked_error_cb(self, error):
pass
-
+
+ def publish(self):
+ self.peer_service.publish()
+
def tab_close_button_clicked(self, button):
self.peer_service.close_from_user(reply_handler = self.__close_button_clicked_reply_cb, \
error_handler = self.__close_button_clicked_error_cb)
@@ -292,6 +295,8 @@ class ActivityContainer(dbus.service.Object):
activity = ActivityHost(self, activity_name)
self.activities.append((sender, activity))
+ self.current_activity = activity
+
#self.__print_activities()
return activity.get_host_activity_id()
@@ -368,7 +373,7 @@ def main():
activity_container = ActivityContainer(service, session_bus)
activity_container.show()
- presence_window = PresenceWindow()
+ presence_window = PresenceWindow(activity_container)
presence_window.show()
console.set_parent_window(activity_container.window)