From 095c732c9af0e756e1c2f1a69978b315c6961339 Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Tue, 28 Jul 2009 11:50:36 +0000 Subject: [PATCH] Add activity.share_button --- src/sugar/activity/activity.py | 42 +++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py index 692b537e..72691b17 100644 --- a/src/sugar/activity/activity.py +++ b/src/sugar/activity/activity.py @@ -61,7 +61,7 @@ import dbus import dbus.service import cjson -from sugar import util +from sugar import util from sugar.presence import presenceservice from sugar.activity.activityservice import ActivityService from sugar.activity.namingalert import NamingAlert @@ -74,6 +74,7 @@ from sugar.graphics.alert import Alert from sugar.graphics.icon import Icon from sugar.graphics.xocolor import XoColor from sugar.graphics.toolbar import Toolbar, ToolbarButton +from sugar.graphics.radiopalette import RadioPalette, RadioMenuButton from sugar.datastore import datastore from sugar.session import XSMPClient from sugar import wm @@ -1098,3 +1099,42 @@ def paste_button(**kwargs): paste.set_tooltip(_('Paste')) paste.show() return paste + +def share_button(activity, **kwargs): + quiet_trigger = [] + + def neighborhood_cb(): + if quiet_trigger: + return + activity.share() + + palette = RadioPalette() + private = palette.append( + icon_name='zoom-home', + tooltip=_('Private')) + neighborhood = palette.append( + icon_name='zoom-neighborhood', + tooltip=_('My Neighborhood'), + toggled_cb=neighborhood_cb) + + def update_share(): + quiet_trigger.append(True) + + logging.error(private.props.sensitive) + + if activity.get_shared(): + private.props.sensitive = False + neighborhood.props.sensitive = False + neighborhood.props.active = True + logging.error(private.props.sensitive) + else: + private.props.sensitive = True + neighborhood.props.sensitive = True + private.props.active = True + + quiet_trigger.pop() + + activity.connect('shared', lambda activity: update_share()) + activity.connect('joined', lambda activity: update_share()) + + return RadioMenuButton(palette=palette)