Make Activity update the presence service activity
name and listen to the name changes in the mesh view.
This commit is contained in:
parent
fbf995e71d
commit
560a914997
@ -26,24 +26,21 @@ from hardware import hardwaremanager
|
|||||||
from hardware import nmclient
|
from hardware import nmclient
|
||||||
|
|
||||||
class ActivityModel:
|
class ActivityModel:
|
||||||
def __init__(self, activity, activity_info):
|
def __init__(self, activity, bundle):
|
||||||
self._activity = activity
|
self.activity = activity
|
||||||
self._activity_info = activity_info
|
self.bundle = bundle
|
||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
return self._activity.props.id
|
return self.activity.props.id
|
||||||
|
|
||||||
def get_icon_name(self):
|
def get_icon_name(self):
|
||||||
return self._activity_info.icon
|
return self.bundle.icon
|
||||||
|
|
||||||
def get_color(self):
|
def get_color(self):
|
||||||
return XoColor(self._activity.props.color)
|
return XoColor(self.activity.props.color)
|
||||||
|
|
||||||
def get_service_name(self):
|
def get_service_name(self):
|
||||||
return self._activity_info.service_name
|
return self.bundle.service_name
|
||||||
|
|
||||||
def get_title(self):
|
|
||||||
return self._activity.props.name
|
|
||||||
|
|
||||||
class MeshModel(gobject.GObject):
|
class MeshModel(gobject.GObject):
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
@ -203,12 +200,12 @@ class MeshModel(gobject.GObject):
|
|||||||
|
|
||||||
def _check_activity(self, presence_activity):
|
def _check_activity(self, presence_activity):
|
||||||
registry = activity.get_registry()
|
registry = activity.get_registry()
|
||||||
activity_info = registry.get_activity(presence_activity.props.type)
|
bundle = registry.get_activity(presence_activity.props.type)
|
||||||
if not activity_info:
|
if not bundle:
|
||||||
return
|
return
|
||||||
if self.has_activity(presence_activity.props.id):
|
if self.has_activity(presence_activity.props.id):
|
||||||
return
|
return
|
||||||
self.add_activity(activity_info, presence_activity)
|
self.add_activity(bundle, presence_activity)
|
||||||
|
|
||||||
def has_activity(self, activity_id):
|
def has_activity(self, activity_id):
|
||||||
return self._activities.has_key(activity_id)
|
return self._activities.has_key(activity_id)
|
||||||
@ -219,8 +216,8 @@ class MeshModel(gobject.GObject):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def add_activity(self, activity_info, activity):
|
def add_activity(self, bundle, activity):
|
||||||
model = ActivityModel(activity, activity_info)
|
model = ActivityModel(activity, bundle)
|
||||||
self._activities[model.get_id()] = model
|
self._activities[model.get_id()] = model
|
||||||
self.emit('activity-added', model)
|
self.emit('activity-added', model)
|
||||||
|
|
||||||
|
@ -181,13 +181,15 @@ class ActivityView(hippo.CanvasBox):
|
|||||||
self.set_layout(self._layout)
|
self.set_layout(self._layout)
|
||||||
|
|
||||||
self._icon = CanvasIcon(file_name=model.get_icon_name(),
|
self._icon = CanvasIcon(file_name=model.get_icon_name(),
|
||||||
xo_color=model.get_color(), box_width=80)
|
xo_color=model.get_color(), box_width=80)
|
||||||
self._icon.connect('activated', self._clicked_cb)
|
self._icon.connect('activated', self._clicked_cb)
|
||||||
self._icon.set_tooltip(self._model.get_title())
|
self._icon.set_tooltip(self._model.activity.props.name)
|
||||||
self._layout.add_center(self._icon)
|
self._layout.add_center(self._icon)
|
||||||
|
|
||||||
def _update_name(self):
|
self._model.activity.connect('notify::name', self._name_changed_cb)
|
||||||
self.palette.set_primary_text(self._model.get_title())
|
|
||||||
|
def _name_changed_cb(self, activity, pspec):
|
||||||
|
self._icon.set_tooltip(activity.props.name)
|
||||||
|
|
||||||
def has_buddy_icon(self, key):
|
def has_buddy_icon(self, key):
|
||||||
return self._icons.has_key(key)
|
return self._icons.has_key(key)
|
||||||
|
@ -137,9 +137,16 @@ class ActivityToolbar(gtk.Toolbar):
|
|||||||
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):
|
||||||
self._activity.metadata['title'] = self.title.get_text()
|
title = self.title.get_text()
|
||||||
|
|
||||||
|
self._activity.metadata['title'] = title
|
||||||
self._activity.metadata['title_set_by_user'] = '1'
|
self._activity.metadata['title_set_by_user'] = '1'
|
||||||
self._activity.save()
|
self._activity.save()
|
||||||
|
|
||||||
|
shared_activity = self._activity._shared_activity
|
||||||
|
if shared_activity:
|
||||||
|
shared_activity.props.name = title
|
||||||
|
|
||||||
self._update_title_sid = None
|
self._update_title_sid = None
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -499,6 +506,9 @@ class Activity(Window, gtk.Container):
|
|||||||
logging.debug('Share of activity %s failed: %s.' % (self._activity_id, err))
|
logging.debug('Share of activity %s failed: %s.' % (self._activity_id, err))
|
||||||
return
|
return
|
||||||
logging.debug('Share of activity %s successful.' % self._activity_id)
|
logging.debug('Share of activity %s successful.' % self._activity_id)
|
||||||
|
|
||||||
|
activity.props.name = self._jobject.metadata['title']
|
||||||
|
|
||||||
self._shared_activity = activity
|
self._shared_activity = activity
|
||||||
self.emit('shared')
|
self.emit('shared')
|
||||||
if self._jobject:
|
if self._jobject:
|
||||||
|
Loading…
Reference in New Issue
Block a user