Commit 07070288 authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

[GTK] [WK2] Add favicon support to the MiniBrowser

https://bugs.webkit.org/show_bug.cgi?id=98063

Patch by Alberto Garcia <agarcia@igalia.com> on 2012-10-03
Reviewed by Carlos Garcia Campos.

Set the icon in the URI text entry using the favicon property of
the WebKitWebView.

* MiniBrowser/gtk/BrowserWindow.c:
(_BrowserWindow):
(updateUriEntryIcon):
(uriEntryTextChanged):
(faviconChanged):
(browserWindowFinalize):
(browser_window_init):
(browserWindowConstructed):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130282 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent fe1e759f
2012-10-03 Alberto Garcia <agarcia@igalia.com>
[GTK] [WK2] Add favicon support to the MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=98063
Reviewed by Carlos Garcia Campos.
Set the icon in the URI text entry using the favicon property of
the WebKitWebView.
* MiniBrowser/gtk/BrowserWindow.c:
(_BrowserWindow):
(updateUriEntryIcon):
(uriEntryTextChanged):
(faviconChanged):
(browserWindowFinalize):
(browser_window_init):
(browserWindowConstructed):
2012-10-03 Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
[Qt][DRT] Add support for overriding the "WebKitDisplayImagesKey" preference.
......
......@@ -51,6 +51,7 @@ struct _BrowserWindow {
GtkWidget *settingsDialog;
WebKitWebView *webView;
GtkWidget *downloadsBar;
GdkPixbuf *favicon;
};
struct _BrowserWindowClass {
......@@ -348,6 +349,33 @@ static void webViewZoomLevelChanged(GObject *object, GParamSpec *paramSpec, Brow
browserWindowUpdateZoomActions(window);
}
static void updateUriEntryIcon(BrowserWindow *window)
{
GtkEntry *entry = GTK_ENTRY(window->uriEntry);
if (window->favicon)
gtk_entry_set_icon_from_pixbuf(entry, GTK_ENTRY_ICON_PRIMARY, window->favicon);
else
gtk_entry_set_icon_from_stock(entry, GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_NEW);
}
static void faviconChanged(GObject *object, GParamSpec *paramSpec, BrowserWindow *window)
{
GdkPixbuf *favicon = NULL;
cairo_surface_t *surface = webkit_web_view_get_favicon(window->webView);
if (surface) {
int width = cairo_image_surface_get_width(surface);
int height = cairo_image_surface_get_height(surface);
favicon = gdk_pixbuf_get_from_surface(surface, 0, 0, width, height);
}
if (window->favicon)
g_object_unref(window->favicon);
window->favicon = favicon;
updateUriEntryIcon(window);
}
static void zoomInCallback(BrowserWindow *window)
{
gdouble zoomLevel = webkit_web_view_get_zoom_level(window->webView) * zoomStep;
......@@ -362,6 +390,12 @@ static void zoomOutCallback(BrowserWindow *window)
static void browserWindowFinalize(GObject *gObject)
{
BrowserWindow *window = BROWSER_WINDOW(gObject);
if (window->favicon) {
g_object_unref(window->favicon);
window->favicon = NULL;
}
G_OBJECT_CLASS(browser_window_parent_class)->finalize(gObject);
if (g_atomic_int_dec_and_test(&windowCount))
......@@ -403,6 +437,8 @@ static void browser_window_init(BrowserWindow *window)
window->uriEntry = gtk_entry_new();
g_signal_connect_swapped(window->uriEntry, "activate", G_CALLBACK(activateUriEntryCallback), (gpointer)window);
gtk_entry_set_icon_activatable(GTK_ENTRY(window->uriEntry), GTK_ENTRY_ICON_PRIMARY, FALSE);
updateUriEntryIcon(window);
GtkWidget *toolbar = gtk_toolbar_new();
window->toolbar = toolbar;
......@@ -476,6 +512,7 @@ static void browserWindowConstructed(GObject *gObject)
g_signal_connect(window->webView, "permission-request", G_CALLBACK(webViewDecidePermissionRequest), window);
g_signal_connect(window->webView, "mouse-target-changed", G_CALLBACK(webViewMouseTargetChanged), window);
g_signal_connect(window->webView, "notify::zoom-level", G_CALLBACK(webViewZoomLevelChanged), window);
g_signal_connect(window->webView, "notify::favicon", G_CALLBACK(faviconChanged), window);
g_signal_connect(webkit_web_view_get_context(window->webView), "download-started", G_CALLBACK(downloadStarted), window);
......
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