[gimp] Set the correct icons if the entry changed a property in the XMPModel and use the new EntryWidget fo



commit 9578088ce8f6f481b28c62cb514babf5846eb7fc
Author: Roman Joost <romanofski gimp org>
Date:   Sat Sep 26 19:12:25 2009 +1000

    Set the correct icons if the entry changed a property in the XMPModel and use the new EntryWidget for the caption writer as well.

 plug-ins/metadata/gimpxmpmodelentry.c |   43 +++++++++++++++++++++++++++++++-
 plug-ins/metadata/interface.c         |    4 +--
 2 files changed, 42 insertions(+), 5 deletions(-)
---
diff --git a/plug-ins/metadata/gimpxmpmodelentry.c b/plug-ins/metadata/gimpxmpmodelentry.c
index 950200e..ddc74d2 100644
--- a/plug-ins/metadata/gimpxmpmodelentry.c
+++ b/plug-ins/metadata/gimpxmpmodelentry.c
@@ -19,7 +19,8 @@
 
 #include <string.h>
 
-#include <gtk/gtk.h>
+#include <libgimp/gimp.h>
+#include <libgimp/gimpui.h>
 
 #include "xmp-schemas.h"
 #include "xmp-model.h"
@@ -37,6 +38,8 @@ static void         entry_changed                   (GimpXMPModelEntry *widget);
 
 const gchar*        find_schema_prefix              (const gchar *schema_uri);
 
+static void         set_property_edit_icon          (GimpXMPModelEntry *entry,
+                                                     GtkTreeIter       *iter);
 
 
 G_DEFINE_TYPE (GimpXMPModelEntry, gimp_xmp_model_entry, GTK_TYPE_ENTRY)
@@ -109,14 +112,19 @@ gimp_entry_xmp_model_changed (XMPModel     *xmp_model,
   GimpXMPModelEntry *entry = GIMP_XMP_MODEL_ENTRY (user_data);
   const gchar       *tree_value;
   const gchar       *property_name;
+  GdkPixbuf         *icon;
 
   gtk_tree_model_get (GTK_TREE_MODEL (xmp_model), iter,
                       COL_XMP_NAME, &property_name,
                       COL_XMP_VALUE, &tree_value,
+                      COL_XMP_EDIT_ICON, &icon,
                       -1);
   if (! strcmp (entry->property_name, property_name))
     gtk_entry_set_text (GTK_ENTRY (entry), tree_value);
 
+  if (icon == NULL)
+    set_property_edit_icon (entry, iter);
+
   return;
 }
 
@@ -128,7 +136,6 @@ entry_changed (GimpXMPModelEntry *entry)
                                  entry->schema_uri,
                                  entry->property_name,
                                  gtk_entry_get_text (GTK_ENTRY (entry)));
-
 }
 
 /* find the schema prefix for the given URI */
@@ -144,3 +151,35 @@ find_schema_prefix (const gchar *schema_uri)
   }
   return NULL;
 }
+
+static void
+set_property_edit_icon (GimpXMPModelEntry *entry,
+                        GtkTreeIter       *iter)
+{
+  GdkPixbuf    *icon;
+  gboolean      editable;
+
+  gtk_tree_model_get (GTK_TREE_MODEL (entry->xmp_model), iter,
+                      COL_XMP_EDITABLE, &editable,
+                      COL_XMP_EDIT_ICON, &icon,
+                      -1);
+
+  if (editable == XMP_AUTO_UPDATE)
+    {
+      icon = gtk_widget_render_icon (GTK_WIDGET (entry), GIMP_STOCK_WILBER,
+                                     GTK_ICON_SIZE_MENU, NULL);
+      gtk_tree_store_set (GTK_TREE_STORE (entry->xmp_model), iter,
+                          COL_XMP_EDIT_ICON, icon,
+                          -1);
+    }
+  else if (editable == TRUE)
+    {
+      icon = gtk_widget_render_icon (GTK_WIDGET (entry), GTK_STOCK_EDIT,
+                                     GTK_ICON_SIZE_MENU, NULL);
+      gtk_tree_store_set (GTK_TREE_STORE (entry->xmp_model), iter,
+                          COL_XMP_EDIT_ICON, icon,
+                          -1);
+    }
+
+  return;
+}
diff --git a/plug-ins/metadata/interface.c b/plug-ins/metadata/interface.c
index a2569db..31c8d31 100644
--- a/plug-ins/metadata/interface.c
+++ b/plug-ins/metadata/interface.c
@@ -285,7 +285,6 @@ add_description_tab (GtkWidget   *notebook,
                              entry, 1, FALSE);
 
   entry = gimp_xmp_model_entry_new (XMP_SCHEMA_DUBLIN_CORE, "creator", mgui->xmp_model);
-  //register_entry_xref (entry, XMP_SCHEMA_DUBLIN_CORE, "creator", mgui);
   gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
                              _("_Author:"), 0.0, 0.5,
                              entry, 1, FALSE);
@@ -309,8 +308,7 @@ add_description_tab (GtkWidget   *notebook,
            _("_Description:"), 0.0, 0.5,
            scrolled_window, 1, FALSE);
 
-  entry = gtk_entry_new ();
-  register_entry_xref (entry, XMP_SCHEMA_PHOTOSHOP, "CaptionWriter", mgui);
+  entry = gimp_xmp_model_entry_new (XMP_SCHEMA_PHOTOSHOP, "CaptionWriter", mgui->xmp_model);
   gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
            _("Description _writer:"), 0.0, 0.5,
            entry, 1, FALSE);



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