Clone in a terminal:
Commit d45a73e
Johan Mattsson - 2015-11-04T09:50:09+00:00
d45a73e67441907c42c1d9f0ff9b725b4b8e5a6cjohan.mattsson.m@gmail.com

Fix dialog layout and set absolute path when saving fonts

Changed files (9)

Diff

diff --git a/libbirdfont/LicenseDialog.vala b/libbirdfont/LicenseDialog.valaindex 7d2bf2a..5bd1d9d 100644--- a/libbirdfont/LicenseDialog.vala+++ b/libbirdfont/LicenseDialog.vala@@ -50,7 +50,7 @@ public class LicenseDialog : Dialog { 		height = 240; 	} -	void layout () {+	public override void layout () { 		double cx = 0; 		double cy = (allocation.height - height) / 2.0; 		double center;diff --git a/libbirdfont/OverwriteBfFile.vala b/libbirdfont/OverwriteBfFile.valaindex b150b33..1002eee 100644--- a/libbirdfont/OverwriteBfFile.vala+++ b/libbirdfont/OverwriteBfFile.vala@@ -22,7 +22,7 @@ public class OverwriteBfFile : QuestionDialog { 	Button cancel; 	 	public OverwriteBfFile (SaveCallback save_callback) {-		base(t_("This file already exists. Do you want to replace it?"), 200);+		base(t_("This file already exists. Do you want to replace it?")); 		 		replace = new Button (t_("Replace")); 		replace.action.connect (() => {diff --git a/libbirdfont/OverwriteDialog.vala b/libbirdfont/OverwriteDialog.valaindex eb37222..2b10041 100644--- a/libbirdfont/OverwriteDialog.vala+++ b/libbirdfont/OverwriteDialog.vala@@ -58,7 +58,7 @@ public class OverwriteDialog : Dialog { 		height = 90 * MainWindow.units; 	} -	void layout () {+	public override void layout () { 		double cx = 0; 		double cy = (allocation.height - height) / 2.0; 		double center;diff --git a/libbirdfont/QuestionDialog.vala b/libbirdfont/QuestionDialog.valaindex fee202f..7cec079 100644--- a/libbirdfont/QuestionDialog.vala+++ b/libbirdfont/QuestionDialog.vala@@ -19,23 +19,22 @@ namespace BirdFont { public class QuestionDialog : Dialog { 	TextArea question; 	public Gee.ArrayList<Button> buttons;--	double width = 0;-	double height; 	 	static const double font_size = 20; 	static const double margin = 20;+	static const double margin_small = 5;+	+	double width = 300;+	double height = 0; 	-	public QuestionDialog (string message, int height) {+	public QuestionDialog (string message) { 		question = new TextArea (font_size); 		question.min_width = 300;+		question.min_height = font_size; 		question.set_editable (false); 		question.draw_border = false; 		question.text_color = Theme.get_color ("Text Tool Box"); 		question.set_text (message);-		-		this.height = height;-		 		buttons = new Gee.ArrayList<Button> (); 	} @@ -43,9 +42,9 @@ public class QuestionDialog : Dialog { 		buttons.add (button); 	} -	void layout () {+	public override void layout () { 		double cx = 0;-		double cy = (allocation.height - height) / 2.0;+		double cy; 		double center; 		double h; 		@@ -60,23 +59,34 @@ public class QuestionDialog : Dialog { 		center = (allocation.width - width) / 2.0; 		 		question.widget_x = margin + center;-		question.widget_y = cy + margin;-		question.allocation = new WidgetAllocation.for_area (0, 0, 300, 450);+		question.allocation = new WidgetAllocation.for_area (0, 0, 3000, 3000); 		question.layout (); 		 		h = question.get_height () + margin;-+		print (@"question.get_height (): $(question.get_height ())\n");+		 		foreach (Button button in buttons) { 			button.widget_x += center;-			button.widget_y = cy + h + margin; 		}+		+		height = h + margin + margin_small;+		+		if (buttons.size > 0) {+			height += buttons.get (0).get_height ();+		}+		+		cy = (allocation.height - height) / 2.0;++		foreach (Button button in buttons) {+			button.widget_y = cy + h + margin_small;+		}+		+		question.widget_y = cy + margin; 	}  	public override void draw (Context cr) {	 		double cx, cy; 		-		layout ();- 		cx = (allocation.width - width) / 2.0; 		cy = (allocation.height - height) / 2.0; 		diff --git a/libbirdfont/Renderer/TextArea.vala b/libbirdfont/Renderer/TextArea.valaindex 1bc78e7..c635ee2 100644--- a/libbirdfont/Renderer/TextArea.vala+++ b/libbirdfont/Renderer/TextArea.vala@@ -880,7 +880,7 @@ public class TextArea : Widget { 	} 	 	/** @return offset to click in text. */-	public void layout () {+	public override void layout () { 		double p; 		double tx, ty; 		string w;diff --git a/libbirdfont/SaveCallback.vala b/libbirdfont/SaveCallback.valaindex 16cd6db..432f485 100644--- a/libbirdfont/SaveCallback.vala+++ b/libbirdfont/SaveCallback.vala@@ -19,7 +19,7 @@ public class SaveCallback : GLib.Object { 	public signal void file_saved (); 	public bool is_done = false; 	-	public string file_name = "";+	public string font_file_path = ""; 	 	public SaveCallback () {	 		file_saved.connect (() => {@@ -38,11 +38,13 @@ public class SaveCallback : GLib.Object { 			string f; 			File file; 			OverwriteBfFile dialog;+			string file_name; 			 			if (fn != null) { 				f = (!) fn;  #if MAC+				font_file_path = f; 				save (); #else 				if (!f.has_suffix (".bf")) {@@ -51,6 +53,7 @@ public class SaveCallback : GLib.Object { 				 				file_name = @"$(f)"; 				file = File.new_for_path (file_name);+				font_file_path = (!) file.get_path (); 				if (!file.query_exists ()) { 					save (); 				} else {@@ -75,10 +78,13 @@ public class SaveCallback : GLib.Object { 		} 		 		f = BirdFont.get_current_font ();--		Preferences.add_recent_files (file_name);-		f.font_file = file_name;-					+		+		if (font_file_path != "") {+			f.font_file = font_file_path;+		}+		+		Preferences.add_recent_files (f.get_path ());+		 		if (f.is_bfp ()) { 			MainWindow.native_window.save (); 		} else {diff --git a/libbirdfont/SaveDialog.vala b/libbirdfont/SaveDialog.valaindex 959e5b4..609baeb 100644--- a/libbirdfont/SaveDialog.vala+++ b/libbirdfont/SaveDialog.vala@@ -56,7 +56,7 @@ public class SaveDialog : Dialog { 		height = 90 * MainWindow.units; 	} -	void layout () {+	public override void layout () { 		double cx = 0; 		double cy = (allocation.height - height) / 2.0; 		double center;diff --git a/libbirdfont/TabContent.vala b/libbirdfont/TabContent.valaindex 4bd14ed..b8dced6 100644--- a/libbirdfont/TabContent.vala+++ b/libbirdfont/TabContent.vala@@ -96,6 +96,7 @@ public class TabContent : GLib.Object {  			if (dialog.visible) { 				dialog.allocation = allocation;+				dialog.layout (); 				dialog.draw (cr); 			} else if (menu.show_menu) { 				menu.draw (allocation, cr);diff --git a/libbirdfont/Widget.vala b/libbirdfont/Widget.valaindex cf5cc00..a0d0455 100644--- a/libbirdfont/Widget.vala+++ b/libbirdfont/Widget.vala@@ -43,6 +43,9 @@ public abstract class Widget : GLib.Object { 		cr.close_path ();			 	} +	public virtual void layout () {+	}+ 	public bool is_over (double x, double y) { 		return widget_x <= x <= widget_x + get_width ()  			&&  widget_y <= y <= widget_y + get_height ();

Contact

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