[gimp] app: remove transient actions with gimp_action_group_remove_action().



commit 2081de5a6c46b46756895e41d63e32a57727af87
Author: Jehan <jehan girinstud io>
Date:   Fri Nov 25 04:28:47 2016 +0100

    app: remove transient actions with gimp_action_group_remove_action().
    
    gtk_action_group_remove_action() removes the action from the group while
    not actually cleaning any accelerator. This is a problem for transient
    actions which have only a meaning within the current session, such as
    the display switching actions named with the display ID (unique within
    the session only).
    Current commit, combined with the previous one (commit c0ee959), fix
    "windows-display-*" actions being saved inside menurc.

 app/actions/windows-actions.c |    9 +++++----
 app/widgets/gimpactiongroup.c |   30 ++++++++++++++++++++++++++++++
 app/widgets/gimpactiongroup.h |    3 +++
 3 files changed, 38 insertions(+), 4 deletions(-)
---
diff --git a/app/actions/windows-actions.c b/app/actions/windows-actions.c
index 88da6f2..a92292c 100644
--- a/app/actions/windows-actions.c
+++ b/app/actions/windows-actions.c
@@ -33,6 +33,7 @@
 #include "core/gimpimage.h"
 #include "core/gimplist.h"
 
+#include "widgets/gimpaction.h"
 #include "widgets/gimpactiongroup.h"
 #include "widgets/gimpdialogfactory.h"
 #include "widgets/gimpdock.h"
@@ -308,8 +309,8 @@ windows_actions_display_remove (GimpContainer   *container,
   action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
 
   if (action)
-    gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
-
+    gimp_action_group_remove_action (group,
+                                     GIMP_ACTION (action));
   g_free (action_name);
 
   windows_actions_update_display_accels (group);
@@ -486,7 +487,7 @@ windows_actions_dock_window_removed (GimpDialogFactory *factory,
   action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
 
   if (action)
-    gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
+    gimp_action_group_remove_action (group, GIMP_ACTION (action));
 
   g_free (action_name);
 }
@@ -574,7 +575,7 @@ windows_actions_recent_remove (GimpContainer   *container,
   action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
 
   if (action)
-    gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
+    gimp_action_group_remove_action (group, GIMP_ACTION (action));
 
   g_free (action_name);
 }
diff --git a/app/widgets/gimpactiongroup.c b/app/widgets/gimpactiongroup.c
index b79f9bc..5d6b8f1 100644
--- a/app/widgets/gimpactiongroup.c
+++ b/app/widgets/gimpactiongroup.c
@@ -678,6 +678,36 @@ gimp_action_group_add_procedure_actions (GimpActionGroup                *group,
     }
 }
 
+/**
+ * gimp_action_group_remove_action:
+ * @group:  the #GimpActionGroup to which @action belongs.
+ * @action: the #GimpAction.
+ *
+ * This function removes action from the groupe and clean any
+ * accelerator this action may have set.
+ * If you wish only to only remove the action from the group, use
+ * gtk_action_group_remove_action() instead.
+ */
+void
+gimp_action_group_remove_action (GimpActionGroup *group,
+                                 GimpAction      *action)
+{
+  const gchar *action_name;
+  const gchar *group_name;
+  gchar       *accel_path;
+
+  action_name = gtk_action_get_name (GTK_ACTION (action));
+  group_name  = gtk_action_group_get_name (GTK_ACTION_GROUP (group));
+  accel_path = g_strconcat ("<Actions>/", group_name, "/",
+                            action_name, NULL);
+
+  gtk_accel_map_change_entry (accel_path, 0, 0, FALSE);
+
+  gtk_action_group_remove_action (GTK_ACTION_GROUP (group),
+                                  GTK_ACTION (action));
+  g_free (accel_path);
+}
+
 void
 gimp_action_group_activate_action (GimpActionGroup *group,
                                    const gchar     *action_name)
diff --git a/app/widgets/gimpactiongroup.h b/app/widgets/gimpactiongroup.h
index 2392826..b0c8652 100644
--- a/app/widgets/gimpactiongroup.h
+++ b/app/widgets/gimpactiongroup.h
@@ -175,6 +175,9 @@ void   gimp_action_group_add_procedure_actions(GimpActionGroup             *grou
                                                guint                        n_entries,
                                                GCallback                    callback);
 
+void   gimp_action_group_remove_action        (GimpActionGroup             *group,
+                                               GimpAction                  *action);
+
 void          gimp_action_group_activate_action       (GimpActionGroup *group,
                                                        const gchar     *action_name);
 void          gimp_action_group_set_action_visible    (GimpActionGroup *group,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]