diff --git a/po/POTFILES.in b/po/POTFILES.in index fc90f166..0d02fc76 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 10ac9a7f..4119ceff 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 c600f674..d6134ba9 100644 --- a/src/client/meson.build +++ b/src/client/meson.build @@ -113,8 +113,8 @@ 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 981898a6..90329f16 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 2885d655..a4df6fea 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 00000000..2d6f48b3 --- /dev/null +++ b/src/client/plugin/plugin-actionable.vala @@ -0,0 +1,43 @@ +/* + * Copyright © 2020 Michael Gratton + * + * 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 25a28ddf..67a0c2c7 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-button.vala b/src/client/plugin/plugin-button.vala deleted file mode 100644 index 498c63d0..00000000 --- a/src/client/plugin/plugin-button.vala +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright © 2020 Michael Gratton - * - * 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 buttons to the user interface. - */ -public class Plugin.Button : Geary.BaseObject { - - - /** - * A short human-readable button label. - * - * This should ideally be less than 10 characters long. - */ - public string label { get; private set; } - - /** The action to be invoked when the button is clicked. */ - 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 button with a text label. */ - public Button(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-info-bar.vala b/src/client/plugin/plugin-info-bar.vala index 2dcfd186..dd8a81b3 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