Ticket #3998: 0001-Control-Panel-defocus-the-search-entry-by-default-SL.patch

File 0001-Control-Panel-defocus-the-search-entry-by-default-SL.patch, 2.5 KB (added by manuq, 12 years ago)

Candidate patch.

  • src/jarabe/controlpanel/gui.py

    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): 
    5555        self.set_resizable(False)
    5656        self.set_modal(True)
    5757
     58        self.set_can_focus(True)
     59        self.connect('key-press-event', self.__key_press_event_cb)
     60
    5861        self._toolbar = None
    5962        self._canvas = None
    6063        self._table = None
    class ControlPanel(Gtk.Window): 
    9093        self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
    9194        self.get_window().set_accept_focus(True)
    9295
     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
    93100    def _set_canvas(self, canvas):
    94101        if self._canvas:
    95102            self._main_view.remove(self._canvas)
    class ControlPanel(Gtk.Window): 
    186193        self._table.show()
    187194        self._scrolledwindow.show()
    188195        entry = self._main_toolbar.get_entry()
    189         entry.grab_focus()
    190196        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()
    191208
    192209    def _update(self, query):
    193210        for option in self._options: