Use double leading underscores for callback names to avoid name collisions

The double underscores invoke Python's name mangling algorithm
This commit is contained in:
Simon Schampijer 2007-10-16 15:51:48 +02:00
parent 8b11585950
commit 91f55488eb

View File

@ -55,19 +55,19 @@ class ActivityToolbar(gtk.Toolbar):
self._activity = activity self._activity = activity
self._updating_share = False self._updating_share = False
activity.connect('shared', self._activity_shared_cb) activity.connect('shared', self.__activity_shared_cb)
activity.connect('joined', self._activity_shared_cb) activity.connect('joined', self.__activity_shared_cb)
activity.connect('notify::max_participants', activity.connect('notify::max_participants',
self._max_participants_changed_cb) self.__max_participants_changed_cb)
if activity.metadata: if activity.metadata:
self.title = gtk.Entry() self.title = gtk.Entry()
self.title.set_size_request(int(gtk.gdk.screen_width() / 6), -1) self.title.set_size_request(int(gtk.gdk.screen_width() / 6), -1)
self.title.set_text(activity.metadata['title']) self.title.set_text(activity.metadata['title'])
self.title.connect('changed', self._title_changed_cb) self.title.connect('changed', self.__title_changed_cb)
self._add_widget(self.title) self._add_widget(self.title)
activity.metadata.connect('updated', self._jobject_updated_cb) activity.metadata.connect('updated', self.__jobject_updated_cb)
separator = gtk.SeparatorToolItem() separator = gtk.SeparatorToolItem()
separator.props.draw = False separator.props.draw = False
@ -76,7 +76,7 @@ class ActivityToolbar(gtk.Toolbar):
separator.show() separator.show()
self.share = ToolComboBox(label_text=_('Share with:')) self.share = ToolComboBox(label_text=_('Share with:'))
self.share.combo.connect('changed', self._share_changed_cb) self.share.combo.connect('changed', self.__share_changed_cb)
self.share.combo.append_item(SCOPE_PRIVATE, _('Private'), self.share.combo.append_item(SCOPE_PRIVATE, _('Private'),
'zoom-home-mini') 'zoom-home-mini')
self.share.combo.append_item(SCOPE_NEIGHBORHOOD, _('My Neighborhood'), self.share.combo.append_item(SCOPE_NEIGHBORHOOD, _('My Neighborhood'),
@ -88,13 +88,13 @@ class ActivityToolbar(gtk.Toolbar):
self.keep = ToolButton('document-save') self.keep = ToolButton('document-save')
self.keep.set_tooltip(_('Keep')) self.keep.set_tooltip(_('Keep'))
self.keep.connect('clicked', self._keep_clicked_cb) self.keep.connect('clicked', self.__keep_clicked_cb)
self.insert(self.keep, -1) self.insert(self.keep, -1)
self.keep.show() self.keep.show()
self.stop = ToolButton('activity-stop') self.stop = ToolButton('activity-stop')
self.stop.set_tooltip(_('Stop')) self.stop.set_tooltip(_('Stop'))
self.stop.connect('clicked', self._stop_clicked_cb) self.stop.connect('clicked', self.__stop_clicked_cb)
self.insert(self.stop, -1) self.insert(self.stop, -1)
self.stop.show() self.stop.show()
@ -115,7 +115,7 @@ class ActivityToolbar(gtk.Toolbar):
self._updating_share = False self._updating_share = False
def _share_changed_cb(self, combo): def __share_changed_cb(self, combo):
if self._updating_share: if self._updating_share:
return return
@ -125,20 +125,20 @@ class ActivityToolbar(gtk.Toolbar):
if scope == SCOPE_NEIGHBORHOOD: if scope == SCOPE_NEIGHBORHOOD:
self._activity.share() self._activity.share()
def _keep_clicked_cb(self, button): def __keep_clicked_cb(self, button):
self._activity.copy() self._activity.copy()
def _stop_clicked_cb(self, button): def __stop_clicked_cb(self, button):
self._activity.close() self._activity.close()
def _jobject_updated_cb(self, jobject): def __jobject_updated_cb(self, jobject):
self.title.set_text(jobject['title']) self.title.set_text(jobject['title'])
def _title_changed_cb(self, entry): def __title_changed_cb(self, entry):
if not self._update_title_sid: if not self._update_title_sid:
self._update_title_sid = gobject.timeout_add(1000, self._update_title_cb) self._update_title_sid = gobject.timeout_add(1000, self.__update_title_cb)
def _update_title_cb(self): def __update_title_cb(self):
title = self.title.get_text() title = self.title.get_text()
self._activity.metadata['title'] = title self._activity.metadata['title'] = title
@ -162,10 +162,10 @@ class ActivityToolbar(gtk.Toolbar):
self.insert(tool_item, -1) self.insert(tool_item, -1)
tool_item.show() tool_item.show()
def _activity_shared_cb(self, activity): def __activity_shared_cb(self, activity):
self._update_share() self._update_share()
def _max_participants_changed_cb(self, activity, pspec): def __max_participants_changed_cb(self, activity, pspec):
self._update_share() self._update_share()
class EditToolbar(gtk.Toolbar): class EditToolbar(gtk.Toolbar):
@ -258,7 +258,7 @@ class Activity(Window, gtk.Container):
proc_title = "%s <%s>" % (get_bundle_name(), handle.activity_id) proc_title = "%s <%s>" % (get_bundle_name(), handle.activity_id)
util.set_proc_title(proc_title) util.set_proc_title(proc_title)
self.connect('realize', self._realize_cb) self.connect('realize', self.__realize_cb)
self.connect('delete-event', self.__delete_event_cb) self.connect('delete-event', self.__delete_event_cb)
self._active = False self._active = False
@ -313,8 +313,8 @@ class Activity(Window, gtk.Container):
self._jobject.file_path = '' self._jobject.file_path = ''
datastore.write(self._jobject, datastore.write(self._jobject,
reply_handler=self._internal_jobject_create_cb, reply_handler=self.__jobject_create_cb,
error_handler=self._internal_jobject_error_cb) error_handler=self.__jobject_error_cb)
else: else:
self._jobject = None self._jobject = None
@ -326,12 +326,12 @@ class Activity(Window, gtk.Container):
logging.debug("*** Act %s joining existing mesh instance" % self._activity_id) logging.debug("*** Act %s joining existing mesh instance" % self._activity_id)
self._shared_activity = mesh_instance self._shared_activity = mesh_instance
self._shared_activity.connect('notify::private', self._shared_activity.connect('notify::private',
self._privacy_changed_cb) self.__privacy_changed_cb)
self._join_id = self._shared_activity.connect("joined", self._internal_joined_cb) self._join_id = self._shared_activity.connect("joined", self.__joined_cb)
if not self._shared_activity.props.joined: if not self._shared_activity.props.joined:
self._shared_activity.join() self._shared_activity.join()
else: else:
self._internal_joined_cb(self._shared_activity, True, None) self.__joined_cb(self._shared_activity, True, None)
elif share_scope != SCOPE_PRIVATE: elif share_scope != SCOPE_PRIVATE:
logging.debug("*** Act %s no existing mesh instance, but used to be shared, will share" % self._activity_id) logging.debug("*** Act %s no existing mesh instance, but used to be shared, will share" % self._activity_id)
# no existing mesh instance, but activity used to be shared, so # no existing mesh instance, but activity used to be shared, so
@ -366,16 +366,16 @@ class Activity(Window, gtk.Container):
def set_canvas(self, canvas): def set_canvas(self, canvas):
Window.set_canvas(self, canvas) Window.set_canvas(self, canvas)
canvas.connect('map', self._canvas_map_cb) canvas.connect('map', self.__canvas_map_cb)
def _canvas_map_cb(self, canvas): def __canvas_map_cb(self, canvas):
if self._jobject and self._jobject.file_path: if self._jobject and self._jobject.file_path:
self.read_file(self._jobject.file_path) self.read_file(self._jobject.file_path)
def _internal_jobject_create_cb(self): def __jobject_create_cb(self):
pass pass
def _internal_jobject_error_cb(self, err): def __jobject_error_cb(self, err):
logging.debug("Error creating activity datastore object: %s" % err) logging.debug("Error creating activity datastore object: %s" % err)
def get_activity_root(self): def get_activity_root(self):
@ -404,15 +404,15 @@ class Activity(Window, gtk.Container):
""" """
raise NotImplementedError raise NotImplementedError
def _internal_save_cb(self): def __save_cb(self):
logging.debug('Activity._internal_save_cb') logging.debug('Activity.__save_cb')
self._updating_jobject = False self._updating_jobject = False
if self._closing: if self._closing:
self._cleanup_jobject() self._cleanup_jobject()
self.destroy() self.destroy()
def _internal_save_error_cb(self, err): def __save_error_cb(self, err):
logging.debug('Activity._internal_save_error_cb') logging.debug('Activity.__save_error_cb')
self._updating_jobject = False self._updating_jobject = False
if self._closing: if self._closing:
self._cleanup_jobject() self._cleanup_jobject()
@ -498,8 +498,8 @@ class Activity(Window, gtk.Container):
self._updating_jobject = True self._updating_jobject = True
datastore.write(self._jobject, datastore.write(self._jobject,
transfer_ownership=True, transfer_ownership=True,
reply_handler=self._internal_save_cb, reply_handler=self.__save_cb,
error_handler=self._internal_save_error_cb) error_handler=self.__save_error_cb)
def copy(self): def copy(self):
logging.debug('Activity.copy: %r' % self._jobject.object_id) logging.debug('Activity.copy: %r' % self._jobject.object_id)
@ -507,13 +507,13 @@ class Activity(Window, gtk.Container):
self.save() self.save()
self._jobject.object_id = None self._jobject.object_id = None
def _privacy_changed_cb(self, shared_activity, param_spec): def __privacy_changed_cb(self, shared_activity, param_spec):
if shared_activity.props.private: if shared_activity.props.private:
self._jobject.metadata['share-scope'] = SCOPE_INVITE_ONLY self._jobject.metadata['share-scope'] = SCOPE_INVITE_ONLY
else: else:
self._jobject.metadata['share-scope'] = SCOPE_NEIGHBORHOOD self._jobject.metadata['share-scope'] = SCOPE_NEIGHBORHOOD
def _internal_joined_cb(self, activity, success, err): def __joined_cb(self, activity, success, err):
"""Callback when join has finished""" """Callback when join has finished"""
self._shared_activity.disconnect(self._join_id) self._shared_activity.disconnect(self._join_id)
self._join_id = None self._join_id = None
@ -523,7 +523,7 @@ class Activity(Window, gtk.Container):
self.present() self.present()
self.emit('joined') self.emit('joined')
self._privacy_changed_cb(self._shared_activity, None) self.__privacy_changed_cb(self._shared_activity, None)
def get_shared(self): def get_shared(self):
"""Returns TRUE if the activity is shared on the mesh.""" """Returns TRUE if the activity is shared on the mesh."""
@ -531,7 +531,7 @@ class Activity(Window, gtk.Container):
return False return False
return self._shared_activity.props.joined return self._shared_activity.props.joined
def _internal_share_cb(self, ps, success, activity, err): def __share_cb(self, ps, success, activity, err):
self._pservice.disconnect(self._share_id) self._pservice.disconnect(self._share_id)
self._share_id = None self._share_id = None
if not success: if not success:
@ -544,9 +544,9 @@ class Activity(Window, gtk.Container):
self._shared_activity = activity self._shared_activity = activity
self._shared_activity.connect('notify::private', self._shared_activity.connect('notify::private',
self._privacy_changed_cb) self.__privacy_changed_cb)
self.emit('shared') self.emit('shared')
self._privacy_changed_cb(self._shared_activity, None) self.__privacy_changed_cb(self._shared_activity, None)
self._send_invites() self._send_invites()
@ -589,7 +589,7 @@ class Activity(Window, gtk.Container):
logging.debug('Requesting %s share of activity %s.' % logging.debug('Requesting %s share of activity %s.' %
(verb, self._activity_id)) (verb, self._activity_id))
self._share_id = self._pservice.connect("activity-shared", self._share_id = self._pservice.connect("activity-shared",
self._internal_share_cb) self.__share_cb)
self._pservice.share_activity(self, private=private) self._pservice.share_activity(self, private=private)
def close(self): def close(self):
@ -605,7 +605,7 @@ class Activity(Window, gtk.Container):
else: else:
self.destroy() self.destroy()
def _realize_cb(self, window): def __realize_cb(self, window):
wm.set_bundle_id(window.window, self.get_bundle_id()) wm.set_bundle_id(window.window, self.get_bundle_id())
wm.set_activity_id(window.window, self._activity_id) wm.set_activity_id(window.window, self._activity_id)