From ec99a182715d6c2efe1167adde2a2b4120a5b8b7 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Fri, 26 Oct 2001 09:00:36 +0000 Subject: If the root node is hidden and selected, don't count it in the selected 2001-10-26 Christopher James Lahey * e-tree-selection-model.c (etsm_selected_count): If the root node is hidden and selected, don't count it in the selected path count. * e-tree.c (et_canvas_root_event): Attach to the event handler on the root canvas item instead of the canvas itself when making the ETree leave editing state. svn path=/trunk/; revision=14128 --- widgets/table/e-tree-selection-model.c | 36 +++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 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 fca526eaf0..6f7a51d651 100644 --- a/widgets/table/e-tree-selection-model.c +++ b/widgets/table/e-tree-selection-model.c @@ -599,19 +599,18 @@ etsm_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) } static ETreeSelectionModelNode * -etsm_recurse_is_path_selected (ESelectionModel *selection, +etsm_recurse_is_path_selected (ETreeSelectionModel *etsm, ETreePath path, gboolean *is_selected) { ETreeSelectionModelNode *selection_node; - ETreeSelectionModel *etsm = E_TREE_SELECTION_MODEL(selection); ETreeSorted *ets = etsm->priv->ets; ETreePath parent; parent = e_tree_model_node_get_parent(E_TREE_MODEL(ets), path); if (parent) { - selection_node = etsm_recurse_is_path_selected (selection, parent, is_selected); + selection_node = etsm_recurse_is_path_selected (etsm, parent, is_selected); if (selection_node) { int position = e_tree_sorted_orig_position(ets, path); if (position < 0 || position >= selection_node->num_children) { @@ -651,6 +650,21 @@ etsm_recurse_is_path_selected (ESelectionModel *selection, } } +static gboolean +etsm_is_path_selected (ETreeSelectionModel *etsm, + ETreePath path) +{ + ETreeSelectionModelNode *selection_node; + gboolean ret_val; + + selection_node = etsm_recurse_is_path_selected (etsm, path, &ret_val); + + if (selection_node) + ret_val = selection_node->selected; + + return ret_val; +} + /** * e_selection_model_is_row_selected * @selection: #ESelectionModel to check @@ -666,22 +680,13 @@ etsm_is_row_selected (ESelectionModel *selection, { ETreeSelectionModel *etsm = E_TREE_SELECTION_MODEL(selection); ETreePath path; - ETreeSelectionModelNode *selection_node; - - gboolean ret_val; g_return_val_if_fail(row < e_table_model_row_count(E_TABLE_MODEL(etsm->priv->etta)), FALSE); g_return_val_if_fail(row >= 0, FALSE); - g_return_val_if_fail(selection != NULL, FALSE); + g_return_val_if_fail(etsm != NULL, FALSE); path = e_tree_table_adapter_node_at_row(etsm->priv->etta, row); - - selection_node = etsm_recurse_is_path_selected (selection, path, &ret_val); - - if (selection_node) - ret_val = selection_node->selected; - - return ret_val; + return etsm_is_path_selected (etsm, path); } @@ -803,6 +808,9 @@ etsm_selected_count (ESelectionModel *selection) ETreePath model_root; model_root = e_tree_model_get_root(etsm->priv->model); etsm_selected_count_recurse(etsm, etsm->priv->root, model_root, &count); + if (!e_tree_table_adapter_root_node_is_visible (etsm->priv->etta) && etsm_is_path_selected (etsm, e_tree_model_get_root(etsm->priv->model))) { + count --; + } } return count; } -- cgit v1.2.3