[geary/mjog/mail-merge-plugin: 61/74] Plugin.MailMerge: Allow CSV chooser to be re-used
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/mail-merge-plugin: 61/74] Plugin.MailMerge: Allow CSV chooser to be re-used
- Date: Fri, 14 Aug 2020 02:09:04 +0000 (UTC)
commit 3f30ebc855f8200eaccf6c310628e0a1af1ededa
Author: Michael Gratton <mike vee net>
Date: Fri Jul 17 18:23:35 2020 +1000
Plugin.MailMerge: Allow CSV chooser to be re-used
src/client/plugin/mail-merge/mail-merge.vala | 59 +++++++++++++++++-----------
1 file changed, 35 insertions(+), 24 deletions(-)
---
diff --git a/src/client/plugin/mail-merge/mail-merge.vala b/src/client/plugin/mail-merge/mail-merge.vala
index c66bac062..0d6164de8 100644
--- a/src/client/plugin/mail-merge/mail-merge.vala
+++ b/src/client/plugin/mail-merge/mail-merge.vala
@@ -203,34 +203,23 @@ public class Plugin.MailMerge :
}
private async void load_composer_data(Composer composer) {
- var chooser = new Gtk.FileChooserNative(
- /// Translators: File chooser title after invoking mail
- /// merge in composer
- _("Mail Merge"),
- null, OPEN,
- _("_Open"),
- _("_Cancel")
- );
- var csv_filter = new Gtk.FileFilter();
- /// Translators: File chooser filer label
- csv_filter.set_filter_name(_("Comma separated values (CSV)"));
- csv_filter.add_mime_type("text/csv");
- chooser.add_filter(csv_filter);
-
- var insert_field_action = new GLib.SimpleAction(
- ACTION_INSERT_FIELD,
- GLib.VariantType.STRING
- );
- composer.register_action(insert_field_action);
- insert_field_action.activate.connect(
- (param) => { insert_field(composer, (string) param); }
- );
+ var data = show_merge_data_chooser();
+ if (data != null) {
+ var insert_field_action = new GLib.SimpleAction(
+ ACTION_INSERT_FIELD,
+ GLib.VariantType.STRING
+ );
+ composer.register_action(insert_field_action);
+ insert_field_action.activate.connect(
+ (param) => {
+ insert_field(composer, (string) param);
+ }
+ );
- if (chooser.run() == Gtk.ResponseType.ACCEPT) {
try {
composer.set_action_bar(
yield new_composer_action_bar(
- chooser.get_file(),
+ data,
composer.action_group_name
)
);
@@ -303,6 +292,28 @@ public class Plugin.MailMerge :
return action_bar;
}
+ private GLib.File? show_merge_data_chooser() {
+ var chooser = new Gtk.FileChooserNative(
+ /// Translators: File chooser title after invoking mail
+ /// merge in composer
+ _("Mail Merge"),
+ null, OPEN,
+ _("_Open"),
+ _("_Cancel")
+ );
+ var csv_filter = new Gtk.FileFilter();
+ /// Translators: File chooser filer label
+ csv_filter.set_filter_name(_("Comma separated values (CSV)"));
+ csv_filter.add_mime_type("text/csv");
+ chooser.add_filter(csv_filter);
+
+ return (
+ chooser.run() == Gtk.ResponseType.ACCEPT
+ ? chooser.get_file()
+ : null
+ );
+ }
+
private void insert_field(Composer composer, string field) {
composer.insert_text(FIELD_START + field + FIELD_END);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]