Add addon: favicon
This commit is contained in:
parent
8843478290
commit
939d0cfb53
|
@ -1,5 +1,6 @@
|
|||
userModules
|
||||
title
|
||||
favicon
|
||||
contextMenu
|
||||
contextMenuWindow
|
||||
contextMenuGo
|
|
@ -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.
Loading…
Reference in New Issue