diff options
author | Manuel Quiñones <manuq@laptop.org> | 2012-10-22 14:34:46 (GMT) |
---|---|---|
committer | Manuel Quiñones <manuq@laptop.org> | 2012-10-23 13:35:45 (GMT) |
commit | ff734de4e8829c9873fb84f0a9cc0166860cdd96 (patch) | |
tree | 5180eecdfaf9b90362eefc041e01ddbde4739627 | |
parent | da5e3e0a76a7a9222a4a36d251aeff7c8d227f5b (diff) |
Control Panel: defocus the search entry by default - SL #3998
Do the same behavior as in the shell views and Journal, explained in
detail in commit 1570f774 .
- overrite grab_focus in the window to grab it in the view widget, the
one that have the icons.
- grab the focus in the view widget on startup.
- connect the clear icon of the search entry to a callback that grabs
the focus again in the view widget.
- clear the search when a section is closed
Signed-off-by: Simon Schampijer <simon@laptop.org>
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
-rw-r--r-- | src/jarabe/controlpanel/gui.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/jarabe/controlpanel/gui.py b/src/jarabe/controlpanel/gui.py index f8afca3..f28b248 100644 --- a/src/jarabe/controlpanel/gui.py +++ b/src/jarabe/controlpanel/gui.py @@ -55,6 +55,9 @@ class ControlPanel(Gtk.Window): self.set_resizable(False) self.set_modal(True) + self.set_can_focus(True) + self.connect('key-press-event', self.__key_press_event_cb) + self._toolbar = None self._canvas = None self._table = None @@ -90,6 +93,10 @@ class ControlPanel(Gtk.Window): self.set_type_hint(Gdk.WindowTypeHint.DIALOG) self.get_window().set_accept_focus(True) + def grab_focus(self): + # overwrite grab focus in order to grab focus on the view + self._main_view.get_child().grab_focus() + def _set_canvas(self, canvas): if self._canvas: self._main_view.remove(self._canvas) @@ -186,8 +193,18 @@ class ControlPanel(Gtk.Window): self._table.show() self._scrolledwindow.show() entry = self._main_toolbar.get_entry() - entry.grab_focus() entry.set_text('') + entry.connect('icon-press', self.__clear_icon_pressed_cb) + self.grab_focus() + + def __key_press_event_cb(self, window, event): + entry = self._main_toolbar.get_entry() + if not entry.has_focus(): + entry.grab_focus() + return False + + def __clear_icon_pressed_cb(self, entry, icon_pos, event): + self.grab_focus() def _update(self, query): for option in self._options: |