Ticket #3968: 0001-Do-not-show-clear-url-icon-when-there-is-not-text-SL.2.patch

File 0001-Do-not-show-clear-url-icon-when-there-is-not-text-SL.2.patch, 2.4 KB (added by humitos, 11 years ago)

v2 - uses 'changed' signal and 'has_focus'

  • webtoolbar.py

    From 2e6d8f7adfb25914be7d10b9b46c1a76239d48dc Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Mon, 21 Jan 2013 10:04:53 -0300
    Subject: [PATCH Browse] Do not show clear url icon when there is not text SL
     #3968
    
    Use 'changed' signal to know if the url entry is empty. Check if the
    entry has_focus() to know if the entry was changed by the user or
    not. We only want to show the clear icon if the user has changed the
    url entry.
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     webtoolbar.py | 18 ++++++++++++++++--
     1 file changed, 16 insertions(+), 2 deletions(-)
    
    diff --git a/webtoolbar.py b/webtoolbar.py
    index 7433bea..0ad06dd 100644
    a b class PrimaryToolbar(ToolbarBase): 
    284284        self.entry.connect('focus-in-event', self.__focus_in_event_cb)
    285285        self.entry.connect('focus-out-event', self.__focus_out_event_cb)
    286286        self.entry.connect('key-press-event', self.__key_press_event_cb)
     287        self.entry.connect('changed', self.__changed_cb)
    287288
    288289        entry_item = Gtk.ToolItem()
    289290        entry_item.set_expand(True)
    class PrimaryToolbar(ToolbarBase): 
    419420        else:
    420421            self.entry.props.address = uri
    421422
     423    def __changed_cb(self, iconentry):
     424        # The WebEntry can be changed when we click on a link, then we
     425        # have to show the clear icon only if is the user who has
     426        # changed the entry
     427        if self.entry.has_focus():
     428            if not self.entry.props.text:
     429                self._show_no_icon()
     430            else:
     431                self._show_clear_icon()
     432
    422433    def __focus_in_event_cb(self, entry, event):
    423434        if not self._tabbed_view.is_current_page_pdf():
    424             self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY,
    425                                           'entry-cancel')
     435            self._show_clear_icon()
    426436
    427437    def __focus_out_event_cb(self, entry, event):
    428438        if self._loading:
    class PrimaryToolbar(ToolbarBase): 
    442452        self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY,
    443453                                      'entry-refresh')
    444454
     455    def _show_clear_icon(self):
     456        self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY,
     457                                      'entry-cancel')
     458
    445459    def _update_navigation_buttons(self):
    446460        can_go_back = self._browser.can_go_back()
    447461        self._back.props.sensitive = can_go_back