diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2018-07-09 12:10:38 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2018-07-09 12:10:38 +0200 |
commit | 709e2d6f5652ec90c194a4ec2b530bebc6f952cb (patch) | |
tree | 496b2f3899e1d5728ee9ae76095cc5056c317447 /src/dialogs/MultiTextEntryDialog.vala | |
parent | f1353e9ffd34db5f755c7da0b3f9c10638fbfd38 (diff) | |
parent | 5c8be07095cc04a6d8a95204b0504fd7ab030154 (diff) |
Merge branch 'release/0.28.3-1'0.28.3-1
Diffstat (limited to 'src/dialogs/MultiTextEntryDialog.vala')
-rw-r--r-- | src/dialogs/MultiTextEntryDialog.vala | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/dialogs/MultiTextEntryDialog.vala b/src/dialogs/MultiTextEntryDialog.vala new file mode 100644 index 0000000..42e5318 --- /dev/null +++ b/src/dialogs/MultiTextEntryDialog.vala @@ -0,0 +1,43 @@ +/* Copyright 2016 Software Freedom Conservancy Inc. + * Copyright 2017 Jens Georg <mail@jensge.org> + * + * This software is licensed under the GNU LGPL (version 2.1 or later). + * See the COPYING file in this distribution. + */ + +[GtkTemplate (ui = "/org/gnome/Shotwell/ui/multitextentrydialog.ui")] +public class MultiTextEntryDialog : Gtk.Dialog { + public delegate bool OnModifyValidateType(string text); + + private unowned OnModifyValidateType on_modify_validate; + [GtkChild] + private Gtk.TextView entry; + + public MultiTextEntryDialog() { + Object (use_header_bar: Resources.use_header_bar()); + } + + public void setup(OnModifyValidateType? modify_validate, string title, string label, string? initial_text) { + set_title(title); + set_parent_window(AppWindow.get_instance().get_parent_window()); + set_transient_for(AppWindow.get_instance()); + on_modify_validate = modify_validate; + + entry.buffer.text = (initial_text != null ? initial_text : ""); + + entry.grab_focus(); + } + + public string? execute() { + string? text = null; + + show_all(); + + if (run() == Gtk.ResponseType.OK) + text = entry.buffer.text; + + destroy(); + + return text; + } +} |