[geary/mjog/mail-merge-plugin: 64/72] Plugin.Infobar: Allow plugins to be notified of close button activation




commit aae3a1a581c9012b65205f01042d5f71b9f5e7bc
Author: Michael Gratton <mike vee net>
Date:   Fri Aug 14 14:53:41 2020 +1000

    Plugin.Infobar: Allow plugins to be notified of close button activation
    
    Add `close_activated` signal, update `Components.InfoBar` to emit it
    when clicked.

 src/client/components/components-info-bar.vala | 16 ++++++++++++++++
 src/client/plugin/plugin-info-bar.vala         |  3 +++
 2 files changed, 19 insertions(+)
---
diff --git a/src/client/components/components-info-bar.vala b/src/client/components/components-info-bar.vala
index 4119ceffb..e3bc6516b 100644
--- a/src/client/components/components-info-bar.vala
+++ b/src/client/components/components-info-bar.vala
@@ -27,6 +27,9 @@ public class Components.InfoBar : Gtk.InfoBar {
     public Gtk.Label? description { get; private set; default = null; }
 
 
+    private Plugin.InfoBar? plugin = null;
+
+
     /**
      * Constructs a new info bar.
      *
@@ -76,6 +79,7 @@ public class Components.InfoBar : Gtk.InfoBar {
                               string action_group_name,
                               int priority) {
         this(plugin.status, plugin.description);
+        this.plugin = plugin;
         this.show_close_button = plugin.show_close_button;
 
         var secondaries = plugin.secondary_buttons.bidir_list_iterator();
@@ -93,6 +97,18 @@ public class Components.InfoBar : Gtk.InfoBar {
         show_all();
     }
 
+    /* {@inheritDoc} */
+    public override void response(int response) {
+        if (response == Gtk.ResponseType.CLOSE && this.plugin != null) {
+            this.plugin.close_activated();
+        }
+    }
+
+    /* {@inheritDoc} */
+    public override void destroy() {
+        this.plugin = null;
+    }
+
     // GTK 3.24.16 fixed the binding for this, but that and the VAPI
     // change has yet to trickle down to common distros like F31
     public new Gtk.Box get_action_area() {
diff --git a/src/client/plugin/plugin-info-bar.vala b/src/client/plugin/plugin-info-bar.vala
index dd8a81b30..00696ace7 100644
--- a/src/client/plugin/plugin-info-bar.vala
+++ b/src/client/plugin/plugin-info-bar.vala
@@ -15,6 +15,9 @@
 public class Plugin.InfoBar : Geary.BaseObject {
 
 
+    /** Emitted when the close button is activated. */
+    public signal void close_activated();
+
     /**
      * A short, human-readable status message.
      *


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