Commit f92880b6 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

allow to cancel context sensitive help by pressing escape.

2005-12-07  Michael Natterer  <mitch@gimp.org>

	* libgimpwidgets/gimphelpui.c: allow to cancel context sensitive
	help by pressing escape.
parent 432f1082
2005-12-07 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimphelpui.c: allow to cancel context sensitive
help by pressing escape.
2005-12-07 Michael Schumacher <schumaml@cvs.gnome.org>
* app/paint/gimpclone.c
......
......@@ -51,6 +51,9 @@ static gboolean gimp_context_help_idle_start (gpointer widget);
static gboolean gimp_context_help_button_press (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data);
static gboolean gimp_context_help_key_press (GtkWidget *widget,
GdkEventKey *kevent,
gpointer data);
static gboolean gimp_context_help_idle_show_help (gpointer data);
......@@ -377,11 +380,23 @@ gimp_context_help_idle_start (gpointer widget)
return FALSE;
}
if (gdk_keyboard_grab (invisible->window, TRUE,
GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
{
gdk_display_pointer_ungrab (gtk_widget_get_display (invisible),
GDK_CURRENT_TIME);
gtk_widget_destroy (invisible);
return FALSE;
}
gtk_grab_add (invisible);
g_signal_connect (invisible, "button-press-event",
G_CALLBACK (gimp_context_help_button_press),
NULL);
g_signal_connect (invisible, "key-press-event",
G_CALLBACK (gimp_context_help_key_press),
NULL);
}
return FALSE;
......@@ -392,15 +407,15 @@ gimp_context_help_button_press (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data)
{
GtkWidget *event_widget;
event_widget = gtk_get_event_widget ((GdkEvent *) bevent);
GtkWidget *event_widget = gtk_get_event_widget ((GdkEvent *) bevent);
if (event_widget && bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS)
{
GdkDisplay *display = gtk_widget_get_display (widget);
gtk_grab_remove (widget);
gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
bevent->time);
gdk_display_keyboard_ungrab (display, bevent->time);
gdk_display_pointer_ungrab (display, bevent->time);
gtk_widget_destroy (widget);
if (event_widget != widget)
......@@ -410,6 +425,24 @@ gimp_context_help_button_press (GtkWidget *widget,
return TRUE;
}
static gboolean
gimp_context_help_key_press (GtkWidget *widget,
GdkEventKey *kevent,
gpointer data)
{
if (kevent->keyval == GDK_Escape)
{
GdkDisplay *display = gtk_widget_get_display (widget);
gtk_grab_remove (widget);
gdk_display_keyboard_ungrab (display, kevent->time);
gdk_display_pointer_ungrab (display, kevent->time);
gtk_widget_destroy (widget);
}
return TRUE;
}
static gboolean
gimp_context_help_idle_show_help (gpointer data)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment