[epiphany] ephy-frecent-store: animate hiding of store items
- From: Claudio Saavedra <csaavedra src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] ephy-frecent-store: animate hiding of store items
- Date: Fri, 31 Aug 2012 18:44:08 +0000 (UTC)
commit 67736b8c9a8917c522e7432bda74379f768ec501
Author: Claudio Saavedra <csaavedra igalia com>
Date: Thu Aug 30 16:22:42 2012 +0300
ephy-frecent-store: animate hiding of store items
Add a ephy_overview_store_animated_remove() that shrinks the thumbnail
in a timeout until it's small enough and then removes it from the
model.
lib/widgets/ephy-frecent-store.c | 36 ++++++++++++++++---
lib/widgets/ephy-overview-store.c | 70 +++++++++++++++++++++++++++++++++++++
lib/widgets/ephy-overview-store.h | 12 ++++++
3 files changed, 113 insertions(+), 5 deletions(-)
---
diff --git a/lib/widgets/ephy-frecent-store.c b/lib/widgets/ephy-frecent-store.c
index 540c100..2a60c7c 100644
--- a/lib/widgets/ephy-frecent-store.c
+++ b/lib/widgets/ephy-frecent-store.c
@@ -341,15 +341,34 @@ ephy_frecent_store_new (void)
}
static void
+animated_remove_cb (EphyOverviewStore *store,
+ GtkTreeIter *iter,
+ gboolean valid,
+ EphyHistoryService *service)
+{
+ ephy_frecent_store_fetch_urls (EPHY_FRECENT_STORE (store), service);
+}
+
+static void
set_url_hidden_cb (EphyHistoryService *service,
gboolean success,
gpointer result_data,
- EphyFrecentStore *store)
+ GtkTreeRowReference *ref)
{
+ EphyOverviewStore *store;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
if (!success)
return;
- ephy_frecent_store_fetch_urls (store, service);
+ store = EPHY_OVERVIEW_STORE (gtk_tree_row_reference_get_model (ref));
+ path = gtk_tree_row_reference_get_path (ref);
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path);
+ gtk_tree_path_free (path);
+ ephy_overview_store_animated_remove (store, ref,
+ (EphyOverviewStoreAnimRemoveFunc)animated_remove_cb,
+ service);
}
void
@@ -357,20 +376,27 @@ ephy_frecent_store_set_hidden (EphyFrecentStore *store,
GtkTreeIter *iter)
{
EphyHistoryService *service;
+ GtkTreeRowReference *ref;
+ GtkTreePath *path;
char *uri;
-
+ GtkTreeModel *model;
g_return_if_fail (EPHY_IS_FRECENT_STORE (store));
g_return_if_fail (iter != NULL);
- gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
+ model = GTK_TREE_MODEL (store);
+ gtk_tree_model_get (model, iter,
EPHY_OVERVIEW_STORE_URI, &uri,
-1);
g_object_get (store, "history-service", &service, NULL);
+ path = gtk_tree_model_get_path (model, iter);
+ ref = gtk_tree_row_reference_new (model, path);
+ gtk_tree_path_free (path);
+
ephy_history_service_set_url_hidden (service,
uri, TRUE, NULL,
(EphyHistoryJobCallback) set_url_hidden_cb,
- store);
+ ref);
g_free (uri);
g_object_unref (service);
}
diff --git a/lib/widgets/ephy-overview-store.c b/lib/widgets/ephy-overview-store.c
index cc8ba8c..478bc15 100644
--- a/lib/widgets/ephy-overview-store.c
+++ b/lib/widgets/ephy-overview-store.c
@@ -507,6 +507,76 @@ ephy_overview_store_remove (EphyOverviewStore *store,
return gtk_list_store_remove (GTK_LIST_STORE (store), iter);
}
+typedef struct {
+ GtkTreeRowReference *ref;
+ EphyOverviewStoreAnimRemoveFunc callback;
+ gpointer user_data;
+} AnimRemoveContext;
+
+static gboolean
+animated_remove_func (AnimRemoveContext *ctx)
+{
+ GtkTreeRowReference *ref;
+ EphyOverviewStore *store;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ GdkPixbuf *orig_pixbuf, *new_pixbuf;
+ int width, height;
+ gboolean valid;
+
+ ref = ctx->ref;
+ store = EPHY_OVERVIEW_STORE (gtk_tree_row_reference_get_model (ref));
+ path = gtk_tree_row_reference_get_path (ref);
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path);
+ gtk_tree_path_free (path);
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
+ EPHY_OVERVIEW_STORE_SNAPSHOT, &orig_pixbuf, -1);
+
+ width = gdk_pixbuf_get_width (orig_pixbuf);
+ height = gdk_pixbuf_get_height (orig_pixbuf);
+
+ if (width > 10) {
+ new_pixbuf = gdk_pixbuf_scale_simple (orig_pixbuf,
+ width * 0.80,
+ height * 0.80,
+ GDK_INTERP_TILES);
+ g_object_unref (orig_pixbuf);
+ gtk_list_store_set (GTK_LIST_STORE (store), &iter,
+ EPHY_OVERVIEW_STORE_SNAPSHOT, new_pixbuf,
+ -1);
+ g_object_unref (new_pixbuf);
+
+ return TRUE;
+ }
+
+ g_object_unref (orig_pixbuf);
+ valid = ephy_overview_store_remove (store, &iter);
+
+ if (ctx->callback)
+ ctx->callback (store, &iter, valid, ctx->user_data);
+
+ gtk_tree_row_reference_free (ref);
+ g_slice_free (AnimRemoveContext, ctx);
+
+ return FALSE;
+}
+
+void
+ephy_overview_store_animated_remove (EphyOverviewStore *store,
+ GtkTreeRowReference *ref,
+ EphyOverviewStoreAnimRemoveFunc callback,
+ gpointer user_data)
+{
+ AnimRemoveContext *ctx = g_slice_new0 (AnimRemoveContext);
+
+ ctx->ref = ref;
+ ctx->callback = callback;
+ ctx->user_data = user_data;
+
+ g_timeout_add (40, (GSourceFunc) animated_remove_func, ctx);
+}
+
gboolean
ephy_overview_store_find_url (EphyOverviewStore *store,
const char *url,
diff --git a/lib/widgets/ephy-overview-store.h b/lib/widgets/ephy-overview-store.h
index 05ad95e..f6201bf 100644
--- a/lib/widgets/ephy-overview-store.h
+++ b/lib/widgets/ephy-overview-store.h
@@ -85,6 +85,18 @@ gboolean ephy_overview_store_needs_snapshot (EphyOverviewStore *store,
gboolean ephy_overview_store_remove (EphyOverviewStore *store,
GtkTreeIter *iter);
+
+typedef void (* EphyOverviewStoreAnimRemoveFunc) (EphyOverviewStore *store,
+ GtkTreeIter *iter,
+ gboolean valid,
+ gpointer user_data);
+
+void ephy_overview_store_animated_remove (EphyOverviewStore *store,
+ GtkTreeRowReference *ref,
+ EphyOverviewStoreAnimRemoveFunc func,
+ gpointer user_data);
+
+
gboolean ephy_overview_store_find_url (EphyOverviewStore *store,
const char *url,
GtkTreeIter *iter);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]