Add addon: favicon

This commit is contained in:
Fierelier 2023-01-10 22:08:35 +01:00
parent 8843478290
commit 939d0cfb53
4 changed files with 27 additions and 0 deletions

View File

@ -1,5 +1,6 @@
userModules
title
favicon
contextMenu
contextMenuWindow
contextMenuGo

View File

@ -0,0 +1,26 @@
import gi
gi.require_version("Gtk","3.0")
from gi.repository import Gdk
import cairo
eventHandler = mfp.Bunch()
defaultIcon = cairo.ImageSurface.create_from_png(mfp.require("config").find(mfp.p("addon","favicon","default.png")))
defaultIcon = Gdk.pixbuf_get_from_surface(defaultIcon,0,0,defaultIcon.get_width(),defaultIcon.get_height())
def onFavicon(webView,_):
window = webView.get_toplevel()
favicon = webView.get_favicon()
if favicon == None:
window.set_icon(defaultIcon)
return
favicon = Gdk.pixbuf_get_from_surface(favicon,0,0,favicon.get_width(),favicon.get_height())
window.set_icon(favicon)
mfp.require("browser").webContext.set_favicon_database_directory(None)
def onWebviewCreated(webView):
onFavicon(webView,None)
webView.connect("notify::favicon",onFavicon)
eventHandler["webview:created"] = onWebviewCreated

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.