summaryrefslogtreecommitdiff
path: root/gtk/gtkactiongroup.c
diff options
context:
space:
mode:
authorMatthias Clasen <maclas@gmx.de>2003-12-31 01:05:57 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2003-12-31 01:05:57 +0000
commite902118f0ff740716db431d2775be4486b41ce7f (patch)
treed6f09bdc3254aed8dbf2af328233c52bb6b1b743 /gtk/gtkactiongroup.c
parentcf60a5987473cdf22fa89f44dd1beccaa17b41fc (diff)
downloadgtk+-e902118f0ff740716db431d2775be4486b41ce7f.tar.gz
Pull accelerator key from the stock item if stock_id is given, but
Wed Dec 31 02:05:39 2003 Matthias Clasen <maclas@gmx.de> * gtk/gtkactiongroup.c (gtk_action_group_add_actions_full): (gtk_action_group_add_toggle_actions_full): (gtk_action_group_add_radio_actions_full): Pull accelerator key from the stock item if stock_id is given, but accelerator not. (Noticed by Jeff Franks and Jody Goldberg) * tests/testmerge.c: Remove the accelerator from the "Open" entry to test the above change.
Diffstat (limited to 'gtk/gtkactiongroup.c')
-rw-r--r--gtk/gtkactiongroup.c68
1 files changed, 47 insertions, 21 deletions
diff --git a/gtk/gtkactiongroup.c b/gtk/gtkactiongroup.c
index 051010ed63..83768473c7 100644
--- a/gtk/gtkactiongroup.c
+++ b/gtk/gtkactiongroup.c
@@ -31,6 +31,7 @@
#include <config.h>
#include "gtkactiongroup.h"
+#include "gtkstock.h"
#include "gtktoggleaction.h"
#include "gtkradioaction.h"
#include "gtkaccelmap.h"
@@ -395,6 +396,10 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group,
gpointer user_data,
GDestroyNotify destroy)
{
+
+ /* Keep this in sync with the other
+ * gtk_action_group_add_..._actions_full() functions.
+ */
guint i;
GtkTranslateFunc translate_func;
gpointer translate_data;
@@ -408,6 +413,9 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group,
{
GtkAction *action;
gchar *accel_path;
+ guint accel_key = 0;
+ GdkModifierType accel_mods;
+ GtkStockItem stock_item;
gchar *label;
gchar *tooltip;
@@ -437,17 +445,19 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group,
/* set the accel path for the menu item */
accel_path = g_strconcat ("<Actions>/", action_group->private_data->name, "/",
entries[i].name, NULL);
+
if (entries[i].accelerator)
+ gtk_accelerator_parse (entries[i].accelerator, &accel_key, &accel_mods);
+ else if (entries[i].stock_id &&
+ gtk_stock_lookup (entries[i].stock_id, &stock_item))
{
- guint accel_key = 0;
- GdkModifierType accel_mods;
-
- gtk_accelerator_parse (entries[i].accelerator, &accel_key,
- &accel_mods);
- if (accel_key)
- gtk_accel_map_add_entry (accel_path, accel_key, accel_mods);
+ accel_key = stock_item.keyval;
+ accel_mods = stock_item.modifier;
}
+ if (accel_key)
+ gtk_accel_map_add_entry (accel_path, accel_key, accel_mods);
+
gtk_action_set_accel_path (action, accel_path);
g_free (accel_path);
@@ -504,6 +514,9 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group,
gpointer user_data,
GDestroyNotify destroy)
{
+ /* Keep this in sync with the other
+ * gtk_action_group_add_..._actions_full() functions.
+ */
guint i;
GtkTranslateFunc translate_func;
gpointer translate_data;
@@ -517,6 +530,9 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group,
{
GtkAction *action;
gchar *accel_path;
+ guint accel_key = 0;
+ GdkModifierType accel_mods;
+ GtkStockItem stock_item;
gchar *label;
gchar *tooltip;
@@ -549,17 +565,19 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group,
/* set the accel path for the menu item */
accel_path = g_strconcat ("<Actions>/", action_group->private_data->name, "/",
entries[i].name, NULL);
+
if (entries[i].accelerator)
+ gtk_accelerator_parse (entries[i].accelerator, &accel_key, &accel_mods);
+ else if (entries[i].stock_id &&
+ gtk_stock_lookup (entries[i].stock_id, &stock_item))
{
- guint accel_key = 0;
- GdkModifierType accel_mods;
-
- gtk_accelerator_parse (entries[i].accelerator, &accel_key,
- &accel_mods);
- if (accel_key)
- gtk_accel_map_add_entry (accel_path, accel_key, accel_mods);
+ accel_key = stock_item.keyval;
+ accel_mods = stock_item.modifier;
}
+ if (accel_key)
+ gtk_accel_map_add_entry (accel_path, accel_key, accel_mods);
+
gtk_action_set_accel_path (action, accel_path);
g_free (accel_path);
@@ -626,6 +644,9 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group,
gpointer user_data,
GDestroyNotify destroy)
{
+ /* Keep this in sync with the other
+ * gtk_action_group_add_..._actions_full() functions.
+ */
guint i;
GtkTranslateFunc translate_func;
gpointer translate_data;
@@ -641,6 +662,9 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group,
{
GtkAction *action;
gchar *accel_path;
+ guint accel_key = 0;
+ GdkModifierType accel_mods;
+ GtkStockItem stock_item;
gchar *label;
gchar *tooltip;
@@ -676,17 +700,19 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group,
accel_path = g_strconcat ("<Actions>/",
action_group->private_data->name, "/",
entries[i].name, NULL);
+
if (entries[i].accelerator)
+ gtk_accelerator_parse (entries[i].accelerator, &accel_key, &accel_mods);
+ else if (entries[i].stock_id &&
+ gtk_stock_lookup (entries[i].stock_id, &stock_item))
{
- guint accel_key = 0;
- GdkModifierType accel_mods;
-
- gtk_accelerator_parse (entries[i].accelerator, &accel_key,
- &accel_mods);
- if (accel_key)
- gtk_accel_map_add_entry (accel_path, accel_key, accel_mods);
+ accel_key = stock_item.keyval;
+ accel_mods = stock_item.modifier;
}
+ if (accel_key)
+ gtk_accel_map_add_entry (accel_path, accel_key, accel_mods);
+
gtk_action_set_accel_path (action, accel_path);
g_free (accel_path);