app/actions/Makefile.am app/actions/context-actions.[ch] added new action

2004-06-15  Michael Natterer  <mitch@gimp.org>

	* app/actions/Makefile.am
	* app/actions/context-actions.[ch]
	* app/actions/context-commands.[ch]: added new action group to
	modify all GimpContext properties. So far there are actions to
	cycle through the lists of brushes, patterns etc., to change the
	opacity, to swap and default colors and to edit generated brushes.

	* app/actions/actions.c: register the new "context" action group.

	* app/actions/tools-actions.c
	* app/actions/tools-commands.[ch]: removed "tools-default-colors"
	and "tools-swap-colors" actions and callbacks because they are
	in the "context" action group now.

	* app/menus/menus.c: add the "context" group to the <Image> and
	<Dock> UI managers.

	* menus/image-menu.xml.in: changed accordingly. Added a temporary
	"Context" menu to test and debug the new actions.
This commit is contained in:
Michael Natterer 2004-06-15 15:42:50 +00:00 committed by Michael Natterer
parent d1e706484c
commit 8ab1ae98a3
12 changed files with 981 additions and 37 deletions

View File

@ -1,3 +1,25 @@
2004-06-15 Michael Natterer <mitch@gimp.org>
* app/actions/Makefile.am
* app/actions/context-actions.[ch]
* app/actions/context-commands.[ch]: added new action group to
modify all GimpContext properties. So far there are actions to
cycle through the lists of brushes, patterns etc., to change the
opacity, to swap and default colors and to edit generated brushes.
* app/actions/actions.c: register the new "context" action group.
* app/actions/tools-actions.c
* app/actions/tools-commands.[ch]: removed "tools-default-colors"
and "tools-swap-colors" actions and callbacks because they are
in the "context" action group now.
* app/menus/menus.c: add the "context" group to the <Image> and
<Dock> UI managers.
* menus/image-menu.xml.in: changed accordingly. Added a temporary
"Context" menu to test and debug the new actions.
2004-06-15 Philip Lafleur <plafleur@cvs.gnome.org>
* app/tools/gimpcroptool.c (crop_selection_callback): Force

View File

@ -21,6 +21,10 @@ libappactions_a_SOURCES = \
colormap-editor-actions.h \
colormap-editor-commands.c \
colormap-editor-commands.h \
context-actions.c \
context-actions.h \
context-commands.c \
context-commands.h \
data-commands.c \
data-commands.h \
debug-actions.c \

View File

@ -45,6 +45,7 @@
#include "buffers-actions.h"
#include "channels-actions.h"
#include "colormap-editor-actions.h"
#include "context-actions.h"
#include "debug-actions.h"
#include "dialogs-actions.h"
#include "dockable-actions.h"
@ -96,6 +97,9 @@ static GimpActionFactoryEntry action_groups[] =
{ "colormap-editor",
colormap_editor_actions_setup,
colormap_editor_actions_update },
{ "context",
context_actions_setup,
context_actions_update },
{ "debug",
debug_actions_setup,
debug_actions_update },

View File

@ -0,0 +1,402 @@
/* 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 "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
#include "core/gimp.h"
#include "core/gimpbrushgenerated.h"
#include "core/gimpcontext.h"
#include "core/gimplist.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "actions.h"
#include "context-actions.h"
#include "context-commands.h"
#include "gimp-intl.h"
/* local function prototypes */
static GimpActionEntry context_actions[] =
{
{ "context-menu", NULL, N_("_Context") },
{ "context-colors-menu", GIMP_STOCK_DEFAULT_COLORS, N_("_Colors") },
{ "context-opacity-menu", GIMP_STOCK_TRANSPARENCY, N_("_Opacity") },
{ "context-brush-menu", GIMP_STOCK_BRUSH, N_("_Brush") },
{ "context-pattern-menu", GIMP_STOCK_PATTERN, N_("_Pattern") },
{ "context-palette-menu", GIMP_STOCK_PALETTE, N_("_Palette") },
{ "context-gradient-menu", GIMP_STOCK_GRADIENT, N_("_Gradient") },
{ "context-font-menu", GIMP_STOCK_FONT, N_("_Font") },
{ "context-colors-default", GIMP_STOCK_DEFAULT_COLORS,
N_("_Default Colors"), "D", NULL,
G_CALLBACK (context_colors_default_cmd_callback),
GIMP_HELP_TOOLBOX_DEFAULT_COLORS },
{ "context-colors-swap", GIMP_STOCK_SWAP_COLORS,
N_("S_wap Colors"), "X", NULL,
G_CALLBACK (context_colors_swap_cmd_callback),
GIMP_HELP_TOOLBOX_SWAP_COLORS }
};
static GimpEnumActionEntry context_opacity_actions[] =
{
{ "context-opacity-transparent", GTK_STOCK_GOTO_FIRST,
"Completely Transparent", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-opacity-opaque", GTK_STOCK_GOTO_LAST,
"Completely Opaque", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-opacity-decrease", GTK_STOCK_REMOVE,
"More Transparent", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-opacity-increase", GTK_STOCK_ADD,
"More Opaque", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL }
};
static GimpEnumActionEntry context_brush_select_actions[] =
{
{ "context-brush-first", GTK_STOCK_GOTO_FIRST,
"First Brush", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-brush-last", GTK_STOCK_GOTO_LAST,
"Last Brush", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-brush-previous", GTK_STOCK_GO_BACK,
"Previous Brush", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-brush-next", GTK_STOCK_GO_FORWARD,
"Next Brush", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL }
};
static GimpEnumActionEntry context_pattern_select_actions[] =
{
{ "context-pattern-first", GTK_STOCK_GOTO_FIRST,
"First Pattern", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-pattern-last", GTK_STOCK_GOTO_LAST,
"Last Pattern", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-pattern-previous", GTK_STOCK_GO_BACK,
"Previous Pattern", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-pattern-next", GTK_STOCK_GO_FORWARD,
"Next Pattern", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL }
};
static GimpEnumActionEntry context_palette_select_actions[] =
{
{ "context-palette-first", GTK_STOCK_GOTO_FIRST,
"First Palette", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-palette-last", GTK_STOCK_GOTO_LAST,
"Last Palette", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-palette-previous", GTK_STOCK_GO_BACK,
"Previous Palette", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-palette-next", GTK_STOCK_GO_FORWARD,
"Next Palette", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL }
};
static GimpEnumActionEntry context_gradient_select_actions[] =
{
{ "context-gradient-first", GTK_STOCK_GOTO_FIRST,
"First Gradient", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-gradient-last", GTK_STOCK_GOTO_LAST,
"Last Gradient", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-gradient-previous", GTK_STOCK_GO_BACK,
"Previous Gradient", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-gradient-next", GTK_STOCK_GO_FORWARD,
"Next Gradient", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL }
};
static GimpEnumActionEntry context_font_select_actions[] =
{
{ "context-font-first", GTK_STOCK_GOTO_FIRST,
"First Font", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-font-last", GTK_STOCK_GOTO_LAST,
"Last Font", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-font-previous", GTK_STOCK_GO_BACK,
"Previous Font", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-font-next", GTK_STOCK_GO_FORWARD,
"Next Font", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL }
};
static GimpEnumActionEntry context_brush_radius_actions[] =
{
{ "context-brush-radius-minimum", GTK_STOCK_GOTO_FIRST,
"Minumum Radius", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-brush-radius-maximum", GTK_STOCK_GOTO_LAST,
"Maximum Radius", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-brush-radius-decrease", GTK_STOCK_GO_BACK,
"Decrease Radius", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-brush-radius-increase", GTK_STOCK_GO_FORWARD,
"Increase Radius", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL },
{ "context-brush-radius-decrease-skip", GTK_STOCK_GO_BACK,
"Decrease Radius More", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_PREVIOUS,
NULL },
{ "context-brush-radius-increase-skip", GTK_STOCK_GO_FORWARD,
"Increase Radius More", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_NEXT,
NULL },
};
static GimpEnumActionEntry context_brush_hardness_actions[] =
{
{ "context-brush-hardness-minimum", GTK_STOCK_GOTO_FIRST,
"Minumum Hardness", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-brush-hardness-maximum", GTK_STOCK_GOTO_LAST,
"Maximum Hardness", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-brush-hardness-decrease", GTK_STOCK_GO_BACK,
"Decrease Hardness", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-brush-hardness-increase", GTK_STOCK_GO_FORWARD,
"Increase Hardness", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL },
{ "context-brush-hardness-decrease-skip", GTK_STOCK_GO_BACK,
"Decrease Hardness More", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_PREVIOUS,
NULL },
{ "context-brush-hardness-increase-skip", GTK_STOCK_GO_FORWARD,
"Increase Hardness More", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_NEXT,
NULL },
};
static GimpEnumActionEntry context_brush_aspect_actions[] =
{
{ "context-brush-aspect-minimum", GTK_STOCK_GOTO_FIRST,
"Minumum Aspect", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-brush-aspect-maximum", GTK_STOCK_GOTO_LAST,
"Maximum Aspect", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-brush-aspect-decrease", GTK_STOCK_GO_BACK,
"Decrease Aspect", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-brush-aspect-increase", GTK_STOCK_GO_FORWARD,
"Increase Aspect", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL },
{ "context-brush-aspect-decrease-skip", GTK_STOCK_GO_BACK,
"Decrease Aspect More", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_PREVIOUS,
NULL },
{ "context-brush-aspect-increase-skip", GTK_STOCK_GO_FORWARD,
"Increase Aspect More", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_NEXT,
NULL },
};
static GimpEnumActionEntry context_brush_angle_actions[] =
{
{ "context-brush-angle-minimum", GIMP_STOCK_FLIP_HORIZONTAL,
"Horizontal", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-brush-angle-maximum", GIMP_STOCK_FLIP_VERTICAL,
"Vertical", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-brush-angle-decrease", GIMP_STOCK_ROTATE_90,
"Rotate Right", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-brush-angle-increase", GIMP_STOCK_ROTATE_270,
"Rotate Left", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL },
{ "context-brush-angle-decrease-skip", GIMP_STOCK_ROTATE_90,
"Rotate Right 15 degrees", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_PREVIOUS,
NULL },
{ "context-brush-angle-increase-skip", GIMP_STOCK_ROTATE_270,
"Rotate Left 15 degrees", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_NEXT,
NULL },
};
void
context_actions_setup (GimpActionGroup *group)
{
gimp_action_group_add_actions (group,
context_actions,
G_N_ELEMENTS (context_actions));
gimp_action_group_add_enum_actions (group,
context_opacity_actions,
G_N_ELEMENTS (context_opacity_actions),
G_CALLBACK (context_opacity_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_brush_select_actions,
G_N_ELEMENTS (context_brush_select_actions),
G_CALLBACK (context_brush_select_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_pattern_select_actions,
G_N_ELEMENTS (context_pattern_select_actions),
G_CALLBACK (context_pattern_select_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_palette_select_actions,
G_N_ELEMENTS (context_palette_select_actions),
G_CALLBACK (context_palette_select_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_gradient_select_actions,
G_N_ELEMENTS (context_gradient_select_actions),
G_CALLBACK (context_gradient_select_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_font_select_actions,
G_N_ELEMENTS (context_font_select_actions),
G_CALLBACK (context_font_select_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_brush_radius_actions,
G_N_ELEMENTS (context_brush_radius_actions),
G_CALLBACK (context_brush_radius_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_brush_hardness_actions,
G_N_ELEMENTS (context_brush_hardness_actions),
G_CALLBACK (context_brush_hardness_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_brush_aspect_actions,
G_N_ELEMENTS (context_brush_aspect_actions),
G_CALLBACK (context_brush_aspect_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_brush_angle_actions,
G_N_ELEMENTS (context_brush_angle_actions),
G_CALLBACK (context_brush_angle_cmd_callback));
}
void
context_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpContext *context;
gboolean generated = FALSE;
gboolean radius = 0.0;
gboolean hardness = 0.0;
gboolean aspect = 0.0;
gboolean angle = 0.0;
context = action_data_get_context (data);
if (context)
{
GimpBrush *brush = gimp_context_get_brush (context);
if (GIMP_IS_BRUSH_GENERATED (brush))
{
GimpBrushGenerated *gen = GIMP_BRUSH_GENERATED (brush);
generated = TRUE;
radius = gimp_brush_generated_get_radius (gen);
hardness = gimp_brush_generated_get_hardness (gen);
aspect = gimp_brush_generated_get_aspect_ratio (gen);
angle = gimp_brush_generated_get_angle (gen);
}
}
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, "context-" action, (condition) != 0)
#if 0
SET_SENSITIVE ("brush-radius-minimum", generated && radius > 1.0);
SET_SENSITIVE ("brush-radius-decrease", generated && radius > 1.0);
SET_SENSITIVE ("brush-radius-decrease-skip", generated && radius > 1.0);
SET_SENSITIVE ("brush-radius-maximum", generated && radius < 4096.0);
SET_SENSITIVE ("brush-radius-increase", generated && radius < 4096.0);
SET_SENSITIVE ("brush-radius-increase-skip", generated && radius < 4096.0);
SET_SENSITIVE ("brush-angle-minimum", generated);
SET_SENSITIVE ("brush-angle-decrease", generated);
SET_SENSITIVE ("brush-angle-decrease-skip", generated);
SET_SENSITIVE ("brush-angle-maximum", generated);
SET_SENSITIVE ("brush-angle-increase", generated);
SET_SENSITIVE ("brush-angle-increase-skip", generated);
#endif
#undef SET_SENSITIVE
}

View File

@ -0,0 +1,28 @@
/* 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.
*/
#ifndef __CONTEXT_ACTIONS_H__
#define __CONTEXT_ACTIONS_H__
void context_actions_setup (GimpActionGroup *group);
void context_actions_update (GimpActionGroup *group,
gpointer data);
#endif /* __CONTEXT_ACTIONS_H__ */

View File

@ -0,0 +1,372 @@
/* 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 <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
#include "core/gimp.h"
#include "core/gimpbrushgenerated.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "core/gimplist.h"
#include "actions.h"
#include "context-commands.h"
/* local function prototypes */
static void context_select_object (GimpContext *context,
GimpContainer *container,
GimpContextSelectType select_type);
static gdouble context_select_value (GimpContextSelectType select_type,
gdouble value,
gdouble min,
gdouble max,
gdouble inc,
gdouble skip_inc,
gboolean wrap);
/* public functions */
void
context_colors_default_cmd_callback (GtkAction *action,
gpointer data)
{
GimpContext *context;
return_if_no_context (context, data);
gimp_context_set_default_colors (context);
}
void
context_colors_swap_cmd_callback (GtkAction *action,
gpointer data)
{
GimpContext *context;
return_if_no_context (context, data);
gimp_context_swap_colors (context);
}
void
context_opacity_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
gdouble opacity;
return_if_no_context (context, data);
opacity = context_select_value ((GimpContextSelectType) value,
gimp_context_get_opacity (context),
GIMP_OPACITY_TRANSPARENT,
GIMP_OPACITY_OPAQUE,
0.01, 0.1, FALSE);
gimp_context_set_opacity (context, opacity);
}
void
context_brush_select_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
return_if_no_context (context, data);
context_select_object (context, context->gimp->brush_factory->container,
(GimpContextSelectType) value);
}
void
context_pattern_select_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
return_if_no_context (context, data);
context_select_object (context, context->gimp->pattern_factory->container,
(GimpContextSelectType) value);
}
void
context_palette_select_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
return_if_no_context (context, data);
context_select_object (context, context->gimp->palette_factory->container,
(GimpContextSelectType) value);
}
void
context_gradient_select_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
return_if_no_context (context, data);
context_select_object (context, context->gimp->gradient_factory->container,
(GimpContextSelectType) value);
}
void
context_font_select_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
return_if_no_context (context, data);
context_select_object (context, context->gimp->fonts,
(GimpContextSelectType) value);
}
void
context_brush_radius_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpBrush *brush;
return_if_no_context (context, data);
brush = gimp_context_get_brush (context);
if (GIMP_IS_BRUSH_GENERATED (brush))
{
GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush);
gdouble radius;
radius = gimp_brush_generated_get_radius (generated);
radius = context_select_value ((GimpContextSelectType) value,
radius,
1.0, 4096.0,
1.0, 10.0, FALSE);
gimp_brush_generated_set_radius (generated, radius);
}
}
void
context_brush_hardness_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpBrush *brush;
return_if_no_context (context, data);
brush = gimp_context_get_brush (context);
if (GIMP_IS_BRUSH_GENERATED (brush))
{
GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush);
gdouble hardness;
hardness = gimp_brush_generated_get_hardness (generated);
hardness = context_select_value ((GimpContextSelectType) value,
hardness,
0.0, 1.0,
0.01, 0.1, FALSE);
gimp_brush_generated_set_hardness (generated, hardness);
}
}
void
context_brush_aspect_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpBrush *brush;
return_if_no_context (context, data);
brush = gimp_context_get_brush (context);
if (GIMP_IS_BRUSH_GENERATED (brush))
{
GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush);
gdouble aspect;
aspect = gimp_brush_generated_get_aspect_ratio (generated);
aspect = context_select_value ((GimpContextSelectType) value,
aspect,
1.0, 1000.0,
1.0, 4.0, FALSE);
gimp_brush_generated_set_aspect_ratio (generated, aspect);
}
}
void
context_brush_angle_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpBrush *brush;
return_if_no_context (context, data);
brush = gimp_context_get_brush (context);
if (GIMP_IS_BRUSH_GENERATED (brush))
{
GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush);
gdouble angle;
angle = gimp_brush_generated_get_angle (generated);
if (value == GIMP_CONTEXT_SELECT_FIRST)
angle = 0.0;
else if (value == GIMP_CONTEXT_SELECT_LAST)
angle = 90.0;
else
angle = context_select_value ((GimpContextSelectType) value,
angle,
0.0, 180.0,
1.0, 15.0, TRUE);
gimp_brush_generated_set_angle (generated, angle);
}
}
/* private functions */
static void
context_select_object (GimpContext *context,
GimpContainer *container,
GimpContextSelectType select_type)
{
GimpObject *current;
gint select_index;
gint n_children;
current = gimp_context_get_by_type (context, container->children_type);
if (! current)
return;
n_children = gimp_container_num_children (container);
if (n_children == 0)
return;
switch (select_type)
{
case GIMP_CONTEXT_SELECT_FIRST:
select_index = 0;
break;
case GIMP_CONTEXT_SELECT_LAST:
select_index = n_children - 1;
break;
case GIMP_CONTEXT_SELECT_PREVIOUS:
select_index = gimp_container_get_child_index (container, current) - 1;
break;
case GIMP_CONTEXT_SELECT_NEXT:
select_index = gimp_container_get_child_index (container, current) + 1;
break;
case GIMP_CONTEXT_SELECT_SKIP_PREVIOUS:
select_index = gimp_container_get_child_index (container, current) - 10;
break;
case GIMP_CONTEXT_SELECT_SKIP_NEXT:
select_index = gimp_container_get_child_index (container, current) + 10;
break;
default:
g_return_if_reached ();
break;
}
select_index = CLAMP (select_index, 0, n_children - 1);
current = gimp_container_get_child_by_index (container, select_index);
if (current)
gimp_context_set_by_type (context, container->children_type, current);
}
static gdouble
context_select_value (GimpContextSelectType select_type,
gdouble value,
gdouble min,
gdouble max,
gdouble inc,
gdouble skip_inc,
gboolean wrap)
{
switch (select_type)
{
case GIMP_CONTEXT_SELECT_FIRST:
value = min;
break;
case GIMP_CONTEXT_SELECT_LAST:
value = max;
break;
case GIMP_CONTEXT_SELECT_PREVIOUS:
value -= inc;
break;
case GIMP_CONTEXT_SELECT_NEXT:
value += inc;
break;
case GIMP_CONTEXT_SELECT_SKIP_PREVIOUS:
value -= skip_inc;
break;
case GIMP_CONTEXT_SELECT_SKIP_NEXT:
value += skip_inc;
break;
default:
g_return_val_if_reached (min);
break;
}
if (! wrap)
return CLAMP (value, min, max);
if (value < min)
return max - (min - value);
else if (value > max)
return min + (max - value);
return value;
}

View File

@ -0,0 +1,73 @@
/* 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.
*/
#ifndef __CONTEXT_COMMANDS_H__
#define __CONTEXT_COMMANDS_H__
typedef enum
{
GIMP_CONTEXT_SELECT_FIRST = -1,
GIMP_CONTEXT_SELECT_LAST = -2,
GIMP_CONTEXT_SELECT_PREVIOUS = -3,
GIMP_CONTEXT_SELECT_NEXT = -4,
GIMP_CONTEXT_SELECT_SKIP_PREVIOUS = -5,
GIMP_CONTEXT_SELECT_SKIP_NEXT = -6
} GimpContextSelectType;
void context_colors_default_cmd_callback (GtkAction *action,
gpointer data);
void context_colors_swap_cmd_callback (GtkAction *action,
gpointer data);
void context_opacity_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void context_brush_select_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void context_pattern_select_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void context_palette_select_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void context_gradient_select_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void context_font_select_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void context_brush_radius_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void context_brush_hardness_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void context_brush_aspect_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void context_brush_angle_cmd_callback (GtkAction *action,
gint value,
gpointer data);
#endif /* __CONTEXT_COMMANDS_H__ */

View File

@ -52,16 +52,6 @@ static GimpActionEntry tools_actions[] =
{ "tools-transform-menu", NULL, N_("_Transform Tools") },
{ "tools-color-menu", NULL, N_("_Color Tools") },
{ "tools-default-colors", GIMP_STOCK_DEFAULT_COLORS,
N_("_Default Colors"), "D", NULL,
G_CALLBACK (tools_default_colors_cmd_callback),
GIMP_HELP_TOOLBOX_DEFAULT_COLORS },
{ "tools-swap-colors", GIMP_STOCK_SWAP_COLORS,
N_("S_wap Colors"), "X", NULL,
G_CALLBACK (tools_swap_colors_cmd_callback),
GIMP_HELP_TOOLBOX_SWAP_COLORS },
{ "tools-reset", GIMP_STOCK_RESET,
N_("_Reset Order & Visibility"), NULL,
N_("Reset tool order and visibility"),

View File

@ -42,26 +42,6 @@
#include "tools-commands.h"
void
tools_default_colors_cmd_callback (GtkAction *action,
gpointer data)
{
GimpContext *context;
return_if_no_context (context, data);
gimp_context_set_default_colors (context);
}
void
tools_swap_colors_cmd_callback (GtkAction *action,
gpointer data)
{
GimpContext *context;
return_if_no_context (context, data);
gimp_context_swap_colors (context);
}
void
tools_select_cmd_callback (GtkAction *action,
const gchar *value,

View File

@ -20,14 +20,9 @@
#define __TOOLS_COMMANDS_H__
void tools_default_colors_cmd_callback (GtkAction *action,
gpointer data);
void tools_swap_colors_cmd_callback (GtkAction *action,
gpointer data);
void tools_select_cmd_callback (GtkAction *action,
const gchar *value,
gpointer data);
void tools_toggle_visibility_cmd_callback (GtkAction *action,
gpointer data);
void tools_reset_cmd_callback (GtkAction *action,

View File

@ -77,6 +77,7 @@ menus_init (Gimp *gimp)
gimp_menu_factory_manager_register (global_menu_factory, "<Image>",
"file",
"context",
"debug",
"help",
"edit",
@ -104,6 +105,7 @@ menus_init (Gimp *gimp)
gimp_menu_factory_manager_register (global_menu_factory, "<Dock>",
"file",
"context",
"edit",
"select",
"image",

View File

@ -33,6 +33,78 @@
<menuitem action="file-quit" />
</menu>
<menu action="context-menu" name="Context">
<menu action="context-colors-menu" name="Colors">
<menuitem action="context-colors-default" />
<menuitem action="context-colors-swap" />
</menu>
<menu action="context-opacity-menu" name="Opacity">
<menuitem action="context-opacity-transparent" />
<menuitem action="context-opacity-opaque" />
<menuitem action="context-opacity-decrease" />
<menuitem action="context-opacity-increase" />
</menu>
<separator />
<menu action="context-brush-menu" name="Brush">
<menuitem action="context-brush-first" />
<menuitem action="context-brush-last" />
<menuitem action="context-brush-previous" />
<menuitem action="context-brush-next" />
<separator />
<menuitem action="context-brush-radius-minimum" />
<menuitem action="context-brush-radius-maximum" />
<menuitem action="context-brush-radius-decrease" />
<menuitem action="context-brush-radius-increase" />
<menuitem action="context-brush-radius-decrease-skip" />
<menuitem action="context-brush-radius-increase-skip" />
<separator />
<menuitem action="context-brush-hardness-minimum" />
<menuitem action="context-brush-hardness-maximum" />
<menuitem action="context-brush-hardness-decrease" />
<menuitem action="context-brush-hardness-increase" />
<menuitem action="context-brush-hardness-decrease-skip" />
<menuitem action="context-brush-hardness-increase-skip" />
<separator />
<menuitem action="context-brush-aspect-minimum" />
<menuitem action="context-brush-aspect-maximum" />
<menuitem action="context-brush-aspect-decrease" />
<menuitem action="context-brush-aspect-increase" />
<menuitem action="context-brush-aspect-decrease-skip" />
<menuitem action="context-brush-aspect-increase-skip" />
<separator />
<menuitem action="context-brush-angle-minimum" />
<menuitem action="context-brush-angle-maximum" />
<menuitem action="context-brush-angle-decrease" />
<menuitem action="context-brush-angle-increase" />
<menuitem action="context-brush-angle-decrease-skip" />
<menuitem action="context-brush-angle-increase-skip" />
</menu>
<menu action="context-pattern-menu" name="Pattern">
<menuitem action="context-pattern-first" />
<menuitem action="context-pattern-last" />
<menuitem action="context-pattern-previous" />
<menuitem action="context-pattern-next" />
</menu>
<menu action="context-palette-menu" name="Palette">
<menuitem action="context-palette-first" />
<menuitem action="context-palette-last" />
<menuitem action="context-palette-previous" />
<menuitem action="context-palette-next" />
</menu>
<menu action="context-gradient-menu" name="Gradient">
<menuitem action="context-gradient-first" />
<menuitem action="context-gradient-last" />
<menuitem action="context-gradient-previous" />
<menuitem action="context-gradient-next" />
</menu>
<menu action="context-font-menu" name="Font">
<menuitem action="context-font-first" />
<menuitem action="context-font-last" />
<menuitem action="context-font-previous" />
<menuitem action="context-font-next" />
</menu>
</menu>
<menu action="edit-menu" name="Edit">
<placeholder name="Undo">
<menuitem action="edit-undo" />
@ -289,8 +361,8 @@
<menu action="tools-menu" name="Tools">
<menuitem action="dialogs-toolbox" />
<menuitem action="tools-default-colors" />
<menuitem action="tools-swap-colors" />
<menuitem action="context-colors-default" />
<menuitem action="context-colors-swap" />
<separator />
<menu action="tools-select-menu" name="Selection Tools">
<menuitem action="tools-rect-select" />