[gimp/soc-2010-cage] Enhancement of the CageOptions object to allow the selection of the mode (creation or transform of t



commit ddfde7d3173d6aafccd338189efe53d984b323a6
Author: Michael Muré <batolettre gmail com>
Date:   Fri Jul 2 10:52:10 2010 +0200

    Enhancement of the CageOptions object to allow the selection of the mode (creation or transform of the cage) + basic gui

 app/tools/gimpcageoptions.c |   88 ++++++++++++++++++++++++++++++++++++++++++-
 app/tools/gimpcageoptions.h |    6 +++
 app/tools/gimpcagetool.c    |    6 +-
 app/tools/tools-enums.c     |   29 ++++++++++++++
 app/tools/tools-enums.h     |   10 +++++
 5 files changed, 135 insertions(+), 4 deletions(-)
---
diff --git a/app/tools/gimpcageoptions.c b/app/tools/gimpcageoptions.c
index 31d5419..f1c7cec 100644
--- a/app/tools/gimpcageoptions.c
+++ b/app/tools/gimpcageoptions.c
@@ -35,10 +35,27 @@
 
 #include "gimpcagetool.h"
 #include "gimpcageoptions.h"
+#include "gimptooloptions-gui.h"
 
 #include "gimp-intl.h"
 
 
+enum
+{
+  PROP_0,
+  PROP_CAGE_MODE
+};
+
+static void gimp_cage_options_set_property  (GObject      *object,
+                                             guint         property_id,
+                                             const GValue *value,
+                                             GParamSpec   *pspec);
+                                 
+static void gimp_cage_options_get_property  (GObject    *object,
+                                             guint       property_id,
+                                             GValue     *value,
+                                             GParamSpec *pspec);
+                                 
 G_DEFINE_TYPE (GimpCageOptions, gimp_cage_options,
                GIMP_TYPE_TRANSFORM_OPTIONS)
 
@@ -48,7 +65,16 @@ G_DEFINE_TYPE (GimpCageOptions, gimp_cage_options,
 static void
 gimp_cage_options_class_init (GimpCageOptionsClass *klass)
 {
- 
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->set_property = gimp_cage_options_set_property;
+  object_class->get_property = gimp_cage_options_get_property;
+
+  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_CAGE_MODE,
+                                 "cage-mode", NULL,
+                                 GIMP_TYPE_CAGE_MODE,
+                                 GIMP_CAGE_MODE_CAGE_CHANGE,
+                                 GIMP_PARAM_STATIC_STRINGS);
 }
 
 static void
@@ -56,3 +82,63 @@ gimp_cage_options_init (GimpCageOptions *options)
 {
 	
 }
+
+static void
+gimp_cage_options_set_property  (GObject      *object,
+                                 guint         property_id,
+                                 const GValue *value,
+                                 GParamSpec   *pspec)
+{
+  GimpCageOptions *options = GIMP_CAGE_OPTIONS (object);
+
+  switch (property_id)
+    {
+    case PROP_CAGE_MODE:
+      options->cage_mode = g_value_get_enum (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+}
+
+static void
+gimp_cage_options_get_property  (GObject    *object,
+                                 guint       property_id,
+                                 GValue     *value,
+                                 GParamSpec *pspec)
+{
+  GimpCageOptions *options = GIMP_CAGE_OPTIONS (object);
+
+  switch (property_id)
+    {
+    case PROP_CAGE_MODE:
+      g_value_set_enum (value, options->cage_mode);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+}
+
+GtkWidget *
+gimp_cage_options_gui (GimpToolOptions *tool_options)
+{
+  GObject   *config = G_OBJECT (tool_options);
+  GtkWidget *vbox   = gimp_tool_options_gui (tool_options);
+  GtkWidget *hbox;
+  GtkWidget *mode;
+
+  hbox = gtk_hbox_new (FALSE, 2);
+  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+  gtk_widget_show (hbox);
+
+
+  mode = gimp_prop_enum_radio_box_new (config, "cage-mode", 0, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), mode, FALSE, FALSE, 0);
+  gtk_widget_show (mode);
+  
+  return vbox;
+}
diff --git a/app/tools/gimpcageoptions.h b/app/tools/gimpcageoptions.h
index 72e1f44..0c9571f 100644
--- a/app/tools/gimpcageoptions.h
+++ b/app/tools/gimpcageoptions.h
@@ -21,6 +21,7 @@
 #define __GIMP_CAGE_OPTIONS_H__
 
 #include "tools/gimptransformoptions.h"
+#include "tools/tools-enums.h"
 
 
 #define GIMP_TYPE_CAGE_OPTIONS            (gimp_cage_options_get_type ())
@@ -34,9 +35,12 @@
 typedef struct _GimpCageOptionsClass GimpCageOptionsClass;
 typedef struct _GimpCageOptions GimpCageOptions;
 
+
 struct _GimpCageOptions
 {
   GimpTransformOptions    parent_instance;
+  
+  GimpCageMode            cage_mode;
 };
 
 
@@ -48,4 +52,6 @@ struct _GimpCageOptionsClass
 
 GType       gimp_cage_options_get_type (void) G_GNUC_CONST;
 
+GtkWidget * gimp_cage_options_gui      (GimpToolOptions *tool_options);
+
 #endif  /*  __GIMP_CAGE_OPTIONS_H__  */
\ No newline at end of file
diff --git a/app/tools/gimpcagetool.c b/app/tools/gimpcagetool.c
index 846719e..e506d06 100644
--- a/app/tools/gimpcagetool.c
+++ b/app/tools/gimpcagetool.c
@@ -65,9 +65,9 @@ void
 gimp_cage_tool_register (GimpToolRegisterCallback  callback,
                            gpointer                  data)
 {
-  (* callback) (GIMP_TYPE_CAGE_TOOL,
-                GIMP_TYPE_CAGE_OPTIONS, 
-                0, //options_gui_func
+  (* callback) (GIMP_TYPE_CAGE_TOOL, //Tool type
+                GIMP_TYPE_CAGE_OPTIONS, //Tool options type
+                gimp_cage_options_gui, //Tool opions gui
                 0, //context_props
                 "gimp-cage-tool",
                 _("Cage Transform"),
diff --git a/app/tools/tools-enums.c b/app/tools/tools-enums.c
index c4cf79a..b692b2e 100644
--- a/app/tools/tools-enums.c
+++ b/app/tools/tools-enums.c
@@ -358,6 +358,35 @@ gimp_vector_mode_get_type (void)
   return type;
 }
 
+GType
+gimp_cage_mode_get_type (void)
+{
+  static const GEnumValue values[] =
+  {
+    { GIMP_CAGE_MODE_CAGE_CHANGE, "GIMP_CAGE_MODE_CAGE_CHANGE", "cage-change" },
+    { GIMP_CAGE_MODE_DEFORM, "GIMP_CAGE_MODE_DEFORM", "deform" },
+    { 0, NULL, NULL }
+  };
+
+  static const GimpEnumDesc descs[] =
+  {
+    { GIMP_CAGE_MODE_CAGE_CHANGE, NC_("cage-mode", "Create or adjust the cage"), NULL },
+    { GIMP_CAGE_MODE_DEFORM, NC_("cage-mode", "Deform the cage to deform the image"), NULL },
+    { 0, NULL, NULL }
+  };
+
+  static GType type = 0;
+
+  if (G_UNLIKELY (! type))
+    {
+      type = g_enum_register_static ("GimpCageMode", values);
+      gimp_type_set_translation_context (type, "cage-mode");
+      gimp_enum_set_value_descriptions (type, descs);
+    }
+
+  return type;
+}
+
 
 /* Generated data ends here */
 
diff --git a/app/tools/tools-enums.h b/app/tools/tools-enums.h
index 874c0de..583d0c9 100644
--- a/app/tools/tools-enums.h
+++ b/app/tools/tools-enums.h
@@ -158,6 +158,16 @@ typedef enum
 } GimpVectorMode;
 
 
+#define GIMP_TYPE_CAGE_MODE (gimp_cage_mode_get_type ())
+
+GType gimp_cage_mode_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+  GIMP_CAGE_MODE_CAGE_CHANGE,  /*< desc="Create or adjust the cage" >*/
+  GIMP_CAGE_MODE_DEFORM    /*< desc="Deform the cage to deform the image"  >*/
+} GimpCageMode;
+
 /*
  * non-registered enums; register them if needed
  */



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