From 30628bfacf06fa3f6e31f780ac821ec22c99dd1e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
Date: Mon, 22 Oct 2012 11:34:46 -0300
Subject: [PATCH shell] Control Panel: defocus the search entry by default -
SL #3998
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
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>
---
src/jarabe/controlpanel/gui.py | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/jarabe/controlpanel/gui.py b/src/jarabe/controlpanel/gui.py
index f8afca3..40955c1 100644
a
|
b
|
class ControlPanel(Gtk.Window): |
55 | 55 | self.set_resizable(False) |
56 | 56 | self.set_modal(True) |
57 | 57 | |
| 58 | self.set_can_focus(True) |
| 59 | self.connect('key-press-event', self.__key_press_event_cb) |
| 60 | |
58 | 61 | self._toolbar = None |
59 | 62 | self._canvas = None |
60 | 63 | self._table = None |
… |
… |
class ControlPanel(Gtk.Window): |
90 | 93 | self.set_type_hint(Gdk.WindowTypeHint.DIALOG) |
91 | 94 | self.get_window().set_accept_focus(True) |
92 | 95 | |
| 96 | def grab_focus(self): |
| 97 | # overwrite grab focus in order to grab focus on the view: |
| 98 | self._main_view.get_child().grab_focus() |
| 99 | |
93 | 100 | def _set_canvas(self, canvas): |
94 | 101 | if self._canvas: |
95 | 102 | self._main_view.remove(self._canvas) |
… |
… |
class ControlPanel(Gtk.Window): |
186 | 193 | self._table.show() |
187 | 194 | self._scrolledwindow.show() |
188 | 195 | entry = self._main_toolbar.get_entry() |
189 | | entry.grab_focus() |
190 | 196 | entry.set_text('') |
| 197 | entry.connect('icon-press', self.__clear_icon_pressed_cb) |
| 198 | self.grab_focus() |
| 199 | |
| 200 | def __key_press_event_cb(self, window, event): |
| 201 | entry = self._main_toolbar.get_entry() |
| 202 | if not entry.has_focus(): |
| 203 | entry.grab_focus() |
| 204 | return False |
| 205 | |
| 206 | def __clear_icon_pressed_cb(self, entry, icon_pos, event): |
| 207 | self.grab_focus() |
191 | 208 | |
192 | 209 | def _update(self, query): |
193 | 210 | for option in self._options: |