本文整理汇总了Python中sugar3.presence.presenceservice.get_instance函数的典型用法代码示例。如果您正苦于以下问题:Python get_instance函数的具体用法?Python get_instance怎么用?Python get_instance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_instance函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, handle, *args, **kwargs):
'''
Initialize the ShareableActivity class.
Kwargs:
service_path
'''
activity.Activity.__init__(self, handle, *args, **kwargs)
self._sync_hid = None
self._message_cbs = {}
self._connection = None
self._tube_conn = None
self._pservice = presenceservice.get_instance()
self._owner = self._pservice.get_owner()
self._owner_id = str(self._owner.props.nick)
self._service_path = kwargs.get('service_path',
self._generate_service_path())
self._dbus_object = None
_logger.debug('Setting service name %s, service path %s',
IFACE, self._service_path)
self._connect_to_ps()
开发者ID:quozl,项目名称:sugarlabs-calculate,代码行数:28,代码来源:shareable_activity.py
示例2: __init__
def __init__(self, handle):
activity.Activity.__init__(self, handle)
self.set_title("SocialCalc")
self._logger = logging.getLogger("OnePageWiki-Activity")
# The XOCom object helps us communicate with the browser
# This uses web/index.html as the default page to load
self.xocom = XOCom(
self.control_sending_text
) # REMEMBER THAT I HAVE STILL TO SEND THE ARGUMENT IN THE XOCOM CLASS
toolbox = ToolbarBox()
activity_button = ActivityButton(self)
toolbox.toolbar.insert(activity_button, 0)
activity_button.show()
title_entry = TitleEntry(self)
toolbox.toolbar.insert(title_entry, -1)
title_entry.show()
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
toolbox.toolbar.insert(separator, -1)
separator.show()
stop_button = ShareButton(self)
toolbox.toolbar.insert(stop_button, -1)
stop_button.show()
self.set_toolbar_box(toolbox)
toolbox.show()
stop_button = StopButton(self)
toolbox.toolbar.insert(stop_button, -1)
stop_button.show()
self.set_toolbar_box(toolbox)
toolbox.show()
##self.xocom.send_to_browser_localize(['initlocalize'])
self.set_canvas(self.xocom.create_webview())
self.hellotube = None # Shared session #REQUIRED
self.initiating = False
self.pservice = presenceservice.get_instance()
owner = self.pservice.get_owner()
self.owner = owner
self.connect("shared", self._shared_cb)
self.connect("joined", self._joined_cb)
self.filename = "" # ADDED SPECIFICALLY TO CALL WRITE AND READ METHODS
self.content = ""
# calling to initialize strings in localization
# should wait for init complete from browser
GObject.timeout_add(4000, self.xocom.send_to_browser_localize, ["initlocalize"])
开发者ID:sugarlabs,项目名称:SocialCalc,代码行数:60,代码来源:SocialCalcActivity.py
示例3: __share_menu_cb
def __share_menu_cb(self, menu_item):
if self._account.url_cache is None:
pservice = presenceservice.get_instance()
if self._activity_id is not None:
logging.debug('getting shared activity from activity id')
self._shared_activity = pservice.get_activity(
self._activity_id, warn_if_none=False)
else:
logging.error('Cannot get activity from pservice.')
self.emit('transfer-state-changed',
_('Cannot join Journal Share activity'))
return
# We set up sharing in the same way as
# sugar-toolkit-gtk3/src/sugar3/activity/activity.py
# There's already an instance on the mesh, so join it
logging.debug('*** Act %s joining existing mesh instance %r',
self._activity_id, self._shared_activity)
self._join_id = self._shared_activity.connect('joined',
self.__joined_cb)
self._shared_activity.join()
else:
logging.debug('skipping join setup')
self.__joined_cb(self, True, '')
开发者ID:cristian99garcia,项目名称:teachershare,代码行数:25,代码来源:account.py
示例4: _object_added_cb
def _object_added_cb(self, cb_service, cb_object):
""" Code snippet to tag clipboard objects from shared activities """
shell = get_model()
logging.debug(shell.get_active_activity())
current = shell.get_active_activity()
active_id = current.get_activity_id()
logging.debug(active_id)
pservice = presenceservice.get_instance()
instance = pservice.get_activity(active_id, warn_if_none=False)
""" For a shared activity should have a pservice entry """
if instance is None:
return
logging.debug("cbobject path " + str(cb_object.get_id()))
if self._icons:
group = self._icons.values()[0]
else:
group = None
icon = ClipboardIcon(cb_object, group)
self.add_item(icon)
icon.show()
self._icons[cb_object.get_id()] = icon
objects_to_delete = self.get_children()[:-self.MAX_ITEMS]
for icon in objects_to_delete:
logging.debug('ClipboardTray: deleting surplus object')
cb_service = clipboard.get_instance()
cb_service.delete_object(icon.get_object_id())
logging.debug('ClipboardTray: %r was added', cb_object.get_id())
开发者ID:native93,项目名称:bulletinframe,代码行数:31,代码来源:clipboardtray.py
示例5: __init__
def __init__(self, handle):
Activity.__init__(self, handle)
# Self-Enforced max_participants
self.max_participants = SUGAR_MAX_PARTICIPANTS
# Prepare Storage Components
self.network_stack = None
self.gstreamer_stack = None
# Set Owner
self.owner = presenceservice.get_instance().get_owner()
""" Setup GUI """
logger.debug("Preparing GUI")
self.set_canvas(Gui(self))
""" Setup GSTStack """
logger.debug("Setting up GSTStack")
self.gststack = GSTStack()
self.get_canvas().set_gstreamer_stack(self.gststack);
""" Setup Network Stack """
logger.debug("Connect Event to Setup Network Stack on Demand")
self.establish_activity_sharing(handle)
开发者ID:HFOSS-OVC,项目名称:Open-Video-chat,代码行数:25,代码来源:ovc.py
示例6: _get_buddy
def _get_buddy(self, cs_handle):
'''Get a Buddy from a (possibly channel-specific) handle.'''
# XXX This will be made redundant once Presence Service
# provides buddy resolution
# Get the Presence Service
pservice = presenceservice.get_instance()
# Get the Telepathy Connection
tp_name, tp_path = pservice.get_preferred_connection()
conn = Connection(tp_name, tp_path)
group = self._text_chan[CHANNEL_INTERFACE_GROUP]
my_csh = group.GetSelfHandle()
if my_csh == cs_handle:
handle = conn.GetSelfHandle()
elif (group.GetGroupFlags() &
CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES):
handle = group.GetHandleOwners([cs_handle])[0]
else:
handle = cs_handle
# XXX: deal with failure to get the handle owner
assert handle != 0
return pservice.get_buddy_by_telepathy_handle(
tp_name, tp_path, handle)
开发者ID:AbrahmAB,项目名称:reflect,代码行数:26,代码来源:textchannelwrapper.py
示例7: _setup_presence_service
def _setup_presence_service(self):
''' Setup the Presence Service. '''
self.pservice = presenceservice.get_instance()
owner = self.pservice.get_owner()
self.owner = owner
self._share = ''
self.connect('shared', self._shared_cb)
self.connect('joined', self._joined_cb)
开发者ID:AbrahmAB,项目名称:reflect,代码行数:9,代码来源:activity.py
示例8: _setup_presence_service
def _setup_presence_service(self):
""" Setup the Presence Service. """
self.pservice = presenceservice.get_instance()
self.initiating = None # sharing (True) or joining (False)
owner = self.pservice.get_owner()
self.owner = owner
self._share = ""
self.connect('shared', self._shared_cb)
self.connect('joined', self._joined_cb)
开发者ID:sugarlabs,项目名称:flip,代码行数:10,代码来源:FlipActivity.py
示例9: _setup_presence_service
def _setup_presence_service(self):
''' Setup the Presence Service. '''
self.pservice = presenceservice.get_instance()
self.initiating = None # sharing (True) or joining (False)
owner = self.pservice.get_owner()
self.owner = owner
self.vmw.buddies.append(self.owner)
self._share = ''
self.connect('shared', self._shared_cb)
self.connect('joined', self._joined_cb)
开发者ID:sugarlabs,项目名称:dimensions,代码行数:11,代码来源:Dimensions.py
示例10: _send_invites
def _send_invites(self):
while self._invites_queue:
account_path, contact_id = self._invites_queue.pop()
pservice = presenceservice.get_instance()
buddy = pservice.get_buddy(account_path, contact_id)
if buddy:
self.shared_activity.invite(
buddy, '', self._invite_response_cb)
else:
logging.error('Cannot invite %s %s, no such buddy',
account_path, contact_id)
开发者ID:godiard,项目名称:sugar-toolkit-gtk3,代码行数:11,代码来源:activity.py
示例11: add_buddy
def add_buddy(self, buddy):
"""
Passes buddy nick to ovc
"""
if buddy == presenceservice.get_instance().get_owner():
return
if buddy:
nick = buddy.props.nick
else:
nick = '???'
self.activity.net_cb('buddy_add', nick)
开发者ID:HFOSS-OVC,项目名称:ovc-backup,代码行数:11,代码来源:network_stack.py
示例12: __init__
def __init__(self, activity, buddy_joined_cb, buddy_left_cb, play_cb, undostack, bootstrap):
self.activity = activity
self.buddy_joined = buddy_joined_cb
self.buddy_left = buddy_left_cb
self.Play_cb = play_cb
self.undostack = undostack
self.bootstrap = bootstrap
self.world = False
self.entered = False
self.presence_service = presenceservice.get_instance()
self.owner = self.presence_service.get_owner()
开发者ID:sugarlabs,项目名称:playgo-activity,代码行数:11,代码来源:collaboration.py
示例13: setup
def setup(self):
# TODO: hand off role of master if sharer leaves
self.pservice = presenceservice.get_instance()
self.initiating = None # sharing (True) or joining (False)
# Add my buddy object to the list
owner = self.pservice.get_owner()
self.owner = owner
self._tw.buddies.append(self.owner)
self._share = ''
self._activity.connect('shared', self._shared_cb)
self._activity.connect('joined', self._joined_cb)
开发者ID:sugarlabs,项目名称:activity-turtle-confusion,代码行数:12,代码来源:tacollaboration.py
示例14: _setup_presence_service
def _setup_presence_service(self):
""" Setup the Presence Service. """
self.pservice = presenceservice.get_instance()
self.initiating = None # sharing (True) or joining (False)
owner = self.pservice.get_owner()
self.owner = owner
self._game.buddies.append(self.nick)
self._player_colors = [self.colors]
self._player_pixbuf = [svg_str_to_pixbuf(
generate_xo(scale=0.8, colors=self.colors))]
self._share = ""
self.connect('shared', self._shared_cb)
self.connect('joined', self._joined_cb)
开发者ID:leonardcj,项目名称:paths,代码行数:14,代码来源:PathsActivity.py
示例15: init_context
def init_context(self, args):
"""Init Javascript context sending buddy information"""
# Get XO colors
buddy = {}
client = gconf.client_get_default()
colors = client.get_string("/desktop/sugar/user/color")
buddy["colors"] = colors.split(",")
# Get XO name
presenceService = presenceservice.get_instance()
buddy["name"] = presenceService.get_owner().props.nick
self.enyo.send_message("buddy", buddy)
if self.context != {}:
self.enyo.send_message("load-context", self.context)
开发者ID:RobbiNespu,项目名称:sugarizer,代码行数:15,代码来源:activity.py
示例16: __map_event_cb
def __map_event_cb(self, event, activity):
logger.debug('__map_event_cb')
# set custom keybindings for Write
logger.debug("Loading keybindings")
keybindings_file = os.path.join( get_bundle_path(), "keybindings.xml" )
self.abiword_canvas.invoke_ex(
'com.abisource.abiword.loadbindings.fromURI',
keybindings_file, 0, 0)
# no ugly borders please
##self.abiword_canvas.set_property("shadow-type", gtk.SHADOW_NONE)
# we only do per-word selections (when using the mouse)
self.abiword_canvas.set_word_selections(True)
# we want a nice border so we can select paragraphs easily
self.abiword_canvas.set_show_margin(True)
# activity sharing
self.participants = {}
pservice = presenceservice.get_instance()
bus = dbus.Bus()
name, path = pservice.get_preferred_connection()
self.conn = telepathy.client.Connection(name, path)
self.initiating = None
self.joined = False
self.connect('shared', self._shared_cb)
self._shared_activity = self.get_shared_activity()
if self._shared_activity:
# we are joining the activity
logger.debug("We are joining an activity")
self.connect('joined', self._joined_cb)
self._shared_activity.connect('buddy-joined', self._buddy_joined_cb)
self._shared_activity.connect('buddy-left', self._buddy_left_cb)
if self.get_shared():
# # oh, OK, we've already joined
self._joined_cb()
else:
# we are creating the activity
logger.debug("We are creating an activity")
owner = pservice.get_owner()
开发者ID:sugarlabs,项目名称:devtutor-activity,代码行数:47,代码来源:AbiWordActivity.py
示例17: __init__
def __init__(self):
Gtk.VBox.__init__(self)
self.messenger = None
self.me = None
self.quiet = False
self._buddies = {}
# chat entry
owner = presenceservice.get_instance().get_owner()
self._chat = ChatBox(owner, _is_tablet_mode())
self._chat.connect('open-on-journal', self.__open_on_journal)
self.me = self._new_face(owner, ENTRY_COLOR)
# add owner to buddy list
self._buddies[owner] = self.me
# buddies box
self._buddies_box = Gtk.HBox()
self._buddies_box.pack_end(self.me, True, True, 0)
self._buddies_sw = Gtk.ScrolledWindow()
self._buddies_sw.set_policy(Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.NEVER)
self._buddies_sw.add_with_viewport(self._buddies_box)
self.chat_post = Gtk.Entry()
self.chat_post.modify_font(Pango.FontDescription('sans bold 24'))
self.chat_post.connect('activate', self._activate_cb)
self.chat_post.connect('key-press-event', self._key_press_cb)
self._entry = Gtk.HBox()
self._entry.pack_start(self._buddies_sw, False, False, 0)
self._entry.pack_start(self.chat_post, True, True, 0)
if _is_tablet_mode():
self.pack_start(self._entry, False, False, 0)
self.pack_end(self._chat, True, True, 0)
else:
self.pack_start(self._chat, True, True, 0)
self.pack_end(self._entry, False, False, 0)
self.resize_chat_box(expanded=False)
self.show_all()
开发者ID:sugarlabs,项目名称:speak,代码行数:47,代码来源:chat.py
示例18: __init__
def __init__(self, handle):
activity.Activity.__init__(self, handle)
self.max_participants = 10
# toolbar with the new toolbar redesign
toolbar_box = ToolbarBox()
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, 0)
activity_button.show()
self.back_button = BackButton()
self.back_button.connect('clicked', self.show_options1)
toolbar_box.toolbar.insert(self.back_button, -1)
self.back_button.show()
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
toolbar_box.toolbar.insert(separator, -1)
separator.show()
stop_button = StopButton(self)
toolbar_box.toolbar.insert(stop_button, -1)
stop_button.show()
self.set_toolbar_box(toolbar_box)
toolbar_box.show()
self.show_options()
self._logger = logging.getLogger('hellomesh-activity')
self.hellotube = None # Shared session
self.initiating = False
# get the Presence Service
self.pservice = presenceservice.get_instance()
# Buddy object for you
owner = self.pservice.get_owner()
self.owner = owner
self.connect('shared', self._shared_cb)
self.connect('joined', self._joined_cb)
开发者ID:sugarlabs,项目名称:devtutor-activity,代码行数:46,代码来源:activity.py
示例19: share
def share(self, private=False):
"""Request that the activity be shared on the network.
private -- bool: True to share by invitation only,
False to advertise as shared to everyone.
Once the activity is shared, its privacy can be changed by setting
its 'private' property.
"""
if self.shared_activity and self.shared_activity.props.joined:
raise RuntimeError('Activity %s already shared.' %
self._activity_id)
verb = private and 'private' or 'public'
logging.debug('Requesting %s share of activity %s.' % (verb,
self._activity_id))
pservice = presenceservice.get_instance()
pservice.connect('activity-shared', self.__share_cb)
pservice.share_activity(self, private=private)
开发者ID:svineet,项目名称:sugar-toolkit-gtk3,代码行数:18,代码来源:activity.py
示例20: __got_channel_cb
def __got_channel_cb(self, wait_loop, connection_path, channel_path,
handle_type):
logging.debug('Activity.__got_channel_cb')
pservice = presenceservice.get_instance()
if handle_type == CONNECTION_HANDLE_TYPE_ROOM:
connection_name = connection_path.replace('/', '.')[1:]
bus = dbus.SessionBus()
channel = bus.get_object(connection_name, channel_path)
room_handle = channel.Get(CHANNEL, 'TargetHandle')
mesh_instance = pservice.get_activity_by_handle(connection_path,
room_handle)
else:
mesh_instance = pservice.get_activity(self._activity_id,
warn_if_none=False)
self._set_up_sharing(mesh_instance, SCOPE_PRIVATE)
wait_loop.quit()
开发者ID:godiard,项目名称:sugar-toolkit-gtk3,代码行数:18,代码来源:activity.py
注:本文中的sugar3.presence.presenceservice.get_instance函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论