aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorManuel Rego Casasnovas <rego@igalia.com>2013-02-26 00:11:06 +0800
committerXan Lopez <xan@igalia.com>2013-03-06 18:37:53 +0800
commitf296357b33972af85e80de6ec42ff135197e3cb1 (patch)
treebecc455e6790ba961c897c035e8b6d27340a9ec3 /src
parentccb6b7caea1dd7a37691a57d3eeae968f100bc4e (diff)
downloadgsoc2013-epiphany-f296357b33972af85e80de6ec42ff135197e3cb1.tar
gsoc2013-epiphany-f296357b33972af85e80de6ec42ff135197e3cb1.tar.gz
gsoc2013-epiphany-f296357b33972af85e80de6ec42ff135197e3cb1.tar.bz2
gsoc2013-epiphany-f296357b33972af85e80de6ec42ff135197e3cb1.tar.lz
gsoc2013-epiphany-f296357b33972af85e80de6ec42ff135197e3cb1.tar.xz
gsoc2013-epiphany-f296357b33972af85e80de6ec42ff135197e3cb1.tar.zst
gsoc2013-epiphany-f296357b33972af85e80de6ec42ff135197e3cb1.zip
Implement get best web app icon in WebKit2
https://bugzilla.gnome.org/show_bug.cgi?id=694091
Diffstat (limited to 'src')
-rw-r--r--src/window-commands.c110
1 files changed, 77 insertions, 33 deletions
diff --git a/src/window-commands.c b/src/window-commands.c
index 3532d5adc..87f140e90 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -1,4 +1,5 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* vim: set sw=8 ts=8 sts=8 noet: */
/*
* Copyright © 2000-2004 Marco Pesenti Gritti
* Copyright © 2009 Collabora Ltd.
@@ -655,47 +656,27 @@ download_icon_and_set_image (EphyApplicationDialogData *data)
#endif
}
-
static void
-fill_default_application_image (EphyApplicationDialogData *data)
+download_icon_or_take_snapshot (EphyApplicationDialogData *data,
+ gboolean res,
+ char *uri,
+ char *color)
{
- WebKitDOMDocument *document;
- const char *base_uri;
- char *image = NULL;
- char *color = NULL;
- gboolean res;
-
- data->icon_rgba.red = 0.5;
- data->icon_rgba.green = 0.5;
- data->icon_rgba.blue = 0.5;
- data->icon_rgba.alpha = 0.3;
-
- base_uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (data->view));
-
-#ifdef HAVE_WEBKIT2
- /* TODO use web extension to get image and color */
- res = FALSE;
-#else
- document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (data->view));
- res = ephy_web_dom_utils_get_best_icon (document,
- base_uri,
- &image,
- &color);
-#endif
+ if (uri != NULL && uri[0] != '\0')
+ data->icon_href = uri;
- if (image != NULL)
+ if (color != NULL && color[0] != '\0')
{
- data->icon_href = g_strdup (image);
+ gdk_rgba_parse (&data->icon_rgba, color);
}
-
- if (color != NULL)
+ else
{
- gdk_rgba_parse (&data->icon_rgba, color);
+ data->icon_rgba.red = 0.5;
+ data->icon_rgba.green = 0.5;
+ data->icon_rgba.blue = 0.5;
+ data->icon_rgba.alpha = 0.3;
}
- g_free (image);
- g_free (color);
-
if (res)
{
download_icon_and_set_image (data);
@@ -707,6 +688,69 @@ fill_default_application_image (EphyApplicationDialogData *data)
}
}
+#ifdef HAVE_WEBKIT2
+static void
+fill_default_application_image_cb (GObject *source,
+ GAsyncResult *async_result,
+ gpointer user_data)
+{
+ EphyApplicationDialogData *data = user_data;
+ GVariant *result;
+ char *uri = NULL;
+ char *color = NULL;
+ gboolean res = FALSE;
+
+ result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source),
+ async_result,
+ NULL);
+
+ if (result)
+ {
+ g_variant_get (result, "(bss)", &res, &uri, &color);
+ g_variant_unref (result);
+ }
+
+ download_icon_or_take_snapshot (data, res, uri, color);
+}
+#endif
+
+static void
+fill_default_application_image (EphyApplicationDialogData *data)
+{
+ const char *base_uri;
+#ifdef HAVE_WEBKIT2
+ GDBusProxy *web_extension;
+#else
+ char *uri = NULL;
+ char *color = NULL;
+ gboolean res;
+#endif
+
+ base_uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (data->view));
+
+#ifdef HAVE_WEBKIT2
+ web_extension = ephy_embed_shell_get_web_extension_proxy (ephy_embed_shell_get_default ());
+ if (web_extension)
+ g_dbus_proxy_call (web_extension,
+ "GetBestWebAppIcon",
+ g_variant_new("(ts)", webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (data->view)), base_uri),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ fill_default_application_image_cb,
+ data);
+ else
+ download_icon_or_take_snapshot (data, FALSE, NULL, NULL);
+#else
+ res = ephy_web_dom_utils_get_best_icon (webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (data->view)),
+ base_uri,
+ &uri,
+ &color);
+
+ download_icon_or_take_snapshot (data, res, uri, color);
+#endif
+}
+
typedef struct {
const char *host;
const char *name;