[gimp] libgimpwidgets: in GimpNumberPairEntry, add clear icon



commit cd8ea6b3ca5cd1f2595154c9a2f63130537e7ecb
Author: Ell <ell_se yahoo com>
Date:   Tue Feb 27 03:50:31 2018 -0500

    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.

 libgimpwidgets/gimpnumberpairentry.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/libgimpwidgets/gimpnumberpairentry.c b/libgimpwidgets/gimpnumberpairentry.c
index 4c0e0ac..38944fe 100644
--- a/libgimpwidgets/gimpnumberpairentry.c
+++ b/libgimpwidgets/gimpnumberpairentry.c
@@ -33,6 +33,7 @@
 
 #include "gimpwidgetstypes.h"
 
+#include "gimpicons.h"
 #include "gimpnumberpairentry.h"
 
 
@@ -139,6 +140,7 @@ static void         gimp_number_pair_entry_get_property      (GObject
                                                               GValue              *value,
                                                               GParamSpec          *pspec);
 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,
                                                               GdkEvent            *event);
 
@@ -326,6 +328,9 @@ gimp_number_pair_entry_init (GimpNumberPairEntry *entry)
   g_signal_connect (entry, "changed",
                     G_CALLBACK (gimp_number_pair_entry_changed),
                     NULL);
+  g_signal_connect (entry, "icon-press",
+                    G_CALLBACK (gimp_number_pair_entry_icon_press),
+                    NULL);
   g_signal_connect (entry, "focus-out-event",
                     G_CALLBACK (gimp_number_pair_entry_events),
                     NULL);
@@ -334,6 +339,10 @@ gimp_number_pair_entry_init (GimpNumberPairEntry *entry)
                     NULL);
 
   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
@@ -773,6 +782,10 @@ gimp_number_pair_entry_modify_font (GimpNumberPairEntry *entry,
 
   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;
 }
 
@@ -839,6 +852,14 @@ gimp_number_pair_entry_changed (GimpNumberPairEntry *entry)
   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
 gimp_number_pair_entry_events (GtkWidget *widget,
                                GdkEvent  *event)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]