Commit 3eb62f87 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

removed crap from ancient times when tools used to be an enum.

2001-02-23  Michael Natterer  <mitch@gimp.org>

	* app/app_procs.c: removed crap from ancient times when tools
	used to be an enum.

	* app/brush_select.[ch]: cleaned up the gui and made global paint
	mode toggling much simpler by expanding vertically instead of
	reparenting.

	* app/context_manager.c: removed hack by using a tool manager
	accessor function.

	* app/gimpcontext.c: use the new standard tool info object. Tools
	also _behave_ like all other data types now (can e.g. be
	refreshed).

	* app/tools/tool.[ch]

	* app/tools/gimptoolinfo.[ch]: added an "identifier" which is an
	untranslated string with a meaningful prefix and name, e.g.
	"gimp:color_picker_tool". Renamed "tool_name" and "tool_desc"
	to "blurb" and "help", changed the constructor accordingly.
	Added gimp_tool_info_get_standards() to make the context work
	with tool refresh.

	* app/tools/tool_manager.[ch]
	* app/tools/tools.c: removed the global list of tool class
	structures because the tool info list is in place.
	Added tool_manager_register_tool_options() which calls
	tool_options_dialog_add() and registers the options in the
	global_tool_info_list.

	* app/tools/Makefile.am
	* app/tools/paint_options.[ch]
	* app/tools/selection_options.[ch]
	* app/tools/tool_options.[ch]
	* app/tools/tool_options_dialog.[ch]: build them all again. This
	is mostly the old tool options system with minor modifications to
	work with the new stuff. The tool options auto-update with the user
	context now, so there are no update functions any more.

	* app/gimpdnd.c
	* app/toolbox.c
	* app/tools/color_picker.c
	* app/tools/measure.c
	* app/tools/move.c: changed accordingly.
parent 9495ea51
2001-02-23 Michael Natterer <mitch@gimp.org>
* app/app_procs.c: removed crap from ancient times when tools
used to be an enum.
* app/brush_select.[ch]: cleaned up the gui and made global paint
mode toggling much simpler by expanding vertically instead of
reparenting.
* app/context_manager.c: removed hack by using a tool manager
accessor function.
* app/gimpcontext.c: use the new standard tool info object. Tools
also _behave_ like all other data types now (can e.g. be
refreshed).
* app/tools/tool.[ch]
* app/tools/gimptoolinfo.[ch]: added an "identifier" which is an
untranslated string with a meaningful prefix and name, e.g.
"gimp:color_picker_tool". Renamed "tool_name" and "tool_desc"
to "blurb" and "help", changed the constructor accordingly.
Added gimp_tool_info_get_standards() to make the context work
with tool refresh.
* app/tools/tool_manager.[ch]
* app/tools/tools.c: removed the global list of tool class
structures because the tool info list is in place.
Added tool_manager_register_tool_options() which calls
tool_options_dialog_add() and registers the options in the
global_tool_info_list.
* app/tools/Makefile.am
* app/tools/paint_options.[ch]
* app/tools/selection_options.[ch]
* app/tools/tool_options.[ch]
* app/tools/tool_options_dialog.[ch]: build them all again. This
is mostly the old tool options system with minor modifications to
work with the new stuff. The tool options auto-update with the user
context now, so there are no update functions any more.
* app/gimpdnd.c
* app/toolbox.c
* app/tools/color_picker.c
* app/tools/measure.c
* app/tools/move.c: changed accordingly.
2001-02-23 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
......
......@@ -649,16 +649,6 @@ app_init (void)
tool_options_dialog_new ();
/* EEK: force signal emission */
if (gimp_context_get_tool (gimp_context_get_user ()) == RECT_SELECT)
{
gimp_context_tool_changed (gimp_context_get_user ());
}
else
{
gimp_context_set_tool (gimp_context_get_user (), RECT_SELECT);
}
/* FIXME: This needs to go in preferences */
message_handler = MESSAGE_BOX;
}
......
......@@ -144,11 +144,10 @@ brush_select_new (gchar *title,
gint init_mode)
{
BrushSelect *bsp;
GtkWidget *vbox;
GtkWidget *main_vbox;
GtkWidget *hbox;
GtkWidget *sep;
GtkWidget *table;
GtkWidget *util_box;
GtkWidget *slider;
GimpBrush *active = NULL;
......@@ -215,21 +214,22 @@ brush_select_new (gchar *title,
}
/* The main vbox */
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (bsp->shell)->vbox), vbox);
main_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 2);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (bsp->shell)->vbox), main_vbox);
/* The horizontal box containing the brush list & options box */
hbox = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (vbox), hbox);
/* Create the active brush label */
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 2);
/* A place holder for paint mode switching */
bsp->left_box = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), bsp->left_box, TRUE, TRUE, 0);
bsp->brush_name = gtk_label_new (_("No Brushes available"));
gtk_box_pack_start (GTK_BOX (hbox), bsp->brush_name, FALSE, FALSE, 4);
bsp->brush_size = gtk_label_new ("(0 x 0)");
gtk_box_pack_start (GTK_BOX (hbox), bsp->brush_size, FALSE, FALSE, 2);
/* The horizontal box containing preview & scrollbar */
bsp->brush_selection_box = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (bsp->left_box), bsp->brush_selection_box);
gtk_widget_show (bsp->brush_name);
gtk_widget_show (bsp->brush_size);
gtk_widget_show (hbox);
/* The Brush Grid */
bsp->view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_GRID,
......@@ -239,45 +239,14 @@ brush_select_new (gchar *title,
MIN_CELL_SIZE,
STD_BRUSH_COLUMNS,
STD_BRUSH_ROWS);
gtk_box_pack_start (GTK_BOX (bsp->brush_selection_box), bsp->view,
TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), bsp->view, TRUE, TRUE, 0);
gtk_widget_show (bsp->view);
gtk_widget_show (bsp->brush_selection_box);
gtk_widget_show (bsp->left_box);
/* Options box */
bsp->options_box = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), bsp->options_box, FALSE, FALSE, 0);
/* Create the active brush label */
util_box = gtk_hbox_new (FALSE, 0);
gtk_container_set_resize_mode (GTK_CONTAINER (util_box), GTK_RESIZE_QUEUE);
gtk_box_pack_start (GTK_BOX (bsp->options_box), util_box, FALSE, FALSE, 2);
bsp->brush_name = gtk_label_new (_("No Brushes available"));
gtk_box_pack_start (GTK_BOX (util_box), bsp->brush_name, FALSE, FALSE, 4);
bsp->brush_size = gtk_label_new ("(0 x 0)");
gtk_box_pack_start (GTK_BOX (util_box), bsp->brush_size, FALSE, FALSE, 2);
gtk_widget_show (bsp->brush_name);
gtk_widget_show (bsp->brush_size);
gtk_widget_show (util_box);
/* A place holder for paint mode switching */
bsp->right_box = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (bsp->options_box), bsp->right_box, TRUE, TRUE, 0);
/* The vbox for the paint options */
bsp->paint_options_box = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (bsp->right_box), bsp->paint_options_box,
gtk_box_pack_start (GTK_BOX (bsp->view), bsp->paint_options_box,
FALSE, FALSE, 0);
/* A separator before the paint options */
sep = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (bsp->paint_options_box), sep, FALSE, FALSE, 0);
gtk_widget_show (sep);
/* Create the frame and the table for the options */
table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
......@@ -309,12 +278,16 @@ brush_select_new (gchar *title,
gtk_widget_show (table);
gtk_widget_show (bsp->paint_options_box);
gtk_widget_show (bsp->right_box);
/* A separator after the paint options */
sep = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (bsp->paint_options_box), sep, FALSE, FALSE, 0);
gtk_widget_show (sep);
/* Create the spacing scale widget */
table = gtk_table_new (1, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
gtk_box_pack_end (GTK_BOX (bsp->options_box), table, FALSE, FALSE, 2);
gtk_box_pack_end (GTK_BOX (bsp->view), table, FALSE, FALSE, 0);
bsp->spacing_data =
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 1.0, 1000.0, 1.0, 1.0, 0.0));
......@@ -336,9 +309,7 @@ brush_select_new (gchar *title,
gtk_widget_show (table);
gtk_widget_show (bsp->options_box);
gtk_widget_show (hbox);
gtk_widget_show (vbox);
gtk_widget_show (main_vbox);
/* add callbacks to keep the display area current */
bsp->name_changed_handler_id =
......@@ -348,7 +319,7 @@ brush_select_new (gchar *title,
bsp);
/* Only for main dialog */
if (!title)
if (! title)
{
/* if we are in per-tool paint options mode, hide the paint options */
brush_select_show_paint_options (bsp, global_paint_options);
......@@ -409,31 +380,11 @@ brush_select_show_paint_options (BrushSelect *bsp,
{
if (! GTK_WIDGET_VISIBLE (bsp->paint_options_box))
gtk_widget_show (bsp->paint_options_box);
if (bsp->brush_selection_box->parent != bsp->left_box)
gtk_widget_reparent (bsp->brush_selection_box, bsp->left_box);
gtk_box_set_child_packing (GTK_BOX (bsp->options_box->parent),
bsp->options_box,
FALSE, FALSE, 0, GTK_PACK_START);
gtk_box_set_child_packing (GTK_BOX (bsp->left_box->parent),
bsp->left_box,
TRUE, TRUE, 0, GTK_PACK_START);
gtk_box_set_spacing (GTK_BOX (bsp->left_box->parent), 2);
}
else
{
if (GTK_WIDGET_VISIBLE (bsp->paint_options_box))
gtk_widget_hide (bsp->paint_options_box);
if (bsp->brush_selection_box->parent != bsp->right_box)
gtk_widget_reparent (bsp->brush_selection_box, bsp->right_box);
gtk_box_set_child_packing (GTK_BOX (bsp->left_box->parent),
bsp->left_box,
FALSE, FALSE, 0, GTK_PACK_START);
gtk_box_set_child_packing (GTK_BOX (bsp->options_box->parent),
bsp->options_box,
TRUE, TRUE, 0, GTK_PACK_START);
gtk_box_set_spacing (GTK_BOX (bsp->left_box->parent), 0);
}
}
......
......@@ -26,22 +26,15 @@ struct _BrushSelect
{
GtkWidget *shell;
/* Place holders which enable global<->per-tool paint options switching */
GtkWidget *left_box;
GtkWidget *right_box;
GtkWidget *brush_selection_box;
GtkWidget *paint_options_box;
GtkWidget *view;
GtkWidget *paint_options_box;
GtkWidget *options_box;
GtkWidget *brush_name;
GtkWidget *brush_size;
GtkAdjustment *opacity_data;
GtkAdjustment *spacing_data;
GtkWidget *edit_button;
GtkWidget *delete_button;
GtkAdjustment *opacity_data;
GtkWidget *option_menu;
/* Callback function name */
......
......@@ -108,7 +108,6 @@ context_manager_tool_changed (GimpContext *user_context,
{
GimpTool *new_tool = NULL;
GimpContext *tool_context = NULL;
GtkType active_tool_type;
if (tool_info->tool_type != GTK_TYPE_NONE)
{
......@@ -121,12 +120,10 @@ context_manager_tool_changed (GimpContext *user_context,
return;
}
active_tool_type = GTK_OBJECT (active_tool)->klass->type;
if (! global_paint_options)
{
if (active_tool &&
(tool_context = tool_manager_get_info_by_type (active_tool_type)->context))
(tool_context = tool_manager_get_info_by_tool (active_tool)->context))
{
gimp_context_unset_parent (tool_context);
}
......
......@@ -1260,6 +1260,8 @@ gimp_context_copy_display (GimpContext *src,
/*****************************************************************************/
/* tool ********************************************************************/
static GimpToolInfo *standard_tool_info = NULL;
GimpToolInfo *
gimp_context_get_tool (GimpContext *context)
{
......@@ -1332,9 +1334,7 @@ gimp_context_tool_list_thaw (GimpContainer *container,
(context,
GIMP_TOOL_INFO (gimp_container_get_child_by_index (container, 0)));
else
gimp_context_real_set_tool (context, NULL);
/* FIXME: GIMP_TOOL_INFO (gimp_tool_info_get_standard ())); */
gimp_context_real_set_tool (context, gimp_tool_info_get_standard ());
}
/* the active tool disappeared */
......@@ -1361,15 +1361,13 @@ static void
gimp_context_real_set_tool (GimpContext *context,
GimpToolInfo *tool_info)
{
/* FIXME
if (! standard_tool_info)
standard_tool_info = GIMP_TOOL_INFO (gimp_tool_info_get_standard ());
*/
standard_tool_info = gimp_tool_info_get_standard ();
if (context->tool_info == tool_info)
return;
if (context->tool_name /* FIXME && tool_info != standard_tool_info*/)
if (context->tool_name && tool_info != standard_tool_info)
{
g_free (context->tool_name);
context->tool_name = NULL;
......@@ -1396,9 +1394,8 @@ gimp_context_real_set_tool (GimpContext *context,
GTK_SIGNAL_FUNC (gimp_context_tool_dirty),
context);
/* FIXME if (tool_info != standard_tool_info) */
context->tool_name = g_strdup (GIMP_OBJECT (tool_info)->name);
if (tool_info != standard_tool_info)
context->tool_name = g_strdup (GIMP_OBJECT (tool_info)->name);
}
gimp_context_tool_changed (context);
......@@ -1410,7 +1407,7 @@ gimp_context_copy_tool (GimpContext *src,
{
gimp_context_real_set_tool (dest, src->tool_info);
if ((!src->tool_info /* FIXME || src->tool_info == standard_tool_info */) &&
if ((!src->tool_info || src->tool_info == standard_tool_info) &&
src->tool_name)
{
g_free (dest->tool_name);
......@@ -1638,6 +1635,8 @@ gimp_context_copy_opacity (GimpContext *src,
LayerModeEffects
gimp_context_get_paint_mode (GimpContext *context)
{
g_return_val_if_fail (! context || GIMP_IS_CONTEXT (context), NORMAL_MODE);
context_check_current (context);
context_return_val_if_fail (context, 0);
......@@ -1648,6 +1647,8 @@ void
gimp_context_set_paint_mode (GimpContext *context,
LayerModeEffects paint_mode)
{
g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
context_check_current (context);
context_return_if_fail (context);
context_find_defined (context, GIMP_CONTEXT_PAINT_MODE_MASK);
......@@ -1658,6 +1659,8 @@ gimp_context_set_paint_mode (GimpContext *context,
void
gimp_context_paint_mode_changed (GimpContext *context)
{
g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
context_check_current (context);
context_return_if_fail (context);
......@@ -1692,6 +1695,8 @@ static GimpBrush *standard_brush = NULL;
GimpBrush *
gimp_context_get_brush (GimpContext *context)
{
g_return_val_if_fail (! context || GIMP_IS_CONTEXT (context), NULL);
context_check_current (context);
context_return_val_if_fail (context, NULL);
......@@ -1702,6 +1707,9 @@ void
gimp_context_set_brush (GimpContext *context,
GimpBrush *brush)
{
g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
g_return_if_fail (! brush || GIMP_IS_BRUSH (brush));
context_check_current (context);
context_return_if_fail (context);
context_find_defined (context, GIMP_CONTEXT_BRUSH_MASK);
......@@ -1712,6 +1720,8 @@ gimp_context_set_brush (GimpContext *context,
void
gimp_context_brush_changed (GimpContext *context)
{
g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
context_check_current (context);
context_return_if_fail (context);
......
......@@ -25,6 +25,9 @@
#include "gimptoolinfo.h"
#include "temp_buf.h"
/* FIXME: include rect_select.h here */
#include "color_picker.h"
static void gimp_tool_info_class_init (GimpToolInfoClass *klass);
static void gimp_tool_info_init (GimpToolInfo *tool_info);
......@@ -82,25 +85,22 @@ gimp_tool_info_class_init (GimpToolInfoClass *klass)
void
gimp_tool_info_init (GimpToolInfo *tool_info)
{
tool_info->tool_type = GTK_TYPE_NONE;
tool_info->tool_name = NULL;
tool_info->tool_type = GTK_TYPE_NONE;
tool_info->menu_path = NULL;
tool_info->menu_accel = NULL;
tool_info->blurb = NULL;
tool_info->help = NULL;
tool_info->tool_desc = 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->icon_data = NULL;
tool_info->icon_data = NULL;
tool_info->context = NULL;
tool_info->context = NULL;
tool_info->tool_options = NULL;
tool_info->tool_widget = NULL;
tool_info->tool_options = NULL;
}
static void
......@@ -110,13 +110,12 @@ gimp_tool_info_destroy (GtkObject *object)
tool_info = (GimpToolInfo *) object;
g_free (tool_info->tool_name);
g_free (tool_info->blurb);
g_free (tool_info->help);
g_free (tool_info->menu_path);
g_free (tool_info->menu_accel);
g_free (tool_info->tool_desc);
g_free (tool_info->help_domain);
g_free (tool_info->help_data);
......@@ -193,10 +192,11 @@ gimp_tool_info_get_new_preview (GimpViewable *viewable,
GimpToolInfo *
gimp_tool_info_new (GtkType tool_type,
const gchar *tool_name,
const gchar *identifier,
const gchar *blurb,
const gchar *help,
const gchar *menu_path,
const gchar *menu_accel,
const gchar *tool_desc,
const gchar *help_domain,
const gchar *help_data,
const gchar **icon_data)
......@@ -205,18 +205,16 @@ gimp_tool_info_new (GtkType tool_type,
tool_info = gtk_type_new (GIMP_TYPE_TOOL_INFO);
/* FIXME */
gimp_object_set_name (GIMP_OBJECT (tool_info), tool_name);
gimp_object_set_name (GIMP_OBJECT (tool_info), identifier);
tool_info->tool_type = tool_type;
tool_info->tool_name = g_strdup (tool_name);
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->tool_desc = g_strdup (tool_desc);
tool_info->help_domain = g_strdup (help_domain);
tool_info->help_data = g_strdup (help_data);
......@@ -224,3 +222,23 @@ gimp_tool_info_new (GtkType tool_type,
return tool_info;
}
GimpToolInfo *
gimp_tool_info_get_standard (void)
{
static GimpToolInfo *standard_tool_info = NULL;
if (! standard_tool_info)
{
standard_tool_info =
gimp_tool_info_new (GIMP_TYPE_COLOR_PICKER,
"gimp:standard_tool",
"Standard Tool",
"Well something must be broken",
NULL, NULL,
NULL, NULL,
NULL);
}
return standard_tool_info;
}
......@@ -39,13 +39,12 @@ struct _GimpToolInfo
GtkType tool_type;
gchar *tool_name;
gchar *blurb;
gchar *help;
gchar *menu_path;
gchar *menu_accel;
gchar *tool_desc;
gchar *help_domain;
gchar *help_data;
......@@ -54,9 +53,6 @@ struct _GimpToolInfo
GimpContext *context;
ToolOptions *tool_options;
/* EEK */
GtkWidget *tool_widget;
};
struct _GimpToolInfoClass
......@@ -65,16 +61,19 @@ struct _GimpToolInfoClass
};
GtkType gimp_tool_info_get_type (void);
GtkType gimp_tool_info_get_type (void);
GimpToolInfo * gimp_tool_info_new (GtkType tool_type,
const gchar *identifier,
const gchar *blurb,
const gchar *help,
const gchar *menu_path,
const gchar *menu_accel,
const gchar *help_domain,
const gchar *help_data,
const gchar **icon_data);
GimpToolInfo * gimp_tool_info_new (GtkType tool_type,
const gchar *tool_name,
const gchar *menu_path,
const gchar *menu_accel,
const gchar *tool_desc,
const gchar *help_domain,
const gchar *help_data,
const gchar **icon_data);
GimpToolInfo * gimp_tool_info_get_standard (void);
#endif /* __GIMP_TOOL_INFO_H__ */
......@@ -23,30 +23,27 @@
#include "apptypes.h"
#include "tool_options.h"
#include "tool.h"
#include "libgimp/gimpintl.h"
void
tool_options_init (ToolOptions *options,
const gchar *title,
ToolOptionsResetFunc reset_func)
{
options->main_vbox = gtk_vbox_new (FALSE, 2);
options->title = g_strdup (title);
options->reset_func = reset_func;
}
ToolOptions *
tool_options_new (const gchar *title)
tool_options_new (void)
{
ToolOptions *options;
GtkWidget *label;
options = g_new (ToolOptions, 1);
tool_options_init (options, title, NULL);
options = g_new0 (ToolOptions, 1);
tool_options_init (options, NULL);
label = gtk_label_new (_("This tool has no options."));
gtk_box_pack_start (GTK_BOX (options->main_vbox), label, FALSE, FALSE, 6);
......
......@@ -23,19 +23,11 @@
#include "gimpobject.h"
#define GIMP_TYPE_TOOL_OPTIONS (gimp_tool_options_get_type ())
#define GIMP_TOOL_OPTIONS(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_TOOL_OPTIONS, GimpToolOptions))
#define GIMP_IS_TOOL_OPTIONS(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_TOOL_OPTIONS))
#define GIMP_TOOL_OPTIONS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_OPTIONS, GimpToolOptionsClass))
#define GIMP_IS_TOOL_OPTIONS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TOOL_OPTIONS))
/* the tool options structures */
struct _ToolOptions
{
GimpObject parent_instance;
GtkWidget *main_vbox;
gchar *title;
ToolOptionsResetFunc reset_func;
};
......@@ -50,13 +42,12 @@ typedef struct _ToolOptionsClass ToolOptionsClass;
/* create a dummy tool options structure
* (to be used by tools without options)
*/
ToolOptions * tool_options_new (const gchar *title);
ToolOptions * tool_options_new (void);