Commit ee21ee99 authored by Cédric Bellegarde's avatar Cédric Bellegarde

Only use webview favicon in widgets

parent 7a51f4ca
......@@ -16,6 +16,7 @@ from gettext import gettext as _
from eolie.label_indicator import LabelIndicator
from eolie.define import App, ArtSize
from eolie.utils import resize_favicon
class PagesManagerChild(Gtk.FlowBoxChild):
......@@ -77,7 +78,7 @@ class PagesManagerChild(Gtk.FlowBoxChild):
view.connect("destroying", self.__on_view_destroying)
self.__view.webview.connect("snapshot-changed",
self.__on_webview_snapshot_changed)
self.__view.webview.connect("favicon-changed",
self.__view.webview.connect("notify::favicon",
self.__on_webview_favicon_changed)
self.__view.webview.connect("notify::is-playing-audio",
self.__on_webview_notify_is_playing_audio)
......@@ -242,34 +243,27 @@ class PagesManagerChild(Gtk.FlowBoxChild):
"""
self.__on_webview_favicon_changed(webview)
def __on_webview_favicon_changed(self, webview, surface=None):
def __on_webview_favicon_changed(self, webview, *ignore):
"""
Set favicon
@param webview as WebView
@param surface as cairo.Surface
"""
image = self.__close_button.get_image()
if webview.is_playing_audio():
image.set_from_icon_name("audio-speakers-symbolic",
Gtk.IconSize.INVALID)
return
if surface is not None:
image.set_from_surface(surface)
return
favicon_path = App().art.get_favicon_path(webview.uri)
if favicon_path is not None:
image.set_from_file(favicon_path)
return
artwork = App().art.get_icon_theme_artwork(webview.uri,
webview.ephemeral)
if artwork is not None:
image.set_from_icon_name(artwork, Gtk.IconSize.INVALID)
return
image.set_from_icon_name("applications-internet", Gtk.IconSize.INVALID)
else:
surface = webview.get_favicon()
if surface is not None:
image.set_from_surface(resize_favicon(surface))
else:
image.set_from_icon_name("applications-internet",
Gtk.IconSize.INVALID)
def __on_webview_title_changed(self, webview, title):
"""
......
......@@ -14,6 +14,7 @@ from gi.repository import Gtk, Gdk, GLib, Pango, GObject, WebKit2
from eolie.label_indicator import LabelIndicator
from eolie.define import App, ArtSize
from eolie.utils import resize_favicon
from eolie.logger import Logger
......@@ -192,7 +193,7 @@ class SitesManagerChild(Gtk.ListBoxRow):
if view not in self.__views:
self.__views.append(view)
view.webview.connect("shown", self.__on_webview_shown)
view.webview.connect("favicon-changed",
view.webview.connect("notify::favicon",
self.__on_webview_favicon_changed)
self.update_label()
self.__indicator_label.update_count(True)
......@@ -414,23 +415,22 @@ class SitesManagerChild(Gtk.ListBoxRow):
webview.view != self.__window.container.current:
return
if not webview.ephemeral:
if surface is not None:
self.__image.set_from_surface(surface)
return
favicon_path = App().art.get_favicon_path(webview.uri)
if favicon_path is not None:
self.__image.set_from_file(favicon_path)
return
if webview.is_playing_audio():
self.__image.set_from_icon_name("audio-speakers-symbolic",
Gtk.IconSize.INVALID)
return
artwork = App().art.get_icon_theme_artwork(webview.uri,
webview.ephemeral)
if artwork is not None:
self.__image.set_from_icon_name(artwork,
Gtk.IconSize.INVALID)
self.__image.set_from_icon_name(artwork, Gtk.IconSize.INVALID)
else:
self.__image.set_from_icon_name("applications-internet",
Gtk.IconSize.INVALID)
surface = webview.get_favicon()
if surface is not None:
self.__image.set_from_surface(resize_favicon(surface))
else:
self.__image.set_from_icon_name("applications-internet",
Gtk.IconSize.INVALID)
def __on_query_tooltip(self, widget, x, y, keyboard, tooltip):
"""
......
......@@ -212,10 +212,8 @@ class WebViewArtwork:
"""
if self.ephemeral:
return
self.__cancellable.cancel()
self.__cancellable.reset()
self.__favicon_db.get_favicon(uri,
self.__cancellable,
None,
self.__on_get_favicon,
uri,
None)
......
......@@ -47,7 +47,6 @@ class WebViewNavigation:
self.__on_insecure_content_detected)
self.connect("run-as-modal", self.__on_run_as_modal)
self.connect("permission_request", self.__on_permission_request)
self.connect("notify::favicon", self.__on_notify_favicon)
self.connect("notify::title", self.__on_title_changed)
self.connect("notify::uri", self.__on_uri_changed)
......@@ -273,7 +272,6 @@ class WebViewNavigation:
# JS bookmark (Bookmarklet)
if not uri.startswith("javascript:") and not self.error:
self.emit("uri-changed", uri)
self.set_current_favicon()
def __on_title_changed(self, webview, param):
"""
......@@ -285,14 +283,6 @@ class WebViewNavigation:
if title:
self.emit("title-changed", title)
def __on_notify_favicon(self, webview, favicon):
"""
Set favicon
@param webview as WebView
@param favicon as GObject.ParamSpec
"""
self.set_favicon()
def __on_decide_policy(self, webview, decision, decision_type):
"""
Navigation policy
......
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