Ticket #851: 0001-Busy-indication-SL-851.2.patch

File 0001-Busy-indication-SL-851.2.patch, 4.5 KB (added by humitos, 12 years ago)
  • browser.py

    From a884b8b402039cfa679d4aef5b5f9020823e52ca Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Mon, 10 Sep 2012 17:52:45 -0300
    Subject: [PATCH v2 Browse] Busy indication SL #851
    
    Show WATCH Cursor when the page is loading and LEFT_PTR when the load
    finishes.
    
    This changes take in consideration the tab that the user is watching,
    so the cursor refers to the state of the current browser / tab.
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     browser.py     | 21 +++++++++++++++++++++
     webactivity.py | 16 ++++++++++++++++
     2 files changed, 37 insertions(+)
    
    diff --git a/browser.py b/browser.py
    index de546f2..99b05d4 100644
    a b import globalhistory 
    3939import downloadmanager
    4040from pdfviewer import PDFTabPage
    4141
     42from webactivity import NORMAL_CURSOR, WATCH_CURSOR
     43
    4244ZOOM_ORIGINAL = 1.0
    4345_ZOOM_AMOUNT = 0.1
    4446_LIBRARY_PATH = '/usr/share/library-common/index.html'
    class TabbedView(BrowserNotebook): 
    188190        self.set_current_page(next_index)
    189191        tab_page.setup(url)
    190192
     193    def __load_status_changed_cb(self, widget, param):
     194        # Do not change the cursor if the load-status changed is not
     195        # on the current browser
     196        if self.props.current_browser != widget:
     197            return
     198
     199        status = widget.get_load_status()
     200        if status in (WebKit.LoadStatus.PROVISIONAL,
     201                      WebKit.LoadStatus.COMMITTED,
     202                      WebKit.LoadStatus.FIRST_VISUALLY_NON_EMPTY_LAYOUT):
     203            self.get_window().set_cursor(WATCH_CURSOR)
     204        elif status in (WebKit.LoadStatus.FAILED,
     205                        WebKit.LoadStatus.FINISHED):
     206            self.get_window().set_cursor(NORMAL_CURSOR)
     207
    191208    def add_tab(self, next_to_current=False):
    192209        browser = Browser()
    193210        browser.connect('new-tab', self.__new_tab_cb)
    194211        browser.connect('open-pdf', self.__open_pdf_in_new_tab_cb)
     212        browser.connect('notify::load-status', self.__load_status_changed_cb)
    195213
    196214        if next_to_current:
    197215            self._insert_tab_next(browser)
    class TabbedView(BrowserNotebook): 
    318336                browser = Browser()
    319337                browser.connect('new-tab', self.__new_tab_cb)
    320338                browser.connect('open-pdf', self.__open_pdf_in_new_tab_cb)
     339                browser.connect('notify::load-status',
     340                                self.__load_status_changed_cb)
    321341                self._append_tab(browser)
    322342                browser.set_history(tab_history)
    323343
    class TabLabel(Gtk.HBox): 
    404424
    405425    def __load_status_changed_cb(self, widget, param):
    406426        status = widget.get_load_status()
     427
    407428        if status == WebKit.LoadStatus.FAILED:
    408429            self._label.set_text(self._title)
    409430        elif WebKit.LoadStatus.PROVISIONAL <= status \
  • webactivity.py

    diff --git a/webactivity.py b/webactivity.py
    index 24f3b44..88555e6 100644
    a b from sugar3.graphics.toolbarbox import ToolbarButton 
    5454
    5555PROFILE_VERSION = 2
    5656
     57NORMAL_CURSOR = Gdk.Cursor(Gdk.CursorType.LEFT_PTR)
     58WATCH_CURSOR = Gdk.Cursor(Gdk.CursorType.WATCH)
     59
    5760_profile_version = 0
    5861_profile_path = os.path.join(activity.get_activity_root(), 'data/gecko')
    5962_version_file = os.path.join(_profile_path, 'version')
    class WebActivity(activity.Activity): 
    169172        self._force_close = False
    170173        self._tabbed_view = TabbedView()
    171174        self._tabbed_view.connect('focus-url-entry', self._on_focus_url_entry)
     175        self._tabbed_view.connect('switch-page', self.__switch_page_cb)
    172176
    173177        self._tray = HTray()
    174178        self.set_tray(self._tray, Gtk.PositionType.BOTTOM)
    class WebActivity(activity.Activity): 
    596600            downloadmanager.remove_all_downloads()
    597601            self.close()
    598602
     603    def __switch_page_cb(self, tabbed_view, page, page_num):
     604        browser = page._browser
     605        status = browser.get_load_status()
     606
     607        if status in (WebKit.LoadStatus.COMMITTED,
     608                      WebKit.LoadStatus.FIRST_VISUALLY_NON_EMPTY_LAYOUT):
     609            self.get_window().set_cursor(WATCH_CURSOR)
     610        elif status in (WebKit.LoadStatus.PROVISIONAL,
     611                        WebKit.LoadStatus.FAILED,
     612                        WebKit.LoadStatus.FINISHED):
     613            self.get_window().set_cursor(NORMAL_CURSOR)
     614
    599615    def get_document_path(self, async_cb, async_err_cb):
    600616        browser = self._tabbed_view.props.current_browser
    601617        browser.get_source(async_cb, async_err_cb)