diff options
Diffstat (limited to 'widgets/table')
-rw-r--r-- | widgets/table/e-tree-selection-model.c | 36 | ||||
-rw-r--r-- | widgets/table/e-tree.c | 35 |
2 files changed, 48 insertions, 23 deletions
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; } diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c index 6bbf20f16c..edd2a960eb 100644 --- a/widgets/table/e-tree.c +++ b/widgets/table/e-tree.c @@ -45,6 +45,14 @@ static GtkObjectClass *parent_class; +#define d(x) + +#if d(!)0 +#define e_table_item_leave_edit_(x) (e_table_item_leave_edit((x)), g_print ("%s: e_table_item_leave_edit\n", __FUNCTION__)) +#else +#define e_table_item_leave_edit_(x) (e_table_item_leave_edit((x))) +#endif + enum { CURSOR_CHANGE, CURSOR_ACTIVATED, @@ -685,14 +693,23 @@ et_canvas_realize (GtkWidget *canvas, ETree *e_tree) } static gint -et_canvas_button_press (GtkWidget *canvas, GdkEventButton *event, ETree *e_tree) -{ - if (GTK_WIDGET_HAS_FOCUS(canvas)) { - GnomeCanvasItem *item = GNOME_CANVAS(canvas)->focused_item; - - if (E_IS_TABLE_ITEM(item)) { - e_table_item_leave_edit(E_TABLE_ITEM(item)); +et_canvas_root_event (GnomeCanvasItem *root, GdkEvent *event, ETree *e_tree) +{ + switch (event->type) { + case GDK_BUTTON_PRESS: + case GDK_2BUTTON_PRESS: + case GDK_BUTTON_RELEASE: + if (GTK_WIDGET_HAS_FOCUS(root->canvas)) { + GnomeCanvasItem *item = GNOME_CANVAS(root->canvas)->focused_item; + + if (E_IS_TABLE_ITEM(item)) { + e_table_item_leave_edit_(E_TABLE_ITEM(item)); + return TRUE; + } } + break; + default: + break; } return FALSE; @@ -781,8 +798,8 @@ e_tree_setup_table (ETree *e_tree) GTK_OBJECT(e_tree->priv->table_canvas), "realize", GTK_SIGNAL_FUNC(et_canvas_realize), e_tree); gtk_signal_connect ( - GTK_OBJECT(e_tree->priv->table_canvas), "button_press_event", - GTK_SIGNAL_FUNC(et_canvas_button_press), e_tree); + GTK_OBJECT(gnome_canvas_root (e_tree->priv->table_canvas)), "event", + GTK_SIGNAL_FUNC(et_canvas_root_event), e_tree); et_build_item(e_tree); } |