[gimp/soc-2013-combined-selection-tool: 188/230] app:added enum in core-enums and edited rectangleselectoptions



commit ef5a2776482a3f582ef5327128ea4bf2b5e4ddd2
Author: Ajay Ramanathan <ajay 010293 gmail com>
Date:   Tue Jun 25 13:41:11 2013 +0530

    app:added enum in core-enums and edited rectangleselectoptions

 app/core/core-enums.c                  |   36 ++++++++++++++++++++++++++++++++
 app/core/core-enums.h                  |   13 ++++++++++-
 app/tools/gimprectangleselectoptions.c |   30 ++++++++++++++++++++++++--
 app/tools/gimprectangleselectoptions.h |    1 +
 4 files changed, 76 insertions(+), 4 deletions(-)
---
diff --git a/app/core/core-enums.c b/app/core/core-enums.c
index 491ec16..1a59baa 100644
--- a/app/core/core-enums.c
+++ b/app/core/core-enums.c
@@ -8,6 +8,42 @@
 #include "gimp-intl.h"
 
 /* enumerations from "./core-enums.h" */
+
+GType
+gimp_shape_type_get_type (void)
+{
+  static const GEnumValue values[] =
+  {
+    { GIMP_SHAPE_RECTANGLE, "GIMP_SHAPE_RECTANGLE", "rectangle" },
+    { GIMP_SHAPE_ELLIPSE, "GIMP_SHAPE_ELLIPSE", "ellipse" },
+    { GIMP_SHAPE_ROUNDED_RECT, "GIMP_SHAPE_ROUNDED_RECT", "rounded-rect" },
+    { GIMP_SHAPE_N_POLYGON, "GIMP_SHAPE_N_POLYGON", "n-polygon" },
+    { GIMP_SHAPE_SINGLE_ROW, "GIMP_SHAPE_SINGLE_ROW", "single-row" },
+    { 0, NULL, NULL }
+  };
+
+  static const GimpEnumDesc descs[] =
+  {
+    { GIMP_SHAPE_RECTANGLE, NC_("shape-type", "Rectnagle"), NULL },
+    { GIMP_SHAPE_ELLIPSE, NC_("shape-type", "Ellipse"), NULL },
+    { GIMP_SHAPE_ROUNDED_RECT, NC_("shape-type", "Rounded Rectangle"), NULL },
+    { GIMP_SHAPE_N_POLYGON, NC_("shape-type", "n Polygon"), NULL },
+    { GIMP_SHAPE_SINGLE_ROW, NC_("shaoe-type", "Single Row"), NULL },
+    { 0, NULL, NULL }
+  };
+
+  static GType type = 0;
+
+  if (G_UNLIKELY (! type))
+    {
+      type = g_enum_register_static ("GimpShapeType", values);
+      gimp_type_set_translation_context (type, "shape-type");
+      gimp_enum_set_value_descriptions (type, descs);
+    }
+
+  return type;
+}
+
 GType
 gimp_component_mask_get_type (void)
 {
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index 4ee7713..585e2bd 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -34,7 +34,18 @@
 /*
  * these enums are registered with the type system
  */
+#define GIMP_TYPE_SHAPE_TYPE (gimp_shape_type_get_type ())
 
+GType gimp_shape_type_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{       
+  GIMP_SHAPE_RECTANGLE,        
+  GIMP_SHAPE_ELLIPSE,        
+  GIMP_SHAPE_ROUNDED_RECT,     
+  GIMP_SHAPE_N_POLYGON,       
+  GIMP_SHAPE_SINGLE_ROW       
+} GimpShapeType;
 
 #define GIMP_TYPE_COMPONENT_MASK (gimp_component_mask_get_type ())
 
diff --git a/app/tools/gimprectangleselectoptions.c b/app/tools/gimprectangleselectoptions.c
index 2eb9012..3695b1c 100644
--- a/app/tools/gimprectangleselectoptions.c
+++ b/app/tools/gimprectangleselectoptions.c
@@ -25,9 +25,12 @@
 
 #include "tools-types.h"
 
+#include "core/gimp.h"
 #include "core/gimptoolinfo.h"
+#include "config/gimpcoreconfig.h"
 
 #include "widgets/gimppropwidgets.h"
+#include "widgets/gimpwidgets-utils.h"
 
 #include "gimprectangleoptions.h"
 #include "gimprectangleselectoptions.h"
@@ -42,7 +45,8 @@ enum
 {
   PROP_ROUND_CORNERS = GIMP_RECTANGLE_OPTIONS_PROP_LAST + 1,
   PROP_CORNER_RADIUS,
-  PROP_SHAPE_OPTIONS
+  PROP_SHAPE_OPTIONS,
+  PROP_SHAPE_TYPE
 };
 
 
@@ -98,6 +102,12 @@ gimp_rectangle_select_options_class_init (GimpRectangleSelectOptionsClass *klass
                                    N_("Shape Options"),
                                    FALSE,
                                    GIMP_PARAM_STATIC_STRINGS);
+  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_SHAPE_TYPE,
+                                 "shape-type",
+                                 N_("Select shape of the selection"),
+                                 GIMP_TYPE_SHAPE_TYPE,
+                                 GIMP_SHAPE_RECTANGLE,
+                                 GIMP_PARAM_STATIC_STRINGS);
 
   gimp_rectangle_options_install_properties (object_class);
 }
@@ -129,6 +139,10 @@ gimp_rectangle_select_options_set_property (GObject      *object,
       options->shape_options = g_value_get_boolean (value);
       break;
 
+    case PROP_SHAPE_TYPE:
+      options->shape_type = g_value_get_enum (value);
+      break; 
+
     default:
       gimp_rectangle_options_set_property (object, property_id, value, pspec);
       break;
@@ -155,7 +169,11 @@ gimp_rectangle_select_options_get_property (GObject    *object,
 
     case PROP_SHAPE_OPTIONS:
       g_value_set_boolean (value, options->shape_options);
-      break;  
+      break;
+
+    case PROP_SHAPE_TYPE:
+      g_value_set_enum (value, options->shape_type);
+      break; 
 
     default:
       gimp_rectangle_options_get_property (object, property_id, value, pspec);
@@ -169,7 +187,8 @@ gimp_rectangle_select_options_gui (GimpToolOptions *tool_options)
   GObject   *config = G_OBJECT (tool_options);
   GtkWidget *vbox   = gimp_selection_options_gui (tool_options);
   GtkWidget *button;
-  
+  GtkWidget *combo;
+
   /*  the round corners frame  */
   if (tool_options->tool_info->tool_type == GIMP_TYPE_RECTANGLE_SELECT_TOOL)
     {
@@ -204,6 +223,11 @@ gimp_rectangle_select_options_gui (GimpToolOptions *tool_options)
       gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
       gtk_widget_show (button);
 
+      combo = gimp_prop_enum_combo_box_new (config, "shape-type", 0, 0);
+      gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Shape"));
+      gtk_box_pack_start (GTK_BOX (vbox), combo, TRUE, TRUE, 0);
+      gtk_widget_show (combo);
+
    }
 
   /*  the rectangle options  */
diff --git a/app/tools/gimprectangleselectoptions.h b/app/tools/gimprectangleselectoptions.h
index bd17f49..8b7fa98 100644
--- a/app/tools/gimprectangleselectoptions.h
+++ b/app/tools/gimprectangleselectoptions.h
@@ -40,6 +40,7 @@ struct _GimpRectangleSelectOptions
   gboolean              round_corners;
   gdouble               corner_radius;
   gboolean              shape_options;
+  GimpShapeType         shape_type;
 };
 
 


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