diff options
Diffstat (limited to 'widgets/table/e-tree-model.c')
-rw-r--r-- | widgets/table/e-tree-model.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/widgets/table/e-tree-model.c b/widgets/table/e-tree-model.c index e3c4f138cd..a38e24ec62 100644 --- a/widgets/table/e-tree-model.c +++ b/widgets/table/e-tree-model.c @@ -41,7 +41,7 @@ struct ETreeModelPriv { GHashTable *expanded_state; /* used for loading/saving expanded state */ GString *sort_group; /* for caching the last sort group info */ gboolean expanded_default; /* whether nodes are created expanded or collapsed by default */ - gboolean pre_change; /* has there been a pre-change event on us? */ + gboolean frozen; /* has there been a pre-change event on us? */ }; struct ETreePath { @@ -173,21 +173,22 @@ e_tree_model_node_traverse (ETreeModel *model, ETreePath *path, ETreePathFunc fu } -/* signal handlers */ -static void -etree_pre_change(GtkObject *object, ETreeModel *etm) + +void +e_tree_model_freeze(ETreeModel *etm) { ETreeModelPriv *priv = etm->priv; - priv->pre_change = TRUE; + priv->frozen = TRUE; } -static void -etree_changed(GtkObject *object, ETreeModel *etm) +void +e_tree_model_thaw(ETreeModel *etm) { ETreeModelPriv *priv = etm->priv; - priv->pre_change = FALSE; + priv->frozen = FALSE; + e_table_model_changed(E_TABLE_MODEL(etm)); } @@ -710,9 +711,6 @@ e_tree_model_construct (ETreeModel *etree) priv->row_array = g_array_new (FALSE, FALSE, sizeof(ETreePath*)); priv->expanded_state = g_hash_table_new (g_str_hash, g_str_equal); priv->sort_group = g_string_new(""); - - gtk_signal_connect((GtkObject *)etree, "model_pre_change", etree_pre_change, etree); - gtk_signal_connect((GtkObject *)etree, "model_changed", etree_changed, etree); } ETreeModel * @@ -951,11 +949,13 @@ e_tree_model_node_insert (ETreeModel *tree_model, parent_row = e_tree_model_row_of_node (tree_model, parent_path); } + e_table_model_pre_change(E_TABLE_MODEL(tree_model)); + priv->row_array = g_array_insert_val (priv->row_array, parent_row + position + 1 + child_offset, new_path); /* only do this if we know a changed signal isn't coming later on */ - if (!priv->pre_change) + if (!priv->frozen) e_table_model_row_inserted (E_TABLE_MODEL(tree_model), parent_row + position + 1 + child_offset); } @@ -1077,6 +1077,8 @@ e_tree_model_node_remove (ETreeModel *etree, ETreePath *path) remove the whole lot do we really care */ dochanged = (visible > 1000) || (visible > (priv->row_array->len / 4)); + e_table_model_pre_change(E_TABLE_MODEL (etree)); + /* and physically remove them */ if (visible == priv->row_array->len) { g_array_set_size(priv->row_array, 0); @@ -1088,7 +1090,7 @@ e_tree_model_node_remove (ETreeModel *etree, ETreePath *path) } /* tell the system we've removed (these) nodes */ - if (!priv->pre_change) { + if (!priv->frozen) { if (dochanged) { e_table_model_changed(E_TABLE_MODEL(etree)); } else { @@ -1110,8 +1112,9 @@ add_visible_descendents_to_array (ETreeModel *etm, ETreePath *node, int *row, in ETreeModelPriv *priv = etm->priv; /* add a row for this node */ + e_table_model_pre_change(E_TABLE_MODEL (etm)); priv->row_array = g_array_insert_val (priv->row_array, (*row), node); - if (!priv->pre_change) + if (!priv->frozen) e_table_model_row_inserted (E_TABLE_MODEL (etm), (*row)); (*row) ++; (*count) ++; @@ -1321,6 +1324,8 @@ e_tree_model_node_sort (ETreeModel *tree_model, if (num_nodes == 0) return; + e_table_model_pre_change(E_TABLE_MODEL (tree_model)); + sort_info = g_new (ETreeSortInfo, num_nodes); child_index = e_tree_model_row_of_node (tree_model, node) + 1; @@ -1360,7 +1365,7 @@ e_tree_model_node_sort (ETreeModel *tree_model, g_free (sort_info); - if (!priv->pre_change) + if (!priv->frozen) e_table_model_changed (E_TABLE_MODEL (tree_model)); } |