app: add all our actions in the GApplication.

Right now, our actions are added both in the GActionMap (a.k.a. as
GApplication|GtkApplication) and with the old GtkActionGroup API. The later code
is meant to be removed soon.

A major difference with the old implementation is that we don't add the actions
in separate action groups. Even though GLib has a GActionGroup concept, these
don't seem to be used at all when adding actions on the GtkApplication level.
It might mean that eventually we will even remove the GimpActionGroup code and
move everything up one level.

Of course, I am still evaluating if we really want an action group concept, in
which case, we could simply recreate it, but I'm actually unsure how useful it
is. The only place where I see a use to this is in the shortcut settings (to
organize actions by groups), but even there, it was rarely useful to me. I
usually rather search for actions by text search anyway.
This commit is contained in:
Jehan 2023-01-30 00:02:17 +01:00
parent dfcc339e15
commit 35b5729bcc
3 changed files with 22 additions and 0 deletions

View File

@ -247,6 +247,8 @@ app_run (const gchar *full_prog_name,
app = gimp_console_app_new (gimp, quit, as_new, filenames, batch_interpreter, batch_commands);
#endif
gimp->app = app;
gimp_cpu_accel_set_use (use_cpu_accel);
/* Check if the user's gimp_directory exists */

View File

@ -36,6 +36,8 @@ struct _Gimp
{
GimpObject parent_instance;
GApplication *app;
GimpCoreConfig *config;
GimpCoreConfig *edit_config; /* don't use this one, it's just
* for the preferences dialog

View File

@ -326,6 +326,24 @@ gimp_action_group_add_action_with_accel (GimpActionGroup *action_group,
GimpAction *action,
const gchar *accelerator)
{
/* Making sure all our Gimp*Action classes are also GAction. */
g_return_if_fail (G_IS_ACTION (action));
g_action_map_add_action (G_ACTION_MAP (action_group->gimp->app), G_ACTION (action));
if ((accelerator != NULL && g_strcmp0 (accelerator, "") != 0))
{
gchar* detailed_action_name;
detailed_action_name = g_strdup_printf ("app.%s",
g_action_get_name (G_ACTION (action)));
gtk_application_set_accels_for_action (GTK_APPLICATION (action_group->gimp->app),
detailed_action_name,
(const char*[]) { accelerator, NULL });
g_free (detailed_action_name);
}
/* TODO: remove the old logic with GtkAction. */
gtk_action_group_add_action_with_accel ((GtkActionGroup *) action_group,
(GtkAction *) action,
accelerator);