Implement the share button on the presence window
This commit is contained in:
parent
2415fee0ed
commit
9ebcd65659
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user