Ticket #1948: 0001-Save-title-when-closing-1948.patch

File 0001-Save-title-when-closing-1948.patch, 2.0 KB (added by erikos, 10 years ago)

save on stop button - disconnect the focus-out handler

  • src/sugar/activity/activity.py

    From 0ba47d0e66c0281c8e5c537e0b98c11bdc0a8e3f Mon Sep 17 00:00:00 2001
    From: Simon Schampijer <simon@schampijer.de>
    Date: Wed, 1 Sep 2010 17:08:45 +0200
    Subject: [PATCH] Save title when closing #1948
    
    ---
     src/sugar/activity/activity.py |    9 ++++++++-
     1 files changed, 8 insertions(+), 1 deletions(-)
    
    diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py
    index 3e97485..6f204b3 100644
    a b class ActivityToolbar(gtk.Toolbar): 
    9999
    100100        self._activity = activity
    101101        self._updating_share = False
     102        self._focus_out_hid = None
    102103
    103104        activity.connect('shared', self.__activity_shared_cb)
    104105        activity.connect('joined', self.__activity_shared_cb)
    class ActivityToolbar(gtk.Toolbar): 
    109110            self.title = gtk.Entry()
    110111            self.title.set_size_request(int(gtk.gdk.screen_width() / 3), -1)
    111112            self.title.set_text(activity.metadata['title'])
    112             self.title.connect('focus-out-event', self.__title_changed_cb)
     113            self._focus_out_hid = self.title.connect('focus-out-event',
     114                                                     self.__title_changed_cb)
    113115            self._add_widget(self.title)
    114116
    115117            activity.metadata.connect('updated', self.__jobject_updated_cb)
    class ActivityToolbar(gtk.Toolbar): 
    176178        self._activity.copy()
    177179
    178180    def __stop_clicked_cb(self, button):
     181        if self._focus_out_hid is not None:
     182            self.title.disconnect(self._focus_out_hid)
     183        self._update_title(self.title.get_text())
    179184        self._activity.close()
    180185
    181186    def __jobject_updated_cb(self, jobject):
    class ActivityToolbar(gtk.Toolbar): 
    183188
    184189    def __title_changed_cb(self, editable, event):
    185190        title = editable.get_text()
     191        self._update_title(title)
    186192
     193    def _update_title(self, title):
    187194        # Title really changed?
    188195        if title == self._activity.metadata['title']:
    189196            return False