Commit 8b8c784a authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

port to G_DEFINE_TYPE() and friends. Some related cleanup.

2005-12-13  Michael Natterer  <mitch@gimp.org>

	* app/tools/*.c: port to G_DEFINE_TYPE() and friends. Some related
	cleanup.
parent c3ad5bdb
2005-12-13 Michael Natterer <mitch@gimp.org>
* app/tools/*.c: port to G_DEFINE_TYPE() and friends. Some related
cleanup.
2005-12-12 Michael Schumacher <schumaml@cvs.gnome.org>
* plug-ins/script-fu/siod/slib.c: added a fix for the script-fu
......
......@@ -37,10 +37,12 @@
#include "gimp-intl.h"
static void gimp_airbrush_tool_init (GimpAirbrushTool *airbrush);
static GtkWidget * gimp_airbrush_options_gui (GimpToolOptions *tool_options);
G_DEFINE_TYPE (GimpAirbrushTool, gimp_airbrush_tool, GIMP_TYPE_PAINTBRUSH_TOOL);
void
gimp_airbrush_tool_register (GimpToolRegisterCallback callback,
gpointer data)
......@@ -59,32 +61,9 @@ gimp_airbrush_tool_register (GimpToolRegisterCallback callback,
data);
}
GType
gimp_airbrush_tool_get_type (void)
static void
gimp_airbrush_tool_class_init (GimpAirbrushToolClass *klass)
{
static GType tool_type = 0;
if (! tool_type)
{
static const GTypeInfo tool_info =
{
sizeof (GimpAirbrushToolClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
NULL, /* class_init */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpAirbrushTool),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_airbrush_tool_init,
};
tool_type = g_type_register_static (GIMP_TYPE_PAINTBRUSH_TOOL,
"GimpAirbrushTool",
&tool_info, 0);
}
return tool_type;
}
static void
......
......@@ -42,56 +42,24 @@ enum
};
static void gimp_align_options_class_init (GimpAlignOptionsClass *options_class);
static void gimp_align_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_align_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_align_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_align_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE (GimpAlignOptions, gimp_align_options, GIMP_TYPE_TOOL_OPTIONS);
static GimpToolOptionsClass *parent_class = NULL;
GType
gimp_align_options_get_type (void)
{
static GType type = 0;
if (! type)
{
static const GTypeInfo info =
{
sizeof (GimpAlignOptionsClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_align_options_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpAlignOptions),
0, /* n_preallocs */
(GInstanceInitFunc) NULL
};
type = g_type_register_static (GIMP_TYPE_TOOL_OPTIONS,
"GimpAlignOptions",
&info, 0);
}
return type;
}
static void
gimp_align_options_class_init (GimpAlignOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->set_property = gimp_align_options_set_property;
object_class->get_property = gimp_align_options_get_property;
......@@ -102,11 +70,16 @@ gimp_align_options_class_init (GimpAlignOptionsClass *klass)
0);
}
static void
gimp_align_options_init (GimpAlignOptions *options)
{
}
static void
gimp_align_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpAlignOptions *options = GIMP_ALIGN_OPTIONS (object);
......@@ -123,9 +96,9 @@ gimp_align_options_set_property (GObject *object,
static void
gimp_align_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpAlignOptions *options = GIMP_ALIGN_OPTIONS (object);
......@@ -173,4 +146,3 @@ gimp_align_options_gui (GimpToolOptions *tool_options)
return vbox;
}
......@@ -41,51 +41,52 @@
#include "gimp-intl.h"
/* local function prototypes */
static void gimp_align_tool_class_init (GimpAlignToolClass *klass);
static void gimp_align_tool_init (GimpAlignTool *align_tool);
/* local function prototypes */
static GObject * gimp_align_tool_constructor (GType type,
guint n_params,
static GObject * gimp_align_tool_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_align_tool_dispose (GObject *object);
static gboolean gimp_align_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static void gimp_align_tool_finalize (GObject *object);
static void gimp_align_tool_dispose (GObject *object);
static gboolean gimp_align_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static void gimp_align_tool_finalize (GObject *object);
static void gimp_align_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_align_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_align_tool_draw (GimpDrawTool *draw_tool);
static GtkWidget *button_with_stock (GimpAlignmentType action,
GimpAlignTool *align_tool);
static GtkWidget *gimp_align_tool_controls (GimpAlignTool *align_tool);
static void set_action (GtkWidget *widget,
gpointer data);
static void do_horizontal_alignment (GtkWidget *widget,
gpointer data);
static void do_vertical_alignment (GtkWidget *widget,
gpointer data);
static void clear_reference (GimpItem *reference_item,
GimpAlignTool *align_tool);
static void clear_target (GimpItem *target_item,
GimpAlignTool *align_tool);
static GtkWidget *button_with_stock (GimpAlignmentType action,
GimpAlignTool *align_tool);
static GtkWidget *gimp_align_tool_controls (GimpAlignTool *align_tool);
static void set_action (GtkWidget *widget,
gpointer data);
static void do_horizontal_alignment (GtkWidget *widget,
gpointer data);
static void do_vertical_alignment (GtkWidget *widget,
gpointer data);
static void clear_reference (GimpItem *reference_item,
GimpAlignTool *align_tool);
static void clear_target (GimpItem *target_item,
GimpAlignTool *align_tool);
G_DEFINE_TYPE (GimpAlignTool, gimp_align_tool, GIMP_TYPE_DRAW_TOOL);
static GimpDrawToolClass *parent_class = NULL;
#define parent_class gimp_align_tool_parent_class
void
gimp_align_tool_register (GimpToolRegisterCallback callback,
gpointer data)
gpointer data)
{
(* callback) (GIMP_TYPE_ALIGN_TOOL,
GIMP_TYPE_ALIGN_OPTIONS,
......@@ -100,34 +101,6 @@ gimp_align_tool_register (GimpToolRegisterCallback callback,
data);
}
GType
gimp_align_tool_get_type (void)
{
static GType tool_type = 0;
if (! tool_type)
{
static const GTypeInfo tool_info =
{
sizeof (GimpAlignToolClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_align_tool_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpAlignTool),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_align_tool_init,
};
tool_type = g_type_register_static (GIMP_TYPE_DRAW_TOOL,
"GimpAlignTool",
&tool_info, 0);
}
return tool_type;
}
static void
gimp_align_tool_class_init (GimpAlignToolClass *klass)
{
......@@ -135,11 +108,10 @@ gimp_align_tool_class_init (GimpAlignToolClass *klass)
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_align_tool_finalize;
object_class->constructor = gimp_align_tool_constructor;
object_class->dispose = gimp_align_tool_dispose;
tool_class->initialize = gimp_align_tool_initialize;
tool_class->button_press = gimp_align_tool_button_press;
tool_class->cursor_update = gimp_align_tool_cursor_update;
......@@ -147,6 +119,60 @@ gimp_align_tool_class_init (GimpAlignToolClass *klass)
draw_tool_class->draw = gimp_align_tool_draw;
}
static void
gimp_align_tool_init (GimpAlignTool *align_tool)
{
GimpTool *tool = GIMP_TOOL (align_tool);
align_tool->controls = NULL;
align_tool->target_item = NULL;
align_tool->reference_item = NULL;
align_tool->select_reference = FALSE;
align_tool->target_horz_align_type = GIMP_ALIGN_LEFT;
align_tool->ref_horz_align_type = GIMP_ALIGN_LEFT;
align_tool->target_vert_align_type = GIMP_ALIGN_TOP;
align_tool->ref_vert_align_type = GIMP_ALIGN_TOP;
align_tool->horz_offset = 0;
align_tool->vert_offset = 0;
gimp_tool_control_set_snap_to (tool->control, FALSE);
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_MOVE);
}
static GObject *
gimp_align_tool_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpTool *tool;
GimpAlignTool *align_tool;
GtkContainer *controls_container;
GObject *options;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
tool = GIMP_TOOL (object);
align_tool = GIMP_ALIGN_TOOL (object);
g_assert (GIMP_IS_TOOL_INFO (tool->tool_info));
options = G_OBJECT (tool->tool_info->tool_options);
controls_container = GTK_CONTAINER (g_object_get_data (options,
"controls-container"));
align_tool->controls = gimp_align_tool_controls (align_tool);
gtk_container_add (controls_container, align_tool->controls);
return object;
}
static void
gimp_align_tool_dispose (GObject *object)
{
......@@ -178,7 +204,7 @@ gimp_align_tool_finalize (GObject *object)
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (object);
if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (object)))
gimp_draw_tool_stop (GIMP_DRAW_TOOL (object));
gimp_draw_tool_stop (GIMP_DRAW_TOOL (object));
if (gimp_tool_control_is_active (tool->control))
gimp_tool_control_halt (tool->control);
......@@ -207,66 +233,12 @@ gimp_align_tool_initialize (GimpTool *tool,
return TRUE;
}
static void
gimp_align_tool_init (GimpAlignTool *align_tool)
{
GimpTool *tool = GIMP_TOOL (align_tool);
align_tool->controls = NULL;
align_tool->target_item = NULL;
align_tool->reference_item = NULL;
align_tool->select_reference = FALSE;
align_tool->target_horz_align_type = GIMP_ALIGN_LEFT;
align_tool->ref_horz_align_type = GIMP_ALIGN_LEFT;
align_tool->target_vert_align_type = GIMP_ALIGN_TOP;
align_tool->ref_vert_align_type = GIMP_ALIGN_TOP;
align_tool->horz_offset = 0;
align_tool->vert_offset = 0;
gimp_tool_control_set_snap_to (tool->control, FALSE);
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_MOVE);
}
static GObject *
gimp_align_tool_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpTool *tool;
GimpAlignTool *align_tool;
GtkContainer *controls_container;
GObject *options;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
tool = GIMP_TOOL (object);
align_tool = GIMP_ALIGN_TOOL (object);
g_assert (GIMP_IS_TOOL_INFO (tool->tool_info));
options = G_OBJECT (tool->tool_info->tool_options);
controls_container = GTK_CONTAINER (g_object_get_data (options,
"controls-container"));
align_tool->controls = gimp_align_tool_controls (align_tool);
gtk_container_add (controls_container, align_tool->controls);
return object;
}
static void
gimp_align_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp)
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (tool);
GimpAlignOptions *options = GIMP_ALIGN_OPTIONS (tool->tool_info->tool_options);
......@@ -355,9 +327,9 @@ gimp_align_tool_button_press (GimpTool *tool,
static void
gimp_align_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp)
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpAlignOptions *options = GIMP_ALIGN_OPTIONS (tool->tool_info->tool_options);
......@@ -757,4 +729,3 @@ clear_reference (GimpItem *reference_item,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (align_tool));
}
......@@ -50,8 +50,6 @@ enum
};
static void gimp_blend_options_class_init (GimpBlendOptionsClass *klass);
static void gimp_blend_options_set_property (GObject *object,
guint property_id,
const GValue *value,
......@@ -66,44 +64,14 @@ static void blend_options_gradient_type_notify (GimpBlendOptions *options,
GtkWidget *repeat_combo);
static GimpPaintOptionsClass *parent_class = NULL;
G_DEFINE_TYPE (GimpBlendOptions, gimp_blend_options, GIMP_TYPE_PAINT_OPTIONS);
GType
gimp_blend_options_get_type (void)
{
static GType type = 0;
if (! type)
{
static const GTypeInfo info =
{
sizeof (GimpBlendOptionsClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_blend_options_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpBlendOptions),
0, /* n_preallocs */
(GInstanceInitFunc) NULL
};
type = g_type_register_static (GIMP_TYPE_PAINT_OPTIONS,
"GimpBlendOptions",
&info, 0);
}
return type;
}
static void
gimp_blend_options_class_init (GimpBlendOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->set_property = gimp_blend_options_set_property;
object_class->get_property = gimp_blend_options_get_property;
......@@ -141,6 +109,11 @@ gimp_blend_options_class_init (GimpBlendOptionsClass *klass)
0);
}
static void
gimp_blend_options_init (GimpBlendOptions *options)
{
}
static void
gimp_blend_options_set_property (GObject *object,
guint property_id,
......
......@@ -52,38 +52,33 @@
/* local function prototypes */
static void gimp_blend_tool_class_init (GimpBlendToolClass *klass);
static void gimp_blend_tool_init (GimpBlendTool *blend_tool);
static void gimp_blend_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_blend_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_blend_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_blend_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_blend_tool_draw (GimpDrawTool *draw_tool);
G_DEFINE_TYPE (GimpBlendTool, gimp_blend_tool, GIMP_TYPE_DRAW_TOOL);
#define parent_class gimp_blend_tool_parent_class
static void gimp_blend_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_blend_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_blend_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_blend_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_blend_tool_draw (GimpDrawTool *draw_tool);
/* private variables */
static GimpDrawToolClass *parent_class = NULL;
/* public functions */
void
gimp_blend_tool_register (GimpToolRegisterCallback callback,
......@@ -106,45 +101,12 @@ gimp_blend_tool_register (GimpToolRegisterCallback callback,
data);
}
GType
gimp_blend_tool_get_type (void)
{
static GType tool_type = 0;
if (! tool_type)
{
static const GTypeInfo tool_info =
{
sizeof (GimpBlendToolClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_blend_tool_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpBlendTool),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_blend_tool_init,
};
tool_type = g_type_register_static (GIMP_TYPE_DRAW_TOOL,
"GimpBlendTool",
&tool_info, 0);
}
return tool_type;
}
/* private functions */
static void
gimp_blend_tool_class_init (GimpBlendToolClass *klass)
{
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
tool_class->button_press = gimp_blend_tool_button_press;