aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2012-08-30 21:22:42 +0800
committerClaudio Saavedra <csaavedra@igalia.com>2012-09-01 02:34:03 +0800
commit67736b8c9a8917c522e7432bda74379f768ec501 (patch)
tree75d6bea1d634747a147c42176d6484af4c1f5184
parent02542c5fd0fde31161b6fe64128e8bf0a029b028 (diff)
downloadgsoc2013-epiphany-67736b8c9a8917c522e7432bda74379f768ec501.tar.gz
gsoc2013-epiphany-67736b8c9a8917c522e7432bda74379f768ec501.tar.zst
gsoc2013-epiphany-67736b8c9a8917c522e7432bda74379f768ec501.zip
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.
-rw-r--r--lib/widgets/ephy-frecent-store.c36
-rw-r--r--lib/widgets/ephy-overview-store.c70
-rw-r--r--lib/widgets/ephy-overview-store.h12
3 files changed, 113 insertions, 5 deletions
diff --git a/lib/widgets/ephy-frecent-store.c b/lib/widgets/ephy-frecent-store.c
index 540c1007c..2a60c7c63 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 cc8ba8c59..478bc1533 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 05ad95e0d..f6201bf99 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);