From 58f06e2752e3a661a4beb611c0b6494429ab1017 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 21 Jan 2013 13:04:53 +0000 Subject: 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 Signed-off-by: Manuel QuiƱones --- (limited to 'webtoolbar.py') diff --git a/webtoolbar.py b/webtoolbar.py index 7433bea..63f22aa 100644 --- a/webtoolbar.py +++ b/webtoolbar.py @@ -284,6 +284,7 @@ class PrimaryToolbar(ToolbarBase): self.entry.connect('focus-in-event', self.__focus_in_event_cb) self.entry.connect('focus-out-event', self.__focus_out_event_cb) self.entry.connect('key-press-event', self.__key_press_event_cb) + self.entry.connect('changed', self.__changed_cb) entry_item = Gtk.ToolItem() entry_item.set_expand(True) @@ -419,10 +420,22 @@ class PrimaryToolbar(ToolbarBase): else: self.entry.props.address = uri + def __changed_cb(self, iconentry): + # The WebEntry can be changed when we click on a link, then we + # have to show the clear icon only if is the user who has + # changed the entry + if self.entry.has_focus(): + if not self.entry.props.text: + self._show_no_icon() + else: + self._show_clear_icon() + def __focus_in_event_cb(self, entry, event): if not self._tabbed_view.is_current_page_pdf(): - self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY, - 'entry-cancel') + if not self.entry.props.text: + self._show_no_icon() + else: + self._show_clear_icon() def __focus_out_event_cb(self, entry, event): if self._loading: @@ -442,6 +455,10 @@ class PrimaryToolbar(ToolbarBase): self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY, 'entry-refresh') + def _show_clear_icon(self): + self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY, + 'entry-cancel') + def _update_navigation_buttons(self): can_go_back = self._browser.can_go_back() self._back.props.sensitive = can_go_back -- cgit v0.9.1