[geary/mjog/mail-merge-plugin: 45/71] Plugin.Button: Rename to Actionable




commit eac2878342353ff7993fb58cc0ee2669925953f8
Author: Michael Gratton <mike vee net>
Date:   Fri Jul 3 18:01:10 2020 +1000

    Plugin.Button: Rename to Actionable
    
    Make the name generic so it can be used for things other than buttons
    (e.g. menu items).

 po/POTFILES.in                                     |  2 +-
 src/client/components/components-info-bar.vala     |  3 +-
 src/client/meson.build                             |  2 +-
 .../plugin/email-templates/email-templates.vala    |  6 +--
 src/client/plugin/mail-merge/mail-merge.vala       |  4 +-
 src/client/plugin/plugin-actionable.vala           | 43 ++++++++++++++++++++++
 src/client/plugin/plugin-application.vala          |  2 +-
 src/client/plugin/plugin-button.vala               | 36 ------------------
 src/client/plugin/plugin-info-bar.vala             |  6 +--
 .../plugin/special-folders/special-folders.vala    |  4 +-
 10 files changed, 58 insertions(+), 50 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index fc90f1666..0d02fc765 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -92,8 +92,8 @@ src/client/folder-list/folder-list-search-branch.vala
 src/client/folder-list/folder-list-special-grouping.vala
 src/client/folder-list/folder-list-tree.vala
 src/client/plugin/plugin-account.vala
+src/client/plugin/plugin-actionable.vala
 src/client/plugin/plugin-application.vala
-src/client/plugin/plugin-button.vala
 src/client/plugin/plugin-composer.vala
 src/client/plugin/plugin-contact-store.vala
 src/client/plugin/plugin-email-extension.vala
diff --git a/src/client/components/components-info-bar.vala b/src/client/components/components-info-bar.vala
index 10ac9a7f4..4119ceffb 100644
--- a/src/client/components/components-info-bar.vala
+++ b/src/client/components/components-info-bar.vala
@@ -99,7 +99,8 @@ public class Components.InfoBar : Gtk.InfoBar {
         return (Gtk.Box) base.get_action_area();
     }
 
-    private void add_plugin_button(Plugin.Button plugin, string action_group_name) {
+    private void add_plugin_button(Plugin.Actionable plugin,
+                                   string action_group_name) {
         var gtk = new Gtk.Button.with_label(plugin.label);
         gtk.set_action_name(action_group_name + "." + plugin.action.name);
         if (plugin.action_target != null) {
diff --git a/src/client/meson.build b/src/client/meson.build
index 20eb6fc78..0bad46e1c 100644
--- a/src/client/meson.build
+++ b/src/client/meson.build
@@ -111,8 +111,8 @@ geary_client_vala_sources = files(
   'folder-list/folder-list-special-grouping.vala',
 
   'plugin/plugin-account.vala',
+  'plugin/plugin-actionable.vala',
   'plugin/plugin-application.vala',
-  'plugin/plugin-button.vala',
   'plugin/plugin-composer.vala',
   'plugin/plugin-contact-store.vala',
   'plugin/plugin-email-extension.vala',
diff --git a/src/client/plugin/email-templates/email-templates.vala 
b/src/client/plugin/email-templates/email-templates.vala
index 39006bea9..dc6511887 100644
--- a/src/client/plugin/email-templates/email-templates.vala
+++ b/src/client/plugin/email-templates/email-templates.vala
@@ -276,7 +276,7 @@ public class Plugin.EmailTemplates :
         var bar = this.info_bars.get(target);
         if (bar == null) {
             bar = new InfoBar(target.display_name);
-            bar.primary_button = new Button(
+            bar.primary_button = new Actionable(
                 // Translators: Info bar button label for creating a
                 // new email template
                 _("New"),
@@ -291,7 +291,7 @@ public class Plugin.EmailTemplates :
     private InfoBar new_template_email_info_bar(EmailIdentifier target) {
         // Translators: Infobar status label for an email template
         var bar = new InfoBar(_("Message template"));
-        bar.primary_button = new Button(
+        bar.primary_button = new Actionable(
             // Translators: Info bar button label for sending an
             // email template
             _("Send"),
@@ -299,7 +299,7 @@ public class Plugin.EmailTemplates :
             target.to_variant()
         );
         bar.secondary_buttons.add(
-            new Button(
+            new Actionable(
                 // Translators: Info bar button label for editing an
                 // existing email template
                 _("Edit"),
diff --git a/src/client/plugin/mail-merge/mail-merge.vala b/src/client/plugin/mail-merge/mail-merge.vala
index 5d0eee083..e1001ad23 100644
--- a/src/client/plugin/mail-merge/mail-merge.vala
+++ b/src/client/plugin/mail-merge/mail-merge.vala
@@ -185,7 +185,7 @@ public class Plugin.MailMerge :
         // Translators: Infobar status label for an email mail merge
         // template
         var bar = new InfoBar(_("Mail merge template"));
-        bar.primary_button = new Button(
+        bar.primary_button = new Actionable(
             // Translators: Info bar button label for performing a
             // mail-merge on an email template
             _("Merge"),
@@ -193,7 +193,7 @@ public class Plugin.MailMerge :
             target.to_variant()
         );
         bar.secondary_buttons.add(
-            new Button(
+            new Actionable(
                 // Translators: Info bar button label for editing an
                 // existing email template
                 _("Edit"),
diff --git a/src/client/plugin/plugin-actionable.vala b/src/client/plugin/plugin-actionable.vala
new file mode 100644
index 000000000..2d6f48b30
--- /dev/null
+++ b/src/client/plugin/plugin-actionable.vala
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2020 Michael Gratton <mike vee net>
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later). See the COPYING file in this distribution.
+ */
+
+/**
+ * Enables plugins to add user interface elements such as buttons.
+ *
+ * Depending on how it is used, this interface may be used to specify
+ * buttons, menu items, and so on. The associated action must be
+ * registered via {@link Application.register_action} or similar calls
+ * for it to be enabled.
+ */
+public class Plugin.Actionable : Geary.BaseObject {
+
+
+    /**
+     * A short human-readable label for the actionable.
+     *
+     * This should ideally be less than 10 characters long. It will be
+     * used as the label for the button, menu item, etc, depending on
+     * how it was registered.
+     */
+    public string label { get; private set; }
+
+    /** The action to be invoked when the actionable is activated. */
+    public GLib.Action action { get; private set; }
+
+    /** The parameter value for the action, if any. */
+    public GLib.Variant? action_target { get; private set; }
+
+    /** Constructs a new actionable with a text label. */
+    public Actionable(string label,
+                      GLib.Action action,
+                      GLib.Variant? action_target = null) {
+        this.label = label;
+        this.action = action;
+        this.action_target = action_target;
+    }
+
+}
diff --git a/src/client/plugin/plugin-application.vala b/src/client/plugin/plugin-application.vala
index 4e532362b..e7ddef228 100644
--- a/src/client/plugin/plugin-application.vala
+++ b/src/client/plugin/plugin-application.vala
@@ -76,7 +76,7 @@ public interface Plugin.Application : Geary.BaseObject {
      * Registers a plugin action with the application.
      *
      * Once registered, the action will be available for use in user
-     * interface elements such as {@link Button}.
+     * interface elements such as {@link Actionable}.
      *
      * @see deregister_action
      */
diff --git a/src/client/plugin/plugin-info-bar.vala b/src/client/plugin/plugin-info-bar.vala
index 2dcfd1861..dd8a81b30 100644
--- a/src/client/plugin/plugin-info-bar.vala
+++ b/src/client/plugin/plugin-info-bar.vala
@@ -42,7 +42,7 @@ public class Plugin.InfoBar : Geary.BaseObject {
      * object's method, such as {@link
      * FolderContext.remove_folder_info_bar}.
      */
-    public Button? primary_button { get; set; default = null; }
+    public Actionable? primary_button { get; set; default = null; }
 
     /**
      * Optional secondary buttons for the info bar.
@@ -56,8 +56,8 @@ public class Plugin.InfoBar : Geary.BaseObject {
      * object's method, such as {@link
      * FolderContext.remove_folder_info_bar}.
      */
-    public Gee.BidirList<Button> secondary_buttons {
-        get; private set; default = new Gee.LinkedList<Button>();
+    public Gee.BidirList<Actionable> secondary_buttons {
+        get; private set; default = new Gee.LinkedList<Actionable>();
     }
 
     /** Constructs a new info bar with the given status. */
diff --git a/src/client/plugin/special-folders/special-folders.vala 
b/src/client/plugin/special-folders/special-folders.vala
index 15affb3b3..109ab1162 100644
--- a/src/client/plugin/special-folders/special-folders.vala
+++ b/src/client/plugin/special-folders/special-folders.vala
@@ -157,7 +157,7 @@ public class Plugin.SpecialFolders :
         var bar = this.info_bars.get(target);
         if (bar == null) {
             bar = new InfoBar(target.display_name);
-            bar.primary_button = new Button(
+            bar.primary_button = new Actionable(
                 // Translators: Info bar button label for emptying
                 // trash/spam folders
                 _("Empty"),
@@ -177,7 +177,7 @@ public class Plugin.SpecialFolders :
             // email
             _("This message has not yet been sent.")
         );
-        bar.primary_button = new Button(
+        bar.primary_button = new Actionable(
             // Translators: Info bar button label for editing a draft
             // email
             _("Edit"),


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