Set title on change. Fixes #1715.
This commit is contained in:
parent
e021bb271c
commit
99369114cb
@ -51,7 +51,7 @@ class ActivityToolbar(gtk.Toolbar):
|
|||||||
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('focus-out-event', self._title_focus_out_event_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)
|
||||||
@ -79,6 +79,8 @@ class ActivityToolbar(gtk.Toolbar):
|
|||||||
self.insert(self.close, -1)
|
self.insert(self.close, -1)
|
||||||
self.close.show()
|
self.close.show()
|
||||||
|
|
||||||
|
self._update_title_sid = None
|
||||||
|
|
||||||
def _share_clicked_cb(self, button):
|
def _share_clicked_cb(self, button):
|
||||||
self._activity.share()
|
self._activity.share()
|
||||||
|
|
||||||
@ -88,10 +90,16 @@ class ActivityToolbar(gtk.Toolbar):
|
|||||||
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_focus_out_event_cb(self, entry, event):
|
def _title_changed_cb(self, entry):
|
||||||
if self._activity.metadata['title'] != self.title.get_text():
|
if not self._update_title_sid:
|
||||||
self._activity.metadata['title'] = self.title.get_text()
|
self._update_title_sid = gobject.timeout_add(1000, self._update_title_cb)
|
||||||
self._activity.save()
|
|
||||||
|
def _update_title_cb(self):
|
||||||
|
self._activity.metadata['title'] = self.title.get_text()
|
||||||
|
self._activity.metadata['title_set_by_user'] = '1'
|
||||||
|
self._activity.save()
|
||||||
|
self._update_title_sid = None
|
||||||
|
return False
|
||||||
|
|
||||||
def _add_widget(self, widget, expand=False):
|
def _add_widget(self, widget, expand=False):
|
||||||
tool_item = gtk.ToolItem()
|
tool_item = gtk.ToolItem()
|
||||||
@ -213,6 +221,7 @@ class Activity(Window, gtk.Container):
|
|||||||
logging.debug('Creating a jobject.')
|
logging.debug('Creating a jobject.')
|
||||||
self._jobject = datastore.create()
|
self._jobject = datastore.create()
|
||||||
self._jobject.metadata['title'] = _('%s Activity') % get_bundle_name()
|
self._jobject.metadata['title'] = _('%s Activity') % get_bundle_name()
|
||||||
|
self._jobject.metadata['title_set_by_user'] = '0'
|
||||||
self._jobject.metadata['activity'] = self.get_service_name()
|
self._jobject.metadata['activity'] = self.get_service_name()
|
||||||
self._jobject.metadata['keep'] = '0'
|
self._jobject.metadata['keep'] = '0'
|
||||||
self._jobject.metadata['buddies'] = ''
|
self._jobject.metadata['buddies'] = ''
|
||||||
|
@ -32,7 +32,7 @@ class DSMetadata(gobject.GObject):
|
|||||||
else:
|
else:
|
||||||
self._props = props
|
self._props = props
|
||||||
|
|
||||||
default_keys = ['activity', 'mime_type']
|
default_keys = ['activity', 'mime_type', 'title_set_by_user']
|
||||||
for key in default_keys:
|
for key in default_keys:
|
||||||
if not self._props.has_key(key):
|
if not self._props.has_key(key):
|
||||||
self._props[key] = ''
|
self._props[key] = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user