Ticket #3499: 0001-Button-to-clear-the-url-entry-SL-3499.patch

File 0001-Button-to-clear-the-url-entry-SL-3499.patch, 3.6 KB (added by humitos, 12 years ago)
  • new file icons/browse-clear-url.svg

    From 44e421d7e963d8c9e916671ca49e8ae2e5cfd3a1 Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Fri, 21 Sep 2012 20:24:15 -0300
    Subject: [PATCH Browse] Button to clear the url entry SL #3499
    
    Added an 'X' to clear the url entry easily. This button is shown when
    the url entry has focus. When the focus is left the icon changes
    again to the correct one (reload or stop loading)
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     icons/browse-clear-url.svg | 18 ++++++++++++++++++
     webtoolbar.py              | 21 ++++++++++++++++++---
     2 files changed, 36 insertions(+), 3 deletions(-)
     create mode 100644 icons/browse-clear-url.svg
    
    diff --git a/icons/browse-clear-url.svg b/icons/browse-clear-url.svg
    new file mode 100644
    index 0000000..f7b3746
    - +  
     1<?xml version="1.0" encoding="UTF-8"?>
     2<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
     3  <!ENTITY fill_color "#FFFFFF">
     4  <!ENTITY stroke_color "#010101">
     5]>
     6<svg
     7   xmlns="http://www.w3.org/2000/svg"
     8   version="1.1"
     9   width="22.16"
     10   height="22.16"
     11   viewBox="0 0 22.16 22.16"
     12   id="browse-dialog-cancel"
     13   xml:space="preserve">
     14  <path
     15   d="m 0,0 0,22.15625 22.15625,0 L 22.15625,0 0,0 z m 16.15625,4.1875 a 1.750175,1.750175 0 0 1 1.25,3.03125 l -3.84375,3.84375 3.84375,3.84375 a 1.7567532,1.7567532 0 1 1 -2.5,2.46875 L 11.09375,13.53125 7.25,17.375 A 1.750175,1.750175 0 1 1 4.78125,14.90625 L 8.625,11.0625 4.78125,7.21875 a 1.750175,1.750175 0 0 1 1.03125,-3 A 1.750175,1.750175 0 0 1 7.25,4.75 L 11.09375,8.59375 14.90625,4.75 A 1.750175,1.750175 0 0 1 15.9375,4.21875 1.750175,1.750175 0 0 1 16.15625,4.1875 z"
     16   id="rect3074"
     17   style="color:&stroke_color;;fill:&stroke_color;;stroke:none;stroke-width:1.5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
     18</svg>
  • webtoolbar.py

    diff --git a/webtoolbar.py b/webtoolbar.py
    index 28bc015..c5db18a 100644
    a b class PrimaryToolbar(ToolbarBase): 
    258258                                      'browse-dialog-cancel')
    259259        self.entry.connect('icon-press', self._stop_and_reload_cb)
    260260        self.entry.connect('activate', self._entry_activate_cb)
     261        self.entry.connect('focus-in-event', self.__focus_in_event_cb)
     262        self.entry.connect('focus-out-event', self.__focus_out_event_cb)
    261263
    262264        entry_item = Gtk.ToolItem()
    263265        entry_item.set_expand(True)
    class PrimaryToolbar(ToolbarBase): 
    387389        self.entry.props.title = title
    388390        self._title = title
    389391
     392    def __focus_in_event_cb(self, entry, event):
     393        self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY,
     394                                      'browse-clear-url')
     395
     396    def __focus_out_event_cb(self, entry, event):
     397        if self._loading:
     398            self._show_stop_icon()
     399        else:
     400            self._show_reload_icon()
     401
    390402    def _show_stop_icon(self):
    391403        self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY,
    392404                                      'browse-dialog-cancel')
    class PrimaryToolbar(ToolbarBase): 
    432444        filepicker.cleanup_temp_files()
    433445
    434446    def _stop_and_reload_cb(self, entry, icon_pos, button):
    435         if self._loading:
    436             self._browser.stop_loading()
     447        if entry.has_focus():
     448            entry.set_text('')
    437449        else:
    438             self._browser.reload()
     450            if self._loading:
     451                self._browser.stop_loading()
     452            else:
     453                self._browser.reload()
    439454
    440455    def _set_loading(self, loading):
    441456        self._loading = loading