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> 2003-02-05 Sven Neumann <sven@gimp.org>
* app/text/gimptext.c: added some blurbs that will show up as * app/text/gimptext.c: added some blurbs that will show up as
......
...@@ -194,7 +194,7 @@ typedef struct _PathList PathList; ...@@ -194,7 +194,7 @@ typedef struct _PathList PathList;
typedef struct _GimpToolOptions GimpToolOptions; /*< proxy-include >*/ typedef struct _GimpToolOptions GimpToolOptions; /*< proxy-include >*/
typedef GimpToolOptions * (* GimpToolOptionsNewFunc) (GimpToolInfo *tool_info); /*< proxy-include >*/ typedef void (* GimpToolOptionsGUIFunc) (GimpToolOptions *tool_options); /*< proxy-include >*/
/* functions */ /* functions */
......
...@@ -103,6 +103,7 @@ gimp_paint_info_finalize (GObject *object) ...@@ -103,6 +103,7 @@ gimp_paint_info_finalize (GObject *object)
GimpPaintInfo * GimpPaintInfo *
gimp_paint_info_new (Gimp *gimp, gimp_paint_info_new (Gimp *gimp,
GType paint_type, GType paint_type,
GType paint_options_type,
const gchar *pdb_string) const gchar *pdb_string)
{ {
GimpPaintInfo *paint_info; GimpPaintInfo *paint_info;
...@@ -114,10 +115,10 @@ gimp_paint_info_new (Gimp *gimp, ...@@ -114,10 +115,10 @@ gimp_paint_info_new (Gimp *gimp,
"name", g_type_name (paint_type), "name", g_type_name (paint_type),
NULL); NULL);
paint_info->gimp = gimp; paint_info->gimp = gimp;
paint_info->paint_type = paint_type; paint_info->paint_type = paint_type;
paint_info->paint_options_type = paint_options_type;
paint_info->pdb_string = g_strdup (pdb_string); paint_info->pdb_string = g_strdup (pdb_string);
return paint_info; return paint_info;
} }
...@@ -40,6 +40,7 @@ struct _GimpPaintInfo ...@@ -40,6 +40,7 @@ struct _GimpPaintInfo
Gimp *gimp; Gimp *gimp;
GType paint_type; GType paint_type;
GType paint_options_type;
gchar *pdb_string; gchar *pdb_string;
...@@ -56,6 +57,7 @@ GType gimp_paint_info_get_type (void) G_GNUC_CONST; ...@@ -56,6 +57,7 @@ GType gimp_paint_info_get_type (void) G_GNUC_CONST;
GimpPaintInfo * gimp_paint_info_new (Gimp *gimp, GimpPaintInfo * gimp_paint_info_new (Gimp *gimp,
GType paint_type, GType paint_type,
GType paint_options_type,
const gchar *pdb_string); const gchar *pdb_string);
......
...@@ -93,23 +93,23 @@ gimp_tool_info_class_init (GimpToolInfoClass *klass) ...@@ -93,23 +93,23 @@ gimp_tool_info_class_init (GimpToolInfoClass *klass)
static void static void
gimp_tool_info_init (GimpToolInfo *tool_info) 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->blurb = NULL;
tool_info->help = NULL; tool_info->help = NULL;
tool_info->menu_path = NULL; tool_info->menu_path = NULL;
tool_info->menu_accel = NULL; tool_info->menu_accel = NULL;
tool_info->help_domain = NULL; tool_info->help_domain = NULL;
tool_info->help_data = NULL; tool_info->help_data = NULL;
tool_info->stock_id = NULL; tool_info->stock_id = NULL;
tool_info->stock_pixbuf = NULL; tool_info->stock_pixbuf = NULL;
tool_info->context = NULL; tool_info->tool_options = NULL;
tool_info->tool_options = NULL; tool_info->paint_info = NULL;
tool_info->paint_info = NULL;
} }
static void static void
...@@ -163,6 +163,12 @@ gimp_tool_info_finalize (GObject *object) ...@@ -163,6 +163,12 @@ gimp_tool_info_finalize (GObject *object)
tool_info->stock_pixbuf = NULL; 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); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
...@@ -234,8 +240,8 @@ gimp_tool_info_get_new_preview (GimpViewable *viewable, ...@@ -234,8 +240,8 @@ gimp_tool_info_get_new_preview (GimpViewable *viewable,
GimpToolInfo * GimpToolInfo *
gimp_tool_info_new (Gimp *gimp, gimp_tool_info_new (Gimp *gimp,
GimpContext *context,
GType tool_type, GType tool_type,
GType tool_options_type,
gboolean tool_context, gboolean tool_context,
const gchar *identifier, const gchar *identifier,
const gchar *blurb, const gchar *blurb,
...@@ -252,7 +258,6 @@ gimp_tool_info_new (Gimp *gimp, ...@@ -252,7 +258,6 @@ gimp_tool_info_new (Gimp *gimp,
GimpToolInfo *tool_info; GimpToolInfo *tool_info;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); 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 (identifier != NULL, NULL);
g_return_val_if_fail (blurb != NULL, NULL); g_return_val_if_fail (blurb != NULL, NULL);
g_return_val_if_fail (help != NULL, NULL); g_return_val_if_fail (help != NULL, NULL);
...@@ -270,25 +275,25 @@ gimp_tool_info_new (Gimp *gimp, ...@@ -270,25 +275,25 @@ gimp_tool_info_new (Gimp *gimp,
"name", identifier, "name", identifier,
NULL); NULL);
tool_info->paint_info = paint_info; tool_info->use_context = tool_context;
tool_info->tool_options = NULL;
if (tool_context) tool_info->paint_info = paint_info;
tool_info->context = gimp_context_new (gimp, identifier, context);
tool_info->gimp = gimp; tool_info->gimp = gimp;
tool_info->tool_type = tool_type; tool_info->tool_type = tool_type;
tool_info->tool_options_type = tool_options_type;
tool_info->blurb = g_strdup (blurb); tool_info->blurb = g_strdup (blurb);
tool_info->help = g_strdup (help); tool_info->help = g_strdup (help);
tool_info->menu_path = g_strdup (menu_path); tool_info->menu_path = g_strdup (menu_path);
tool_info->menu_accel = g_strdup (menu_accel); tool_info->menu_accel = g_strdup (menu_accel);
tool_info->help_domain = g_strdup (help_domain); tool_info->help_domain = g_strdup (help_domain);
tool_info->help_data = g_strdup (help_data); tool_info->help_data = g_strdup (help_data);
tool_info->stock_id = g_strdup (stock_id); tool_info->stock_id = g_strdup (stock_id);
tool_info->stock_pixbuf = stock_pixbuf; tool_info->stock_pixbuf = stock_pixbuf;
if (stock_pixbuf) if (stock_pixbuf)
g_object_ref (stock_pixbuf); g_object_ref (stock_pixbuf);
......
...@@ -42,6 +42,7 @@ struct _GimpToolInfo ...@@ -42,6 +42,7 @@ struct _GimpToolInfo
Gimp *gimp; Gimp *gimp;
GType tool_type; GType tool_type;
GType tool_options_type;
gchar *blurb; gchar *blurb;
gchar *help; gchar *help;
...@@ -55,10 +56,7 @@ struct _GimpToolInfo ...@@ -55,10 +56,7 @@ struct _GimpToolInfo
gchar *stock_id; gchar *stock_id;
GdkPixbuf *stock_pixbuf; GdkPixbuf *stock_pixbuf;
/* temp_hack, will be a GType once tool_options are GimpContext derived */ gboolean use_context;
GimpToolOptionsNewFunc options_new_func;
GimpContext *context;
GimpToolOptions *tool_options; GimpToolOptions *tool_options;
GimpPaintInfo *paint_info; GimpPaintInfo *paint_info;
}; };
...@@ -72,8 +70,8 @@ struct _GimpToolInfoClass ...@@ -72,8 +70,8 @@ struct _GimpToolInfoClass
GType gimp_tool_info_get_type (void) G_GNUC_CONST; GType gimp_tool_info_get_type (void) G_GNUC_CONST;
GimpToolInfo * gimp_tool_info_new (Gimp *gimp, GimpToolInfo * gimp_tool_info_new (Gimp *gimp,
GimpContext *context,
GType tool_type, GType tool_type,
GType tool_options_type,
gboolean tool_context, gboolean tool_context,
const gchar *identifier, const gchar *identifier,
const gchar *blurb, const gchar *blurb,
......
...@@ -22,31 +22,164 @@ ...@@ -22,31 +22,164 @@
#include "tools-types.h" #include "tools-types.h"
#include "config/gimpconfig.h"
#include "core/gimptoolinfo.h"
#include "tool_options.h" #include "tool_options.h"
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
void enum
tool_options_init (GimpToolOptions *options,
GimpToolInfo *tool_info)
{ {
options->main_vbox = gtk_vbox_new (FALSE, 2); PROP_0,
options->tool_info = tool_info; 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 * static void
tool_options_new (GimpToolInfo *tool_info) 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; GimpToolOptions *options;
GtkWidget *label;
options = g_new0 (GimpToolOptions, 1); options = GIMP_TOOL_OPTIONS (object);
tool_options_init (options, tool_info);
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.")); 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); gtk_widget_show (label);
return options;
} }
...@@ -20,26 +20,42 @@ ...@@ -20,26 +20,42 @@
#define __TOOL_OPTIONS_H__ #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 struct _GimpToolOptions
{ {
GtkWidget *main_vbox; GimpContext parent_instance;
GimpToolInfo *tool_info; GimpToolInfo *tool_info;
GtkWidget *main_vbox;
GimpToolOptionsResetFunc reset_func; GimpToolOptionsResetFunc reset_func;
}; };
/* create a dummy tool options structure struct _GimpToolOptionsClass
* (to be used by tools without options) {
*/ GimpContextClass parent_class;
GimpToolOptions * tool_options_new (GimpToolInfo *tool_info);
/* initialize an already allocated ToolOptions structure void (* reset) (GimpToolOptions *tool_options);
* (to be used by derived tool options only) };
*/
void tool_options_init (GimpToolOptions *options,
GimpToolInfo *tool_info); 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__ */ #endif /* __TOOL_OPTIONS_H__ */
...@@ -22,14 +22,24 @@ libapppaint_a_sources = \ ...@@ -22,14 +22,24 @@ libapppaint_a_sources = \
paint.h \ paint.h \
gimpairbrush.c \ gimpairbrush.c \