コード例 #1
0
    def on_browser_decide_policy(self, webview, decision, decision_type):
        """
        We want to load files and links externally.
        """
        if decision_type == browser.WebKit2.PolicyDecisionType.NAVIGATION_ACTION:
            action = decision.get_navigation_action()
            if action.is_user_gesture():
                uri = action.get_request().get_uri()
                logging.info('Clicked URI "%s"' % uri)

                if urls.is_entry_reference_uri(uri):
                    self.navigate_to_referenced_entry(uri)
                else:
                    urls.open_url(uri)

                decision.ignore()

        # Stop processing this event.
        return True
コード例 #2
0
 def navigate_to_uri(self, uri):
     logging.info('Navigating to URI "%s"' % uri)
     if urls.is_entry_reference_uri(uri):
         self.navigate_to_referenced_entry(uri)
     else:
         urls.open_url(uri)