Clone in a terminal:
Commit 673f7af
Johan Mattsson - 2014-03-21T19:36:55+00:00
673f7af6e7ae07400874af1fd183a758f96033a0johan.mattsson.m@gmail.com

Fix preview bug

Changed files (8)

Diff

diff --git a/birdfont/GtkWindow.vala b/birdfont/GtkWindow.valaindex d4e818c..5b44a3d 100644--- a/birdfont/GtkWindow.vala+++ b/birdfont/GtkWindow.vala@@ -852,7 +852,11 @@ public class GtkWindow : Gtk.Window, NativeWindow { 	} 	 	// TODO: add tooltip-	public void tooltip (string tooltip, int x, int y) {+	public void show_tooltip (string tooltip, int x, int y) {+		+	}++	public void hide_tooltip () { 		 	} }diff --git a/libbirdfont/BirdFont.vala b/libbirdfont/BirdFont.valaindex fa171c5..103bdb7 100644--- a/libbirdfont/BirdFont.vala+++ b/libbirdfont/BirdFont.vala@@ -131,6 +131,7 @@ public static int run_export (string[] arg) { 		ExportTool.export_ttf_font_path (File.new_for_path (output_directory), false); 	} 	+	Toolbox.redraw_tool_box (); 	return 0; } diff --git a/libbirdfont/NativeWindow.vala b/libbirdfont/NativeWindow.valaindex f3d0b7c..2922873 100644--- a/libbirdfont/NativeWindow.vala+++ b/libbirdfont/NativeWindow.vala@@ -53,7 +53,10 @@ public interface NativeWindow : GLib.Object { 	public abstract bool convert_to_png (string from, string to);  	/** Show help text. */-	public abstract void tooltip (string tooltip, int x, int y);+	public abstract void show_tooltip (string tooltip, int x, int y);+	+	/** Hide help text. */+	public abstract void hide_tooltip (); }  }diff --git a/libbirdfont/Preview.vala b/libbirdfont/Preview.valaindex 0ab10c3..fb77dff 100644--- a/libbirdfont/Preview.vala+++ b/libbirdfont/Preview.vala@@ -57,7 +57,7 @@ public class Preview : FontDisplay { 	 	public static string get_windows_uri () { 		Font font = BirdFont.get_current_font ();-		string html = @"$(font.get_name ()).html";+		string html = @"$(font.get_full_name ()).html"; 		File dir = font.get_folder (); 		File file = dir.get_child (html); 		return "file:///" + (!)	file.get_path ();@@ -76,15 +76,18 @@ public class Preview : FontDisplay { 		File f_ttf; 		File f_eot; 		File f_svg;-		+		File r_ttf;+		File r_svg;+			+			 		try { 			dis = new DataInputStream (get_file ().read ()); 			 			preview_directory = BirdFont.get_preview_directory (); 			-			f_ttf = font.get_folder ().get_child (@"$(font.get_name ()).ttf");-			f_eot = font.get_folder ().get_child (@"$(font.get_name ()).eot");-			f_svg = font.get_folder ().get_child (@"$(font.get_name ()).svg");+			f_ttf = font.get_folder ().get_child (@"$(font.get_full_name ()).ttf");+			f_eot = font.get_folder ().get_child (@"$(font.get_full_name ()).eot");+			f_svg = font.get_folder ().get_child (@"$(font.get_full_name ()).svg");  			if (!f_ttf.query_exists ()) { 				warning ("TTF file does not exist.");@@ -94,26 +97,34 @@ public class Preview : FontDisplay { 				warning ("SVG file does not exist."); 			} 			-			File r_ttf = preview_directory.get_child (@"$(font.get_name ())$rid.ttf");-			File r_svg = preview_directory.get_child (@"$(font.get_name ())$rid.svg");+			r_ttf = preview_directory.get_child (@"$(font.get_full_name ())$rid.ttf");+			r_svg = preview_directory.get_child (@"$(font.get_full_name ())$rid.svg"); 			-			if (BirdFont.win32) {-				f_ttf.copy (r_ttf, FileCopyFlags.NONE);+			try {+				if (BirdFont.win32) {+					f_ttf.copy (r_ttf, FileCopyFlags.NONE);+				}+			} catch (Error e) {+				warning (e.message);+				warning ("Failed to copy ttf file."); 			}-			-			f_svg.copy (r_svg, FileCopyFlags.NONE); +			try {+				f_svg.copy (r_svg, FileCopyFlags.NONE);+			} catch (Error e) {+				warning (e.message);+				warning ("Failed to copy svg file.");+			} 			while ((line = dis.read_line (null)) != null) {-				line = ((!) line).replace (@"$(font.get_name ()).ttf", @"$(FontDisplay.path_to_uri ((!) f_ttf.get_path ()))?$rid");-				line = ((!) line).replace (@"$(font.get_name ()).eot", @"$(FontDisplay.path_to_uri ((!) f_eot.get_path ()))?$rid");-				line = ((!) line).replace (@"$(font.get_name ()).svg", @"$(FontDisplay.path_to_uri ((!) f_svg.get_path ()))?$rid");+				line = ((!) line).replace (@"$(font.get_full_name ()).ttf", @"$(FontDisplay.path_to_uri ((!) f_ttf.get_path ()))?$rid");+				line = ((!) line).replace (@"$(font.get_full_name ()).eot", @"$(FontDisplay.path_to_uri ((!) f_eot.get_path ()))?$rid");+				line = ((!) line).replace (@"$(font.get_full_name ()).svg", @"$(FontDisplay.path_to_uri ((!) f_svg.get_path ()))?$rid"); 				sb.append ((!) line); 			} 		} catch (Error e) { 			warning (e.message); 			warning ("Failed to load html into canvas."); 		}- 		return sb.str; 	} }diff --git a/libbirdfont/SvgFontFormatWriter.vala b/libbirdfont/SvgFontFormatWriter.valaindex f599e39..0f7fad2 100644--- a/libbirdfont/SvgFontFormatWriter.vala+++ b/libbirdfont/SvgFontFormatWriter.vala@@ -34,7 +34,7 @@ class SvgFontFormatWriter : Object  { 	} 	 	public void write_font_file (Font font) throws Error {-		string font_name = font.get_name ();+		string font_name = font.get_full_name (); 		 		int units_per_em = 100; 		diff --git a/libbirdfont/Tool.vala b/libbirdfont/Tool.valaindex 68ba9d5..58ba87c 100644--- a/libbirdfont/Tool.vala+++ b/libbirdfont/Tool.vala@@ -90,6 +90,9 @@ public class Tool : GLib.Object { 	public bool persistent = false; 	public bool editor_events = false; 	+	bool showing_tooltip = false;+	bool waiting_for_tooltip = false;+	 	/** Create tool with a certain name and load icon "name".png */ 	public Tool (string? name = null, string tip = "", unichar key = '\0', uint modifier_flag = 0) { 		this.tip = tip;@@ -116,6 +119,44 @@ public class Tool : GLib.Object { 			MainWindow.get_tool_tip ().set_text_from_tool (); 		}); 		+		panel_move_action.connect ((self, x, y) => {+			bool show_tooltip = false;+			int tooltip_cycles = 0;+			TimeoutSource timer;+			+			if (show_tooltip) {+				MainWindow.native_window.show_tooltip (tip, (int)x, (int)y);+			}+		+			if (!waiting_for_tooltip) {+				waiting_for_tooltip = true;+				timer = new TimeoutSource (600);+				timer.set_callback (() => {+					if (is_active () && !showing_tooltip) {+						MainWindow.native_window.show_tooltip (tip, (int)x, (int)y);+						showing_tooltip = true;+						return true;+					}+					+					if (!is_active () && showing_tooltip) {	+						MainWindow.native_window.hide_tooltip ();+						showing_tooltip = false;+						waiting_for_tooltip = false;+						return false;+					}+					+					if (!is_active () && !showing_tooltip) {+						waiting_for_tooltip = false;+						return false;+					}+					+					return true;+				});+				timer.attach (null);+			}+			return false;+		});+		 		r = r_default; 		g = g_default; 		b = b_default;diff --git a/libbirdfont/Toolbox.vala b/libbirdfont/Toolbox.valaindex 32e4c51..e02653e 100644--- a/libbirdfont/Toolbox.vala+++ b/libbirdfont/Toolbox.vala@@ -72,8 +72,11 @@ public class Toolbox : GLib.Object  { 	}  	public static void set_allocation (int w, int h) {-		allocation_width = w;-		allocation_height = h;+		if (w != allocation_width || allocation_height != h) {+			allocation_width = w;+			allocation_height = h;+			Toolbox.redraw_tool_box ();+		} 	}  	public void key_press (uint keyval) {diff --git a/libbirdfont/TrackTool.vala b/libbirdfont/TrackTool.valaindex 4a29344..63ade3f 100644--- a/libbirdfont/TrackTool.vala+++ b/libbirdfont/TrackTool.vala@@ -58,7 +58,7 @@ public class TrackTool : Tool { 	public TrackTool (string name) { 		string sw; 		-		base (name, t_("Free hand drawing"));+		base (name, t_("Freehand drawing")); 		 		sw = Preferences.get ("free_hand_stroke_width"); 		if (sw != "") {

Contact

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