[gimp] Bug 747057 - Usability issues with GimpFileEntry



commit c72bc50e5d1f50eb0ee0a13dbc5d6d9a60dc6e78
Author: Michael Natterer <mitch gimp org>
Date:   Wed Apr 15 22:56:19 2015 +0200

    Bug 747057 - Usability issues with GimpFileEntry
    
    Make the "Show in File Manager" button insensitive when the file entry
    is empty.

 libgimpwidgets/gimpfileentry.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/libgimpwidgets/gimpfileentry.c b/libgimpwidgets/gimpfileentry.c
index 90ccf10..56dc1f5 100644
--- a/libgimpwidgets/gimpfileentry.c
+++ b/libgimpwidgets/gimpfileentry.c
@@ -70,6 +70,8 @@ enum
 
 static void   gimp_file_entry_dispose              (GObject       *object);
 
+static void   gimp_file_entry_entry_changed        (GtkWidget     *widget,
+                                                    GtkWidget     *button);
 static void   gimp_file_entry_entry_activate       (GtkWidget     *widget,
                                                     GimpFileEntry *entry);
 static gint   gimp_file_entry_entry_focus_out      (GtkWidget     *widget,
@@ -134,6 +136,8 @@ gimp_file_entry_init (GimpFileEntry *entry)
   gtk_box_pack_end (GTK_BOX (entry), button, FALSE, FALSE, 0);
   gtk_widget_show (button);
 
+  gtk_widget_set_sensitive (button, FALSE);
+
   image = gtk_image_new_from_icon_name ("gtk-directory", GTK_ICON_SIZE_BUTTON);
   gtk_container_add (GTK_CONTAINER (button), image);
   gtk_widget_show (image);
@@ -161,6 +165,9 @@ gimp_file_entry_init (GimpFileEntry *entry)
   gtk_box_pack_end (GTK_BOX (entry), entry->entry, TRUE, TRUE, 0);
   gtk_widget_show (entry->entry);
 
+  g_signal_connect (entry->entry, "changed",
+                    G_CALLBACK (gimp_file_entry_entry_changed),
+                    button);
   g_signal_connect (entry->entry, "activate",
                     G_CALLBACK (gimp_file_entry_entry_activate),
                     entry);
@@ -290,6 +297,18 @@ gimp_file_entry_set_filename (GimpFileEntry *entry,
 }
 
 static void
+gimp_file_entry_entry_changed (GtkWidget *widget,
+                               GtkWidget *button)
+{
+  const gchar *text = gtk_entry_get_text (GTK_ENTRY (widget));
+
+  if (text && strlen (text))
+    gtk_widget_set_sensitive (button, TRUE);
+  else
+    gtk_widget_set_sensitive (button, FALSE);
+}
+
+static void
 gimp_file_entry_entry_activate (GtkWidget     *widget,
                                 GimpFileEntry *entry)
 {


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