[gimp] app: add gimp_prop_polar_new()



commit fe7aa1384da90ddfe6484e23567b920b02bc1b64
Author: Michael Natterer <mitch gimp org>
Date:   Fri May 30 00:33:02 2014 +0200

    app: add gimp_prop_polar_new()

 app/widgets/gimppropwidgets.c |   49 +++++++++++++++++++++++++++++++++++++---
 app/widgets/gimppropwidgets.h |    4 +++
 2 files changed, 49 insertions(+), 4 deletions(-)
---
diff --git a/app/widgets/gimppropwidgets.c b/app/widgets/gimppropwidgets.c
index 6414e64..248af86 100644
--- a/app/widgets/gimppropwidgets.c
+++ b/app/widgets/gimppropwidgets.c
@@ -48,6 +48,7 @@
 #include "gimpscalebutton.h"
 #include "gimpspinscale.h"
 #include "gimpview.h"
+#include "gimppolar.h"
 #include "gimppropwidgets.h"
 #include "gimpwidgets-constructors.h"
 #include "gimpwidgets-utils.h"
@@ -808,10 +809,9 @@ gimp_prop_angle_dial_new (GObject     *config,
   dial = gimp_dial_new ();
 
   g_object_set (dial,
-                "size",         32,
-                "border-width", 0,
-                "background",   GIMP_CIRCLE_BACKGROUND_PLAIN,
-                "draw-beta",    FALSE,
+                "size",       32,
+                "background", GIMP_CIRCLE_BACKGROUND_PLAIN,
+                "draw-beta",  FALSE,
                 NULL);
 
   set_param_spec (G_OBJECT (dial), dial, param_spec);
@@ -896,6 +896,47 @@ gimp_prop_angle_range_dial_new  (GObject     *config,
   return dial;
 }
 
+GtkWidget *
+gimp_prop_polar_new  (GObject     *config,
+                      const gchar *angle_property_name,
+                      const gchar *radius_property_name)
+{
+  GParamSpec *angle_param_spec;
+  GParamSpec *radius_param_spec;
+  GtkWidget  *polar;
+
+  angle_param_spec = find_param_spec (config, angle_property_name, G_STRFUNC);
+  if (! angle_param_spec)
+    return NULL;
+
+  radius_param_spec = find_param_spec (config, radius_property_name, G_STRFUNC);
+  if (! radius_param_spec)
+    return NULL;
+
+  polar = gimp_polar_new ();
+
+  g_object_set (polar,
+                "size",         90,
+                "border-width", 3,
+                "background",   GIMP_CIRCLE_BACKGROUND_HSV,
+                NULL);
+
+  g_object_bind_property_full (config, angle_property_name,
+                               polar,  "angle",
+                               G_BINDING_BIDIRECTIONAL |
+                               G_BINDING_SYNC_CREATE,
+                               deg_to_rad,
+                               rad_to_deg,
+                               NULL, NULL);
+
+  g_object_bind_property (config, radius_property_name,
+                          polar, "radius",
+                          G_BINDING_BIDIRECTIONAL |
+                          G_BINDING_SYNC_CREATE);
+
+  return polar;
+}
+
 
 /**********/
 /*  view  */
diff --git a/app/widgets/gimppropwidgets.h b/app/widgets/gimppropwidgets.h
index e0c7b99..233b6f7 100644
--- a/app/widgets/gimppropwidgets.h
+++ b/app/widgets/gimppropwidgets.h
@@ -73,6 +73,10 @@ GtkWidget * gimp_prop_angle_range_dial_new  (GObject       *config,
                                              const gchar   *beta_property_name,
                                              const gchar   *clockwise_property_name);
 
+GtkWidget * gimp_prop_polar_new             (GObject       *config,
+                                             const gchar   *angle_property_name,
+                                             const gchar   *radius_property_name);
+
 
 /*  GParamObject (GimpViewable)  */
 


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