Fix favicon support properly
This commit is contained in:
parent
aecac9b748
commit
762babfeee
1 changed files with 12 additions and 11 deletions
|
@ -943,10 +943,12 @@ midori_web_view_get_link_uri (MidoriWebView* web_view)
|
||||||
GdkPixbuf*
|
GdkPixbuf*
|
||||||
midori_web_view_get_icon (MidoriWebView* web_view)
|
midori_web_view_get_icon (MidoriWebView* web_view)
|
||||||
{
|
{
|
||||||
|
#if GLIB_CHECK_VERSION (2, 16, 0)
|
||||||
GFile* file;
|
GFile* file;
|
||||||
GFile* icon_file;
|
GFile* icon_file;
|
||||||
GIcon* icon;
|
GIcon* icon;
|
||||||
GInputStream* stream;
|
GInputStream* stream;
|
||||||
|
#endif
|
||||||
GdkPixbuf* pixbuf;
|
GdkPixbuf* pixbuf;
|
||||||
|
|
||||||
g_return_val_if_fail (MIDORI_IS_WEB_VIEW (web_view), NULL);
|
g_return_val_if_fail (MIDORI_IS_WEB_VIEW (web_view), NULL);
|
||||||
|
@ -955,23 +957,22 @@ midori_web_view_get_icon (MidoriWebView* web_view)
|
||||||
file = g_file_new_for_uri (web_view->uri ? web_view->uri : "");
|
file = g_file_new_for_uri (web_view->uri ? web_view->uri : "");
|
||||||
icon_file = g_file_get_child (file, "favicon.ico");
|
icon_file = g_file_get_child (file, "favicon.ico");
|
||||||
icon = g_file_icon_new (icon_file);
|
icon = g_file_icon_new (icon_file);
|
||||||
if (icon)
|
if (icon && (stream = g_loadable_icon_load (G_LOADABLE_ICON (icon),
|
||||||
stream = g_loadable_icon_load (G_LOADABLE_ICON (icon),
|
|
||||||
GTK_ICON_SIZE_MENU,
|
GTK_ICON_SIZE_MENU,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL)))
|
||||||
else
|
|
||||||
stream = NULL;
|
|
||||||
if (stream)
|
|
||||||
{
|
{
|
||||||
pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
|
pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
|
||||||
g_object_unref (stream);
|
g_object_unref (stream);
|
||||||
}
|
}
|
||||||
g_object_unref (icon);
|
else
|
||||||
g_object_unref (icon_file);
|
|
||||||
g_object_unref (file);
|
|
||||||
if (!stream)
|
|
||||||
#endif
|
#endif
|
||||||
pixbuf = gtk_widget_render_icon (GTK_WIDGET (web_view),
|
pixbuf = gtk_widget_render_icon (GTK_WIDGET (web_view),
|
||||||
GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL);
|
GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL);
|
||||||
|
#if GLIB_CHECK_VERSION (2, 16, 0)
|
||||||
|
if (icon)
|
||||||
|
g_object_unref (icon);
|
||||||
|
g_object_unref (icon_file);
|
||||||
|
g_object_unref (file);
|
||||||
|
#endif
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue