libgimpwidgets: in GimpNumberPairEntry, add clear icon

Since the entry behaves differently based on whether the user
provided an explicit input or not, it makes sense to have a button
for clearing the entry.
This commit is contained in:
Ell 2018-02-27 03:50:31 -05:00
parent 45bfa168bf
commit cd8ea6b3ca
1 changed files with 21 additions and 0 deletions

View File

@ -33,6 +33,7 @@
#include "gimpwidgetstypes.h" #include "gimpwidgetstypes.h"
#include "gimpicons.h"
#include "gimpnumberpairentry.h" #include "gimpnumberpairentry.h"
@ -139,6 +140,7 @@ static void gimp_number_pair_entry_get_property (GObject
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gimp_number_pair_entry_changed (GimpNumberPairEntry *entry); static void gimp_number_pair_entry_changed (GimpNumberPairEntry *entry);
static void gimp_number_pair_entry_icon_press (GimpNumberPairEntry *entry);
static gboolean gimp_number_pair_entry_events (GtkWidget *widget, static gboolean gimp_number_pair_entry_events (GtkWidget *widget,
GdkEvent *event); GdkEvent *event);
@ -326,6 +328,9 @@ gimp_number_pair_entry_init (GimpNumberPairEntry *entry)
g_signal_connect (entry, "changed", g_signal_connect (entry, "changed",
G_CALLBACK (gimp_number_pair_entry_changed), G_CALLBACK (gimp_number_pair_entry_changed),
NULL); NULL);
g_signal_connect (entry, "icon-press",
G_CALLBACK (gimp_number_pair_entry_icon_press),
NULL);
g_signal_connect (entry, "focus-out-event", g_signal_connect (entry, "focus-out-event",
G_CALLBACK (gimp_number_pair_entry_events), G_CALLBACK (gimp_number_pair_entry_events),
NULL); NULL);
@ -334,6 +339,10 @@ gimp_number_pair_entry_init (GimpNumberPairEntry *entry)
NULL); NULL);
gtk_widget_set_direction (GTK_WIDGET (entry), GTK_TEXT_DIR_LTR); gtk_widget_set_direction (GTK_WIDGET (entry), GTK_TEXT_DIR_LTR);
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY,
GIMP_ICON_EDIT_CLEAR);
} }
static void static void
@ -773,6 +782,10 @@ gimp_number_pair_entry_modify_font (GimpNumberPairEntry *entry,
gtk_widget_modify_style (GTK_WIDGET (entry), rc_style); gtk_widget_modify_style (GTK_WIDGET (entry), rc_style);
gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY,
! italic);
priv->font_italic = italic; priv->font_italic = italic;
} }
@ -839,6 +852,14 @@ gimp_number_pair_entry_changed (GimpNumberPairEntry *entry)
gimp_number_pair_entry_modify_font (entry, FALSE); gimp_number_pair_entry_modify_font (entry, FALSE);
} }
static void
gimp_number_pair_entry_icon_press (GimpNumberPairEntry *entry)
{
gimp_number_pair_entry_set_user_override (entry, FALSE);
gtk_editable_set_position (GTK_EDITABLE (entry), -1);
}
static gboolean static gboolean
gimp_number_pair_entry_events (GtkWidget *widget, gimp_number_pair_entry_events (GtkWidget *widget,
GdkEvent *event) GdkEvent *event)