install a "key-press-event" handler and reset the entry when the Escape
2008-04-30 Sven Neumann <sven@gimp.org> * app/display/gimpscalecombobox.c: install a "key-press-event" handler and reset the entry when the Escape key is pressed. svn path=/trunk/; revision=25552
This commit is contained in:

committed by
Sven Neumann

parent
1b332ec856
commit
89e4fdbc44
@ -1,3 +1,8 @@
|
|||||||
|
2008-04-30 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/display/gimpscalecombobox.c: install a "key-press-event"
|
||||||
|
handler and reset the entry when the Escape key is pressed.
|
||||||
|
|
||||||
2008-04-29 Sven Neumann <sven@gimp.org>
|
2008-04-29 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* themes/Default/gtkrc
|
* themes/Default/gtkrc
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include "gdk/gdkkeysyms.h"
|
||||||
|
|
||||||
#include "libgimpbase/gimpbase.h"
|
#include "libgimpbase/gimpbase.h"
|
||||||
#include "libgimpmath/gimpmath.h"
|
#include "libgimpmath/gimpmath.h"
|
||||||
@ -58,7 +59,10 @@ static void gimp_scale_combo_box_style_set (GtkWidget *widget,
|
|||||||
GtkStyle *prev_style);
|
GtkStyle *prev_style);
|
||||||
|
|
||||||
static void gimp_scale_combo_box_changed (GimpScaleComboBox *combo_box);
|
static void gimp_scale_combo_box_changed (GimpScaleComboBox *combo_box);
|
||||||
static void gimp_scale_combo_box_entry_activate (GtkEntry *entry,
|
static void gimp_scale_combo_box_entry_activate (GtkWidget *entry,
|
||||||
|
GimpScaleComboBox *combo_box);
|
||||||
|
static gboolean gimp_scale_combo_box_entry_key_press (GtkWidget *entry,
|
||||||
|
GdkEventKey *event,
|
||||||
GimpScaleComboBox *combo_box);
|
GimpScaleComboBox *combo_box);
|
||||||
|
|
||||||
static void gimp_scale_combo_box_scale_iter_set (GtkListStore *store,
|
static void gimp_scale_combo_box_scale_iter_set (GtkListStore *store,
|
||||||
@ -167,6 +171,9 @@ gimp_scale_combo_box_init (GimpScaleComboBox *combo_box)
|
|||||||
g_signal_connect (entry, "activate",
|
g_signal_connect (entry, "activate",
|
||||||
G_CALLBACK (gimp_scale_combo_box_entry_activate),
|
G_CALLBACK (gimp_scale_combo_box_entry_activate),
|
||||||
combo_box);
|
combo_box);
|
||||||
|
g_signal_connect (entry, "key-press-event",
|
||||||
|
G_CALLBACK (gimp_scale_combo_box_entry_key_press),
|
||||||
|
combo_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -303,12 +310,13 @@ gimp_scale_combo_box_parse_text (const gchar *text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_scale_combo_box_entry_activate (GtkEntry *entry,
|
gimp_scale_combo_box_entry_activate (GtkWidget *entry,
|
||||||
GimpScaleComboBox *combo_box)
|
GimpScaleComboBox *combo_box)
|
||||||
{
|
{
|
||||||
|
const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||||
gdouble scale;
|
gdouble scale;
|
||||||
|
|
||||||
if (gimp_scale_combo_box_parse_text (gtk_entry_get_text (entry), &scale) &&
|
if (gimp_scale_combo_box_parse_text (text, &scale) &&
|
||||||
scale >= 1.0 / 256.0 &&
|
scale >= 1.0 / 256.0 &&
|
||||||
scale <= 256.0)
|
scale <= 256.0)
|
||||||
{
|
{
|
||||||
@ -316,7 +324,7 @@ gimp_scale_combo_box_entry_activate (GtkEntry *entry,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_widget_error_bell (GTK_WIDGET (entry));
|
gtk_widget_error_bell (entry);
|
||||||
|
|
||||||
gimp_scale_combo_box_set_scale (combo_box, combo_box->scale);
|
gimp_scale_combo_box_set_scale (combo_box, combo_box->scale);
|
||||||
}
|
}
|
||||||
@ -324,6 +332,23 @@ gimp_scale_combo_box_entry_activate (GtkEntry *entry,
|
|||||||
g_signal_emit (combo_box, scale_combo_box_signals[ENTRY_ACTIVATED], 0);
|
g_signal_emit (combo_box, scale_combo_box_signals[ENTRY_ACTIVATED], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gimp_scale_combo_box_entry_key_press (GtkWidget *entry,
|
||||||
|
GdkEventKey *event,
|
||||||
|
GimpScaleComboBox *combo_box)
|
||||||
|
{
|
||||||
|
if (event->keyval == GDK_Escape)
|
||||||
|
{
|
||||||
|
gimp_scale_combo_box_set_scale (combo_box, combo_box->scale);
|
||||||
|
|
||||||
|
g_signal_emit (combo_box, scale_combo_box_signals[ENTRY_ACTIVATED], 0);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_scale_combo_box_scale_iter_set (GtkListStore *store,
|
gimp_scale_combo_box_scale_iter_set (GtkListStore *store,
|
||||||
GtkTreeIter *iter,
|
GtkTreeIter *iter,
|
||||||
|
Reference in New Issue
Block a user