[Sugar-devel] [PATCH shell] Journal: defocus the search entry by default

Manuel Quiñones manuq at laptop.org
Wed Sep 26 15:27:43 EDT 2012


This has a regression whlie trying to rename an entry in the journal.
Please don't push, I will fix it :)

2012/9/26 Manuel Quiñones <manuq at laptop.org>:
> Do the same behavior as in the shell views, explained in detail in
> commit 1570f774 .
>
> - make MainToolBox search_entry a public attribute to make it visible
>   from JournalActivity
>
> - as a consequence of the previous item, remove give_entry_focus
>   method from MainToolBox and use the attribute directly
>
> Signed-off-by: Manuel Quiñones <manuq at laptop.org>
> ---
>  src/jarabe/journal/journalactivity.py | 12 ++++++++++--
>  src/jarabe/journal/journaltoolbox.py  | 27 +++++++++++++--------------
>  2 files changed, 23 insertions(+), 16 deletions(-)
>
> diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py
> index 23a0b38..1ecb6e3 100644
> --- a/src/jarabe/journal/journalactivity.py
> +++ b/src/jarabe/journal/journalactivity.py
> @@ -173,6 +173,7 @@ class JournalActivity(JournalWindow):
>      def _setup_main_view(self):
>          self._main_toolbox = MainToolbox()
>          self._main_view = Gtk.VBox()
> +        self._main_view.set_can_focus(True)
>
>          self._list_view = ListView()
>          self._list_view.connect('detail-clicked', self.__detail_clicked_cb)
> @@ -188,6 +189,8 @@ class JournalActivity(JournalWindow):
>          self._main_view.pack_start(self._volumes_toolbar, False, True, 0)
>
>          self._main_toolbox.connect('query-changed', self._query_changed_cb)
> +        self._main_toolbox.search_entry.connect('icon-press',
> +                                                self.__search_icon_pressed_cb)
>          self._main_toolbox.set_mount_point('/')
>
>      def _setup_secondary_view(self):
> @@ -203,6 +206,9 @@ class JournalActivity(JournalWindow):
>          self._detail_view.show()
>
>      def _key_press_event_cb(self, widget, event):
> +        if not self._main_toolbox.search_entry.has_focus():
> +            self._main_toolbox.search_entry.grab_focus()
> +
>          keyname = Gdk.keyval_name(event.keyval)
>          if keyname == 'Escape':
>              self.show_main_view()
> @@ -220,6 +226,9 @@ class JournalActivity(JournalWindow):
>          self._list_view.update_with_query(query)
>          self.show_main_view()
>
> +    def __search_icon_pressed_cb(self, entry, icon_pos, event):
> +        self._main_view.grab_focus()
> +
>      def show_main_view(self):
>          if self.toolbar_box != self._main_toolbox:
>              self.set_toolbar_box(self._main_toolbox)
> @@ -279,7 +288,6 @@ class JournalActivity(JournalWindow):
>              self.show_main_view()
>
>      def _focus_in_event_cb(self, window, event):
> -        self.search_grab_focus()
>          self._list_view.update_dates()
>
>      def _check_for_bundle(self, object_id):
> @@ -319,7 +327,7 @@ class JournalActivity(JournalWindow):
>          model.write(metadata)
>
>      def search_grab_focus(self):
> -        self._main_toolbox.give_entry_focus()
> +        self._main_toolbox.search_entry.grab_focus()
>
>      def __window_state_event_cb(self, window, event):
>          logging.debug('window_state_event_cb %r', self)
> diff --git a/src/jarabe/journal/journaltoolbox.py b/src/jarabe/journal/journaltoolbox.py
> index a4f80fc..09d8a31 100644
> --- a/src/jarabe/journal/journaltoolbox.py
> +++ b/src/jarabe/journal/journaltoolbox.py
> @@ -76,14 +76,16 @@ class MainToolbox(ToolbarBox):
>
>          self._mount_point = None
>
> -        self._search_entry = iconentry.IconEntry()
> -        self._search_entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY,
> -                                              'system-search')
> -        self._search_entry.connect('activate', self._search_entry_activated_cb)
> -        self._search_entry.connect('changed', self._search_entry_changed_cb)
> -        self._search_entry.add_clear_button()
> +        self.search_entry = iconentry.IconEntry()
> +        self.search_entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY,
> +                                             'system-search')
> +        text = _('Search in %s') % _('Journal')
> +        self.search_entry.set_placeholder_text(text)
> +        self.search_entry.connect('activate', self._search_entry_activated_cb)
> +        self.search_entry.connect('changed', self._search_entry_changed_cb)
> +        self.search_entry.add_clear_button()
>          self._autosearch_timer = None
> -        self._add_widget(self._search_entry, expand=True)
> +        self._add_widget(self.search_entry, expand=True)
>
>          self._favorite_button = ToggleToolButton('emblem-favorite')
>          self._favorite_button.connect('toggled',
> @@ -121,9 +123,6 @@ class MainToolbox(ToolbarBox):
>
>          self.refresh_filters()
>
> -    def give_entry_focus(self):
> -        self._search_entry.grab_focus()
> -
>      def _get_when_search_combo(self):
>          when_search = ComboBox()
>          when_search.append_item(_ACTION_ANYTIME, _('Anytime'))
> @@ -188,8 +187,8 @@ class MainToolbox(ToolbarBox):
>              date_from, date_to = self._get_date_range()
>              query['timestamp'] = {'start': date_from, 'end': date_to}
>
> -        if self._search_entry.props.text:
> -            text = self._search_entry.props.text.strip()
> +        if self.search_entry.props.text:
> +            text = self.search_entry.props.text.strip()
>              if text:
>                  query['query'] = text
>
> @@ -256,7 +255,7 @@ class MainToolbox(ToolbarBox):
>      def _autosearch_timer_cb(self):
>          logging.debug('_autosearch_timer_cb')
>          self._autosearch_timer = None
> -        self._search_entry.activate()
> +        self.search_entry.activate()
>          return False
>
>      def set_mount_point(self, mount_point):
> @@ -345,7 +344,7 @@ class MainToolbox(ToolbarBox):
>          self._update_if_needed()
>
>      def clear_query(self):
> -        self._search_entry.props.text = ''
> +        self.search_entry.props.text = ''
>          self._what_search_combo.set_active(0)
>          self._when_search_combo.set_active(0)
>          self._favorite_button.props.active = False
> --
> 1.7.11.4
>



-- 
.. manuq ..


More information about the Sugar-devel mailing list