Fix Zoom Shortcuts (fixes issue #9797)

This commit is contained in:
programmer_ceds 2023-09-05 22:35:06 +00:00 committed by Jehan
parent 9c965efd81
commit 9e06e2aa53
4 changed files with 96 additions and 10 deletions

View File

@ -63,6 +63,7 @@
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmenufactory.h"
#include "widgets/gimpmessagebox.h"
#include "widgets/gimpradioaction.h"
#include "widgets/gimpsessioninfo.h"
#include "widgets/gimpuimanager.h"
#include "widgets/gimpwidgets-utils.h"
@ -860,10 +861,26 @@ gui_check_unique_accelerators (Gimp *gimp)
for (gint i = 0; actions[i] != NULL; i++)
{
gchar **accels;
gchar *detailed_name;
gchar **accels;
gchar *detailed_name;
GimpAction *action;
gint value;
action = (GimpAction *) g_action_map_lookup_action (G_ACTION_MAP (gimp->app), actions[i]);
if (GIMP_IS_RADIO_ACTION (action))
{
g_object_get ((GObject *) action,
"value", &value,
NULL);
detailed_name = g_strdup_printf ("app.%s(%i)", actions[i],
value);
}
else
{
detailed_name = g_strdup_printf ("app.%s", actions[i]);
}
detailed_name = g_strdup_printf ("app.%s", actions[i]);
accels = gtk_application_get_accels_for_action (GTK_APPLICATION (gimp->app),
detailed_name);
g_free (detailed_name);
@ -872,10 +889,25 @@ gui_check_unique_accelerators (Gimp *gimp)
{
for (gint k = i + 1; actions[k] != NULL; k++)
{
gchar **accels2;
gchar *detailed_name2;
gchar **accels2;
gchar *detailed_name2;
GimpAction *action2;
action2 = (GimpAction *) g_action_map_lookup_action (G_ACTION_MAP (gimp->app), actions[k]);
if (GIMP_IS_RADIO_ACTION (action2))
{
g_object_get ((GObject *) action2,
"value", &value,
NULL);
detailed_name2 = g_strdup_printf ("app.%s(%i)", actions[k],
value);
}
else
{
detailed_name2 = g_strdup_printf ("app.%s", actions[k]);
}
detailed_name2 = g_strdup_printf ("app.%s", actions[k]);
accels2 = gtk_application_get_accels_for_action (GTK_APPLICATION (gimp->app),
detailed_name2);
g_free (detailed_name2);

View File

@ -30,6 +30,7 @@
#include "menus-types.h"
#include "widgets/gimpaction.h"
#include "widgets/gimpradioaction.h"
#include "shortcuts-rc.h"
@ -208,8 +209,25 @@ shortcuts_rc_write (GtkApplication *application,
action = (GimpAction *) g_action_map_lookup_action (G_ACTION_MAP (application), actions[i]);
detailed_name = g_strdup_printf ("app.%s", actions[i]);
accels = gtk_application_get_accels_for_action (application, detailed_name);
if (GIMP_IS_RADIO_ACTION (action))
{
gint value;
g_object_get ((GObject *) action,
"value",
&value,
NULL);
detailed_name = g_strdup_printf ("app.%s(%i)", actions[i],
value);
}
else
{
detailed_name = g_strdup_printf ("app.%s", actions[i]);
}
accels = gtk_application_get_accels_for_action (application, detailed_name);
if (gimp_action_use_default_accels (action))
commented = TRUE;
@ -259,6 +277,10 @@ shortcuts_action_deserialize (GScanner *scanner,
for (gint i = 0; dup_actions[i] != NULL; i++)
{
GimpAction *conflict_action;
gchar *left_paren_ptr = strchr (dup_actions[i], '(');
if (left_paren_ptr)
*left_paren_ptr = '\0'; /* ignore target part of detailed name */
/* dup_actions[i] will be the detailed name prefixed with "app." */
if (g_strcmp0 (dup_actions[i] + 4, action_name) == 0)

View File

@ -564,6 +564,10 @@ gimp_action_view_conflict_response (GtkWidget *dialog,
{
GAction *conflict_action;
gint start;
gchar *left_paren_ptr = strchr (dup_actions[i], '(');
if (left_paren_ptr)
*left_paren_ptr = '\0'; /* ignore target part of detailed name */
start = g_str_has_prefix (dup_actions[i], "app.") ? 4 : 0;
conflict_action = g_action_map_lookup_action (G_ACTION_MAP (confirm_data->gimp->app),
@ -572,6 +576,9 @@ gimp_action_view_conflict_response (GtkWidget *dialog,
g_return_if_fail (GIMP_IS_ACTION (conflict_action));
gimp_action_set_accels (GIMP_ACTION (conflict_action), (const char*[]) { NULL });
}
g_strfreev (dup_actions);
gimp_action_set_accels (confirm_data->action, (const char*[]) { accel, NULL });
}
@ -749,10 +756,18 @@ gimp_action_view_accel_edited (GtkCellRendererAccel *accel,
if (dup_actions != NULL && dup_actions[0] != NULL)
{
GimpAction *conflict_action = NULL;
gchar *left_paren_ptr0 = strchr (dup_actions[0], '(');
if (left_paren_ptr0)
*left_paren_ptr0 = '\0'; /* ignore target part of detailed name */
for (gint i = 0; dup_actions[i] != NULL; i++)
{
gint start;
gint start;
gchar *left_paren_ptr1 = strchr (dup_actions[i], '(');
if (left_paren_ptr1)
*left_paren_ptr1 = '\0'; /* ignore target part of detailed name */
start = g_str_has_prefix (dup_actions[i], "app.") ? 4 : 0;
conflict_action = GIMP_ACTION (g_action_map_lookup_action (G_ACTION_MAP (view->gimp->app),

View File

@ -37,6 +37,7 @@
#include "gimpaction.h"
#include "gimpactiongroup.h"
#include "gimpradioaction.h"
#include "gimphelp.h"
#include "gimphelp-ids.h"
#include "gimpmenu.h"
@ -1220,7 +1221,23 @@ gimp_ui_manager_image_accels_changed (GimpAction *action,
{
gchar *detailed_action_name;
detailed_action_name = g_strdup_printf ("app.%s", g_action_get_name (G_ACTION (action)));
if (GIMP_IS_RADIO_ACTION (action))
{
gint value;
g_object_get ((GObject *) action,
"value", &value,
NULL);
detailed_action_name = g_strdup_printf ("app.%s(%i)",
g_action_get_name (G_ACTION (action)),
value);
}
else
{
detailed_action_name = g_strdup_printf ("app.%s",
g_action_get_name (G_ACTION (action)));
}
gtk_application_set_accels_for_action (GTK_APPLICATION (manager->gimp->app),
detailed_action_name,
accels ? accels : (const gchar *[]) { NULL });