[gimp] app: experimental: use the new coordinate picking in property tables



commit 38e9c79d1e1ab725939cf12becd435c37e1bff74
Author: Michael Natterer <mitch gimp org>
Date:   Thu May 30 23:36:39 2013 +0200

    app: experimental: use the new coordinate picking in property tables
    
    If we add a chain button to link x/y or width/height properties, also
    add a coordinate pick button for these properties. This looks totally
    ugly and is broken for most cases where it happens, but it works
    nicely for e.g. gegl:fractal-explorer or gegl:grid. This clearly needs
    some metadata for operation properties to be useful.

 app/widgets/gimpproptable.c |   40 ++++++++++++++++++++++++++++++++++------
 1 files changed, 34 insertions(+), 6 deletions(-)
---
diff --git a/app/widgets/gimpproptable.c b/app/widgets/gimpproptable.c
index f229583..f626342 100644
--- a/app/widgets/gimpproptable.c
+++ b/app/widgets/gimpproptable.c
@@ -97,6 +97,7 @@ gimp_prop_table_new (GObject              *config,
   guint          n_param_specs;
   gint           i;
   gint           row = 0;
+  GParamSpec    *last_pspec = NULL;
   GtkAdjustment *last_x_adj = NULL;
   gint           last_x_row = 0;
 
@@ -244,11 +245,13 @@ gimp_prop_table_new (GObject              *config,
           if (g_str_has_suffix (pspec->name, "x") ||
               g_str_has_suffix (pspec->name, "width"))
             {
+              last_pspec = pspec;
               last_x_adj = adj;
               last_x_row = row;
             }
           else if ((g_str_has_suffix (pspec->name, "y") ||
                     g_str_has_suffix (pspec->name, "height")) &&
+                   last_pspec != NULL &&
                    last_x_adj != NULL &&
                    last_x_row == row - 1)
             {
@@ -279,6 +282,28 @@ gimp_prop_table_new (GObject              *config,
                                 last_x_adj);
 
               g_object_set_data (G_OBJECT (last_x_adj), "y-adjustment", adj);
+
+              if (create_picker_func)
+                {
+                  GtkWidget *button;
+                  gchar     *pspec_name;
+
+                  pspec_name = g_strconcat (last_pspec->name, ":",
+                                            pspec->name, NULL);
+
+                  button = create_picker_func (picker_creator,
+                                               pspec_name,
+                                               GIMP_STOCK_CURSOR,
+                                               _("Pick coordinates from the image"));
+                  gtk_table_attach (GTK_TABLE (table), button,
+                                    4, 5, last_x_row, row + 1,
+                                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL,
+                                    0, 0);
+                  gtk_widget_show (button);
+
+                  g_object_weak_ref (G_OBJECT (button),
+                                     (GWeakNotify) g_free, pspec_name);
+                }
             }
         }
       else if (GIMP_IS_PARAM_SPEC_RGB (pspec))
@@ -296,12 +321,15 @@ gimp_prop_table_new (GObject              *config,
           gtk_box_pack_start (GTK_BOX (widget), button, TRUE, TRUE, 0);
           gtk_widget_show (button);
 
-          button = create_picker_func (picker_creator,
-                                       pspec->name,
-                                       GIMP_STOCK_COLOR_PICKER_GRAY,
-                                       _("Pick color from image"));
-          gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
-          gtk_widget_show (button);
+          if (create_picker_func)
+            {
+              button = create_picker_func (picker_creator,
+                                           pspec->name,
+                                           GIMP_STOCK_COLOR_PICKER_GRAY,
+                                           _("Pick color from the image"));
+              gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
+              gtk_widget_show (button);
+            }
 
           label = g_param_spec_get_nick (pspec);
         }


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