Bug 736746 - Alt+Number only switches to lower-numbered windows

Add "action-group" signal to GimpActionGroup, such that we can
properly set the accel group and connect the accelerator on actions
that are created after the initial setup of the menus.
This commit is contained in:
Kristian Rietveld 2015-01-09 22:53:19 +01:00
parent b87d97ae68
commit dd7d332fb8
3 changed files with 41 additions and 0 deletions

View file

@ -29,6 +29,7 @@
#include "widgets-types.h"
#include "core/gimp.h"
#include "core/gimpmarshal.h"
#include "core/gimpviewable.h"
#include "gimpactiongroup.h"
@ -41,6 +42,11 @@
#include "gimp-intl.h"
enum
{
ACTION_ADDED,
LAST_SIGNAL
};
enum
{
@ -66,6 +72,8 @@ static void gimp_action_group_get_property (GObject *object,
G_DEFINE_TYPE (GimpActionGroup, gimp_action_group, GTK_TYPE_ACTION_GROUP)
static guint signals[LAST_SIGNAL] = { 0, };
#define parent_class gimp_action_group_parent_class
@ -102,6 +110,16 @@ gimp_action_group_class_init (GimpActionGroupClass *klass)
G_PARAM_CONSTRUCT_ONLY));
klass->groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
signals[ACTION_ADDED] =
g_signal_new ("action-added",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GimpActionGroupClass, action_added),
NULL, NULL,
gimp_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GTK_TYPE_ACTION);
}
static void
@ -367,6 +385,7 @@ gimp_action_group_add_actions (GimpActionGroup *group,
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
GTK_ACTION (action),
entries[i].accelerator);
g_signal_emit (group, signals[ACTION_ADDED], 0, action);
if (entries[i].help_id)
g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID,
@ -422,6 +441,7 @@ gimp_action_group_add_toggle_actions (GimpActionGroup *group,
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
GTK_ACTION (action),
entries[i].accelerator);
g_signal_emit (group, signals[ACTION_ADDED], 0, action);
if (entries[i].help_id)
g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID,
@ -484,6 +504,7 @@ gimp_action_group_add_radio_actions (GimpActionGroup *group,
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
GTK_ACTION (action),
entries[i].accelerator);
g_signal_emit (group, signals[ACTION_ADDED], 0, action);
if (entries[i].help_id)
g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID,
@ -547,6 +568,7 @@ gimp_action_group_add_enum_actions (GimpActionGroup *group,
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
GTK_ACTION (action),
entries[i].accelerator);
g_signal_emit (group, signals[ACTION_ADDED], 0, action);
if (entries[i].help_id)
g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID,
@ -602,6 +624,7 @@ gimp_action_group_add_string_actions (GimpActionGroup *group,
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
GTK_ACTION (action),
entries[i].accelerator);
g_signal_emit (group, signals[ACTION_ADDED], 0, action);
if (entries[i].help_id)
g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID,
@ -643,6 +666,7 @@ gimp_action_group_add_plug_in_actions (GimpActionGroup *group,
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
GTK_ACTION (action),
entries[i].accelerator);
g_signal_emit (group, signals[ACTION_ADDED], 0, action);
if (entries[i].help_id)
g_object_set_qdata_full (G_OBJECT (action), GIMP_HELP_ID,

View file

@ -50,6 +50,10 @@ struct _GimpActionGroupClass
GtkActionGroupClass parent_class;
GHashTable *groups;
/* signals */
void (* action_added) (GimpActionGroup *group,
GtkAction *action);
};
struct _GimpActionEntry

View file

@ -191,6 +191,15 @@ gimp_menu_factory_get_registered_menus (GimpMenuFactory *factory)
return factory->p->registered_menus;
}
static void
gimp_menu_factory_manager_action_added (GimpActionGroup *group,
GtkAction *action,
GtkAccelGroup *accel_group)
{
gtk_action_set_accel_group (action, accel_group);
gtk_action_connect_accelerator (action);
}
GimpUIManager *
gimp_menu_factory_manager_new (GimpMenuFactory *factory,
const gchar *identifier,
@ -240,6 +249,10 @@ gimp_menu_factory_manager_new (GimpMenuFactory *factory,
g_list_free (actions);
g_signal_connect_object (group, "action-added",
G_CALLBACK (gimp_menu_factory_manager_action_added),
accel_group, 0);
gtk_ui_manager_insert_action_group (GTK_UI_MANAGER (manager),
GTK_ACTION_GROUP (group),
-1);