diff options
author | Claudio Saavedra <csaavedra@igalia.com> | 2012-08-30 21:22:42 +0800 |
---|---|---|
committer | Claudio Saavedra <csaavedra@igalia.com> | 2012-09-01 02:34:03 +0800 |
commit | 67736b8c9a8917c522e7432bda74379f768ec501 (patch) | |
tree | 75d6bea1d634747a147c42176d6484af4c1f5184 /lib/widgets/ephy-overview-store.c | |
parent | 02542c5fd0fde31161b6fe64128e8bf0a029b028 (diff) | |
download | gsoc2013-epiphany-67736b8c9a8917c522e7432bda74379f768ec501.tar gsoc2013-epiphany-67736b8c9a8917c522e7432bda74379f768ec501.tar.gz gsoc2013-epiphany-67736b8c9a8917c522e7432bda74379f768ec501.tar.bz2 gsoc2013-epiphany-67736b8c9a8917c522e7432bda74379f768ec501.tar.lz gsoc2013-epiphany-67736b8c9a8917c522e7432bda74379f768ec501.tar.xz 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.
Diffstat (limited to 'lib/widgets/ephy-overview-store.c')
-rw-r--r-- | lib/widgets/ephy-overview-store.c | 70 |
1 files changed, 70 insertions, 0 deletions
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, |