[epiphany/overview: 25/28] ephy-active-store: handle removal of rows internally
- From: Claudio Saavedra <csaavedra src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/overview: 25/28] ephy-active-store: handle removal of rows internally
- Date: Fri, 3 Aug 2012 09:45:59 +0000 (UTC)
commit 83178271386ab686be4268eb82ce9ec6fb92402f
Author: Claudio Saavedra <csaavedra igalia com>
Date: Wed Jun 13 16:58:38 2012 +0300
ephy-active-store: handle removal of rows internally
When a row is removed by the model itself, we need to ensure that
this is replicated in the notebook too.
src/ephy-active-store.c | 45 ++++++++++++++++++++++++++++++++++++---------
1 files changed, 36 insertions(+), 9 deletions(-)
---
diff --git a/src/ephy-active-store.c b/src/ephy-active-store.c
index 7beaf70..b76445b 100644
--- a/src/ephy-active-store.c
+++ b/src/ephy-active-store.c
@@ -29,6 +29,8 @@
struct _EphyActiveStorePrivate
{
EphyNotebook *notebook;
+
+ gboolean removing_internally : 1;
};
enum
@@ -59,6 +61,23 @@ ephy_active_store_set_property (GObject *object,
}
static void
+on_row_deleted_cb (GtkTreeModel *model,
+ GtkTreePath *path,
+ gpointer user_data)
+{
+ EphyActiveStore *self;
+ int index;
+
+ self = EPHY_ACTIVE_STORE (model);
+ index = gtk_tree_path_get_indices (path) [0];
+
+ self->priv->removing_internally = TRUE;
+ gtk_notebook_remove_page (GTK_NOTEBOOK (self->priv->notebook),
+ index);
+ self->priv->removing_internally = FALSE;
+}
+
+static void
ephy_active_store_get_property (GObject *object,
guint prop_id,
GValue *value,
@@ -118,6 +137,9 @@ ephy_active_store_init (EphyActiveStore *self)
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (self),
EPHY_ACTIVE_STORE_TAB_POS,
GTK_SORT_ASCENDING);
+
+ g_signal_connect_after (self, "row-deleted",
+ G_CALLBACK (on_row_deleted_cb), NULL);
}
typedef void (* BindingFunc) (GtkTreeModel *model, GtkTreeIter *iter, GValue *value, gpointer data);
@@ -348,15 +370,20 @@ ephy_active_store_remove_embed (EphyActiveStore *store,
HelperCtx *ctx;
webview = ephy_embed_get_web_view (embed);
- ctx = g_slice_new0 (HelperCtx);
- ctx->cmp_uri = g_intern_string (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (webview)));
- gtk_tree_model_foreach (GTK_TREE_MODEL (store),
- (GtkTreeModelForeachFunc) foreach_helper,
- ctx);
- iter = ctx->iter;
- g_slice_free (HelperCtx, ctx);
-
- gtk_list_store_remove (GTK_LIST_STORE (store), &iter);
+
+ if (store->priv->removing_internally == FALSE) {
+ ctx = g_slice_new0 (HelperCtx);
+ ctx->cmp_uri = g_intern_string (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (webview)));
+ gtk_tree_model_foreach (GTK_TREE_MODEL (store),
+ (GtkTreeModelForeachFunc) foreach_helper,
+ ctx);
+ iter = ctx->iter;
+ g_slice_free (HelperCtx, ctx);
+
+ g_signal_handlers_block_by_func (store, on_row_deleted_cb, NULL);
+ gtk_list_store_remove (GTK_LIST_STORE (store), &iter);
+ g_signal_handlers_unblock_by_func (store, on_row_deleted_cb, NULL);
+ }
bindings_drop (G_OBJECT (webview));
bindings_drop (G_OBJECT (embed));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]