From 0f85f30ab1145a7ed3c6ee7b2e2216874dc2074f Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Fri, 13 Apr 2001 00:40:49 +0000 Subject: Upped the version number to 0.6.99.0. Upped the so number to 6. 2001-04-12 Christopher James Lahey * configure.in: Upped the version number to 0.6.99.0. Upped the so number to 6. * docs/etablexml.txt: Made some updates here. * tests/test-tree-1.c, tests/test-tree-3.c: Added NULL, NULL to the call to e_tree_memory_callbacks_new. From gal/e-table/ChangeLog: 2001-04-12 Christopher James Lahey * e-table-item.c (eti_cursor_change): Only move the screen to show the cursor if there are no changes pending. Updated the commented out code for alternating colors a bit. * e-table-model.c, e-table-model.h: Added e_table_model_has_change_pending. * e-tree-memory-callbacks.c, e-tree-memory-callbacks.h: Added has_get_node_by_id and get_node_by_id. * e-tree-model.c, e-tree-model.h: Added e_tree_model_has_get_node_by_id and e_tree_model_get_node_by_id. Added e_tree_model_has_change_pending. * e-tree-selection-model.c: Handle the selection and cursor properly across the tree changing. * e-tree-sorted.c: Implemented has_get_node_by_id and get_node_by_id, and has_changes_pending. * e-tree-table-adapter.c: Implemented has_changes_pending. Fixed an array underflow. svn path=/trunk/; revision=9289 --- widgets/table/e-tree-selection-model.c | 83 ++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 18 deletions(-) (limited to 'widgets/table/e-tree-selection-model.c') diff --git a/widgets/table/e-tree-selection-model.c b/widgets/table/e-tree-selection-model.c index e376352f19..6ae9f209a6 100644 --- a/widgets/table/e-tree-selection-model.c +++ b/widgets/table/e-tree-selection-model.c @@ -54,6 +54,8 @@ struct ETreeSelectionModelPriv { gint cursor_col; ETreePath selection_start_path; + char *cursor_save_id; + int tree_model_pre_change_id; int tree_model_node_changed_id; int tree_model_node_data_changed_id; @@ -165,8 +167,8 @@ etsm_real_clear (ETreeSelectionModel *etsm) static ETreeSelectionModelNode * etsm_find_node_unless_equals (ETreeSelectionModel *etsm, - ETreePath path, - gboolean grow) + ETreePath path, + gboolean grow) { ETreeSelectionModelNode *selection_node; ETreeSorted *ets = etsm->priv->ets; @@ -333,22 +335,59 @@ update_parents (ETreeSelectionModel *etsm, ETreePath path) static void etsm_pre_change (ETreeModel *etm, ETreeSelectionModel *etsm) { + g_free (etsm->priv->cursor_save_id); + etsm->priv->cursor_save_id = NULL; + + if (e_tree_model_has_get_node_by_id (etm) && + e_tree_model_has_save_id (etm) && + etsm->priv->cursor_path) { + etsm->priv->cursor_save_id = e_tree_model_get_save_id (etm, etsm->priv->cursor_path); + } } static void etsm_node_changed (ETreeModel *etm, ETreePath node, ETreeSelectionModel *etsm) { + int cursor_row; + etsm_real_clear (etsm); + + if (e_tree_model_has_get_node_by_id (etm) && etsm->priv->cursor_save_id) { + ETreePath cursor_path; + + cursor_path = e_tree_model_get_node_by_id (etm, etsm->priv->cursor_save_id); + etsm->priv->cursor_path = cursor_path; + if (cursor_path != NULL && etsm->priv->cursor_col == -1) + etsm->priv->cursor_col = 0; + + e_tree_selection_model_select_single_path(etsm, cursor_path); + } + + cursor_row = etsm_cursor_row_real (etsm); + e_selection_model_selection_changed(E_SELECTION_MODEL(etsm)); + if (cursor_row != -1) + e_selection_model_cursor_changed(E_SELECTION_MODEL(etsm), cursor_row, etsm->priv->cursor_col); + else { + e_selection_model_cursor_changed(E_SELECTION_MODEL(etsm), -1, -1); + e_selection_model_cursor_activated(E_SELECTION_MODEL(etsm), -1, -1); + } + + g_free (etsm->priv->cursor_save_id); + etsm->priv->cursor_save_id = NULL; } static void etsm_node_data_changed (ETreeModel *etm, ETreePath node, ETreeSelectionModel *etsm) { + g_free (etsm->priv->cursor_save_id); + etsm->priv->cursor_save_id = NULL; } static void etsm_node_col_changed (ETreeModel *etm, ETreePath node, int col, ETreeSelectionModel *etsm) { + g_free (etsm->priv->cursor_save_id); + etsm->priv->cursor_save_id = NULL; } static void @@ -391,6 +430,7 @@ etsm_sorted_node_changed (ETreeModel *etm, ETreePath node, ETreeSelectionModel * { int cursor_row = etsm_cursor_row_real (etsm); e_selection_model_selection_changed(E_SELECTION_MODEL(etsm)); + if (cursor_row != -1) e_selection_model_cursor_changed(E_SELECTION_MODEL(etsm), cursor_row, etsm->priv->cursor_col); else @@ -546,7 +586,11 @@ etsm_destroy (GtkObject *object) etsm_real_clear (etsm); drop_model(etsm); drop_ets(etsm); + + g_free (etsm->priv->cursor_save_id); + g_free(etsm->priv); + etsm->priv = NULL; } static void @@ -1110,27 +1154,30 @@ static void e_tree_selection_model_init (ETreeSelectionModel *etsm) { ETreeSelectionModelPriv *priv; - priv = g_new(ETreeSelectionModelPriv, 1); - etsm->priv = priv; + priv = g_new(ETreeSelectionModelPriv, 1); + etsm->priv = priv; - priv->etta = NULL; - priv->ets = NULL; - priv->model = NULL; + priv->etta = NULL; + priv->ets = NULL; + priv->model = NULL; - priv->root = NULL; + priv->root = NULL; - priv->cursor_path = NULL; - priv->cursor_col = -1; - priv->selection_start_path = NULL; + priv->cursor_path = NULL; + priv->cursor_col = -1; + priv->selection_start_path = NULL; - priv->tree_model_pre_change_id = 0; - priv->tree_model_node_changed_id = 0; - priv->tree_model_node_data_changed_id = 0; - priv->tree_model_node_col_changed_id = 0; - priv->tree_model_node_inserted_id = 0; - priv->tree_model_node_removed_id = 0; + priv->cursor_save_id = NULL; + + + priv->tree_model_pre_change_id = 0; + priv->tree_model_node_changed_id = 0; + priv->tree_model_node_data_changed_id = 0; + priv->tree_model_node_col_changed_id = 0; + priv->tree_model_node_inserted_id = 0; + priv->tree_model_node_removed_id = 0; - priv->sorted_model_pre_change_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; -- cgit