Commit 49b3f2c
More GTK dialogs.
Changed files (4)
modifiedbirdfont/GtkWindow.valamodifiedlibbirdfont/MenuTab.valamodifiedlibbirdfont/OverWriteDialogListener.valadeletedlibbirdfont/OverwriteDialog.vala
Diff
@@ -296,7 +296,28 @@ public class GtkWindow : Gtk.Window, NativeWindow { } public void set_overwrite_dialog (OverWriteDialogListener d) {+ Gtk.Dialog dialog = new Gtk.Dialog.with_buttons (d.message, null, 0);+ + dialog.add_button (d.overwrite_message, 0);+ dialog.add_button (d.cancel_message, 1);+ dialog.add_button (d.dont_ask_again_message, 2);+ + dialog.response.connect ((respons) => {+ switch (respons) {+ case 0:+ d.overwrite ();+ break;+ case 1:+ d.cancel ();+ break;+ case 2:+ d.overwrite_dont_ask_again ();+ break;+ }+ dialog.destroy ();+ }); + dialog.show_all (); } public void spawn (string command) {@@ -473,26 +473,22 @@ c.append (""" } public static void preview () {- TabBar tab_bar;- FontFormat format;- OverwriteDialog overwrite;-+ OverWriteDialogListener dialog = new OverWriteDialogListener ();+ TabBar tab_bar = MainWindow.get_tab_bar ();+ FontFormat format = BirdFont.get_current_font ().format;+ if (suppress_event) { return;- }-- tab_bar = MainWindow.get_tab_bar ();- format = BirdFont.get_current_font ().format;- overwrite = new OverwriteDialog ();-- overwrite.finished.connect (() => {- tab_bar.add_unique_tab (new Preview (), 80); + } + + dialog.overwrite_signal.connect (() => {+ tab_bar.add_unique_tab (new Preview (), 80); });- - if ((format == FontFormat.SVG || format == FontFormat.FREETYPE) && !OverwriteDialog.ignore) {- tab_bar.add_unique_tab (overwrite);+ + if ((format == FontFormat.SVG || format == FontFormat.FREETYPE) && !OverWriteDialogListener.dont_ask_again) {+ MainWindow.native_window.set_overwrite_dialog (dialog); } else {- overwrite.finished ();+ dialog.overwrite (); } } @@ -19,9 +19,31 @@ namespace BirdFont { public class OverWriteDialogListener : GLib.Object { + public signal void overwrite_signal ();+ public signal void cancel_signal ();+ + public static bool dont_ask_again = false;+ + public string message = _("Overwrite TTF file?");+ public string overwrite_message = _("Overwrite");+ public string cancel_message = _("Cancel");+ public string dont_ask_again_message = _("Yes, don't ask again.");+ public OverWriteDialogListener () { } + public void overwrite () {+ overwrite_signal ();+ }+ + public void cancel () {+ cancel_signal (); + }++ public void overwrite_dont_ask_again () {+ dont_ask_again = true;+ overwrite ();+ } } }deleted file mode 100644@@ -1,85 +0,0 @@-/*- Copyright (C) 2013 Johan Mattsson-- This program is free software: you can redistribute it and/or modify- it under the terms of the GNU General Public License as published by- the Free Software Foundation, either version 3 of the License, or- (at your option) any later version.-- This program is distributed in the hope that it will be useful,- but WITHOUT ANY WARRANTY; without even the implied warranty of- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- GNU General Public License for more details.-- You should have received a copy of the GNU General Public License- along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--using Cairo;--namespace BirdFont {--public class OverwriteDialog : FontDisplay {-- public signal void finished ();- public static bool ignore = false; // ignore this dialog- - public OverwriteDialog () {- add_html_callback ("overwrite_dialog", (val) => {- TabBar tb = MainWindow.get_tab_bar ();- - if (val == "overwrite") {- tb.close_display (this);- finished ();- }- - if (val == "cancel") {- tb.close_display (this);- }- - if (val == "ignore") {- ignore = true;- tb.close_display (this);- finished ();- }- });- }-- public override string get_name () {- return _("Overwrite?");- }-- public override bool is_html_canvas () {- return true;- }-- public override string get_html () {- string mess = _("The loaded font can be overwritten if you choose to continue with preview.");- string headline = _("Overwrite?");- return """-<html>-<head>- <script type="text/javascript" src="supplement.js"></script>- <style type="text/css">@import url("style.css");</style>-</head>-<body>- - <div style="width:350px; margin: 50px auto 0 auto;">- <div class="heading"><h2>""" + headline + """</h2></div>- - <p>""" + mess + """</p>- - <form>- <input class="button" type="button" value=""" + "\"" + _("Continue") + "\"" + """ onclick="call ('overwrite_dialog:overwrite');"/>- <input class="button" type="button" value=""" + "\"" + _("Cancel") + "\"" + """ onclick="call ('overwrite_dialog:cancel');"/>- <input class="button" type="button" value=""" + "\"" + _("Continue and don't ask me again.") + "\"" + """ onclick="call ('overwrite_dialog:ignore');"/>- <br />- </form>- </div>-</body>-</html>""";- }-}- -}-