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

File 0001-Button-to-clear-the-url-entry-SL-3499.2.patch, 4.0 KB (added by humitos, 12 years ago)

v2 - don't show icons on pdf tabs

  • browser.py

    From ac32aae77830f636203abc824e7c24c58192aa4c Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Fri, 21 Sep 2012 20:24:15 -0300
    Subject: [PATCH v2 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 and the user is not reading a .pdf
    webpage. When the focus is left the icon changes again to the correct
    one (reload, stop loading or none)
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     browser.py    |  5 +++++
     pdfviewer.py  |  6 ++++++
     webtoolbar.py | 32 ++++++++++++++++++++++++++++----
     3 files changed, 39 insertions(+), 4 deletions(-)
    
    diff --git a/browser.py b/browser.py
    index 0d94649..f0b711d 100644
    a b class TabbedView(BrowserNotebook): 
    341341                self._append_tab(browser)
    342342                browser.set_history(tab_history)
    343343
     344    def is_current_page_pdf(self):
     345        index = self.get_current_page()
     346        current_page = self.get_nth_page(index)
     347        return isinstance(current_page, PDFTabPage)
     348
    344349
    345350Gtk.rc_parse_string('''
    346351    style "browse-tab-close" {
  • pdfviewer.py

    diff --git a/pdfviewer.py b/pdfviewer.py
    index 5f607bf..6ce4fcf 100644
    a b class DummyBrowser(GObject.GObject): 
    270270    def reload(self):
    271271        pass
    272272
     273    def load_uri(self, uri):
     274        pass
     275
     276    def grab_focus(self):
     277        pass
     278
    273279
    274280class PDFTabPage(Gtk.HBox):
    275281    """Shows a basic PDF viewer, download the file first if the PDF is
  • webtoolbar.py

    diff --git a/webtoolbar.py b/webtoolbar.py
    index 28bc015..1e1b02f 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        if not self._tabbed_view.is_current_page_pdf():
     394            self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY,
     395                                          'dialog-cancel')
     396
     397    def __focus_out_event_cb(self, entry, event):
     398        if self._loading:
     399            self._show_stop_icon()
     400        else:
     401            if not self._tabbed_view.is_current_page_pdf():
     402                self._show_reload_icon()
     403
     404    def _show_no_icon(self):
     405        self.entry.remove_icon(iconentry.ICON_ENTRY_SECONDARY)
     406
    390407    def _show_stop_icon(self):
    391408        self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY,
    392409                                      'browse-dialog-cancel')
    class PrimaryToolbar(ToolbarBase): 
    432449        filepicker.cleanup_temp_files()
    433450
    434451    def _stop_and_reload_cb(self, entry, icon_pos, button):
    435         if self._loading:
    436             self._browser.stop_loading()
     452        if entry.has_focus() and \
     453                not self._tabbed_view.is_current_page_pdf():
     454            entry.set_text('')
    437455        else:
    438             self._browser.reload()
     456            if self._loading:
     457                self._browser.stop_loading()
     458            else:
     459                self._browser.reload()
    439460
    440461    def _set_loading(self, loading):
    441462        self._loading = loading
    class PrimaryToolbar(ToolbarBase): 
    443464        if self._loading:
    444465            self._show_stop_icon()
    445466        else:
    446             self._show_reload_icon()
     467            if not self._tabbed_view.is_current_page_pdf():
     468                self._show_reload_icon()
     469            else:
     470                self._show_no_icon()
    447471
    448472    def _reload_session_history(self):
    449473        back_forward_list = self._browser.get_back_forward_list()