[gtk+/bgo121113-filechooser-single-click-activate: 2/3] Single-click activate for GtkTreeView
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/bgo121113-filechooser-single-click-activate: 2/3] Single-click activate for GtkTreeView
- Date: Fri, 28 May 2010 16:06:06 +0000 (UTC)
commit 37037053f1572190c091d2d1605ad6fe2f1db7c9
Author: Christian Neumair <cneumair gnome org>
Date: Fri May 28 10:59:35 2010 -0500
Single-click activate for GtkTreeView
Signed-off-by: Federico Mena Quintero <federico novell com>
gtk/gtktreeprivate.h | 4 ++++
gtk/gtktreeview.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 53 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtktreeprivate.h b/gtk/gtktreeprivate.h
index e8887e0..ca8a0e5 100644
--- a/gtk/gtktreeprivate.h
+++ b/gtk/gtktreeprivate.h
@@ -271,6 +271,8 @@ struct _GtkTreeViewPrivate
guint has_rules : 1;
guint mark_rows_col_dirty : 1;
+ guint single_click_activate : 1;
+
/* for DnD */
guint empty_view_drop : 1;
@@ -463,6 +465,8 @@ void _gtk_tree_view_column_get_neighbor_sizes (GtkTreeViewColumn *c
gint *left,
gint *right);
+void _gtk_tree_view_set_single_click_activate (GtkTreeView *tree_view,
+ gboolean single_click_activate);
G_END_DECLS
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index c7a5ad7..f165574 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -3021,6 +3021,45 @@ gtk_tree_view_button_release_column_resize (GtkWidget *widget,
}
static gboolean
+gtk_tree_view_button_release_single_click (GtkTreeView *tree_view,
+ GdkEventButton *event)
+{
+ gboolean retval = FALSE;
+
+ if (tree_view->priv->single_click_activate &&
+ (tree_view->priv->selection->type != GTK_SELECTION_MULTIPLE ||
+ (event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) == 0))
+ {
+ GtkTreePath *path;
+ GtkTreeViewColumn *column;
+
+ gtk_tree_view_get_path_at_pos (tree_view,
+ event->x, event->y,
+ &path,
+ &column,
+ NULL,
+ NULL);
+ if (path != NULL)
+ {
+ GtkRBTree *tree = NULL;
+ GtkRBNode *node = NULL;
+
+ _gtk_tree_view_find_node (tree_view, path,
+ &tree, &node);
+ if (node != NULL && (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED)))
+ {
+ gtk_tree_view_row_activated (tree_view, path, column);
+ retval = TRUE;
+ }
+ }
+
+ gtk_tree_path_free (path);
+ }
+
+ return retval;
+}
+
+static gboolean
gtk_tree_view_button_release (GtkWidget *widget,
GdkEventButton *event)
{
@@ -3039,7 +3078,7 @@ gtk_tree_view_button_release (GtkWidget *widget,
return gtk_tree_view_button_release_column_resize (widget, event);
if (tree_view->priv->button_pressed_node == NULL)
- return FALSE;
+ return gtk_tree_view_button_release_single_click (tree_view, event);
if (event->button == 1)
{
@@ -6587,6 +6626,15 @@ _gtk_tree_view_column_autosize (GtkTreeView *tree_view,
gtk_widget_queue_resize (GTK_WIDGET (tree_view));
}
+void
+_gtk_tree_view_set_single_click_activate (GtkTreeView *tree_view,
+ gboolean single_click_activate)
+{
+ g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
+
+ tree_view->priv->single_click_activate = single_click_activate;
+}
+
/* Drag-and-drop */
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]