[12fb7b835d44de11f6cf0365cd49304d84fe9eeff9fdcd21330f8fcd9eaf1b81/mjog/mail-merge-plugin: 6/8] Plugin.Composer: Add insert_text method



commit b7fa380791ea18be13ee835ecbc4c12e5cebf8f5
Author: Michael Gratton <mike vee net>
Date:   Wed Jul 8 16:17:54 2020 +1000

    Plugin.Composer: Add insert_text method
    
    Supports plugins that insert text into the composer.

 src/client/application/application-plugin-manager.vala |  9 +++++++++
 src/client/plugin/plugin-composer.vala                 | 13 +++++++++++++
 2 files changed, 22 insertions(+)
---
diff --git a/src/client/application/application-plugin-manager.vala 
b/src/client/application/application-plugin-manager.vala
index 60ea7a48e..ce3acdeb5 100644
--- a/src/client/application/application-plugin-manager.vala
+++ b/src/client/application/application-plugin-manager.vala
@@ -416,6 +416,15 @@ public class Application.PluginManager : GLib.Object {
             this.application.backing.controller.present_composer(this.backing);
         }
 
+        public void insert_text(string plain_text) {
+            var entry = this.backing.focused_input_widget as Gtk.Entry;
+            if (entry != null) {
+                entry.insert_at_cursor(plain_text);
+            } else {
+                this.backing.editor.insert_text(plain_text);
+            }
+        }
+
         public void register_action(GLib.Action action) {
             if (this.action_group == null) {
                 this.action_group = new GLib.SimpleActionGroup();
diff --git a/src/client/plugin/plugin-composer.vala b/src/client/plugin/plugin-composer.vala
index 03a0d7471..e2fb71e4d 100644
--- a/src/client/plugin/plugin-composer.vala
+++ b/src/client/plugin/plugin-composer.vala
@@ -81,6 +81,19 @@ public interface Plugin.Composer : Geary.BaseObject {
      */
     public abstract void present();
 
+    /**
+     * Inserts text at the current cursor position.
+     *
+     * The given text is inserted at the current cursor position in
+     * the composer. Note that this may be in an address field,
+     * subject line, or message body, depending on which component is
+     * focused.
+     *
+     * If the text is inserted into the message body, any HTML markup
+     * present in the string will appear as-is.
+     */
+    public abstract void insert_text(string plain_text);
+
     /**
      * Sets the folder used to save the message being composed.
      *


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