Queue thumbnails for speed dial, and load if missing
This commit is contained in:
parent
ff569e8328
commit
6bb66ed111
1 changed files with 44 additions and 29 deletions
|
@ -64,6 +64,11 @@ midori_view_web_view_get_snapshot (GtkWidget* web_view,
|
||||||
gint width,
|
gint width,
|
||||||
gint height);
|
gint height);
|
||||||
|
|
||||||
|
static void
|
||||||
|
midori_view_speed_dial_get_thumb (MidoriView* view,
|
||||||
|
gchar* dial_id,
|
||||||
|
gchar* url);
|
||||||
|
|
||||||
struct _MidoriView
|
struct _MidoriView
|
||||||
{
|
{
|
||||||
GtkVBox parent_instance;
|
GtkVBox parent_instance;
|
||||||
|
@ -207,6 +212,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 void
|
static void
|
||||||
midori_view_finalize (GObject* object);
|
midori_view_finalize (GObject* object);
|
||||||
|
@ -3766,6 +3772,7 @@ prepare_speed_dial_html (MidoriView* view)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
encoded = g_strdup ("");
|
encoded = g_strdup ("");
|
||||||
|
midori_view_speed_dial_get_thumb (view, dial_entry, uri);
|
||||||
}
|
}
|
||||||
g_free (thumb_file);
|
g_free (thumb_file);
|
||||||
|
|
||||||
|
@ -5362,8 +5369,9 @@ thumb_view_load_status_cb (WebKitWebView* thumb_view_,
|
||||||
#endif
|
#endif
|
||||||
gchar* file_path;
|
gchar* file_path;
|
||||||
gchar* thumb_dir;
|
gchar* thumb_dir;
|
||||||
gchar* thumb_uri;
|
gchar* spec;
|
||||||
gchar* thumb_slot;
|
gchar* url;
|
||||||
|
gchar* dial_id;
|
||||||
MidoriBrowser* browser;
|
MidoriBrowser* browser;
|
||||||
GKeyFile* key_file;
|
GKeyFile* key_file;
|
||||||
const gchar* title;
|
const gchar* title;
|
||||||
|
@ -5371,6 +5379,10 @@ thumb_view_load_status_cb (WebKitWebView* thumb_view_,
|
||||||
if (webkit_web_view_get_load_status (thumb_view_) != WEBKIT_LOAD_FINISHED)
|
if (webkit_web_view_get_load_status (thumb_view_) != WEBKIT_LOAD_FINISHED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
spec = g_object_get_data (G_OBJECT (thumb_view), "spec");
|
||||||
|
url = strstr (spec, "|") + 1;
|
||||||
|
dial_id = g_strndup (spec, url - spec - 1);
|
||||||
|
|
||||||
#if HAVE_OFFSCREEN
|
#if HAVE_OFFSCREEN
|
||||||
img = gtk_offscreen_window_get_pixbuf (GTK_OFFSCREEN_WINDOW (
|
img = gtk_offscreen_window_get_pixbuf (GTK_OFFSCREEN_WINDOW (
|
||||||
gtk_widget_get_parent (GTK_WIDGET (thumb_view))));
|
gtk_widget_get_parent (GTK_WIDGET (thumb_view))));
|
||||||
|
@ -5380,8 +5392,7 @@ thumb_view_load_status_cb (WebKitWebView* thumb_view_,
|
||||||
gtk_widget_realize (thumb_view);
|
gtk_widget_realize (thumb_view);
|
||||||
img = midori_view_web_view_get_snapshot (thumb_view, 240, 160);
|
img = midori_view_web_view_get_snapshot (thumb_view, 240, 160);
|
||||||
#endif
|
#endif
|
||||||
thumb_uri = g_object_get_data (G_OBJECT (thumb_view), "thumb-uri");
|
file_path = sokoke_build_thumbnail_path (url);
|
||||||
file_path = sokoke_build_thumbnail_path (thumb_uri);
|
|
||||||
thumb_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (),
|
thumb_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (),
|
||||||
PACKAGE_NAME, "thumbnails", NULL);
|
PACKAGE_NAME, "thumbnails", NULL);
|
||||||
|
|
||||||
|
@ -5395,22 +5406,23 @@ thumb_view_load_status_cb (WebKitWebView* thumb_view_,
|
||||||
g_free (file_path);
|
g_free (file_path);
|
||||||
g_free (thumb_dir);
|
g_free (thumb_dir);
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (
|
|
||||||
thumb_view, thumb_view_load_status_cb, view);
|
|
||||||
|
|
||||||
/* Destroying the view here may trigger a WebKitGTK+ 1.1.14 bug */
|
|
||||||
#if 0
|
|
||||||
gtk_widget_destroy (GTK_WIDGET (thumb_view));
|
|
||||||
thumb_view = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
browser = midori_browser_get_for_widget (GTK_WIDGET (view));
|
browser = midori_browser_get_for_widget (GTK_WIDGET (view));
|
||||||
g_object_get (browser, "speed-dial", &key_file, NULL);
|
g_object_get (browser, "speed-dial", &key_file, NULL);
|
||||||
thumb_slot = g_object_get_data (G_OBJECT (thumb_view), "thumb-slot");
|
|
||||||
title = webkit_web_view_get_title (WEBKIT_WEB_VIEW (thumb_view));
|
title = webkit_web_view_get_title (WEBKIT_WEB_VIEW (thumb_view));
|
||||||
g_key_file_set_string (key_file, thumb_slot, "title",
|
g_key_file_set_string (key_file, dial_id, "title", title ? title : url);
|
||||||
title ? title : thumb_uri);
|
|
||||||
midori_view_save_speed_dial_config (view, key_file);
|
midori_view_save_speed_dial_config (view, key_file);
|
||||||
|
|
||||||
|
thumb_queue = g_list_remove (thumb_queue, spec);
|
||||||
|
if (thumb_queue != NULL)
|
||||||
|
{
|
||||||
|
g_object_set_data_full (G_OBJECT (thumb_view), "spec",
|
||||||
|
thumb_queue->data, (GDestroyNotify)g_free);
|
||||||
|
webkit_web_view_open (WEBKIT_WEB_VIEW (thumb_view),
|
||||||
|
strstr (thumb_queue->data, "|") + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
g_signal_handlers_disconnect_by_func (
|
||||||
|
thumb_view, thumb_view_load_status_cb, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5446,6 +5458,15 @@ midori_view_speed_dial_get_thumb (MidoriView* view,
|
||||||
if (!thumb_view)
|
if (!thumb_view)
|
||||||
{
|
{
|
||||||
thumb_view = webkit_web_view_new ();
|
thumb_view = webkit_web_view_new ();
|
||||||
|
settings = g_object_new (WEBKIT_TYPE_WEB_SETTINGS,
|
||||||
|
"enable-scripts", FALSE,
|
||||||
|
"enable-plugins", FALSE, "auto-load-images", TRUE,
|
||||||
|
"enable-html5-database", FALSE, "enable-html5-local-storage", FALSE,
|
||||||
|
#if WEBKIT_CHECK_VERSION (1, 1, 22)
|
||||||
|
"enable-java-applet", FALSE,
|
||||||
|
#endif
|
||||||
|
NULL);
|
||||||
|
webkit_web_view_set_settings (WEBKIT_WEB_VIEW (thumb_view), settings);
|
||||||
#if HAVE_OFFSCREEN
|
#if HAVE_OFFSCREEN
|
||||||
browser = gtk_offscreen_window_new ();
|
browser = gtk_offscreen_window_new ();
|
||||||
gtk_container_add (GTK_CONTAINER (browser), thumb_view);
|
gtk_container_add (GTK_CONTAINER (browser), thumb_view);
|
||||||
|
@ -5459,25 +5480,19 @@ midori_view_speed_dial_get_thumb (MidoriView* view,
|
||||||
/* We use an empty label. It's not invisible but at least hard to spot. */
|
/* We use an empty label. It's not invisible but at least hard to spot. */
|
||||||
label = gtk_event_box_new ();
|
label = gtk_event_box_new ();
|
||||||
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), thumb_view, label);
|
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), thumb_view, label);
|
||||||
#endif
|
|
||||||
gtk_widget_show (thumb_view);
|
gtk_widget_show (thumb_view);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#if !HAVE_OFFSCREEN
|
#if !HAVE_OFFSCREEN
|
||||||
g_object_unref (notebook);
|
g_object_unref (notebook);
|
||||||
#endif
|
#endif
|
||||||
settings = g_object_new (WEBKIT_TYPE_WEB_SETTINGS, "enable-scripts", FALSE,
|
|
||||||
"enable-plugins", FALSE, "auto-load-images", TRUE,
|
|
||||||
"enable-html5-database", FALSE, "enable-html5-local-storage", FALSE,
|
|
||||||
#if WEBKIT_CHECK_VERSION (1, 1, 22)
|
|
||||||
"enable-java-applet", FALSE,
|
|
||||||
#endif
|
|
||||||
NULL);
|
|
||||||
webkit_web_view_set_settings (WEBKIT_WEB_VIEW (thumb_view), settings);
|
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (thumb_view), "thumb-uri",
|
thumb_queue = g_list_append (thumb_queue, g_strconcat (dial_id, "|", url, NULL));
|
||||||
g_strdup (url), (GDestroyNotify)g_free);
|
if (g_list_nth_data (thumb_queue, 1) != NULL)
|
||||||
g_object_set_data_full (G_OBJECT (thumb_view), "thumb-slot",
|
return;
|
||||||
g_strdup (dial_id), (GDestroyNotify)g_free);
|
|
||||||
|
g_object_set_data_full (G_OBJECT (thumb_view), "spec",
|
||||||
|
thumb_queue->data, (GDestroyNotify)g_free);
|
||||||
g_signal_connect (thumb_view, "notify::load-status",
|
g_signal_connect (thumb_view, "notify::load-status",
|
||||||
G_CALLBACK (thumb_view_load_status_cb), view);
|
G_CALLBACK (thumb_view_load_status_cb), view);
|
||||||
webkit_web_view_open (WEBKIT_WEB_VIEW (thumb_view), url);
|
webkit_web_view_open (WEBKIT_WEB_VIEW (thumb_view), url);
|
||||||
|
|
Loading…
Reference in a new issue