Commit 95d14e6c authored by Cédric Bellegarde's avatar Cédric Bellegarde

Code cleanup

parent 325b8c04
Pipeline #58291 passed with stage
in 13 minutes and 30 seconds
......@@ -446,7 +446,7 @@ class WebView(WebKit2.WebView):
@param view as View
"""
WebViewErrors.__init__(self)
WebViewNavigation.__init__(self, related_view)
WebViewNavigation.__init__(self)
WebViewSignals.__init__(self)
self.__context = context
WebViewArtwork.__init__(self)
......@@ -469,51 +469,53 @@ class WebView(WebKit2.WebView):
self.set_hexpand(True)
self.set_vexpand(True)
self.clear_text_entry()
# Set settings
settings = self.get_settings()
system = Gio.Settings.new("org.gnome.desktop.interface")
animations = system.get_value("enable-animations")
settings.set_property("enable-java",
App().settings.get_value('enable-plugins'))
settings.set_property("enable-plugins",
App().settings.get_value('enable-plugins'))
settings.set_property("minimum-font-size",
App().settings.get_value(
"min-font-size").get_int32())
if App().settings.get_value("use-system-fonts"):
self.__set_system_fonts(settings, system)
else:
settings.set_property("monospace-font-family",
App().settings.get_value(
"font-monospace").get_string())
settings.set_property("sans-serif-font-family",
App().settings.get_value(
"font-sans-serif").get_string())
settings.set_property("serif-font-family",
if related_view is None:
# Set settings
settings = self.get_settings()
system = Gio.Settings.new("org.gnome.desktop.interface")
animations = system.get_value("enable-animations")
settings.set_property("enable-java",
App().settings.get_value('enable-plugins'))
settings.set_property("enable-plugins",
App().settings.get_value('enable-plugins'))
settings.set_property("minimum-font-size",
App().settings.get_value(
"font-serif").get_string())
settings.set_property("auto-load-images", True)
settings.set_property("enable-site-specific-quirks", True)
settings.set_property("allow-universal-access-from-file-urls", False)
settings.set_property("allow-file-access-from-file-urls", False)
settings.set_property("enable-javascript", True)
settings.set_property("enable-media-stream", True)
settings.set_property("enable-mediasource", False)
autoplay_videos = App().settings.get_value('autoplay-videos')
settings.set_property("media-playback-requires-user-gesture",
not autoplay_videos)
settings.set_property("enable-developer-extras",
App().settings.get_value("developer-extras"))
settings.set_property("enable-offline-web-application-cache", True)
settings.set_property("enable-page-cache", True)
settings.set_property("enable-resizable-text-areas", True)
settings.set_property("enable-smooth-scrolling", animations)
settings.set_property("enable-webaudio", True)
settings.set_property("enable-webgl", True)
settings.set_property("javascript-can-access-clipboard", True)
settings.set_property("javascript-can-open-windows-automatically",
True)
settings.set_property("media-playback-allows-inline", True)
"min-font-size").get_int32())
if App().settings.get_value("use-system-fonts"):
self.__set_system_fonts(settings, system)
else:
settings.set_property("monospace-font-family",
App().settings.get_value(
"font-monospace").get_string())
settings.set_property("sans-serif-font-family",
App().settings.get_value(
"font-sans-serif").get_string())
settings.set_property("serif-font-family",
App().settings.get_value(
"font-serif").get_string())
settings.set_property("auto-load-images", True)
settings.set_property("enable-site-specific-quirks", True)
settings.set_property("allow-universal-access-from-file-urls",
False)
settings.set_property("allow-file-access-from-file-urls", False)
settings.set_property("enable-javascript", True)
settings.set_property("enable-media-stream", True)
settings.set_property("enable-mediasource", False)
autoplay_videos = App().settings.get_value('autoplay-videos')
settings.set_property("media-playback-requires-user-gesture",
not autoplay_videos)
settings.set_property("enable-developer-extras",
App().settings.get_value("developer-extras"))
settings.set_property("enable-offline-web-application-cache", True)
settings.set_property("enable-page-cache", True)
settings.set_property("enable-resizable-text-areas", True)
settings.set_property("enable-smooth-scrolling", animations)
settings.set_property("enable-webaudio", True)
settings.set_property("enable-webgl", True)
settings.set_property("javascript-can-access-clipboard", True)
settings.set_property("javascript-can-open-windows-automatically",
True)
settings.set_property("media-playback-allows-inline", True)
self.connect("create", self.__on_create)
self.connect("load-changed", self._on_load_changed)
......
......@@ -15,8 +15,7 @@ from gi.repository import GLib, Gtk, Gio, WebKit2, Gdk
from urllib.parse import urlparse
from time import time
from eolie.define import App, LoadingType, EOLIE_DATA_PATH
from eolie.define import COOKIES_PATH
from eolie.define import App, LoadingType
from eolie.utils import get_ftp_cmd
from eolie.logger import Logger
......@@ -32,16 +31,10 @@ class WebViewNavigation:
"multipart/related", "application/x-mimearchive",
"application/x-extension-html"]
def __init__(self, related_view):
def __init__(self):
"""
Init navigation
@param related_view as WebView
"""
self.__related_view = related_view
if related_view is None:
self.__profile = None
else:
self.__profile = related_view.profile
self.__insecure_content_detected = False
self.connect("decide-policy", self.__on_decide_policy)
self.connect("insecure-content-detected",
......@@ -51,8 +44,6 @@ class WebViewNavigation:
self.connect("notify::title", self.__on_title_changed)
self.connect("notify::uri", self.__on_uri_changed)
self.__switch_profile(None)
def load_uri(self, uri):
"""
Load uri
......@@ -96,14 +87,6 @@ class WebViewNavigation:
self.stop_loading()
GLib.idle_add(WebKit2.WebView.load_uri, self, uri)
@property
def profile(self):
"""
Get profile
@return str
"""
return self.__profile
#######################
# PROTECTED #
#######################
......@@ -123,19 +106,6 @@ class WebViewNavigation:
self.__update_bookmark_metadata(self.uri)
elif event == WebKit2.LoadEvent.REDIRECTED:
self.__update_bookmark_metadata(self.uri)
# Block ads, useful for some site
if App().settings.get_value("adblock") and\
webview.__related_view is not None and\
parsed.scheme in ["http", "https"] and\
not App().adblock_exceptions.find_parsed(parsed):
if App().adblock.is_netloc_blocked(parsed.netloc) or\
App().adblock.is_uri_blocked(self.uri,
parsed.netloc):
Logger.debug("WebView::__wait_for_uri(): blocking %s",
self.uri)
webview.stop_loading()
self._window.container.close_view(self.view)
return
elif event == WebKit2.LoadEvent.COMMITTED:
self.emit("uri-changed", self.uri)
App().history.set_page_state(self.uri)
......@@ -188,29 +158,11 @@ class WebViewNavigation:
App().bookmarks.set_access_time(uri, round(time(), 2))
App().bookmarks.set_more_popular(uri)
def __switch_profile(self, uri):
"""
Handle cookies manager
@param uri as str
"""
if self.ephemeral or self.__related_view is not None:
return
# profile = App().websettings.get_profile(uri)
profile = "default"
if self.__profile != profile:
self.__profile = profile
cookie_manager = self.get_context().get_cookie_manager()
path = COOKIES_PATH % (EOLIE_DATA_PATH, profile)
cookie_manager.set_persistent_storage(
path,
WebKit2.CookiePersistentStorage.SQLITE)
def __set_adblock(self, uri):
"""
Set adblocker
@param uri as str
"""
return
parsed = urlparse(uri)
http_scheme = parsed.scheme in ["http", "https"]
self.content_manager.remove_all_style_sheets()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment