Don't queue thumbs already waiting, 5 seconds timeout
This commit is contained in:
parent
6ea98c6569
commit
55227d2a3b
1 changed files with 49 additions and 3 deletions
|
@ -69,6 +69,9 @@ midori_view_speed_dial_get_thumb (MidoriView* view,
|
||||||
gchar* dial_id,
|
gchar* dial_id,
|
||||||
gchar* url);
|
gchar* url);
|
||||||
|
|
||||||
|
static void
|
||||||
|
midori_view_speed_dial_thumb_apply (MidoriView* view);
|
||||||
|
|
||||||
struct _MidoriView
|
struct _MidoriView
|
||||||
{
|
{
|
||||||
GtkVBox parent_instance;
|
GtkVBox parent_instance;
|
||||||
|
@ -195,6 +198,7 @@ static guint signals[LAST_SIGNAL];
|
||||||
static gchar* speeddial_markup = NULL;
|
static gchar* speeddial_markup = NULL;
|
||||||
static GtkWidget* thumb_view = NULL;
|
static GtkWidget* thumb_view = NULL;
|
||||||
static GList* thumb_queue = NULL;
|
static GList* thumb_queue = NULL;
|
||||||
|
static guint thumb_timeout = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_view_finalize (GObject* object);
|
midori_view_finalize (GObject* object);
|
||||||
|
@ -5345,6 +5349,22 @@ static void
|
||||||
thumb_view_load_status_cb (WebKitWebView* thumb_view_,
|
thumb_view_load_status_cb (WebKitWebView* thumb_view_,
|
||||||
GParamSpec* pspec,
|
GParamSpec* pspec,
|
||||||
MidoriView* view)
|
MidoriView* view)
|
||||||
|
{
|
||||||
|
if (webkit_web_view_get_load_status (thumb_view_) != WEBKIT_LOAD_FINISHED)
|
||||||
|
return;
|
||||||
|
|
||||||
|
midori_view_speed_dial_thumb_apply (view);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
midori_view_speed_dial_thumb_timeout (MidoriView* view)
|
||||||
|
{
|
||||||
|
webkit_web_view_stop_loading (WEBKIT_WEB_VIEW (thumb_view));
|
||||||
|
midori_view_speed_dial_thumb_apply (view);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
midori_view_speed_dial_thumb_apply (MidoriView* view)
|
||||||
{
|
{
|
||||||
GdkPixbuf* img;
|
GdkPixbuf* img;
|
||||||
#if HAVE_OFFSCREEN
|
#if HAVE_OFFSCREEN
|
||||||
|
@ -5359,8 +5379,8 @@ thumb_view_load_status_cb (WebKitWebView* thumb_view_,
|
||||||
GKeyFile* key_file;
|
GKeyFile* key_file;
|
||||||
const gchar* title;
|
const gchar* title;
|
||||||
|
|
||||||
if (webkit_web_view_get_load_status (thumb_view_) != WEBKIT_LOAD_FINISHED)
|
if (thumb_timeout > 0)
|
||||||
return;
|
g_source_remove (thumb_timeout);
|
||||||
|
|
||||||
spec = g_object_get_data (G_OBJECT (thumb_view), "spec");
|
spec = g_object_get_data (G_OBJECT (thumb_view), "spec");
|
||||||
url = strstr (spec, "|") + 1;
|
url = strstr (spec, "|") + 1;
|
||||||
|
@ -5398,6 +5418,10 @@ thumb_view_load_status_cb (WebKitWebView* thumb_view_,
|
||||||
thumb_queue = g_list_remove (thumb_queue, spec);
|
thumb_queue = g_list_remove (thumb_queue, spec);
|
||||||
if (thumb_queue != NULL)
|
if (thumb_queue != NULL)
|
||||||
{
|
{
|
||||||
|
/* At best wait 5 seconds for a single thumbnail to load */
|
||||||
|
thumb_timeout = g_timeout_add_seconds (5,
|
||||||
|
(GSourceFunc)midori_view_speed_dial_thumb_timeout, view);
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (thumb_view), "spec",
|
g_object_set_data_full (G_OBJECT (thumb_view), "spec",
|
||||||
thumb_queue->data, (GDestroyNotify)g_free);
|
thumb_queue->data, (GDestroyNotify)g_free);
|
||||||
webkit_web_view_open (WEBKIT_WEB_VIEW (thumb_view),
|
webkit_web_view_open (WEBKIT_WEB_VIEW (thumb_view),
|
||||||
|
@ -5408,6 +5432,14 @@ thumb_view_load_status_cb (WebKitWebView* thumb_view_,
|
||||||
thumb_view, thumb_view_load_status_cb, view);
|
thumb_view, thumb_view_load_status_cb, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
midori_view_speed_dial_thumb_cf (gconstpointer spec1,
|
||||||
|
gconstpointer spec2)
|
||||||
|
{
|
||||||
|
/* Compare URL without dial id */
|
||||||
|
return strcmp (strstr (spec1, "|") + 1, strstr (spec2, "|") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* midori_view_speed_dial_get_thumb
|
* midori_view_speed_dial_get_thumb
|
||||||
* @view: a #MidoriView
|
* @view: a #MidoriView
|
||||||
|
@ -5421,6 +5453,7 @@ midori_view_speed_dial_get_thumb (MidoriView* view,
|
||||||
{
|
{
|
||||||
WebKitWebSettings* settings;
|
WebKitWebSettings* settings;
|
||||||
GtkWidget* browser;
|
GtkWidget* browser;
|
||||||
|
gchar* spec;
|
||||||
#if !HAVE_OFFSCREEN
|
#if !HAVE_OFFSCREEN
|
||||||
GtkWidget* notebook;
|
GtkWidget* notebook;
|
||||||
GtkWidget* label;
|
GtkWidget* label;
|
||||||
|
@ -5470,10 +5503,23 @@ midori_view_speed_dial_get_thumb (MidoriView* view,
|
||||||
g_object_unref (notebook);
|
g_object_unref (notebook);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
thumb_queue = g_list_append (thumb_queue, g_strconcat (dial_id, "|", url, NULL));
|
spec = g_strconcat (dial_id, "|", url, NULL);
|
||||||
|
/* If spec is already queued, there's nothing to be done */
|
||||||
|
if (g_list_find_custom (thumb_queue, spec, midori_view_speed_dial_thumb_cf))
|
||||||
|
{
|
||||||
|
g_free (spec);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
thumb_queue = g_list_append (thumb_queue, spec);
|
||||||
if (g_list_nth_data (thumb_queue, 1) != NULL)
|
if (g_list_nth_data (thumb_queue, 1) != NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* At best wait 5 seconds for a single thumbnail to load */
|
||||||
|
if (thumb_timeout > 0)
|
||||||
|
g_source_remove (thumb_timeout);
|
||||||
|
thumb_timeout = g_timeout_add_seconds (5,
|
||||||
|
(GSourceFunc)midori_view_speed_dial_thumb_timeout, view);
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (thumb_view), "spec",
|
g_object_set_data_full (G_OBJECT (thumb_view), "spec",
|
||||||
thumb_queue->data, (GDestroyNotify)g_free);
|
thumb_queue->data, (GDestroyNotify)g_free);
|
||||||
g_signal_connect (thumb_view, "notify::load-status",
|
g_signal_connect (thumb_view, "notify::load-status",
|
||||||
|
|
Loading…
Reference in a new issue