Lookup page icons via javascript
This commit is contained in:
parent
e5812d0478
commit
06bd549cb1
2 changed files with 40 additions and 27 deletions
|
@ -525,7 +525,6 @@ katze_net_load_icon (KatzeNet* net,
|
||||||
GtkWidget* widget,
|
GtkWidget* widget,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
guint i;
|
|
||||||
KatzeNetIconPriv* priv;
|
KatzeNetIconPriv* priv;
|
||||||
gchar* icon_uri;
|
gchar* icon_uri;
|
||||||
gchar* icon_file;
|
gchar* icon_file;
|
||||||
|
@ -535,22 +534,28 @@ katze_net_load_icon (KatzeNet* net,
|
||||||
|
|
||||||
g_return_val_if_fail (KATZE_IS_NET (net), NULL);
|
g_return_val_if_fail (KATZE_IS_NET (net), NULL);
|
||||||
g_return_val_if_fail (!widget || GTK_IS_WIDGET (widget), NULL);
|
g_return_val_if_fail (!widget || GTK_IS_WIDGET (widget), NULL);
|
||||||
|
g_return_val_if_fail (uri != NULL, NULL);
|
||||||
|
|
||||||
pixbuf = NULL;
|
pixbuf = NULL;
|
||||||
if (uri && (g_str_has_prefix (uri, "http://") ||
|
icon_uri = g_strdup (g_object_get_data (G_OBJECT (net), uri));
|
||||||
g_str_has_prefix (uri, "https://")))
|
g_object_set_data (G_OBJECT (net), uri, NULL);
|
||||||
|
if ((icon_uri && g_str_has_prefix (icon_uri, "http"))
|
||||||
|
|| g_str_has_prefix (uri, "http"))
|
||||||
{
|
{
|
||||||
i = 8;
|
if (!icon_uri)
|
||||||
while (uri[i] != '\0' && uri[i] != '/')
|
|
||||||
i++;
|
|
||||||
if (uri[i] == '/')
|
|
||||||
{
|
{
|
||||||
icon_uri = g_strdup (uri);
|
guint i = 8;
|
||||||
icon_uri[i] = '\0';
|
while (uri[i] != '\0' && uri[i] != '/')
|
||||||
icon_uri = g_strdup_printf ("%s/favicon.ico", icon_uri);
|
i++;
|
||||||
|
if (uri[i] == '/')
|
||||||
|
{
|
||||||
|
icon_uri = g_strdup (uri);
|
||||||
|
icon_uri[i] = '\0';
|
||||||
|
icon_uri = g_strdup_printf ("%s/favicon.ico", icon_uri);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
icon_uri = g_strdup_printf ("%s/favicon.ico", uri);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
icon_uri = g_strdup_printf ("%s/favicon.ico", uri);
|
|
||||||
|
|
||||||
icon_file = katze_net_get_cached_path (net, icon_uri, "icons");
|
icon_file = katze_net_get_cached_path (net, icon_uri, "icons");
|
||||||
|
|
||||||
|
|
|
@ -696,9 +696,6 @@ midori_view_update_load_status (MidoriView* view,
|
||||||
if (view->tab_icon)
|
if (view->tab_icon)
|
||||||
katze_throbber_set_animated (KATZE_THROBBER (view->tab_icon),
|
katze_throbber_set_animated (KATZE_THROBBER (view->tab_icon),
|
||||||
view->load_status != MIDORI_LOAD_FINISHED);
|
view->load_status != MIDORI_LOAD_FINISHED);
|
||||||
|
|
||||||
if (view->web_view && view->load_status == MIDORI_LOAD_COMMITTED)
|
|
||||||
_midori_web_view_load_icon (view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -857,11 +854,13 @@ webkit_web_view_load_finished_cb (WebKitWebView* web_view,
|
||||||
URI1|title1,URI2|title2
|
URI1|title1,URI2|title2
|
||||||
FIXME: Ensure separators contained in the string can't break it */
|
FIXME: Ensure separators contained in the string can't break it */
|
||||||
gchar* value = sokoke_js_script_eval (js_context,
|
gchar* value = sokoke_js_script_eval (js_context,
|
||||||
"function feeds (l) { var f = new Array (); for (i in l) "
|
"function links (l) { var f = new Array (); for (i in l) "
|
||||||
"{ var t = l[i].type; "
|
"{ var t = l[i].type; var r = l[i].rel; "
|
||||||
"if (t && (t.indexOf ('rss') != -1 || t.indexOf ('atom') != -1)) "
|
"if (t && (t.indexOf ('rss') != -1 || t.indexOf ('atom') != -1)) "
|
||||||
"f.push (l[i].href + '|' + l[i].title); } return f; }"
|
"f.push (l[i].href + '|' + l[i].title);"
|
||||||
"feeds (document.getElementsByTagName ('link'))", NULL);
|
"else if (r && r.indexOf ('icon') != -1) f.push (l[i].href); } "
|
||||||
|
"return f; }"
|
||||||
|
"links (document.getElementsByTagName ('link'))", NULL);
|
||||||
gchar** items = g_strsplit (value, ",", 0);
|
gchar** items = g_strsplit (value, ",", 0);
|
||||||
guint i = 0;
|
guint i = 0;
|
||||||
gchar* default_uri = NULL;
|
gchar* default_uri = NULL;
|
||||||
|
@ -871,14 +870,21 @@ webkit_web_view_load_finished_cb (WebKitWebView* web_view,
|
||||||
while (items[i] != NULL)
|
while (items[i] != NULL)
|
||||||
{
|
{
|
||||||
gchar** parts = g_strsplit (items[i], "|", 2);
|
gchar** parts = g_strsplit (items[i], "|", 2);
|
||||||
KatzeItem* item = g_object_new (KATZE_TYPE_ITEM,
|
if (parts == NULL)
|
||||||
"uri", parts ? *parts : "",
|
;
|
||||||
"name", parts && *parts ? parts[1] : NULL,
|
else if (*parts && parts[1])
|
||||||
NULL);
|
{
|
||||||
katze_array_add_item (view->news_feeds, item);
|
KatzeItem* item = g_object_new (KATZE_TYPE_ITEM,
|
||||||
g_object_unref (item);
|
"uri", parts[0], "name", parts[1], NULL);
|
||||||
if (!default_uri)
|
katze_array_add_item (view->news_feeds, item);
|
||||||
default_uri = g_strdup (parts ? *parts : NULL);
|
g_object_unref (item);
|
||||||
|
if (!default_uri)
|
||||||
|
default_uri = g_strdup (parts[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
g_object_set_data_full (G_OBJECT (view->net), view->uri,
|
||||||
|
g_strdup (*parts), (GDestroyNotify)g_free);
|
||||||
|
|
||||||
g_strfreev (parts);
|
g_strfreev (parts);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -889,6 +895,8 @@ webkit_web_view_load_finished_cb (WebKitWebView* web_view,
|
||||||
g_object_notify (G_OBJECT (view), "load-status");
|
g_object_notify (G_OBJECT (view), "load-status");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_midori_web_view_load_icon (view);
|
||||||
|
|
||||||
g_object_thaw_notify (G_OBJECT (view));
|
g_object_thaw_notify (G_OBJECT (view));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue