def __init__(self, activity, state=None):
        WebKit2.WebView.__init__(self)
        self._activity = activity
        web_settings = self.get_settings()

        # "Experimental" features that Epiphany enabled by default
        web_settings.props.enable_webgl = True
        web_settings.props.enable_webaudio = True

        # Add SugarLabs user agent:
        identifier = ' SugarLabs/' + self.CURRENT_SUGAR_VERSION
        web_settings.props.user_agent += identifier

        self.set_settings(web_settings)

        # This property is used to set the title immediatly the user
        # presses Enter on the URL Entry
        self.loading_uri = None

        self.security_status = None

        # Reference to the global history and callbacks to handle it:
        self._global_history = globalhistory.get_global_history()
        self.connect('load-changed', self.__load_changed_cb)
        self.connect('notify::title', self.__title_changed_cb)
        self.connect('decide-policy', self.__decide_policy_cb)
        self.connect('permission-request', self.__permission_request_cb)
        self.connect('run-file-chooser', self.__run_file_chooser)
        self.connect('load-failed', self.__load_failed_cb)

        self._inject_media_style = False
        self.props.zoom_level = ZOOM_ORIGINAL

        ContentInvoker(self)

        if state is not None:
            gbytes = GLib.Bytes(b64decode(state))
            session_state = WebKit2.WebViewSessionState(gbytes)
            self.restore_session_state(session_state)
            # this is what epiphany does:
            # https://github.com/GNOME/epiphany/blob/
            # 04e7811c32ba8a2c980a77aac1316b77f0969057/src/ephy-session.c#L280
            bf_list = self.get_back_forward_list()
            item = bf_list.get_current_item()
            if item is not None:
                self.go_to_back_forward_list_item(item)

        # we use this if the browser crashes
        self.cached_uri = None
    def __init__(self, activity, state=None):
        WebKit2.WebView.__init__(self)
        self._activity = activity
        web_settings = self.get_settings()

        # "Experimental" features that Epiphany enabled by default
        web_settings.props.enable_webgl = True
        web_settings.props.enable_webaudio = True

        # Add SugarLabs user agent:
        identifier = ' SugarLabs/' + self.CURRENT_SUGAR_VERSION
        web_settings.props.user_agent += identifier

        self.set_settings(web_settings)

        # This property is used to set the title immediatly the user
        # presses Enter on the URL Entry
        self.loading_uri = None

        self.security_status = None

        # Reference to the global history and callbacks to handle it:
        self._global_history = globalhistory.get_global_history()
        self.connect('load-changed', self.__load_changed_cb)
        self.connect('notify::title', self.__title_changed_cb)
        self.connect('decide-policy', self.__decide_policy_cb)
        self.connect('permission-request', self.__permission_request_cb)
        self.connect('run-file-chooser', self.__run_file_chooser)
        self.connect('load-failed', self.__load_failed_cb)

        self._inject_media_style = False
        self.props.zoom_level = ZOOM_ORIGINAL

        ContentInvoker(self)

        if state is not None:
            gbytes = GLib.Bytes(b64decode(state))
            session_state = WebKit2.WebViewSessionState(gbytes)
            self.restore_session_state(session_state)
            # this is what epiphany does:
            # https://github.com/GNOME/epiphany/blob/
            # 04e7811c32ba8a2c980a77aac1316b77f0969057/src/ephy-session.c#L280
            bf_list = self.get_back_forward_list()
            item = bf_list.get_current_item()
            if item is not None:
                self.go_to_back_forward_list_item(item)

        # we use this if the browser crashes
        self.cached_uri = None
Beispiel #3
0
    def __init__(self):
        WebKit.WebView.__init__(self)

        web_settings = self.get_settings()

        # Add SugarLabs user agent:
        identifier = ' SugarLabs/' + self.CURRENT_SUGAR_VERSION
        web_settings.props.user_agent += identifier

        # Change font size based in the GtkSettings font size.  The
        # gtk-font-name property is a string with format '[font name]
        # [font size]' like 'Sans Serif 10'.
        gtk_settings = Gtk.Settings.get_default()
        gtk_font_name = gtk_settings.get_property('gtk-font-name')
        gtk_font_size = float(gtk_font_name.split()[-1])
        web_settings.props.default_font_size = gtk_font_size * 1.2
        web_settings.props.default_monospace_font_size = \
            gtk_font_size * 1.2 - 2

        self.set_settings(web_settings)

        # Scale text and graphics:
        self.set_full_content_zoom(True)

        # This property is used to set the title immediatly the user
        # presses Enter on the URL Entry
        self.loading_uri = None

        self.security_status = None

        # Reference to the global history and callbacks to handle it:
        self._global_history = globalhistory.get_global_history()
        self.connect('notify::load-status', self.__load_status_changed_cb)
        self.connect('notify::title', self.__title_changed_cb)
        self.connect('download-requested', self.__download_requested_cb)
        self.connect('mime-type-policy-decision-requested',
                     self.__mime_type_policy_cb)
        self.connect('load-error', self.__load_error_cb)

        self._inject_media_style = False

        ContentInvoker(self)

        try:
            self.connect('run-file-chooser', self.__run_file_chooser)
        except TypeError:
            # Only present in WebKit1 > 1.9.3 and WebKit2
            pass
Beispiel #4
0
    def __init__(self):
        WebKit.WebView.__init__(self)

        web_settings = self.get_settings()

        # Add SugarLabs user agent:
        identifier = ' SugarLabs/' + self.CURRENT_SUGAR_VERSION
        web_settings.props.user_agent += identifier

        # Change font size based in the GtkSettings font size.  The
        # gtk-font-name property is a string with format '[font name]
        # [font size]' like 'Sans Serif 10'.
        gtk_settings = Gtk.Settings.get_default()
        gtk_font_name = gtk_settings.get_property('gtk-font-name')
        gtk_font_size = float(gtk_font_name.split()[-1])
        web_settings.props.default_font_size = gtk_font_size * 1.2
        web_settings.props.default_monospace_font_size = \
            gtk_font_size * 1.2 - 2

        self.set_settings(web_settings)

        # Scale text and graphics:
        self.set_full_content_zoom(True)

        # This property is used to set the title immediatly the user
        # presses Enter on the URL Entry
        self.loading_uri = None

        self.security_status = None

        # Reference to the global history and callbacks to handle it:
        self._global_history = globalhistory.get_global_history()
        self.connect('notify::load-status', self.__load_status_changed_cb)
        self.connect('notify::title', self.__title_changed_cb)
        self.connect('download-requested', self.__download_requested_cb)
        self.connect('mime-type-policy-decision-requested',
                     self.__mime_type_policy_cb)
        self.connect('load-error', self.__load_error_cb)

        self._inject_media_style = False

        ContentInvoker(self)

        try:
            self.connect('run-file-chooser', self.__run_file_chooser)
        except TypeError:
            # Only present in WebKit1 > 1.9.3 and WebKit2
            pass