summaryrefslogtreecommitdiff
path: root/embed/ephy-embed-shell.c
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@gnome.org>2016-12-04 20:56:00 -0600
committerMichael Catanzaro <mcatanzaro@gnome.org>2016-12-06 09:14:04 -0600
commit19322541e8be8f11ad6a4aee4457b9cc636c5a69 (patch)
tree2f36d589210a0fdf99120487d979d66f9db897c1 /embed/ephy-embed-shell.c
parent02fdbf1ff21e33dbd5270f95e28f35521ebd8753 (diff)
downloadepiphany-19322541e8be8f11ad6a4aee4457b9cc636c5a69.tar.gz
Refactor delayed overview thumbnail update handling
Move this logic to EphyEmbedShell. It will be needed there in the next commit and I don't want to duplicate the code in two different places. https://bugzilla.gnome.org/show_bug.cgi?id=775612
Diffstat (limited to 'embed/ephy-embed-shell.c')
-rw-r--r--embed/ephy-embed-shell.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 2de56037d..135657e3c 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -433,6 +433,56 @@ ephy_embed_shell_set_thumbnail_path (EphyEmbedShell *shell,
}
}
+typedef struct {
+ char *url;
+ time_t mtime;
+} GetSnapshotPathAsyncData;
+
+static void
+got_snapshot_path_for_url_cb (EphySnapshotService *service,
+ GAsyncResult *result,
+ GetSnapshotPathAsyncData *data)
+{
+ char *snapshot;
+ GError *error = NULL;
+
+ snapshot = ephy_snapshot_service_get_snapshot_path_for_url_finish (service, result, &error);
+ if (snapshot) {
+ ephy_embed_shell_set_thumbnail_path (ephy_embed_shell_get_default (), data->url, data->mtime, snapshot);
+ g_free (snapshot);
+ } else {
+ /* Bad luck, not something to warn about. */
+ g_info ("Failed to get snapshot for URL %s: %s", data->url, error->message);
+ g_error_free (error);
+ }
+ g_free (data->url);
+ g_free (data);
+}
+
+void
+ephy_embed_shell_schedule_thumbnail_update (EphyEmbedShell *shell,
+ EphyHistoryURL *url)
+{
+ EphySnapshotService *service;
+ const char *snapshot;
+
+ service = ephy_snapshot_service_get_default ();
+ snapshot = ephy_snapshot_service_lookup_cached_snapshot_path (service, url->url);
+
+ if (snapshot) {
+ ephy_embed_shell_set_thumbnail_path (shell, url->url, url->thumbnail_time, snapshot);
+ } else {
+ GetSnapshotPathAsyncData *data = g_new (GetSnapshotPathAsyncData, 1);
+
+ data->url = g_strdup (url->url);
+ data->mtime = url->thumbnail_time;
+ ephy_snapshot_service_get_snapshot_path_for_url_async (service,
+ url->url, url->thumbnail_time, NULL,
+ (GAsyncReadyCallback)got_snapshot_path_for_url_cb,
+ data);
+ }
+}
+
/**
* ephy_embed_shell_get_global_history_service:
* @shell: the #EphyEmbedShell