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

Fixed bug #165618:

2005-03-04  Michael Natterer  <mitch@gimp.org>

	Fixed bug #165618:

	* app/tools/gimptoolcontrol.[ch]: added new functions
	gimp_tool_control_set/get_action_value_1/2/3/4() which allow tools
	to specify their primary, secondary etc. "values" using
	action-identifying strings like "context/context-brush-radius-set".

	* app/tools/gimpblendtool.c
	* app/tools/gimpbucketfilltool.c
	* app/tools/gimpcolortool.c
	* app/tools/gimpinktool.c
	* app/tools/gimppainttool.c: set actions where appropriate. Still
	needs some way to document the mapping in a user-visible way.

	* app/tools/gimpblendtool.c
	* app/tools/gimpbucketfilltool.c: tab removal and minor cleanups.

	* app/actions/actions.[ch]: added utility function
	action_select_property().

	* app/actions/tools-actions.c
	* app/actions/tools-commands.[ch]: added actions and callbacks for
	setting the ink blob size, aspect and angle. Also added actions
	and callbacks for the new generic tool values.
parent e6d4e369
2005-03-04 Michael Natterer <mitch@gimp.org>
Fixed bug #165618:
* app/tools/gimptoolcontrol.[ch]: added new functions
gimp_tool_control_set/get_action_value_1/2/3/4() which allow tools
to specify their primary, secondary etc. "values" using
action-identifying strings like "context/context-brush-radius-set".
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolortool.c
* app/tools/gimpinktool.c
* app/tools/gimppainttool.c: set actions where appropriate. Still
needs some way to document the mapping in a user-visible way.
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c: tab removal and minor cleanups.
* app/actions/actions.[ch]: added utility function
action_select_property().
* app/actions/tools-actions.c
* app/actions/tools-commands.[ch]: added actions and callbacks for
setting the ink blob size, aspect and angle. Also added actions
and callbacks for the new generic tool values.
2005-03-03 Helvetix Victorinox <helvetix@gimp.org>
* app/composite/make-installer.py:Applied patch from
......
......@@ -412,6 +412,36 @@ action_select_value (GimpActionSelectType select_type,
return value;
}
void
action_select_property (GimpActionSelectType select_type,
GObject *object,
const gchar *property_name,
gdouble inc,
gdouble skip_inc,
gboolean wrap)
{
GParamSpec *pspec;
gdouble value;
g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (property_name != NULL);
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
property_name);
g_return_if_fail (G_IS_PARAM_SPEC_DOUBLE (pspec));
g_object_get (object, property_name, &value, NULL);
value = action_select_value (select_type,
value,
G_PARAM_SPEC_DOUBLE (pspec)->minimum,
G_PARAM_SPEC_DOUBLE (pspec)->maximum,
inc, skip_inc, wrap);
g_object_set (object, property_name, value, NULL);
}
GimpObject *
action_select_object (GimpActionSelectType select_type,
GimpContainer *container,
......
......@@ -39,6 +39,12 @@ gdouble action_select_value (GimpActionSelectType select_type,
gdouble inc,
gdouble skip_inc,
gboolean wrap);
void action_select_property (GimpActionSelectType select_type,
GObject *object,
const gchar *property_name,
gdouble inc,
gdouble skip_inc,
gboolean wrap);
GimpObject * action_select_object (GimpActionSelectType select_type,
GimpContainer *container,
GimpObject *current);
......
......@@ -140,6 +140,230 @@ static GimpEnumActionEntry tools_color_average_radius_actions[] =
NULL },
};
static GimpEnumActionEntry tools_ink_blob_size_actions[] =
{
{ "tools-ink-blob-size-set", GIMP_STOCK_TOOL_INK,
"Set Ink Blob Size", NULL, NULL,
GIMP_ACTION_SELECT_SET, TRUE,
NULL },
{ "tools-ink-blob-size-minimum", GIMP_STOCK_TOOL_INK,
"Minumum Ink Blob Size", NULL, NULL,
GIMP_ACTION_SELECT_FIRST, FALSE,
NULL },
{ "tools-ink-blob-size-maximum", GIMP_STOCK_TOOL_INK,
"Maximum Ink Blob Size", NULL, NULL,
GIMP_ACTION_SELECT_LAST, FALSE,
NULL },
{ "tools-ink-blob-size-decrease", GIMP_STOCK_TOOL_INK,
"Decrease Ink Blob Size", NULL, NULL,
GIMP_ACTION_SELECT_PREVIOUS, FALSE,
NULL },
{ "tools-ink-blob-size-increase", GIMP_STOCK_TOOL_INK,
"Increase Ink Blob Size", NULL, NULL,
GIMP_ACTION_SELECT_NEXT, FALSE,
NULL },
{ "tools-ink-blob-size-decrease-skip", GIMP_STOCK_TOOL_INK,
"Decrease Ink Blob Size More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
NULL },
{ "tools-ink-blob-size-increase-skip", GIMP_STOCK_TOOL_INK,
"Increase Ink Blob Size More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
NULL },
};
static GimpEnumActionEntry tools_ink_blob_aspect_actions[] =
{
{ "tools-ink-blob-aspect-set", GIMP_STOCK_TOOL_INK,
"Set Ink Blob Aspect", NULL, NULL,
GIMP_ACTION_SELECT_SET, TRUE,
NULL },
{ "tools-ink-blob-aspect-minimum", GIMP_STOCK_TOOL_INK,
"Minumum Ink Blob Aspect", NULL, NULL,
GIMP_ACTION_SELECT_FIRST, FALSE,
NULL },
{ "tools-ink-blob-aspect-maximum", GIMP_STOCK_TOOL_INK,
"Maximum Ink Blob Aspect", NULL, NULL,
GIMP_ACTION_SELECT_LAST, FALSE,
NULL },
{ "tools-ink-blob-aspect-decrease", GIMP_STOCK_TOOL_INK,
"Decrease Ink Blob Aspect", NULL, NULL,
GIMP_ACTION_SELECT_PREVIOUS, FALSE,
NULL },
{ "tools-ink-blob-aspect-increase", GIMP_STOCK_TOOL_INK,
"Increase Ink Blob Aspect", NULL, NULL,
GIMP_ACTION_SELECT_NEXT, FALSE,
NULL },
{ "tools-ink-blob-aspect-decrease-skip", GIMP_STOCK_TOOL_INK,
"Decrease Ink Blob Aspect More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
NULL },
{ "tools-ink-blob-aspect-increase-skip", GIMP_STOCK_TOOL_INK,
"Increase Ink Blob Aspect More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
NULL },
};
static GimpEnumActionEntry tools_ink_blob_angle_actions[] =
{
{ "tools-ink-blob-angle-set", GIMP_STOCK_TOOL_INK,
"Set Ink Blob Angle", NULL, NULL,
GIMP_ACTION_SELECT_SET, TRUE,
NULL },
{ "tools-ink-blob-angle-minimum", GIMP_STOCK_TOOL_INK,
"Minumum Ink Blob Angle", NULL, NULL,
GIMP_ACTION_SELECT_FIRST, FALSE,
NULL },
{ "tools-ink-blob-angle-maximum", GIMP_STOCK_TOOL_INK,
"Maximum Ink Blob Angle", NULL, NULL,
GIMP_ACTION_SELECT_LAST, FALSE,
NULL },
{ "tools-ink-blob-angle-decrease", GIMP_STOCK_TOOL_INK,
"Decrease Ink Blob Angle", NULL, NULL,
GIMP_ACTION_SELECT_PREVIOUS, FALSE,
NULL },
{ "tools-ink-blob-angle-increase", GIMP_STOCK_TOOL_INK,
"Increase Ink Blob Angle", NULL, NULL,
GIMP_ACTION_SELECT_NEXT, FALSE,
NULL },
{ "tools-ink-blob-angle-decrease-skip", GIMP_STOCK_TOOL_INK,
"Decrease Ink Blob Angle More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
NULL },
{ "tools-ink-blob-angle-increase-skip", GIMP_STOCK_TOOL_INK,
"Increase Ink Blob Angle More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
NULL },
};
static GimpEnumActionEntry tools_value_1_actions[] =
{
{ "tools-value-1-set", GIMP_STOCK_TOOL_OPTIONS,
"Set Value 1", NULL, NULL,
GIMP_ACTION_SELECT_SET, TRUE,
NULL },
{ "tools-value-1-minimum", GIMP_STOCK_TOOL_OPTIONS,
"Minimize Value 1", NULL, NULL,
GIMP_ACTION_SELECT_FIRST, FALSE,
NULL },
{ "tools-value-1-maximum", GIMP_STOCK_TOOL_OPTIONS,
"Maximize Value 1", NULL, NULL,
GIMP_ACTION_SELECT_LAST, FALSE,
NULL },
{ "tools-value-1-decrease", GIMP_STOCK_TOOL_OPTIONS,
"Decrease Value 1", NULL, NULL,
GIMP_ACTION_SELECT_PREVIOUS, FALSE,
NULL },
{ "tools-value-1-increase", GIMP_STOCK_TOOL_OPTIONS,
"Increase Value 1", NULL, NULL,
GIMP_ACTION_SELECT_NEXT, FALSE,
NULL },
{ "tools-value-1-decrease-skip", GIMP_STOCK_TOOL_OPTIONS,
"Decrease Value 1 More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
NULL },
{ "tools-value-1-increase-skip", GIMP_STOCK_TOOL_OPTIONS,
"Increase Value 1 More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
NULL },
};
static GimpEnumActionEntry tools_value_2_actions[] =
{
{ "tools-value-2-set", GIMP_STOCK_TOOL_OPTIONS,
"Set Value 2", NULL, NULL,
GIMP_ACTION_SELECT_SET, TRUE,
NULL },
{ "tools-value-2-minimum", GIMP_STOCK_TOOL_OPTIONS,
"Minimize Value 2", NULL, NULL,
GIMP_ACTION_SELECT_FIRST, FALSE,
NULL },
{ "tools-value-2-maximum", GIMP_STOCK_TOOL_OPTIONS,
"Maximize Value 2", NULL, NULL,
GIMP_ACTION_SELECT_LAST, FALSE,
NULL },
{ "tools-value-2-decrease", GIMP_STOCK_TOOL_OPTIONS,
"Decrease Value 2", NULL, NULL,
GIMP_ACTION_SELECT_PREVIOUS, FALSE,
NULL },
{ "tools-value-2-increase", GIMP_STOCK_TOOL_OPTIONS,
"Increase Value 2", NULL, NULL,
GIMP_ACTION_SELECT_NEXT, FALSE,
NULL },
{ "tools-value-2-decrease-skip", GIMP_STOCK_TOOL_OPTIONS,
"Decrease Value 2 More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
NULL },
{ "tools-value-2-increase-skip", GIMP_STOCK_TOOL_OPTIONS,
"Increase Value 2 More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
NULL },
};
static GimpEnumActionEntry tools_value_3_actions[] =
{
{ "tools-value-3-set", GIMP_STOCK_TOOL_OPTIONS,
"Set Value 3", NULL, NULL,
GIMP_ACTION_SELECT_SET, TRUE,
NULL },
{ "tools-value-3-minimum", GIMP_STOCK_TOOL_OPTIONS,
"Minimize Value 3", NULL, NULL,
GIMP_ACTION_SELECT_FIRST, FALSE,
NULL },
{ "tools-value-3-maximum", GIMP_STOCK_TOOL_OPTIONS,
"Maximize Value 3", NULL, NULL,
GIMP_ACTION_SELECT_LAST, FALSE,
NULL },
{ "tools-value-3-decrease", GIMP_STOCK_TOOL_OPTIONS,
"Decrease Value 3", NULL, NULL,
GIMP_ACTION_SELECT_PREVIOUS, FALSE,
NULL },
{ "tools-value-3-increase", GIMP_STOCK_TOOL_OPTIONS,
"Increase Value 3", NULL, NULL,
GIMP_ACTION_SELECT_NEXT, FALSE,
NULL },
{ "tools-value-3-decrease-skip", GIMP_STOCK_TOOL_OPTIONS,
"Decrease Value 3 More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
NULL },
{ "tools-value-3-increase-skip", GIMP_STOCK_TOOL_OPTIONS,
"Increase Value 3 More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
NULL },
};
static GimpEnumActionEntry tools_value_4_actions[] =
{
{ "tools-value-4-set", GIMP_STOCK_TOOL_OPTIONS,
"Set Value 4", NULL, NULL,
GIMP_ACTION_SELECT_SET, TRUE,
NULL },
{ "tools-value-4-minimum", GIMP_STOCK_TOOL_OPTIONS,
"Minimize Value 4", NULL, NULL,
GIMP_ACTION_SELECT_FIRST, FALSE,
NULL },
{ "tools-value-4-maximum", GIMP_STOCK_TOOL_OPTIONS,
"Maximize Value 4", NULL, NULL,
GIMP_ACTION_SELECT_LAST, FALSE,
NULL },
{ "tools-value-4-decrease", GIMP_STOCK_TOOL_OPTIONS,
"Decrease Value 4", NULL, NULL,
GIMP_ACTION_SELECT_PREVIOUS, FALSE,
NULL },
{ "tools-value-4-increase", GIMP_STOCK_TOOL_OPTIONS,
"Increase Value 4", NULL, NULL,
GIMP_ACTION_SELECT_NEXT, FALSE,
NULL },
{ "tools-value-4-decrease-skip", GIMP_STOCK_TOOL_OPTIONS,
"Decrease Value 4 More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
NULL },
{ "tools-value-4-increase-skip", GIMP_STOCK_TOOL_OPTIONS,
"Increase Value 4 More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
NULL },
};
void
tools_actions_setup (GimpActionGroup *group)
......@@ -173,6 +397,36 @@ tools_actions_setup (GimpActionGroup *group)
G_N_ELEMENTS (tools_color_average_radius_actions),
G_CALLBACK (tools_color_average_radius_cmd_callback));
gimp_action_group_add_enum_actions (group,
tools_ink_blob_size_actions,
G_N_ELEMENTS (tools_ink_blob_size_actions),
G_CALLBACK (tools_ink_blob_size_cmd_callback));
gimp_action_group_add_enum_actions (group,
tools_ink_blob_aspect_actions,
G_N_ELEMENTS (tools_ink_blob_aspect_actions),
G_CALLBACK (tools_ink_blob_aspect_cmd_callback));
gimp_action_group_add_enum_actions (group,
tools_ink_blob_angle_actions,
G_N_ELEMENTS (tools_ink_blob_angle_actions),
G_CALLBACK (tools_ink_blob_angle_cmd_callback));
gimp_action_group_add_enum_actions (group,
tools_value_1_actions,
G_N_ELEMENTS (tools_value_1_actions),
G_CALLBACK (tools_value_1_cmd_callback));
gimp_action_group_add_enum_actions (group,
tools_value_2_actions,
G_N_ELEMENTS (tools_value_2_actions),
G_CALLBACK (tools_value_2_cmd_callback));
gimp_action_group_add_enum_actions (group,
tools_value_3_actions,
G_N_ELEMENTS (tools_value_3_actions),
G_CALLBACK (tools_value_3_cmd_callback));
gimp_action_group_add_enum_actions (group,
tools_value_4_actions,
G_N_ELEMENTS (tools_value_4_actions),
G_CALLBACK (tools_value_4_cmd_callback));
for (list = GIMP_LIST (group->gimp->tool_info_list)->list;
list;
list = g_list_next (list))
......
......@@ -18,6 +18,8 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "actions-types.h"
......@@ -27,9 +29,15 @@
#include "core/gimpcontext.h"
#include "core/gimptoolinfo.h"
#include "paint/gimpinkoptions.h"
#include "widgets/gimpenumaction.h"
#include "widgets/gimpuimanager.h"
#include "tools/gimp-tools.h"
#include "tools/gimpcoloroptions.h"
#include "tools/gimpimagemaptool.h"
#include "tools/gimptoolcontrol.h"
#include "tools/tool_manager.h"
#include "actions.h"
......@@ -231,21 +239,193 @@ tools_color_average_radius_cmd_callback (GtkAction *action,
if (tool_info && GIMP_IS_COLOR_OPTIONS (tool_info->tool_options))
{
GimpToolOptions *options = tool_info->tool_options;
GParamSpec *pspec;
gdouble radius;
action_select_property ((GimpActionSelectType) value,
G_OBJECT (tool_info->tool_options),
"average-radius",
1.0, 10.0, FALSE);
}
}
void
tools_ink_blob_size_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpToolInfo *tool_info;
return_if_no_context (context, data);
tool_info = gimp_context_get_tool (context);
if (tool_info && GIMP_IS_INK_OPTIONS (tool_info->tool_options))
{
action_select_property ((GimpActionSelectType) value,
G_OBJECT (tool_info->tool_options),
"size",
1.0, 10.0, FALSE);
}
}
void
tools_ink_blob_aspect_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpToolInfo *tool_info;
return_if_no_context (context, data);
tool_info = gimp_context_get_tool (context);
if (tool_info && GIMP_IS_INK_OPTIONS (tool_info->tool_options))
{
action_select_property ((GimpActionSelectType) value,
G_OBJECT (tool_info->tool_options),
"blob-aspect",
0.1, 1.0, FALSE);
}
}
void
tools_ink_blob_angle_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpToolInfo *tool_info;
return_if_no_context (context, data);
tool_info = gimp_context_get_tool (context);
if (tool_info && GIMP_IS_INK_OPTIONS (tool_info->tool_options))
{
action_select_property ((GimpActionSelectType) value,
G_OBJECT (tool_info->tool_options),
"blob-angle",
1.0, 15.0, TRUE);
}
}
static void
tools_activate_value_action (const gchar *action_desc,
gint value)
{
gchar *group_name;
gchar *action_name;
group_name = g_strdup (action_desc);
action_name = strchr (group_name, '/');
if (action_name)
{
GList *managers;
GtkAction *action;
*action_name++ = '\0';
g_object_get (options, "average-radius", &radius, NULL);
managers = gimp_ui_managers_from_name ("<Image>");
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (options),
"average-radius");
action = gimp_ui_manager_find_action (managers->data,
group_name, action_name);
if (GIMP_IS_ENUM_ACTION (action))
{
gint old_value;
old_value = GIMP_ENUM_ACTION (action)->value;
GIMP_ENUM_ACTION (action)->value = value;
gtk_action_activate (action);
GIMP_ENUM_ACTION (action)->value = old_value;
}
}
g_free (group_name);
}
void
tools_value_1_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpTool *tool;
return_if_no_context (context, data);
tool = tool_manager_get_active (context->gimp);
if (tool)
{
const gchar *action_desc;
action_desc = gimp_tool_control_get_action_value_1 (tool->control);
if (action_desc)
tools_activate_value_action (action_desc, value);
}
}
void
tools_value_2_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpTool *tool;
return_if_no_context (context, data);
tool = tool_manager_get_active (context->gimp);
if (tool)
{
const gchar *action_desc;
action_desc = gimp_tool_control_get_action_value_2 (tool->control);
if (action_desc)
tools_activate_value_action (action_desc, value);
}
}
void
tools_value_3_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpTool *tool;
return_if_no_context (context, data);
tool = tool_manager_get_active (context->gimp);
if (tool)
{
const gchar *action_desc;
action_desc = gimp_tool_control_get_action_value_3 (tool->control);
if (action_desc)
tools_activate_value_action (action_desc, value);
}
}
void
tools_value_4_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpTool *tool;
return_if_no_context (context, data);
tool = tool_manager_get_active (context->gimp);
if (tool)
{
const gchar *action_desc;
radius = action_select_value ((GimpActionSelectType) value,
radius,
G_PARAM_SPEC_DOUBLE (pspec)->minimum,
G_PARAM_SPEC_DOUBLE (pspec)->maximum,
1.0, 10.0, FALSE);
action_desc = gimp_tool_control_get_action_value_4 (tool->control);
g_object_set (options, "average-radius", radius, NULL);
if (action_desc)
tools_activate_value_action (action_desc, value);
}
}
......@@ -42,5 +42,28 @@ void tools_color_average_radius_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void tools_ink_blob_size_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void tools_ink_blob_aspect_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void tools_ink_blob_angle_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void tools_value_1_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void tools_value_2_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void tools_value_3_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void tools_value_4_cmd_callback (GtkAction *action,
gint value,
gpointer data);
#endif /* __TOOLS_COMMANDS_H__ */
......@@ -58,22 +58,22 @@ static void gimp_blend_tool_init (GimpBlendTool *blend_tool
static void gimp_blend_tool_button_press (GimpTool *tool,
GimpCoords *coords,