Ticket #1434: escape_browse.patch

File escape_browse.patch, 2.2 KB (added by erikos, 7 years ago)

use overwrite method

  • webactivity.py

    diff --git a/webactivity.py b/webactivity.py
    index 0fbf858..732dbde 100644
    a b class WebActivity(activity.Activity): 
    207207        self.model = Model()
    208208        self.model.connect('add_link', self._add_link_model_cb)
    209209
    210         # HACK to allow Escape key stop loading on fullscreen mode
    211         # http://bugs.sugarlabs.org/ticket/1434
    212         self.disconnect_by_func(self._Window__key_press_cb)
    213210        self.connect('key-press-event', self._key_press_cb)
    214211
    215212        if handle.uri:
    class WebActivity(activity.Activity): 
    431428    def _go_home_button_cb(self, button):
    432429        self._tabbed_view.load_homepage()
    433430
    434     def _key_press_cb(self, widget, event):
    435         # HACK: this is the hacked version of
    436         # sugar3.graphics.Window.__key_press_cb function to allow stop
    437         # loading on fullscreen
    438         def __key_press_cb(widget, event):
    439             status = self._tabbed_view.props.current_browser.get_load_status()
    440             loading = WebKit.LoadStatus.PROVISIONAL <= status \
    441                 < WebKit.LoadStatus.FINISHED
    442 
    443             key = Gdk.keyval_name(event.keyval)
    444             if event.get_state() & Gdk.ModifierType.MOD1_MASK:
    445                 if self.tray is not None and key == 'space':
    446                     self.tray.props.visible = not self.tray.props.visible
    447                     return True
    448             elif key == 'Escape' and self._is_fullscreen and \
    449                     self.props.enable_fullscreen_mode and \
    450                     not loading:
    451                 self.unfullscreen()
    452                 return True
    453             return False
     431    def escape_fullscreen(self):
     432        status = self._tabbed_view.props.current_browser.get_load_status()
     433        loading = WebKit.LoadStatus.PROVISIONAL <= status \
     434            < WebKit.LoadStatus.FINISHED
    454435
    455         # Call the original sugar3.graphics.Window.__key_press_cb function
    456         __key_press_cb(widget, event)
     436        if loading:
     437            browser.stop_loading()
     438        else:
     439            activity.Activity.escape_fullscreen(self)
    457440
     441    def _key_press_cb(self, widget, event):
    458442        key_name = Gdk.keyval_name(event.keyval)
    459443        browser = self._tabbed_view.props.current_browser
    460444