From 78dc7a128a3f11fc1590e8b95a1017171b0c7f2a Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Tue, 25 Sep 2001 03:19:26 +0000 Subject: Attach to the resorted signal instead of the changed signal on the sorted 2001-09-24 Christopher James Lahey * e-tree-selection-model.c (etsm_sorted_node_resorted): Attach to the resorted signal instead of the changed signal on the sorted model. * e-tree-sorted.c, e-tree-sorted.h (e_tree_sorted_node_resorted): Added this signal. svn path=/trunk/; revision=13108 --- widgets/table/e-tree-selection-model.c | 78 +++------------------------------- widgets/table/e-tree-sorted.c | 46 +++++++++++++++++--- widgets/table/e-tree-sorted.h | 7 +++ 3 files changed, 54 insertions(+), 77 deletions(-) diff --git a/widgets/table/e-tree-selection-model.c b/widgets/table/e-tree-selection-model.c index 282e0bfb49..d7dcb7b648 100644 --- a/widgets/table/e-tree-selection-model.c +++ b/widgets/table/e-tree-selection-model.c @@ -63,12 +63,7 @@ struct ETreeSelectionModelPriv { int tree_model_node_inserted_id; int tree_model_node_removed_id; - int sorted_model_pre_change_id; - int sorted_model_node_changed_id; - int sorted_model_node_data_changed_id; - int sorted_model_node_col_changed_id; - int sorted_model_node_inserted_id; - int sorted_model_node_removed_id; + int sorted_model_node_resorted_id; }; /* ETreeSelectionModelNode helpers */ @@ -419,14 +414,8 @@ etsm_node_removed (ETreeModel *etm, ETreePath parent, ETreePath child, int old_p } - static void -etsm_sorted_pre_change (ETreeModel *etm, ETreeSelectionModel *etsm) -{ -} - -static void -etsm_sorted_node_changed (ETreeModel *etm, ETreePath node, ETreeSelectionModel *etsm) +etsm_sorted_node_resorted (ETreeModel *etm, ETreePath node, ETreeSelectionModel *etsm) { int cursor_row = etsm_cursor_row_real (etsm); e_selection_model_selection_changed(E_SELECTION_MODEL(etsm)); @@ -437,29 +426,6 @@ etsm_sorted_node_changed (ETreeModel *etm, ETreePath node, ETreeSelectionModel * e_selection_model_cursor_changed(E_SELECTION_MODEL(etsm), -1, -1); } -static void -etsm_sorted_node_data_changed (ETreeModel *etm, ETreePath node, ETreeSelectionModel *etsm) -{ -} - -static void -etsm_sorted_node_col_changed (ETreeModel *etm, ETreePath node, int col, ETreeSelectionModel *etsm) -{ -} - -static void -etsm_sorted_node_inserted (ETreeModel *etm, ETreePath parent, ETreePath child, ETreeSelectionModel *etsm) -{ - etsm_sorted_node_changed(etm, parent, etsm); -} - -static void -etsm_sorted_node_removed (ETreeModel *etm, ETreePath parent, ETreePath child, int old_position, ETreeSelectionModel *etsm) -{ - etsm_sorted_node_changed(etm, parent, etsm); -} - - static void add_model(ETreeSelectionModel *etsm, ETreeModel *model) { @@ -529,18 +495,8 @@ add_ets(ETreeSelectionModel *etsm, ETreeSorted *ets) return; gtk_object_ref(GTK_OBJECT(priv->ets)); - priv->sorted_model_pre_change_id = gtk_signal_connect (GTK_OBJECT (priv->ets), "pre_change", - GTK_SIGNAL_FUNC (etsm_sorted_pre_change), etsm); - priv->sorted_model_node_changed_id = gtk_signal_connect (GTK_OBJECT (priv->ets), "node_changed", - GTK_SIGNAL_FUNC (etsm_sorted_node_changed), etsm); - priv->sorted_model_node_data_changed_id = gtk_signal_connect (GTK_OBJECT (priv->ets), "node_data_changed", - GTK_SIGNAL_FUNC (etsm_sorted_node_data_changed), etsm); - priv->sorted_model_node_col_changed_id = gtk_signal_connect (GTK_OBJECT (priv->ets), "node_col_changed", - GTK_SIGNAL_FUNC (etsm_sorted_node_col_changed), etsm); - priv->sorted_model_node_inserted_id = gtk_signal_connect (GTK_OBJECT (priv->ets), "node_inserted", - GTK_SIGNAL_FUNC (etsm_sorted_node_inserted), etsm); - priv->sorted_model_node_removed_id = gtk_signal_connect (GTK_OBJECT (priv->ets), "node_removed", - GTK_SIGNAL_FUNC (etsm_sorted_node_removed), etsm); + priv->sorted_model_node_resorted_id = gtk_signal_connect (GTK_OBJECT (priv->ets), "node_resorted", + GTK_SIGNAL_FUNC (etsm_sorted_node_resorted), etsm); } static void @@ -552,27 +508,12 @@ drop_ets(ETreeSelectionModel *etsm) return; gtk_signal_disconnect (GTK_OBJECT (priv->ets), - priv->sorted_model_pre_change_id); - gtk_signal_disconnect (GTK_OBJECT (priv->ets), - priv->sorted_model_node_changed_id); - gtk_signal_disconnect (GTK_OBJECT (priv->ets), - priv->sorted_model_node_data_changed_id); - gtk_signal_disconnect (GTK_OBJECT (priv->ets), - priv->sorted_model_node_col_changed_id); - gtk_signal_disconnect (GTK_OBJECT (priv->ets), - priv->sorted_model_node_inserted_id); - gtk_signal_disconnect (GTK_OBJECT (priv->ets), - priv->sorted_model_node_removed_id); + priv->sorted_model_node_resorted_id); gtk_object_unref (GTK_OBJECT (priv->ets)); priv->ets = NULL; - priv->sorted_model_pre_change_id = 0; - priv->sorted_model_node_changed_id = 0; - priv->sorted_model_node_data_changed_id = 0; - priv->sorted_model_node_col_changed_id = 0; - priv->sorted_model_node_inserted_id = 0; - priv->sorted_model_node_removed_id = 0; + priv->sorted_model_node_resorted_id = 0; } /* Virtual functions */ @@ -1235,12 +1176,7 @@ e_tree_selection_model_init (ETreeSelectionModel *etsm) priv->tree_model_node_inserted_id = 0; priv->tree_model_node_removed_id = 0; - priv->sorted_model_pre_change_id = 0; - priv->sorted_model_node_changed_id = 0; - priv->sorted_model_node_data_changed_id = 0; - priv->sorted_model_node_col_changed_id = 0; - priv->sorted_model_node_inserted_id = 0; - priv->sorted_model_node_removed_id = 0; + priv->sorted_model_node_resorted_id = 0; } static void diff --git a/widgets/table/e-tree-sorted.c b/widgets/table/e-tree-sorted.c index add0b2ca2d..f771c55914 100644 --- a/widgets/table/e-tree-sorted.c +++ b/widgets/table/e-tree-sorted.c @@ -45,6 +45,13 @@ static ETreeModel *parent_class; static GMemChunk *node_chunk; +enum { + NODE_RESORTED, + LAST_SIGNAL +}; + +static guint signals [LAST_SIGNAL] = {0, }; + typedef struct ETreeSortedPath ETreeSortedPath; struct ETreeSortedPath { @@ -381,6 +388,7 @@ reposition_path (ETreeSorted *ets, ETreeSortedPath *path) for (i = old_index; i <= new_index; i++) parent->children[i]->position = i; e_tree_model_node_changed(E_TREE_MODEL(ets), parent); + e_tree_sorted_node_resorted(ets, parent); e_tree_model_pre_change(E_TREE_MODEL(ets)); } else if (new_index < old_index) { int i; @@ -390,6 +398,7 @@ reposition_path (ETreeSorted *ets, ETreeSortedPath *path) for (i = new_index; i <= old_index; i++) parent->children[i]->position = i; e_tree_model_node_changed(E_TREE_MODEL(ets), parent); + e_tree_sorted_node_resorted(ets, parent); e_tree_model_pre_change(E_TREE_MODEL(ets)); } } @@ -481,8 +490,10 @@ resort_node (ETreeSorted *ets, ETreeSortedPath *path, gboolean resort_all_childr path->child_needs_resort = 0; path->needs_regen_to_sort = 0; path->resort_all_children = 0; - if (needs_resort && send_signals && path->num_children > 0) + if (needs_resort && send_signals && path->num_children > 0) { e_tree_model_node_changed(E_TREE_MODEL(ets), path); + e_tree_sorted_node_resorted(ets, path); + } } } @@ -1103,17 +1114,20 @@ ets_sort_info_changed (ETableSortInfo *sort_info, ETreeSorted *ets) /* Initialization and creation */ static void -e_tree_sorted_class_init (GtkObjectClass *klass) +e_tree_sorted_class_init (ETreeSortedClass *klass) { - ETreeModelClass *tree_class = (ETreeModelClass *) klass; + ETreeModelClass *tree_class = E_TREE_MODEL_CLASS (klass); + GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); parent_class = gtk_type_class (PARENT_TYPE); node_chunk = g_mem_chunk_create (ETreeSortedPath, TREEPATH_CHUNK_AREA_SIZE, G_ALLOC_AND_FREE); + + klass->node_resorted = NULL; - klass->destroy = ets_destroy; - klass->set_arg = ets_set_arg; - klass->get_arg = ets_get_arg; + object_class->destroy = ets_destroy; + object_class->set_arg = ets_set_arg; + object_class->get_arg = ets_get_arg; tree_class->get_root = ets_get_root; tree_class->get_parent = ets_get_parent; @@ -1155,6 +1169,16 @@ e_tree_sorted_class_init (GtkObjectClass *klass) gtk_object_add_arg_type ("ETreeSorted::sort_info", E_TABLE_SORT_INFO_TYPE, GTK_ARG_READWRITE, ARG_SORT_INFO); + + signals [NODE_RESORTED] = + gtk_signal_new ("node_resorted", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETreeSortedClass, node_resorted), + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); + + gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); } static void @@ -1279,3 +1303,13 @@ e_tree_sorted_node_num_children (ETreeSorted *ets, ETreeSortedPath *sorted_path = path; return sorted_path->num_children; } + +void +e_tree_sorted_node_resorted (ETreeSorted *sorted, ETreePath node) +{ + g_return_if_fail (sorted != NULL); + g_return_if_fail (E_IS_TREE_SORTED (sorted)); + + gtk_signal_emit (GTK_OBJECT (sorted), + signals [NODE_RESORTED], node); +} diff --git a/widgets/table/e-tree-sorted.h b/widgets/table/e-tree-sorted.h index 1ad5438c29..7181a60ce1 100644 --- a/widgets/table/e-tree-sorted.h +++ b/widgets/table/e-tree-sorted.h @@ -30,6 +30,9 @@ struct ETreeSorted { struct ETreeSortedClass { ETreeModelClass parent_class; + + /* Signals */ + void (*node_resorted) (ETreeSorted *etm, ETreePath node); }; @@ -51,6 +54,10 @@ int e_tree_sorted_orig_position (ETreeSorted *ets, int e_tree_sorted_node_num_children (ETreeSorted *ets, ETreePath path); +void e_tree_sorted_node_resorted (ETreeSorted *tree_model, + ETreePath node); + + #ifdef __cplusplus } #endif /* __cplusplus */ -- cgit