From a1bf73c3f1e291e7825a7020fdbb899c7656fc91 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 11 Mar 2006 05:47:09 +0000 Subject: [PATCH] =?UTF-8?q?Allow=20to=20cancel=20a=20drag=20with=20ESC.=20?= =?UTF-8?q?(#58389,=20S=C3=B8ren=20Sandmann)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2006-03-11 Matthias Clasen * gtk/gtkrange.c (gtk_range_key_press): Allow to cancel a drag with ESC. (#58389, Søren Sandmann) --- ChangeLog | 5 +++++ ChangeLog.pre-2-10 | 5 +++++ gtk/gtkrange.c | 24 ++++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/ChangeLog b/ChangeLog index ea24cc8cd8..058e653301 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-03-11 Matthias Clasen + + * gtk/gtkrange.c (gtk_range_key_press): Allow to cancel + a drag with ESC. (#58389, Søren Sandmann) + 2006-03-10 Matthias Clasen * gtk/gtkrange.c: Add a style property ::activate_slider that diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index ea24cc8cd8..058e653301 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +2006-03-11 Matthias Clasen + + * gtk/gtkrange.c (gtk_range_key_press): Allow to cancel + a drag with ESC. (#58389, Søren Sandmann) + 2006-03-10 Matthias Clasen * gtk/gtkrange.c: Add a style property ::activate_slider that diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index a5f5ca2fb6..b1dcc14491 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "gtkintl.h" #include "gtkmain.h" #include "gtkmarshalers.h" @@ -186,6 +187,8 @@ static gboolean gtk_range_real_change_value (GtkRange *range, GtkScrollType scroll, gdouble value); static void gtk_range_update_value (GtkRange *range); +static gboolean gtk_range_key_press (GtkWidget *range, + GdkEventKey *event); static GtkWidgetClass *parent_class = NULL; @@ -255,6 +258,7 @@ gtk_range_class_init (GtkRangeClass *class) widget_class->grab_notify = gtk_range_grab_notify; widget_class->state_changed = gtk_range_state_changed; widget_class->style_set = gtk_range_style_set; + widget_class->key_press_event = gtk_range_key_press; class->move_slider = gtk_range_move_slider; class->change_value = gtk_range_real_change_value; @@ -1410,6 +1414,26 @@ coord_to_value (GtkRange *range, return value; } +static gboolean +gtk_range_key_press (GtkWidget *widget, + GdkEventKey *event) +{ + GtkRange *range = (GtkRange *)widget; + + if (event->keyval == GDK_Escape) + { + stop_scrolling (range); + + update_slider_position (range, + range->slide_initial_coordinate, + range->slide_initial_coordinate); + + return TRUE; + } + + return FALSE; +} + static gint gtk_range_button_press (GtkWidget *widget, GdkEventButton *event)