[geary/mjog/mail-merge-plugin: 53/74] Plugin.Composer: Add new action_group_name property




commit 97f629c5ba220f8460311b2ed392f84f671c339a
Author: Michael Gratton <mike vee net>
Date:   Wed Jul 8 16:09:19 2020 +1000

    Plugin.Composer: Add new action_group_name property
    
    Since GLib.Menu instances require fully qualified action names for menu
    item actions, plugins need to be able to access the group name their
    actions have been added to.
    
    This lets plugins activate arbitrary actions, but that's perhaps not a
    big risk?

 src/client/application/application-plugin-manager.vala | 10 ++++++----
 src/client/plugin/plugin-composer.vala                 | 11 +++++++++++
 2 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/src/client/application/application-plugin-manager.vala 
b/src/client/application/application-plugin-manager.vala
index 021d0bf59..60ea7a48e 100644
--- a/src/client/application/application-plugin-manager.vala
+++ b/src/client/application/application-plugin-manager.vala
@@ -359,6 +359,11 @@ public class Application.PluginManager : GLib.Object {
         }
         private Plugin.Account? _sender_context = null;
 
+        public string action_group_name {
+            get { return this._action_group_name; }
+        }
+        private string _action_group_name;
+
         public Plugin.Folder? save_to  {
             get {
                 // Ugh
@@ -379,16 +384,13 @@ public class Application.PluginManager : GLib.Object {
         private GLib.SimpleActionGroup? action_group = null;
         private GLib.Menu? menu_items = null;
         private Gtk.ActionBar? action_bar = null;
-        private string action_group_name;
-
-
 
 
         public ComposerImpl(Composer.Widget backing,
                             ApplicationImpl application) {
             this.backing = backing;
             this.application = application;
-            this.action_group_name = application.plugin.action_group_name + "-cmp";
+            this._action_group_name = application.plugin.action_group_name + "-cmp";
         }
 
         public void save_to_folder(Plugin.Folder? location) {
diff --git a/src/client/plugin/plugin-composer.vala b/src/client/plugin/plugin-composer.vala
index 8407336d4..03a0d7471 100644
--- a/src/client/plugin/plugin-composer.vala
+++ b/src/client/plugin/plugin-composer.vala
@@ -49,6 +49,17 @@ public interface Plugin.Composer : Geary.BaseObject {
      */
     public abstract bool can_send { get; set; }
 
+    /**
+     * The group name for GLib actions registered against this object.
+     *
+     * All actions are registered via {@link register_action} will be
+     * added to an action group with the name returned by this
+     * property.
+     *
+     * This must be used when using actions with GLib MenuModel items.
+     */
+    public abstract string action_group_name { get; }
+
     /**
      * Denotes the folder that the email will be saved to.
      *


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