From ae128ff635fde7de2e99db1dc2818d29bea55545 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Sun, 9 Jan 2005 01:29:30 +0000 Subject: [PATCH] connect to "button_press_event" and start editing immidiately instead of 2005-01-09 Sven Neumann * app/widgets/gimpactionview.c (gimp_action_view_new): connect to "button_press_event" and start editing immidiately instead of waiting for a second click. Fixes bug #163385. --- ChangeLog | 6 ++++ app/widgets/gimpactionview.c | 66 ++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/ChangeLog b/ChangeLog index f52ab9b017..51d35da4f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-01-09 Sven Neumann + + * app/widgets/gimpactionview.c (gimp_action_view_new): connect to + "button_press_event" and start editing immidiately instead of + waiting for a second click. Fixes bug #163385. + 2005-01-09 Sven Neumann * app/widgets/gimpdialogfactory.c (gimp_dialog_factories_toggle): diff --git a/app/widgets/gimpactionview.c b/app/widgets/gimpactionview.c index 2e2c3b1cbc..5cd668b770 100644 --- a/app/widgets/gimpactionview.c +++ b/app/widgets/gimpactionview.c @@ -136,6 +136,68 @@ gimp_action_view_dispose (GObject *object) G_OBJECT_CLASS (parent_class)->dispose (object); } +static gboolean +idle_start_editing (GtkTreeView *tree_view) +{ + GtkTreePath *path; + + path = g_object_get_data (G_OBJECT (tree_view), "start_editing_path"); + + if (path) + { + gtk_widget_grab_focus (GTK_WIDGET (tree_view)); + + gtk_tree_view_set_cursor (tree_view, path, + gtk_tree_view_get_column (tree_view, 1), + TRUE); + + g_object_set_data (G_OBJECT (tree_view), "start_editing_path", NULL); + } + + return FALSE; +} + +static gboolean +gimp_action_view_button_press (GtkWidget *widget, + GdkEventButton *event) +{ + GtkTreeView *tree_view = GTK_TREE_VIEW (widget); + GtkTreePath *path; + + if (event->window != gtk_tree_view_get_bin_window (tree_view)) + return FALSE; + + if (gtk_tree_view_get_path_at_pos (tree_view, + (gint) event->x, + (gint) event->y, + &path, NULL, + NULL, NULL)) + { + GClosure *closure; + GSource *source; + + if (gtk_tree_path_get_depth (path) == 1) + { + gtk_tree_path_free (path); + return FALSE; + } + + g_object_set_data_full (G_OBJECT (tree_view), "start_editing_path", + path, (GDestroyNotify) gtk_tree_path_free); + + g_signal_stop_emission_by_name (tree_view, "button_press_event"); + + closure = g_cclosure_new_object (G_CALLBACK (idle_start_editing), + G_OBJECT (tree_view)); + + source = g_idle_source_new (); + g_source_set_closure (source, closure); + g_source_attach (source, NULL); + } + + return TRUE; +} + GtkWidget * gimp_action_view_new (GimpUIManager *manager, const gchar *select_action, @@ -309,6 +371,10 @@ gimp_action_view_new (GimpUIManager *manager, if (show_shortcuts) { + g_signal_connect (view, "button_press_event", + G_CALLBACK (gimp_action_view_button_press), + NULL); + g_signal_connect (accel_group, "accel-changed", G_CALLBACK (gimp_action_view_accel_changed), view);