Enabled disabling all menu mnemonics. Addresses bug #120034:

2004-07-28  Michael Natterer  <mitch@gimp.org>

	Enabled disabling all menu mnemonics. Addresses bug #120034:

	* app/config/gimpguiconfig.[ch]
	* app/config/gimprc-blurbs.h: added boolean RESTART property
	"menu-menonics".

	* app/gui/preferences-dialog.c: added a GUI for it.

	* app/widgets/gimpactiongroup.[ch]: added boolean CONSTRUCT_ONLY
	property "mnemonics".

	(gimp_action_group_add_*_actions): call gimp_strip_uline() on
	the actions' labels if mnemonics is FALSE.

	* app/widgets/gimpactionfactory.[ch]
	* app/actions/actions.c: pass gui_config->menu_menmonics to
	all action groups.
This commit is contained in:
Michael Natterer
2004-07-27 22:17:30 +00:00
committed by Michael Natterer
parent 1bf6319d1b
commit 210ef45abb
11 changed files with 135 additions and 19 deletions

View File

@ -1,3 +1,23 @@
2004-07-28 Michael Natterer <mitch@gimp.org>
Enabled disabling all menu mnemonics. Addresses bug #120034:
* app/config/gimpguiconfig.[ch]
* app/config/gimprc-blurbs.h: added boolean RESTART property
"menu-menonics".
* app/gui/preferences-dialog.c: added a GUI for it.
* app/widgets/gimpactiongroup.[ch]: added boolean CONSTRUCT_ONLY
property "mnemonics".
(gimp_action_group_add_*_actions): call gimp_strip_uline() on
the actions' labels if mnemonics is FALSE.
* app/widgets/gimpactionfactory.[ch]
* app/actions/actions.c: pass gui_config->menu_menmonics to
all action groups.
2004-07-27 Sven Neumann <sven@gimp.org>
* menus/image-menu.xml.in: commented out "Context" menu now that

View File

@ -24,6 +24,8 @@
#include "actions-types.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
@ -187,12 +189,16 @@ static GimpActionFactoryEntry action_groups[] =
void
actions_init (Gimp *gimp)
{
gint i;
GimpGuiConfig *gui_config;
gint i;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (global_action_factory == NULL);
global_action_factory = gimp_action_factory_new (gimp);
gui_config = GIMP_GUI_CONFIG (gimp->config);
global_action_factory = gimp_action_factory_new (gimp,
gui_config->menu_mnemonics);
for (i = 0; i < G_N_ELEMENTS (action_groups); i++)
gimp_action_factory_group_register (global_action_factory,

View File

@ -74,6 +74,7 @@ enum
PROP_CAN_CHANGE_ACCELS,
PROP_SAVE_ACCELS,
PROP_RESTORE_ACCELS,
PROP_MENU_MNEMONICS,
PROP_LAST_OPENED_SIZE,
PROP_MAX_NEW_IMAGE_SIZE,
PROP_TOOLBOX_COLOR_AREA,
@ -186,6 +187,10 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
"restore-accels", RESTORE_ACCELS_BLURB,
TRUE,
0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_MENU_MNEMONICS,
"menu-mnemonics", MENU_MNEMONICS_BLURB,
TRUE,
GIMP_PARAM_RESTART);
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_LAST_OPENED_SIZE,
"last-opened-size", LAST_OPENED_SIZE_BLURB,
0, 1024, 10,
@ -315,6 +320,9 @@ gimp_gui_config_set_property (GObject *object,
case PROP_RESTORE_ACCELS:
gui_config->restore_accels = g_value_get_boolean (value);
break;
case PROP_MENU_MNEMONICS:
gui_config->menu_mnemonics = g_value_get_boolean (value);
break;
case PROP_LAST_OPENED_SIZE:
gui_config->last_opened_size = g_value_get_int (value);
break;
@ -414,6 +422,9 @@ gimp_gui_config_get_property (GObject *object,
case PROP_RESTORE_ACCELS:
g_value_set_boolean (value, gui_config->restore_accels);
break;
case PROP_MENU_MNEMONICS:
g_value_set_boolean (value, gui_config->menu_mnemonics);
break;
case PROP_LAST_OPENED_SIZE:
g_value_set_int (value, gui_config->last_opened_size);
break;

View File

@ -52,6 +52,7 @@ struct _GimpGuiConfig
gboolean can_change_accels;
gboolean save_accels;
gboolean restore_accels;
gboolean menu_mnemonics;
gint last_opened_size;
guint64 max_new_image_size;
gboolean toolbox_color_area;

View File

@ -181,6 +181,9 @@ N_("Speed of marching ants in the selection outline. This value is in " \
N_("GIMP will warn the user if an attempt is made to create an image that " \
"would take more memory than the size specified here.")
#define MENU_MNEMONICS_BLURB \
N_("When enabled, GIMP will show mnemonics in menus.")
#define MIN_COLORS_BLURB \
N_("Generally only a concern for 8-bit displays, this sets the minimum " \
"number of system colors allocated for the GIMP.")

View File

@ -1351,6 +1351,9 @@ prefs_dialog_new (Gimp *gimp,
G_CALLBACK (prefs_keyboard_shortcuts_dialog),
gimp);
prefs_check_button_add (object, "menu-mnemonics",
_("Show menu _mnemonics (access keys)"),
GTK_BOX (vbox2));
prefs_check_button_add (object, "can-change-accels",
_("Use dynamic _keyboard shortcuts"),
GTK_BOX (vbox2));

View File

@ -1351,6 +1351,9 @@ prefs_dialog_new (Gimp *gimp,
G_CALLBACK (prefs_keyboard_shortcuts_dialog),
gimp);
prefs_check_button_add (object, "menu-mnemonics",
_("Show menu _mnemonics (access keys)"),
GTK_BOX (vbox2));
prefs_check_button_add (object, "can-change-accels",
_("Use dynamic _keyboard shortcuts"),
GTK_BOX (vbox2));

View File

@ -112,7 +112,8 @@ gimp_action_factory_finalize (GObject *object)
}
GimpActionFactory *
gimp_action_factory_new (Gimp *gimp)
gimp_action_factory_new (Gimp *gimp,
gboolean mnemonics)
{
GimpActionFactory *factory;
@ -120,7 +121,8 @@ gimp_action_factory_new (Gimp *gimp)
factory = g_object_new (GIMP_TYPE_ACTION_FACTORY, NULL);
factory->gimp = gimp;
factory->gimp = gimp;
factory->mnemonics = mnemonics ? TRUE : FALSE;
return factory;
}
@ -175,6 +177,7 @@ gimp_action_factory_group_new (GimpActionFactory *factory,
entry->identifier,
entry->label,
entry->stock_id,
factory->mnemonics,
user_data,
entry->update_func);

View File

@ -54,6 +54,8 @@ struct _GimpActionFactory
Gimp *gimp;
GList *registered_groups;
gboolean mnemonics;
};
struct _GimpActionFactoryClass
@ -64,7 +66,8 @@ struct _GimpActionFactoryClass
GType gimp_action_factory_get_type (void) G_GNUC_CONST;
GimpActionFactory * gimp_action_factory_new (Gimp *gimp);
GimpActionFactory * gimp_action_factory_new (Gimp *gimp,
gboolean mnemonics);
void gimp_action_factory_group_register (GimpActionFactory *factory,
const gchar *identifier,

View File

@ -23,6 +23,7 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
@ -45,7 +46,8 @@ enum
PROP_0,
PROP_GIMP,
PROP_LABEL,
PROP_STOCK_ID
PROP_STOCK_ID,
PROP_MNEMONICS
};
@ -132,6 +134,13 @@ gimp_action_group_class_init (GimpActionGroupClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_MNEMONICS,
g_param_spec_boolean ("mnemonics",
NULL, NULL,
TRUE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
klass->groups = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
}
@ -139,7 +148,6 @@ gimp_action_group_class_init (GimpActionGroupClass *klass)
static void
gimp_action_group_init (GimpActionGroup *group)
{
group->gimp = NULL;
}
static GObject *
@ -147,11 +155,16 @@ gimp_action_group_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
const gchar *name;
GObject *object;
GimpActionGroup *group;
const gchar *name;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
group = GIMP_ACTION_GROUP (object);
g_assert (GIMP_IS_GIMP (group->gimp));
name = gtk_action_group_get_name (GTK_ACTION_GROUP (object));
if (name)
@ -242,6 +255,9 @@ gimp_action_group_set_property (GObject *object,
case PROP_STOCK_ID:
group->stock_id = g_value_dup_string (value);
break;
case PROP_MNEMONICS:
group->mnemonics = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -267,6 +283,9 @@ gimp_action_group_get_property (GObject *object,
case PROP_STOCK_ID:
g_value_set_string (value, group->stock_id);
break;
case PROP_MNEMONICS:
g_value_set_boolean (value, group->mnemonics);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -279,6 +298,7 @@ gimp_action_group_get_property (GObject *object,
* @name: the name of the action group.
* @label: the user visible label of the action group.
* @stock_id: the icon of the action group.
* @mnemonics: whether or not to show mnemonics.
* @user_data: the user_data for #GtkAction callbacks.
* @update_func: the function that will be called on
* gimp_action_group_update().
@ -294,6 +314,7 @@ gimp_action_group_new (Gimp *gimp,
const gchar *name,
const gchar *label,
const gchar *stock_id,
gboolean mnemonics,
gpointer user_data,
GimpActionGroupUpdateFunc update_func)
{
@ -303,10 +324,11 @@ gimp_action_group_new (Gimp *gimp,
g_return_val_if_fail (name != NULL, NULL);
group = g_object_new (GIMP_TYPE_ACTION_GROUP,
"gimp", gimp,
"name", name,
"label", label,
"stock-id", stock_id,
"gimp", gimp,
"name", name,
"label", label,
"stock-id", stock_id,
"mnemonics", mnemonics,
NULL);
group->user_data = user_data;
@ -354,15 +376,21 @@ gimp_action_group_add_actions (GimpActionGroup *group,
for (i = 0; i < n_entries; i++)
{
GimpAction *action;
const gchar *label;
gchar *label;
const gchar *tooltip;
label = gettext (entries[i].label);
tooltip = gettext (entries[i].tooltip);
if (! group->mnemonics)
label = gimp_strip_uline (label);
action = gimp_action_new (entries[i].name, label, tooltip,
entries[i].stock_id);
if (! group->mnemonics)
g_free (label);
if (entries[i].callback)
g_signal_connect (action, "activate",
entries[i].callback,
@ -401,15 +429,21 @@ gimp_action_group_add_toggle_actions (GimpActionGroup *group,
for (i = 0; i < n_entries; i++)
{
GtkToggleAction *action;
const gchar *label;
gchar *label;
const gchar *tooltip;
label = gettext (entries[i].label);
tooltip = gettext (entries[i].tooltip);
if (! group->mnemonics)
label = gimp_strip_uline (label);
action = gtk_toggle_action_new (entries[i].name, label, tooltip,
entries[i].stock_id);
if (! group->mnemonics)
g_free (label);
gtk_toggle_action_set_active (action, entries[i].is_active);
if (entries[i].callback)
@ -454,16 +488,22 @@ gimp_action_group_add_radio_actions (GimpActionGroup *group,
for (i = 0; i < n_entries; i++)
{
GtkRadioAction *action;
const gchar *label;
gchar *label;
const gchar *tooltip;
label = gettext (entries[i].label);
tooltip = gettext (entries[i].tooltip);
if (! group->mnemonics)
label = gimp_strip_uline (label);
action = gtk_radio_action_new (entries[i].name, label, tooltip,
entries[i].stock_id,
entries[i].value);
if (! group->mnemonics)
g_free (label);
if (i == 0)
first_action = action;
@ -512,16 +552,22 @@ gimp_action_group_add_enum_actions (GimpActionGroup *group,
for (i = 0; i < n_entries; i++)
{
GimpEnumAction *action;
const gchar *label;
gchar *label;
const gchar *tooltip;
label = gettext (entries[i].label);
tooltip = gettext (entries[i].tooltip);
if (! group->mnemonics)
label = gimp_strip_uline (label);
action = gimp_enum_action_new (entries[i].name, label, tooltip,
entries[i].stock_id,
entries[i].value);
if (! group->mnemonics)
g_free (label);
if (callback)
g_signal_connect (action, "selected",
callback,
@ -561,16 +607,22 @@ gimp_action_group_add_string_actions (GimpActionGroup *group,
for (i = 0; i < n_entries; i++)
{
GimpStringAction *action;
const gchar *label;
gchar *label;
const gchar *tooltip;
label = gettext (entries[i].label);
tooltip = gettext (entries[i].tooltip);
if (! group->mnemonics)
label = gimp_strip_uline (label);
action = gimp_string_action_new (entries[i].name, label, tooltip,
entries[i].stock_id,
entries[i].value);
if (! group->mnemonics)
g_free (label);
if (callback)
g_signal_connect (action, "selected",
callback,
@ -610,13 +662,22 @@ gimp_action_group_add_plug_in_actions (GimpActionGroup *group,
for (i = 0; i < n_entries; i++)
{
GimpPlugInAction *action;
gchar *label;
label = (gchar *) entries[i].label;
if (! group->mnemonics)
label = gimp_strip_uline (label);
action = gimp_plug_in_action_new (entries[i].name,
entries[i].label,
label,
entries[i].tooltip,
entries[i].stock_id,
entries[i].proc_def);
if (! group->mnemonics)
g_free (label);
if (callback)
g_signal_connect (action, "selected",
callback,

View File

@ -42,6 +42,7 @@ struct _GimpActionGroup
Gimp *gimp;
gchar *label;
gchar *stock_id;
gboolean mnemonics;
gpointer user_data;
@ -134,6 +135,7 @@ GimpActionGroup *gimp_action_group_new (Gimp *gimp,
const gchar *name,
const gchar *label,
const gchar *stock_id,
gboolean mnemonics,
gpointer user_data,
GimpActionGroupUpdateFunc update_func);