Changes
Jump to navigation
Jump to search
Line 1:
Line 1:
+
Line 159:
Line 160:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Development Team/Almanac/sugar.activity.activity (view source)
Revision as of 08:04, 2 October 2008
, 08:04, 2 October 2008no edit summary
{{Sugar Almanac}}
{{Sugar Almanac TOC}}
{{Sugar Almanac TOC}}
The sugar.activity.activity package includes several important classes that are needed to run a basic activity.
The sugar.activity.activity package includes several important classes that are needed to run a basic activity.
...
...
</pre>
</pre>
If you wanted to just share the activity with a particular buddy, then first you would need to have access to your buddy's key and then you can send him a personal invite (without inviting everyone else in your neighborhood).
The code below shows how personal invites can be achieved. First, the _populate_buddy_box gives UI controls for inviting specific buddies through the activation of toggle buttons. Each toggle button corresponds to a specific buddy and is connected to a callback (_buddy_toggled_cb) which then personally invites a buddy. Notice that we pass buddy.get_property("key") to our callback. This is needed because personal invites require a buddy key (as used in sugar.presence.buddy) in order to identify who you are inviting.
<pre>
#### Method: _populate_buddy_box, which updates the list of buddies available for this
# XO and then updates the _buddy_box UI widget accordingly.
def _populate_buddy_box(self):
buddies = self._ps.get_buddies()
self._buddy_box = gtk.VBox()
for buddy in buddies:
tb = gtk.ToggleButton(buddy.get_property("nick"))
tb.connect("toggled", self._buddy_toggled_cb, tb, buddy.get_property("key"))
self._buddy_box.pack_start(tb, expand=False, fill=False, padding=10)
#### Method: _buddy_toggled_cb, which is called when a togglebutton for a buddy
# has its state changed (indicating user wants a specific buddy to join or exit
# the conversation).
def _buddy_toggled_cb(self, widget, tb, buddy_key):
if tb.get_active():
self.invite(buddy_key)
</pre>
= Class: ActivityToolbox ([[Sugar.graphics.toolbox|Toolbox]])=
= Class: ActivityToolbox ([[Sugar.graphics.toolbox|Toolbox]])=