Ticket #1434: 0001-Escape-key-stops-page-loading-SL-3373.patch

File 0001-Escape-key-stops-page-loading-SL-3373.patch, 2.6 KB (added by humitos, 7 years ago)

v2 - considers full screen mode

  • webactivity.py

    From f8aedef538060c2f6b180a4d7396240491827c38 Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Mon, 24 Sep 2012 15:52:04 -0300
    Subject: [PATCH Browse] Escape key stops page loading SL #3373
    
    Allow Esc key to stop page loading. If the activity is on fullscreen
    mode, the first time that Esc key is pressed the page loading will
    stop and the second time it will call unfullscreen mode.
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     webactivity.py | 30 ++++++++++++++++++++++++++++++
     1 file changed, 30 insertions(+)
    
    diff --git a/webactivity.py b/webactivity.py
    index 24f3b44..cdd556f 100644
    a b class WebActivity(activity.Activity): 
    204204        self.model = Model()
    205205        self.model.connect('add_link', self._add_link_model_cb)
    206206
     207        # HACK to allow Escape key stop loading on fullscreen mode
     208        # http://bugs.sugarlabs.org/ticket/1434
     209        self.disconnect_by_func(self._Window__key_press_cb)
    207210        self.connect('key-press-event', self._key_press_cb)
    208211
    209212        if handle.uri:
    class WebActivity(activity.Activity): 
    426429        self._tabbed_view.load_homepage()
    427430
    428431    def _key_press_cb(self, widget, event):
     432        # HACK: this is the hacked version of
     433        # sugar3.graphics.Window.__key_press_cb function to allow stop
     434        # loading on fullscreen
     435        def __key_press_cb(widget, event):
     436            status = self._tabbed_view.props.current_browser.get_load_status()
     437            loading = WebKit.LoadStatus.PROVISIONAL <= status \
     438                < WebKit.LoadStatus.FINISHED
     439
     440            key = Gdk.keyval_name(event.keyval)
     441            if event.get_state() & Gdk.ModifierType.MOD1_MASK:
     442                if self.tray is not None and key == 'space':
     443                    self.tray.props.visible = not self.tray.props.visible
     444                    return True
     445            elif key == 'Escape' and self._is_fullscreen and \
     446                    self.props.enable_fullscreen_mode and \
     447                    not loading:
     448                self.unfullscreen()
     449                return True
     450            return False
     451
     452        # Call the original sugar3.graphics.Window.__key_press_cb function
     453        __key_press_cb(widget, event)
     454
    429455        key_name = Gdk.keyval_name(event.keyval)
    430456        browser = self._tabbed_view.props.current_browser
    431457
    class WebActivity(activity.Activity): 
    482508
    483509            return True
    484510
     511        elif key_name == 'Escape':
     512            _logger.debug('keyboard: Stop loading')
     513            browser.stop_loading()
     514
    485515        return False
    486516
    487517    def _add_link(self):