[gimp/gimp-2-8] app: GimpContainerEntry's text is red when not a valid item.



commit 202c8ed76283a8550dd0c1c15caae6049b1aa07a
Author: Jehan <jehan girinstud io>
Date:   Sat Apr 27 11:26:04 2013 +0900

    app: GimpContainerEntry's text is red when not a valid item.
    
    If the selected item in a GimpContainerEntry is invalid, or else when the entry
    is being updated, the text shows in red.
    (cherry picked from commit 64fe3af1a913bb61953b6faf727f3cf9700167b7)

 app/widgets/gimpcontainerentry.c |   33 +++++++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/app/widgets/gimpcontainerentry.c b/app/widgets/gimpcontainerentry.c
index 79a785a..9c4290a 100644
--- a/app/widgets/gimpcontainerentry.c
+++ b/app/widgets/gimpcontainerentry.c
@@ -284,7 +284,22 @@ gimp_container_entry_select_item (GimpContainerView *view,
                                    gimp_container_entry_changed,
                                    view);
 
-  gtk_entry_set_text (entry, iter ? gimp_object_get_name (viewable) : "");
+  if (iter)
+    {
+      gtk_widget_modify_text (GTK_WIDGET (entry), GTK_STATE_NORMAL, NULL);
+    }
+  else
+    {
+      /* The selected item does not exist. */
+      GdkColor     gdk_red;
+
+      gdk_red.red = 65535;
+      gdk_red.green = 0;
+      gdk_red.blue = 0;
+
+      gtk_widget_modify_text (GTK_WIDGET (entry), GTK_STATE_NORMAL, &gdk_red);
+    }
+  gtk_entry_set_text (entry, viewable? gimp_object_get_name (viewable) : "");
 
   g_signal_handlers_unblock_by_func (entry,
                                      gimp_container_entry_changed,
@@ -331,7 +346,21 @@ gimp_container_entry_changed (GtkEntry          *entry,
   object = gimp_container_get_child_by_name (container, text);
 
   if (object)
-    gimp_container_view_item_selected (view, GIMP_VIEWABLE (object));
+    {
+      gtk_widget_modify_text (GTK_WIDGET (entry), GTK_STATE_NORMAL, NULL);
+      gimp_container_view_item_selected (view, GIMP_VIEWABLE (object));
+    }
+  else
+    {
+      /* While editing the entry, contents shows in red for non-existent item. */
+      GdkColor     gdk_red;
+
+      gdk_red.red = 65535;
+      gdk_red.green = 0;
+      gdk_red.blue = 0;
+
+      gtk_widget_modify_text (GTK_WIDGET (entry), GTK_STATE_NORMAL, &gdk_red);
+    }
 }
 
 static void


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