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

This commit is contained in:
Michael Muré 2010-07-02 10:52:10 +02:00
parent b389ec701c
commit 6a387f7db0
5 changed files with 135 additions and 4 deletions

View File

@ -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;
}

View File

@ -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__ */

View File

@ -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"),

View File

@ -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 */

View File

@ -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
*/