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): |
284 | 284 | self.entry.connect('focus-in-event', self.__focus_in_event_cb) |
285 | 285 | self.entry.connect('focus-out-event', self.__focus_out_event_cb) |
286 | 286 | self.entry.connect('key-press-event', self.__key_press_event_cb) |
| 287 | self.entry.connect('changed', self.__changed_cb) |
287 | 288 | |
288 | 289 | entry_item = Gtk.ToolItem() |
289 | 290 | entry_item.set_expand(True) |
… |
… |
class PrimaryToolbar(ToolbarBase): |
419 | 420 | else: |
420 | 421 | self.entry.props.address = uri |
421 | 422 | |
| 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 | |
422 | 433 | def __focus_in_event_cb(self, entry, event): |
423 | 434 | 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() |
426 | 436 | |
427 | 437 | def __focus_out_event_cb(self, entry, event): |
428 | 438 | if self._loading: |
… |
… |
class PrimaryToolbar(ToolbarBase): |
442 | 452 | self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY, |
443 | 453 | 'entry-refresh') |
444 | 454 | |
| 455 | def _show_clear_icon(self): |
| 456 | self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY, |
| 457 | 'entry-cancel') |
| 458 | |
445 | 459 | def _update_navigation_buttons(self): |
446 | 460 | can_go_back = self._browser.can_go_back() |
447 | 461 | self._back.props.sensitive = can_go_back |