[12fb7b835d44de11f6cf0365cd49304d84fe9eeff9fdcd21330f8fcd9eaf1b81/mjog/mail-merge-plugin: 2/8] Plugin.MailMerge: Show a composer action bar after loading CSV



commit b2eb583377f66eb5225fe87b5eb1dfc308342a30
Author: Michael Gratton <mike vee net>
Date:   Tue Jul 7 16:28:02 2020 +1000

    Plugin.MailMerge: Show a composer action bar after loading CSV

 src/client/plugin/mail-merge/mail-merge.vala | 31 ++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/src/client/plugin/mail-merge/mail-merge.vala b/src/client/plugin/mail-merge/mail-merge.vala
index fe5fa254d..179d888ed 100644
--- a/src/client/plugin/mail-merge/mail-merge.vala
+++ b/src/client/plugin/mail-merge/mail-merge.vala
@@ -209,13 +209,9 @@ public class Plugin.MailMerge :
         chooser.add_filter(csv_filter);
         if (chooser.run() == Gtk.ResponseType.ACCEPT) {
             try {
-                var input = yield chooser.get_file().read_async(
-                    GLib.Priority.DEFAULT,
-                    this.cancellable
+                composer.set_action_bar(
+                    yield new_composer_action_bar(chooser.get_file())
                 );
-                var csv = yield new Util.Csv.Reader(input, this.cancellable);
-                var record = yield csv.read_record();
-                debug("XXX record: %s", string.join(",", record));
             } catch (GLib.Error err) {
                 debug("Error loading CSV: %s", err.message);
             }
@@ -245,6 +241,29 @@ public class Plugin.MailMerge :
         return bar;
     }
 
+    private async ActionBar new_composer_action_bar(GLib.File csv_file)
+        throws GLib.Error {
+        var info = yield csv_file.query_info_async(
+            GLib.FileAttribute.STANDARD_DISPLAY_NAME,
+            NONE,
+            GLib.Priority.DEFAULT,
+            this.cancellable
+        );
+        var input = yield csv_file.read_async(
+            GLib.Priority.DEFAULT,
+            this.cancellable
+        );
+        var csv = yield new Util.Csv.Reader(input, this.cancellable);
+        var record = yield csv.read_record();
+        debug("XXX record: %s", string.join(",", record));
+
+        var action_bar = new ActionBar();
+        action_bar.append_item(
+            new ActionBar.LabelItem(info.get_display_name()), CENTRE
+        );
+        return action_bar;
+    }
+
     private bool contains_field(string value) {
         var found = false;
         var index = 0;


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