Clone in a terminal:
Commit 49b3f2c
Johan Mattsson - 2013-07-12T16:48:49+00:00
49b3f2cf5ad39f99abcc88032bf9d90e3b76bfb4johan.mattsson.m@gmail.com

More GTK dialogs.

Changed files (4)

Diff

diff --git a/birdfont/GtkWindow.vala b/birdfont/GtkWindow.valaindex 58035a7..37f4f26 100644--- a/birdfont/GtkWindow.vala+++ b/birdfont/GtkWindow.vala@@ -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) {diff --git a/libbirdfont/MenuTab.vala b/libbirdfont/MenuTab.valaindex 71f0719..537e2ce 100644--- a/libbirdfont/MenuTab.vala+++ b/libbirdfont/MenuTab.vala@@ -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 (); 		} 	} 	diff --git a/libbirdfont/OverWriteDialogListener.vala b/libbirdfont/OverWriteDialogListener.valaindex 07773a3..8025ee9 100644--- a/libbirdfont/OverWriteDialogListener.vala+++ b/libbirdfont/OverWriteDialogListener.vala@@ -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 ();+	} }  }diff --git a/libbirdfont/OverwriteDialog.vala b/libbirdfont/OverwriteDialog.valadeleted file mode 100644index 881b497..0000000--- a/libbirdfont/OverwriteDialog.vala+++ /dev/null@@ -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>""";-	}-}-	-}-

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112