gimp/app/actions/tool-options-actions.c
Michael Natterer c49df22eef Action code review and pre-release consistency cleanup:
2004-10-18  Michael Natterer  <mitch@gimp.org>

	Action code review and pre-release consistency cleanup:

	* app/actions/*-actions.c: added some missing and resolved
	conflicting mnemonics, added missing help IDs. Cleaned up the
	*_actions_update() functions.

	* app/actions/channels-actions.c
	* app/actions/layers-actions.c
	* app/actions/vectors-actions.c (*_actions_update): simplified
	the code that figures the prev and next channel,layer,vectors.

	* app/actions/qmask-actions.c: use the same accelerator for
	"qmask-active" and "qmask-toggle". Fixed action sensitivity.

	* app/actions/channels-commands.c
	* app/actions/dockable-commands.c
	* app/actions/documents-commands.c
	* app/actions/gradients-commands.c
	* app/actions/layers-commands.c
	* app/actions/palettes-commands.c
	* app/actions/image-commands.c
	* app/actions/select-commands.c
	* app/actions/vectors-commands.c: folded tons of private utility
	functions into their only callers (they used to be public and
	called from outside before the switch to action based menus).
	Renamed functions and variables saying "query" or "qbox" to
	"dialog". Moved static functions to the end of the files. Misc
	minor cleanups.

	* app/actions/drawable-actions.c
	* app/actions/drawable-commands.c: made the "drawable-visible" and
	"drawable-linked" actions affect the layer if the active drawable
	is a layer mask.

	* app/actions/select-commands.c: added action to stroke with the
	last values used in an attempt to address bug #135746 but #if 0'ed
	it because the approach is too ugly.

	* app/tools/gimpiscissorstool.c: changed mnemonic from I to S.

	* menus/image-menu-xml.in: added more stuff to the (commented out)
	"context" menu.
2004-10-18 11:29:58 +00:00

215 lines
7.3 KiB
C

/* 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/gimpcontext.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "tool-options-actions.h"
#include "tool-options-commands.h"
#include "gimp-intl.h"
/* local function prototypes */
static void tool_options_actions_update_presets (GimpActionGroup *group,
const gchar *action_prefix,
GCallback callback,
const gchar *stock_id,
const gchar *help_id,
GimpContainer *presets);
/* global variables */
static GimpActionEntry tool_options_actions[] =
{
{ "tool-options-popup", GIMP_STOCK_TOOL_OPTIONS,
N_("Tool Options Menu"), NULL, NULL, NULL,
GIMP_HELP_TOOL_OPTIONS_DIALOG },
{ "tool-options-save-menu", GTK_STOCK_SAVE,
N_("_Save Options to"), "", NULL, NULL,
GIMP_HELP_TOOL_OPTIONS_SAVE },
{ "tool-options-restore-menu", GTK_STOCK_REVERT_TO_SAVED,
N_("_Restore Options from"), "", NULL, NULL,
GIMP_HELP_TOOL_OPTIONS_RESTORE },
{ "tool-options-rename-menu", GIMP_STOCK_EDIT,
N_("Re_name Saved Options"), NULL, NULL, NULL,
GIMP_HELP_TOOL_OPTIONS_RENAME },
{ "tool-options-delete-menu", GTK_STOCK_DELETE,
N_("_Delete Saved Options"), "", NULL, NULL,
GIMP_HELP_TOOL_OPTIONS_DELETE },
{ "tool-options-save-new", GTK_STOCK_NEW,
N_("_New Entry..."), "", NULL,
G_CALLBACK (tool_options_save_new_cmd_callback),
GIMP_HELP_TOOL_OPTIONS_SAVE },
{ "tool-options-reset", GIMP_STOCK_RESET,
N_("R_eset Tool Options"), "",
N_("Reset to default values"),
G_CALLBACK (tool_options_reset_cmd_callback),
GIMP_HELP_TOOL_OPTIONS_RESET },
{ "tool-options-reset-all", GIMP_STOCK_RESET,
N_("Reset _all Tool Options..."), "",
N_("Reset all tool options"),
G_CALLBACK (tool_options_reset_all_cmd_callback),
GIMP_HELP_TOOL_OPTIONS_RESET }
};
/* public functions */
#define SET_VISIBLE(action,condition) \
gimp_action_group_set_action_visible (group, action, (condition) != 0)
#define SET_IMPORTANT(action,condition) \
gimp_action_group_set_action_important (group, action, (condition) != 0)
void
tool_options_actions_setup (GimpActionGroup *group)
{
gimp_action_group_add_actions (group,
tool_options_actions,
G_N_ELEMENTS (tool_options_actions));
SET_IMPORTANT ("tool-options-restore-menu", TRUE);
SET_IMPORTANT ("tool-options-rename-menu", TRUE);
SET_IMPORTANT ("tool-options-delete-menu", TRUE);
}
void
tool_options_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpContext *context = gimp_get_user_context (group->gimp);
GimpToolInfo *tool_info = gimp_context_get_tool (context);
SET_VISIBLE ("tool-options-save-menu", tool_info->options_presets);
SET_VISIBLE ("tool-options-restore-menu", tool_info->options_presets);
SET_VISIBLE ("tool-options-rename-menu", tool_info->options_presets);
SET_VISIBLE ("tool-options-delete-menu", tool_info->options_presets);
tool_options_actions_update_presets (group, "tool-options-save-",
G_CALLBACK (tool_options_save_to_cmd_callback),
GTK_STOCK_SAVE,
GIMP_HELP_TOOL_OPTIONS_SAVE,
tool_info->options_presets);
tool_options_actions_update_presets (group, "tool-options-restore-",
G_CALLBACK (tool_options_restore_from_cmd_callback),
GTK_STOCK_REVERT_TO_SAVED,
GIMP_HELP_TOOL_OPTIONS_RESTORE,
tool_info->options_presets);
tool_options_actions_update_presets (group, "tool-options-rename-",
G_CALLBACK (tool_options_rename_saved_cmd_callback),
GIMP_STOCK_EDIT,
GIMP_HELP_TOOL_OPTIONS_RENAME,
tool_info->options_presets);
tool_options_actions_update_presets (group, "tool-options-delete-",
G_CALLBACK (tool_options_delete_saved_cmd_callback),
GTK_STOCK_DELETE,
GIMP_HELP_TOOL_OPTIONS_DELETE,
tool_info->options_presets);
}
/* privat function */
static void
tool_options_actions_update_presets (GimpActionGroup *group,
const gchar *action_prefix,
GCallback callback,
const gchar *stock_id,
const gchar *help_id,
GimpContainer *presets)
{
GList *list;
gint n_children = 0;
gint i;
for (i = 0; ; i++)
{
gchar *action_name;
GtkAction *action;
action_name = g_strdup_printf ("%s%03d", action_prefix, i);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
action_name);
g_free (action_name);
if (! action)
break;
gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
}
if (presets)
n_children = gimp_container_num_children (presets);
if (n_children > 0)
{
GimpEnumActionEntry entry;
entry.name = NULL;
entry.stock_id = stock_id;
entry.label = NULL;
entry.accelerator = "";
entry.tooltip = NULL;
entry.value = 0;
entry.help_id = help_id;
for (list = GIMP_LIST (presets)->list, i = 0;
list;
list = g_list_next (list), i++)
{
GimpToolOptions *options = list->data;
entry.name = g_strdup_printf ("%s%03d", action_prefix, i);
entry.label = gimp_object_get_name (GIMP_OBJECT (options));
entry.value = i;
gimp_action_group_add_enum_actions (group, &entry, 1, callback);
g_free ((gchar *) entry.name);
}
}
}
#undef SET_VISIBLE
#undef SET_IMPORTANT