Commit aa9f82d1 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Made GimpToolOptions a GimpContext subclass and objectified all tool

2003-02-05  Michael Natterer  <mitch@gimp.org>

	Made GimpToolOptions a GimpContext subclass and objectified
	all tool options types.

	* app/core/core-types.h: replaced GimpToolOptionsNewFunc by
	GimpToolOptionsGUIFunc.

	* libgimpproxy/gimpproxytypes.h: regenerated.

	* app/core/gimppaintinfo.[ch]: added "GType paint_options_type".

	* app/core/gimptoolinfo.[ch]: added "GType tool_options_type",
	removed tool_info->context since GimpToolOptions are a GimpContext
	now. Added "gboolean use_context" as a temp_hack.

	* libgimptool/gimptooltypes.h: added the tool_options_type to
	the tool registering callback.

	* app/tools/tool_options.[ch]: is a real GimpContext subclass now.

	* app/paint/paint-types.h
	* app/paint/paint.c: added the paint_options_type to the paint
	registering stuff.

	* app/paint/gimppaintoptions.[ch]: is a real GimpToolOptions
	subclass now.

	* app/paint/Makefile.am
	* app/paint/gimpairbrushoptions.[ch]
	* app/paint/gimpcloneoptions.[ch]
	* app/paint/gimpconvolveoptions.[ch]
	* app/paint/gimpdodgeburnoptions.[ch]
	* app/paint/gimperaseroptions.[ch]
	* app/paint/gimpsmudgeoptions.[ch]: new files holding
	GimpPaintOptions subclasses.

	* app/paint/gimpairbrush.[ch]
	* app/paint/gimpclone.[ch]
	* app/paint/gimpconvolve.[ch]
	* app/paint/gimpdodgeburn.[ch]
	* app/paint/gimperaser.[ch]
	* app/paint/gimppaintbrush.c
	* app/paint/gimppaintcore.c
	* app/paint/gimppencil.[ch]
	* app/paint/gimpsmudge.[ch]: removed paint options stuff, lots
	of related changed & cleanups.

	* tools/pdbgen/pdb/paint_tools.pdb: changed accordingly.

	* app/pdb/paint_tools_cmds.c: regenerated.

	* app/tools/Makefile.am
	* app/tools/gimpblendoptions.[ch]
	* app/tools/gimpbucketfilloptions.[ch]
	* app/tools/gimpcolorpickeroptions.[ch]
	* app/tools/gimpcropoptions.[ch]
	* app/tools/gimpflipoptions.[ch]
	* app/tools/gimpinkoptions.[ch]
	* app/tools/gimpmagnifyoptions.[ch]
	* app/tools/gimpmeasureoptions.[ch]
	* app/tools/gimpmoveoptions.[ch]
	* app/tools/gimptextoptions.[ch]
	* app/tools/gimpvectoroptions.[ch]: new files holding the various
	tool options classes.

	* app/tools/selection_options.[ch]
	* app/tools/transform_options.[ch]: made them objects.

	* app/tools/paint_options.[ch]: contains only the paint_options
	GUI and reset stuff.

	* app/tools/tools-types.h: removed SelectionOptions typedef for
	now.

	* app/tools/[all tools]: removed the tool options stuff except
	some GUI constructors. Tons of related changes.

	* app/tools/tool_manager.[ch]: changed tool registration / restore /
	switching accordingly.

	* app/widgets/gimpdrawablelistview.c
	* app/widgets/gimpselectioneditor.c: changed accordingly.
parent 87b133f8
2003-02-05 Michael Natterer <mitch@gimp.org>
Made GimpToolOptions a GimpContext subclass and objectified
all tool options types.
* app/core/core-types.h: replaced GimpToolOptionsNewFunc by
GimpToolOptionsGUIFunc.
* libgimpproxy/gimpproxytypes.h: regenerated.
* app/core/gimppaintinfo.[ch]: added "GType paint_options_type".
* app/core/gimptoolinfo.[ch]: added "GType tool_options_type",
removed tool_info->context since GimpToolOptions are a GimpContext
now. Added "gboolean use_context" as a temp_hack.
* libgimptool/gimptooltypes.h: added the tool_options_type to
the tool registering callback.
* app/tools/tool_options.[ch]: is a real GimpContext subclass now.
* app/paint/paint-types.h
* app/paint/paint.c: added the paint_options_type to the paint
registering stuff.
* app/paint/gimppaintoptions.[ch]: is a real GimpToolOptions
subclass now.
* app/paint/Makefile.am
* app/paint/gimpairbrushoptions.[ch]
* app/paint/gimpcloneoptions.[ch]
* app/paint/gimpconvolveoptions.[ch]
* app/paint/gimpdodgeburnoptions.[ch]
* app/paint/gimperaseroptions.[ch]
* app/paint/gimpsmudgeoptions.[ch]: new files holding
GimpPaintOptions subclasses.
* app/paint/gimpairbrush.[ch]
* app/paint/gimpclone.[ch]
* app/paint/gimpconvolve.[ch]
* app/paint/gimpdodgeburn.[ch]
* app/paint/gimperaser.[ch]
* app/paint/gimppaintbrush.c
* app/paint/gimppaintcore.c
* app/paint/gimppencil.[ch]
* app/paint/gimpsmudge.[ch]: removed paint options stuff, lots
of related changed & cleanups.
* tools/pdbgen/pdb/paint_tools.pdb: changed accordingly.
* app/pdb/paint_tools_cmds.c: regenerated.
* app/tools/Makefile.am
* app/tools/gimpblendoptions.[ch]
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpcolorpickeroptions.[ch]
* app/tools/gimpcropoptions.[ch]
* app/tools/gimpflipoptions.[ch]
* app/tools/gimpinkoptions.[ch]
* app/tools/gimpmagnifyoptions.[ch]
* app/tools/gimpmeasureoptions.[ch]
* app/tools/gimpmoveoptions.[ch]
* app/tools/gimptextoptions.[ch]
* app/tools/gimpvectoroptions.[ch]: new files holding the various
tool options classes.
* app/tools/selection_options.[ch]
* app/tools/transform_options.[ch]: made them objects.
* app/tools/paint_options.[ch]: contains only the paint_options
GUI and reset stuff.
* app/tools/tools-types.h: removed SelectionOptions typedef for
now.
* app/tools/[all tools]: removed the tool options stuff except
some GUI constructors. Tons of related changes.
* app/tools/tool_manager.[ch]: changed tool registration / restore /
switching accordingly.
* app/widgets/gimpdrawablelistview.c
* app/widgets/gimpselectioneditor.c: changed accordingly.
2003-02-05 Sven Neumann <sven@gimp.org>
* app/text/gimptext.c: added some blurbs that will show up as
......
......@@ -194,7 +194,7 @@ typedef struct _PathList PathList;
typedef struct _GimpToolOptions GimpToolOptions; /*< proxy-include >*/
typedef GimpToolOptions * (* GimpToolOptionsNewFunc) (GimpToolInfo *tool_info); /*< proxy-include >*/
typedef void (* GimpToolOptionsGUIFunc) (GimpToolOptions *tool_options); /*< proxy-include >*/
/* functions */
......
......@@ -103,6 +103,7 @@ gimp_paint_info_finalize (GObject *object)
GimpPaintInfo *
gimp_paint_info_new (Gimp *gimp,
GType paint_type,
GType paint_options_type,
const gchar *pdb_string)
{
GimpPaintInfo *paint_info;
......@@ -114,10 +115,10 @@ gimp_paint_info_new (Gimp *gimp,
"name", g_type_name (paint_type),
NULL);
paint_info->gimp = gimp;
paint_info->paint_type = paint_type;
paint_info->pdb_string = g_strdup (pdb_string);
paint_info->gimp = gimp;
paint_info->paint_type = paint_type;
paint_info->paint_options_type = paint_options_type;
paint_info->pdb_string = g_strdup (pdb_string);
return paint_info;
}
......@@ -40,6 +40,7 @@ struct _GimpPaintInfo
Gimp *gimp;
GType paint_type;
GType paint_options_type;
gchar *pdb_string;
......@@ -56,6 +57,7 @@ GType gimp_paint_info_get_type (void) G_GNUC_CONST;
GimpPaintInfo * gimp_paint_info_new (Gimp *gimp,
GType paint_type,
GType paint_options_type,
const gchar *pdb_string);
......
......@@ -93,23 +93,23 @@ gimp_tool_info_class_init (GimpToolInfoClass *klass)
static void
gimp_tool_info_init (GimpToolInfo *tool_info)
{
tool_info->tool_type = G_TYPE_NONE;
tool_info->tool_type = G_TYPE_NONE;
tool_info->tool_options_type = G_TYPE_NONE;
tool_info->blurb = NULL;
tool_info->help = NULL;
tool_info->blurb = NULL;
tool_info->help = NULL;
tool_info->menu_path = NULL;
tool_info->menu_accel = NULL;
tool_info->menu_path = NULL;
tool_info->menu_accel = NULL;
tool_info->help_domain = NULL;
tool_info->help_data = NULL;
tool_info->help_domain = NULL;
tool_info->help_data = NULL;
tool_info->stock_id = NULL;
tool_info->stock_pixbuf = NULL;
tool_info->stock_id = NULL;
tool_info->stock_pixbuf = NULL;
tool_info->context = NULL;
tool_info->tool_options = NULL;
tool_info->paint_info = NULL;
tool_info->tool_options = NULL;
tool_info->paint_info = NULL;
}
static void
......@@ -163,6 +163,12 @@ gimp_tool_info_finalize (GObject *object)
tool_info->stock_pixbuf = NULL;
}
if (tool_info->tool_options)
{
g_object_unref (tool_info->tool_options);
tool_info->tool_options = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......@@ -234,8 +240,8 @@ gimp_tool_info_get_new_preview (GimpViewable *viewable,
GimpToolInfo *
gimp_tool_info_new (Gimp *gimp,
GimpContext *context,
GType tool_type,
GType tool_options_type,
gboolean tool_context,
const gchar *identifier,
const gchar *blurb,
......@@ -252,7 +258,6 @@ gimp_tool_info_new (Gimp *gimp,
GimpToolInfo *tool_info;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (identifier != NULL, NULL);
g_return_val_if_fail (blurb != NULL, NULL);
g_return_val_if_fail (help != NULL, NULL);
......@@ -270,25 +275,25 @@ gimp_tool_info_new (Gimp *gimp,
"name", identifier,
NULL);
tool_info->paint_info = paint_info;
if (tool_context)
tool_info->context = gimp_context_new (gimp, identifier, context);
tool_info->use_context = tool_context;
tool_info->tool_options = NULL;
tool_info->paint_info = paint_info;
tool_info->gimp = gimp;
tool_info->tool_type = tool_type;
tool_info->gimp = gimp;
tool_info->tool_type = tool_type;
tool_info->tool_options_type = tool_options_type;
tool_info->blurb = g_strdup (blurb);
tool_info->help = g_strdup (help);
tool_info->blurb = g_strdup (blurb);
tool_info->help = g_strdup (help);
tool_info->menu_path = g_strdup (menu_path);
tool_info->menu_accel = g_strdup (menu_accel);
tool_info->menu_path = g_strdup (menu_path);
tool_info->menu_accel = g_strdup (menu_accel);
tool_info->help_domain = g_strdup (help_domain);
tool_info->help_data = g_strdup (help_data);
tool_info->help_domain = g_strdup (help_domain);
tool_info->help_data = g_strdup (help_data);
tool_info->stock_id = g_strdup (stock_id);
tool_info->stock_pixbuf = stock_pixbuf;
tool_info->stock_id = g_strdup (stock_id);
tool_info->stock_pixbuf = stock_pixbuf;
if (stock_pixbuf)
g_object_ref (stock_pixbuf);
......
......@@ -42,6 +42,7 @@ struct _GimpToolInfo
Gimp *gimp;
GType tool_type;
GType tool_options_type;
gchar *blurb;
gchar *help;
......@@ -55,10 +56,7 @@ struct _GimpToolInfo
gchar *stock_id;
GdkPixbuf *stock_pixbuf;
/* temp_hack, will be a GType once tool_options are GimpContext derived */
GimpToolOptionsNewFunc options_new_func;
GimpContext *context;
gboolean use_context;
GimpToolOptions *tool_options;
GimpPaintInfo *paint_info;
};
......@@ -72,8 +70,8 @@ struct _GimpToolInfoClass
GType gimp_tool_info_get_type (void) G_GNUC_CONST;
GimpToolInfo * gimp_tool_info_new (Gimp *gimp,
GimpContext *context,
GType tool_type,
GType tool_options_type,
gboolean tool_context,
const gchar *identifier,
const gchar *blurb,
......
......@@ -22,31 +22,164 @@
#include "tools-types.h"
#include "config/gimpconfig.h"
#include "core/gimptoolinfo.h"
#include "tool_options.h"
#include "libgimp/gimpintl.h"
void
tool_options_init (GimpToolOptions *options,
GimpToolInfo *tool_info)
enum
{
options->main_vbox = gtk_vbox_new (FALSE, 2);
options->tool_info = tool_info;
PROP_0,
PROP_TOOL_INFO
};
static void gimp_tool_options_init (GimpToolOptions *options);
static void gimp_tool_options_class_init (GimpToolOptionsClass *options_class);
static void gimp_tool_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_tool_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_tool_options_real_reset (GimpToolOptions *tool_options);
static GimpContextClass *parent_class = NULL;
GType
gimp_tool_options_get_type (void)
{
static GType type = 0;
if (! type)
{
static const GTypeInfo info =
{
sizeof (GimpToolOptionsClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_tool_options_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpToolOptions),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_tool_options_init,
};
type = g_type_register_static (GIMP_TYPE_CONTEXT,
"GimpToolOptions",
&info, 0);
}
return type;
}
static void
gimp_tool_options_class_init (GimpToolOptionsClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->set_property = gimp_tool_options_set_property;
object_class->get_property = gimp_tool_options_get_property;
klass->reset = gimp_tool_options_real_reset;
g_object_class_install_property (object_class, PROP_TOOL_INFO,
g_param_spec_object ("tool-info",
NULL, NULL,
GIMP_TYPE_TOOL_INFO,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
GimpToolOptions *
tool_options_new (GimpToolInfo *tool_info)
static void
gimp_tool_options_init (GimpToolOptions *options)
{
options->tool_info = NULL;
options->main_vbox = gtk_vbox_new (FALSE, 2);
options->reset_func = NULL;
}
static void
gimp_tool_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpToolOptions *options;
options = GIMP_TOOL_OPTIONS (object);
switch (property_id)
{
case PROP_TOOL_INFO:
options->tool_info = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_tool_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpToolOptions *options;
GtkWidget *label;
options = g_new0 (GimpToolOptions, 1);
tool_options_init (options, tool_info);
options = GIMP_TOOL_OPTIONS (object);
switch (property_id)
{
case PROP_TOOL_INFO:
g_value_set_object (value, options->tool_info);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_tool_options_real_reset (GimpToolOptions *tool_options)
{
gimp_config_reset (G_OBJECT (tool_options));
}
void
gimp_tool_options_reset (GimpToolOptions *tool_options)
{
g_return_if_fail (GIMP_IS_TOOL_OPTIONS (tool_options));
GIMP_TOOL_OPTIONS_GET_CLASS (tool_options)->reset (tool_options);
}
void
gimp_tool_options_gui (GimpToolOptions *tool_options)
{
GtkWidget *label;
label = gtk_label_new (_("This tool has no options."));
gtk_box_pack_start (GTK_BOX (options->main_vbox), label, FALSE, FALSE, 6);
gtk_box_pack_start (GTK_BOX (tool_options->main_vbox), label,
FALSE, FALSE, 6);
gtk_widget_show (label);
return options;
}
......@@ -20,26 +20,42 @@
#define __TOOL_OPTIONS_H__
/* the tool options structures */
#include "core/gimpcontext.h"
#define GIMP_TYPE_TOOL_OPTIONS (gimp_tool_options_get_type ())
#define GIMP_TOOL_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TOOL_OPTIONS, GimpToolOptions))
#define GIMP_TOOL_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_OPTIONS, GimpToolOptionsClass))
#define GIMP_IS_TOOL_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TOOL_OPTIONS))
#define GIMP_IS_TOOL_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TOOL_OPTIONS))
#define GIMP_TOOL_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TOOL_OPTIONS, GimpToolOptionsClass))
typedef struct _GimpToolOptionsClass GimpToolOptionsClass;
struct _GimpToolOptions
{
GtkWidget *main_vbox;
GimpContext parent_instance;
GimpToolInfo *tool_info;
GtkWidget *main_vbox;
GimpToolOptionsResetFunc reset_func;
};
/* create a dummy tool options structure
* (to be used by tools without options)
*/
GimpToolOptions * tool_options_new (GimpToolInfo *tool_info);
struct _GimpToolOptionsClass
{
GimpContextClass parent_class;
/* initialize an already allocated ToolOptions structure
* (to be used by derived tool options only)
*/
void tool_options_init (GimpToolOptions *options,
GimpToolInfo *tool_info);
void (* reset) (GimpToolOptions *tool_options);
};
GType gimp_tool_options_get_type (void) G_GNUC_CONST;
void gimp_tool_options_reset (GimpToolOptions *tool_options);
void gimp_tool_options_gui (GimpToolOptions *tool_options);
#endif /* __TOOL_OPTIONS_H__ */
......@@ -22,14 +22,24 @@ libapppaint_a_sources = \
paint.h \
gimpairbrush.c \
gimpairbrush.h \
gimpairbrushoptions.c \
gimpairbrushoptions.h \
gimpclone.c \
gimpclone.h \
gimpcloneoptions.c \
gimpcloneoptions.h \
gimpconvolve.c \
gimpconvolve.h \
gimpconvolveoptions.c \
gimpconvolveoptions.h \
gimpdodgeburn.c \
gimpdodgeburn.h \
gimpdodgeburnoptions.c \
gimpdodgeburnoptions.h \
gimperaser.c \
gimperaser.h \
gimperaseroptions.c \
gimperaseroptions.h \
gimppaintcore.c \
gimppaintcore.h \
gimppaintcore-kernels.h \
......@@ -42,7 +52,9 @@ libapppaint_a_sources = \
gimppaintbrush.c \
gimppaintbrush.h \
gimpsmudge.c \
gimpsmudge.h
gimpsmudge.h \
gimpsmudgeoptions.c \
gimpsmudgeoptions.h
libapppaint_a_built_sources = paint-enums.c
......
......@@ -36,10 +36,7 @@
#include "core/gimpimage.h"
#include "gimpairbrush.h"
#define AIRBRUSH_DEFAULT_RATE 80.0
#define AIRBRUSH_DEFAULT_PRESSURE 10.0
#include "gimpairbrushoptions.h"
typedef struct _AirbrushTimeout AirbrushTimeout;
......@@ -78,7 +75,7 @@ void
gimp_airbrush_register (Gimp *gimp,
GimpPaintRegisterCallback callback)
{
(* callback) (gimp, GIMP_TYPE_AIRBRUSH);
(* callback) (gimp, GIMP_TYPE_AIRBRUSH, GIMP_TYPE_AIRBRUSH_OPTIONS);
}
GType
......@@ -322,23 +319,3 @@ gimp_airbrush_timeout (gpointer client_data)
return FALSE;
}
/* paint options stuff */
GimpAirbrushOptions *
gimp_airbrush_options_new (GimpContext *context)
{
GimpAirbrushOptions *options;
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
options = g_new0 (GimpAirbrushOptions, 1);
gimp_paint_options_init ((GimpPaintOptions *) options, context);
options->rate = options->rate_d = AIRBRUSH_DEFAULT_RATE;
options->pressure = options->pressure_d = AIRBRUSH_DEFAULT_PRESSURE;
return options;
}
......@@ -21,7 +21,6 @@
#include "gimppaintcore.h"
#include "gimppaintoptions.h"
#define GIMP_TYPE_AIRBRUSH (gimp_airbrush_get_type ())
......@@ -46,29 +45,10 @@ struct _GimpAirbrushClass
};
typedef struct _GimpAirbrushOptions GimpAirbrushOptions;
struct _GimpAirbrushOptions
{
GimpPaintOptions paint_options;
gdouble rate;
gdouble rate_d;
GtkObject *rate_w;
gdouble pressure;
gdouble pressure_d;
GtkObject *pressure_w;
};
void gimp_airbrush_register (Gimp *gimp,
GimpPaintRegisterCallback callback);
GType gimp_airbrush_get_type (void) G_GNUC_CONST;
GimpAirbrushOptions * gimp_airbrush_options_new (GimpContext *context);
#endif /* __GIMP_AIRBRUSH_H__ */
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "paint-types.h"
#include "gimpairbrushoptions.h"
#define AIRBRUSH_DEFAULT_RATE 80.0
#define AIRBRUSH_DEFAULT_PRESSURE 10.0
static void gimp_airbrush_options_init (GimpAirbrushOptions *options);
static void gimp_airbrush_options_class_init (GimpAirbrushOptionsClass *options_class);
GType
gimp_airbrush_options_get_type (void)
{
static GType type = 0;
if (! type)
{
static const GTypeInfo info =
{
sizeof (GimpAirbrushOptionsClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_airbrush_options_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpAirbrushOptions),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_airbrush_options_init,
};
type = g_type_register_static (GIMP_TYPE_PAINT_OPTIONS,
"GimpAirbrushOptions",
&info, 0);
}
return type;
}
static void
gimp_airbrush_options_class_init (GimpAirbrushOptionsClass *klass)
{
}
static void
gimp_airbrush_options_init (</