Clone in a terminal:
Commit 0210c3f
Johan Mattsson - 2012-10-12T16:43:57+00:00
0210c3f0528d8fad503d6d157a3e4b548d3a05fcjohan.mattsson.m@gmail.com

remove native gtk window from libbirdfont

Changed files (35)

Diff

diff --git a/src/Birdfont.vala b/src/Birdfont.valaindex e27e169..881cb52 100644--- a/src/Birdfont.vala+++ b/src/Birdfont.vala@@ -18,107 +18,6 @@ using Supplement;  namespace Birdfont { -public static int run_gui (string[] arg) {-	int err_arg;-	File font_file;-	Argument args;-	IdleSource idle;-	int i;-	string exec_path;--	Supplement.Supplement supplement = new Supplement.Supplement ();--	supplement.args = new Argument.command_line (arg);-	args = supplement.args;-	-	if (supplement.args.has_argument ("--help")) {-		args.print_help ();-		Process.exit (0);-	}--	err_arg = args.validate ();-	if (err_arg != 0) {-		stdout.printf (@"Unknown parameter $(arg [err_arg])\n\n");-		args.print_help ();-		Process.exit (0);-	}--	stdout.printf ("birdfont version %s\n", VERSION);-	stdout.printf ("built on %s\n", BUILD_TIMESTAMP);--	supplement.current_font = new Font ();-	supplement.current_glyph = new Glyph ("");--	supplement.experimental = args.has_argument ("--test");-	supplement.show_coordinates = args.has_argument ("--show-coordinates");-	supplement.fatal_wanings = args.has_argument ("--fatal-warning");-	supplement.win32 = (arg[0].index_of (".exe") > -1) || arg[0] == "wine";-	supplement.exec_path = "";-	-	print (@"$(arg[0]) \n");--	if (supplement.win32) {-		// wine hack to get "." folder in win32 environment-		i = arg[0].last_index_of ("\\");-		-		if (i != -1) {	-			exec_path = arg[0];-			exec_path = exec_path.substring (0, i);-			supplement.exec_path = wine_to_unix_path (exec_path);			-		}-	} else {-		supplement.exec_path = "./";-	}-	-	print (@"arg[0]: $(arg[0])\n");-	print (@"supplement.win32: $(supplement.win32)\n");-	print (@"supplement.exec_path: $(supplement.exec_path)\n");-		-	Preferences preferences = new Preferences ();-	preferences.load ();-	-	if (args.get_file () != "") {-		font_file = File.new_for_path (args.get_file ());-		-		if (!font_file.query_exists ()) {-			stderr.printf (@"File $(args.get_file ()) not found.");-			return -1;-		}-	}-	-	Gtk.init (ref arg);-	MainWindow window = new MainWindow ();-	GtkWindow native_window = new GtkWindow ("birdfont");-	window.set_native (native_window);--	if (supplement.fatal_wanings) {-		LogLevelFlags levels = LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL | LogLevelFlags.LEVEL_WARNING;-		Log.set_handler (null, levels, supplement.fatal_warning);-	}-	-	idle = new IdleSource ();-	idle.set_callback(() => {-		preferences.load ();-		-		if (args.get_file () != "") {-			supplement.get_current_font ().load (args.get_file ());-			MainWindow.get_toolbox ().select_tool_by_name ("available_characters");-		} else {-			MainWindow.get_tab_bar ().select_tab_name ("Menu");-		}-		-		return false;-	});-	-	idle.attach (null);-	-	Gtk.main ();-	-	preferences.set_last_file (supplement.get_current_font ().get_path ());-	-	return 0;-}- static void print_export_help (string[] arg) { 	stdout.printf ("Usage: "); 	stdout.printf (arg[0]);diff --git a/src/DropMenu.vala b/src/DropMenu.valaindex 15c9820..6cd5c86 100644--- a/src/DropMenu.vala+++ b/src/DropMenu.vala@@ -19,12 +19,12 @@ using Cairo;  namespace Supplement { -enum MenuDirection {+public enum MenuDirection { 	DROP_DOWN, 	POP_UP; } -class DropMenu : GLib.Object {+public class DropMenu : GLib.Object {  	public delegate void Selected (MenuAction self); 	public signal void selected (DropMenu self);@@ -198,7 +198,7 @@ class DropMenu : GLib.Object { 	} } -class MenuAction : GLib.Object {+public class MenuAction : GLib.Object { 	public string label; 	public DropMenu.Selected action; 	public DropMenu? parent = null;diff --git a/src/EditPoint.vala b/src/EditPoint.valaindex edc6f5b..24ae2d0 100644--- a/src/EditPoint.vala+++ b/src/EditPoint.vala@@ -19,7 +19,7 @@ using Math;  namespace Supplement { -enum PointType {+public enum PointType { 	NONE, 	NORMAL, 	LINE,@@ -29,7 +29,7 @@ enum PointType { 	FLOATING } -class EditPoint {+public class EditPoint { 	 	public double x; 	public double y;diff --git a/src/EditPointHandle.vala b/src/EditPointHandle.valaindex be92256..c03fcc1 100644--- a/src/EditPointHandle.vala+++ b/src/EditPointHandle.vala@@ -19,7 +19,7 @@ using Math;  namespace Supplement { 		-class EditPointHandle  {+public class EditPointHandle  { 	 	public double angle; 	public double length;diff --git a/src/Expander.vala b/src/Expander.valanew file mode 100644index 0000000..7e2bd50--- /dev/null+++ b/src/Expander.vala@@ -0,0 +1,225 @@+/*+    Copyright (C) 2012 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;+using Math;++namespace Supplement {++public class Expander : GLib.Object {+	+	public double x = 7;+	public double y = 5;++	public double w = 6;+	public double h = 5;+	+	public double margin = 0;+	+	protected double rotation = 0;+	protected double opacity = 0.5;+	+	protected bool active = false;+	protected bool open = false;++	public List<Tool> tool;++	bool persist = false;+	bool unique = false;+	+	public Expander () {+	}++	/** Returns true if tools can be used with the current canvas after+	 * they have been selectes and false if they are a commands to be executed.+	 */+	public bool is_persistent () {+		return persist;+	}++	/** Returns true if all other tools in thid expander should be deselected +	 * when a tool is selected.+	 */+	public bool is_unique () {+		return unique;+	}++	public void set_persistent (bool p) {+		persist = p;+	}++	public void set_unique (bool u) {+		unique = u;+	}+	+	private void update_tool_position () {+		int i = 0;+		double xt = x + 10;+		double yt = y - 4;+		foreach (var t in tool) {+			t.set_properties (xt, yt, w, h);+			+			if (i == 3) {+				yt += 31;+				i = 0;+				xt = x + 10;+			} else {+				i++;+				xt += w + 3 + 25;+			}+		}+	}+	+	public void set_offset (double ty) {+		y = ty;+		+		if (open) {+			update_tool_position ();+		}+	}+	+	public void add_tool (Tool t) {+		tool.append (t);+		update_tool_position ();+		+		t.select_action.connect ((selected) => {+				if (!selected.new_selection) {+					if (is_persistent ()) {+						selected.set_selected (true);+					} else {+						selected.set_selected (false);+					}+				}+			+				MainWindow.get_toolbox ().redraw ((int) x, (int) y, (int) w  + 300, (int) (h + margin));+			+				if (is_unique ()) {+					foreach (var deselected in tool) {+						if (selected.get_id () != deselected.get_id ()) {+							deselected.set_selected (false);+						}+					}+				}++				if (!is_persistent ()) {+						var time = new TimeoutSource(200);+						time.set_callback(() => {+							selected.set_selected (false);+							MainWindow.get_toolbox ().redraw ((int) x, (int) y, (int) w  + 300, (int) (h + margin));+							return false;+						});+						time.attach(null);+				}++				selected.new_selection = false;+			});+	}+	+	public bool is_over (double xp, double yp) {	+		return (x - 7/2.0 <= xp <= x + w  + 7/2.0 && y - 7/2.0<= yp <= y + w + 7/2.0);  +	}+	+	public bool set_active (bool a) {+		bool r = (active != a);+		opacity = (a) ? 1 : 0;+		active = a;+		return r;+	}+	+	public bool is_open () {+		return open;+	}+	+	public virtual bool set_open (bool o) {+		bool r = (open != o);+		rotation = (o) ? Math.PI_2 : 0;+		+		if (o) {+			margin = 35 * (int)((tool.length () / 4.0) + 1) ;+			rotation = Math.PI_2;			+			if (tool.length () % 4 == 0) {+				margin -= 35;+			}+		} else {+			margin = 0;+			rotation = 0; +		}+		+		open = o;+		return r;+	}+	+	public void draw (int wd, int hd, Context cr) {+		double lx, ly;+		double ih2 = 5.4 / 2;+		double iw2 = 5.4 / 2;+		+		// box+		cr.save ();+		cr.set_line_join (LineJoin.ROUND);+		cr.set_line_width(7);+		cr.set_source_rgba (176/255.0, 211/255.0, 230/255.0, opacity);+		cr.rectangle (x, y, w, h);+		cr.stroke ();+		cr.restore ();+		+		// arrow+		cr.save ();+		+		cr.translate (x + w/2, y + h/2);+		cr.rotate (rotation);++		cr.set_line_width (1);+		cr.set_source_rgba (0, 0, 0, opacity);++		cr.new_path ();+		cr.move_to (-iw2, -ih2);+		cr.line_to (iw2, 0);	+		cr.line_to (-iw2, +ih2);++		cr.close_path();+		cr.stroke ();+		cr.restore ();+		+		// separator+		cr.save ();+		lx = x + w + 7;+		ly = y + ih2;+		if (lx < wd) {+			cr.set_line_width(1);+			cr.set_source_rgba (0, 0, 0, 0.2);+			cr.move_to (lx, ly);+			cr.line_to (wd - w - x + 4, ly);	+			cr.stroke ();+		}+		cr.restore ();++	}+	+	public void draw_content (int w, int h, Context cr) {+		if (open) {+			cr.save ();+			foreach (var t in tool) {+				t.draw (cr);+			}+			cr.restore ();+		}+	}+	+}++}diff --git a/src/ExportTool.vala b/src/ExportTool.valaindex b936ffb..df40d52 100644--- a/src/ExportTool.vala+++ b/src/ExportTool.vala@@ -17,7 +17,7 @@  namespace Supplement { -class ExportTool : Tool {+public class ExportTool : Tool {  	private static string? prefered_browser = null; 	private static ExportThread export_thread;@@ -496,7 +496,7 @@ os.put_string ( 	}  -	class ExportThread : GLib.Object {+	public class ExportThread : GLib.Object {  		private string ffi; 		private string ttf;diff --git a/src/Font.vala b/src/Font.valaindex f279e44..8e8cc77 100644--- a/src/Font.vala+++ b/src/Font.vala@@ -20,7 +20,7 @@ using Xml;  namespace Supplement { -class Font : GLib.Object {+public class Font : GLib.Object { 	 	GlyphTable glyph_cache = new GlyphTable (); 	diff --git a/src/FontDisplay.vala b/src/FontDisplay.valaindex 9275a57..020dd6b 100644--- a/src/FontDisplay.vala+++ b/src/FontDisplay.vala@@ -23,12 +23,12 @@ using Birdfont; namespace Supplement {  /** Javascripts in webkit do use this callback. */-internal class PropertyFunction {+public class PropertyFunction { 	public delegate void PropertyCallback (string val); 	public PropertyCallback call; } -internal abstract class FontDisplay : GLib.Object {+public abstract class FontDisplay : GLib.Object { 	 	List<string> property = new List<string> (); 	List<PropertyFunction> call = new List<PropertyFunction> ();diff --git a/src/Glyph.vala b/src/Glyph.valaindex ebcb25c..eed7c6a 100644--- a/src/Glyph.vala+++ b/src/Glyph.vala@@ -22,7 +22,7 @@ using Math;  namespace Supplement { -class Glyph : FontDisplay {+public class Glyph : FontDisplay {  	public const double SCALE = 1.0; diff --git a/src/GlyphBackgroundImage.vala b/src/GlyphBackgroundImage.valaindex a976be5..4f29cca 100644--- a/src/GlyphBackgroundImage.vala+++ b/src/GlyphBackgroundImage.vala@@ -22,7 +22,7 @@ using Math;  namespace Supplement { 	-class GlyphBackgroundImage {+public class GlyphBackgroundImage { 		 	public double img_x = 0; 	public double img_y = 0;diff --git a/src/GlyphCanvas.vala b/src/GlyphCanvas.valaindex ba89d9e..5ea856c 100644--- a/src/GlyphCanvas.vala+++ b/src/GlyphCanvas.vala@@ -22,7 +22,7 @@ using Math; 
 namespace Supplement {
 
-class GlyphCanvas : DrawingArea  {
+public class GlyphCanvas : DrawingArea  {
 
 	FontDisplay current_display;
 	
diff --git a/src/GlyphCollection.vala b/src/GlyphCollection.valaindex 55e944d..6024037 100644--- a/src/GlyphCollection.vala+++ b/src/GlyphCollection.vala@@ -22,7 +22,7 @@ using Math;  namespace Supplement { -class GlyphCollection : GLib.Object {+public class GlyphCollection : GLib.Object { 	VersionList versions; 	 	public GlyphCollection (Glyph? current = null) {diff --git a/src/GlyphRange.vala b/src/GlyphRange.valaindex d12481d..ddc638d 100644--- a/src/GlyphRange.vala+++ b/src/GlyphRange.vala@@ -17,7 +17,7 @@  namespace Supplement { -class GlyphRange {+public class GlyphRange { 	 	List<UniRange> ranges; 	diff --git a/src/GtkInterface.vala b/src/GtkInterface.valaindex 5ae9fc9..1244f5f 100644--- a/src/GtkInterface.vala+++ b/src/GtkInterface.vala@@ -54,8 +54,7 @@ public class GtkWindow : Gtk.Window, NativeWindow { 		html_canvas.get_settings ().enable_default_context_menu = false; 				 		html_canvas.title_changed.connect ((p, s) => {-			FontDisplay fd = MainWindow.get_current_display ();-			fd.process_property (s);+			webkit_callback (s); 		}); 		 		html_box = new ScrolledWindow (null, null);@@ -153,6 +152,23 @@ public class GtkWindow : Gtk.Window, NativeWindow { 	 	} +	void set_first_view () {+/*//FIXA		IdleSource idle = new IdleSource ();+		idle.set_callback(() => {+			if (args.get_file () != "") {+				Supplement.get_current_font ().load (args.get_file ());+				MainWindow.get_toolbox ().select_tool_by_name ("available_characters");+			} else {+				MainWindow.get_tab_bar ().select_tab_name ("Menu");+			}+			+			return false;+		});+		+		idle.attach (null);		+*/+	}+ 	internal void toggle_expanded_margin_bottom () { 		int w, h; 		margin_bottom.get_size_request (out w, out h);diff --git a/src/Icons.vala b/src/Icons.valaindex 5705383..3dc19f3 100644--- a/src/Icons.vala+++ b/src/Icons.vala@@ -19,7 +19,7 @@ namespace Supplement {  using Cairo;	 -class Icons {+public class Icons { 	 	public static ImageSurface? get_icon (string? name) { 		ImageSurface? img = null;diff --git a/src/Kerning.vala b/src/Kerning.valaindex af54573..537e57f 100644--- a/src/Kerning.vala+++ b/src/Kerning.vala@@ -20,7 +20,7 @@ using Xml;  namespace Supplement { -class Kerning : GLib.Object {+public class Kerning : GLib.Object { 	public string glyph_right; 	public double val; 	diff --git a/src/KeyBindings.vala b/src/KeyBindings.valaindex 4c5bba4..5e06ca7 100644--- a/src/KeyBindings.vala+++ b/src/KeyBindings.vala@@ -19,7 +19,7 @@ using Gdk;  namespace Supplement { -enum Key {+public enum Key { 	NONE = 0, 	UP = 65362, 	RIGHT = 65363,@@ -68,17 +68,17 @@ bool is_modifier_key (uint i) { }  /** Modifier flags */-internal static const uint NONE  = 0;-internal static const uint CTRL  = 1 << 0;-internal static const uint ALT   = 1 << 2;-internal static const uint SHIFT = 1 << 3;+public static const uint NONE  = 0;+public static const uint CTRL  = 1 << 0;+public static const uint ALT   = 1 << 2;+public static const uint SHIFT = 1 << 3; -internal bool is_mod (EventKey e) {+public bool is_mod (EventKey e) { 	return (e.keyval == Key.CTRL_RIGHT || e.keyval == Key.CTRL_LEFT || e.keyval == Key.ALT_RIGHT || e.keyval == Key.ALT_LEFT); }  /** A list of all valid key bindings. */-class BindingList {+public class BindingList { 	static ShortCut[]? nc = null; 	 	public static ShortCut[] get_default_bindings () {	@@ -274,7 +274,7 @@ class CloseTab : ShortCut { }  /** Function to be executed for each global key binding. */-abstract class ShortCut : GLib.Object {+public abstract class ShortCut : GLib.Object { 	uint modifier = 0; 	uint key = 0; 	@@ -310,7 +310,7 @@ abstract class ShortCut : GLib.Object { 	 } -class KeyBindings {+public class KeyBindings { 	 	bool modifier_ctrl = false; 	bool modifier_alt = false;diff --git a/src/Line.vala b/src/Line.valaindex 9b23057..a923818 100644--- a/src/Line.vala+++ b/src/Line.vala@@ -22,7 +22,7 @@ using Gdk; namespace Supplement {  /** Help line */-class Line : GLib.Object {+public class Line : GLib.Object { 	public static const bool VERTICAL = true; 	public static const bool HOROIZONTAL = false; 	diff --git a/src/Main.vala b/src/Main.valaindex e3c774c..20b0b64 100644--- a/src/Main.vala+++ b/src/Main.vala@@ -16,7 +16,19 @@ */  using Birdfont;+using Supplement; 	 public static int main (string[] arg) {-	return run_gui (arg);+	Supplement.Supplement supplement = new Supplement.Supplement ();+	+	supplement.init (arg);+	+	Gtk.init (ref arg);+	MainWindow window = new MainWindow ();+	GtkWindow native_window = new GtkWindow ("birdfont");	+	window.set_native (native_window);+	Gtk.main ();++	return 0; }+diff --git a/src/MainWindow.vala b/src/MainWindow.valaindex 8663341..1c1921f 100644--- a/src/MainWindow.vala+++ b/src/MainWindow.vala@@ -17,11 +17,10 @@ 
 using Gdk;
 using Gtk;
-using WebKit;
 
 namespace Supplement {
 
-internal class MainWindow {
+public class MainWindow {
 	
 	public static Toolbox tools;
 	public static GlyphCanvas glyph_canvas;
@@ -69,7 +68,7 @@ internal class MainWindow { 		return get_glyph_canvas ().get_current_display ();
 	}
 	
-	internal static GlyphCanvas get_glyph_canvas () {
+	public static GlyphCanvas get_glyph_canvas () {
 		return glyph_canvas;
 	}
 	
@@ -90,7 +89,7 @@ internal class MainWindow { 		return get_singleton ().tools.get_tool (n);
 	}
 	
-	internal static TabBar get_tab_bar () {
+	public static TabBar get_tab_bar () {
 		return get_singleton ().tabs;
 	}
 
diff --git a/src/MenuTab.vala b/src/MenuTab.valaindex 1d32530..5cb4a12 100644--- a/src/MenuTab.vala+++ b/src/MenuTab.vala@@ -19,7 +19,7 @@ using WebKit;  namespace Supplement { -class MenuTab : FontDisplay {	+public class MenuTab : FontDisplay {	 	 	List<Font> recent_fonts = new List<Font> (); diff --git a/src/NativeWindow.vala b/src/NativeWindow.valaindex 1676055..3adf50b 100644--- a/src/NativeWindow.vala+++ b/src/NativeWindow.vala@@ -15,6 +15,8 @@     along with this program.  If not, see <http://www.gnu.org/licenses/>. */ +namespace Supplement {+ public interface NativeWindow : GLib.Object { 	public abstract string? file_chooser (string title); 	public abstract string? set_title (string title);@@ -23,4 +25,11 @@ public interface NativeWindow : GLib.Object { 	public abstract void toggle_expanded_margin_right (); 	 	public abstract void update_window_size ();++	protected void webkit_callback (string s) {+		FontDisplay fd = MainWindow.get_current_display ();+		fd.process_property (s);+	}+}+ }diff --git a/src/OverView.vala b/src/OverView.valaindex 3fc23fc..27e669b 100644--- a/src/OverView.vala+++ b/src/OverView.vala@@ -22,7 +22,7 @@ using Gdk; namespace Supplement {  /** A display with all glyphs present in this font. */-class OverView : FontDisplay {+public class OverView : FontDisplay { 	Allocation allocation; 	 	int rows = 0;diff --git a/src/Path.vala b/src/Path.valaindex 6357fea..3fe19a2 100644--- a/src/Path.vala+++ b/src/Path.vala@@ -22,12 +22,12 @@ using Math;  namespace Supplement { -enum Direction {+public enum Direction { 	CLOCKWISE, 	COUNTER_CLOCKWISE } -class Path {+public class Path { 	 	public List<EditPoint> points = new List<EditPoint> (); @@ -76,14 +76,6 @@ class Path { 		return points.length () == 0; 	} -	public void set_selected (bool s) {-		selected = s;-	}--	public bool is_selected () {-		return selected;-	}- 	public void draw_outline (Context cr, Allocation allocation, double view_zoom) { 		unowned List<EditPoint> ep = points; 		@@ -96,7 +88,7 @@ class Path { 		} 		 		cr.new_path ();-					+		 		// draw lines 		foreach (EditPoint e in ep) { 			if (n != null) {@@ -1883,7 +1875,7 @@ class Path {  } -class PathList : GLib.Object {+public class PathList : GLib.Object { 	public List<Path> paths = new List<Path> (); 	 	public PathList () {diff --git a/src/Preferences.vala b/src/Preferences.valaindex 9bca886..d3202bf 100644--- a/src/Preferences.vala+++ b/src/Preferences.vala@@ -16,7 +16,7 @@ */ namespace Supplement { -internal class Preferences {+public class Preferences { 		 	static HashTable<string, string> data; diff --git a/src/SaveDialog.vala b/src/SaveDialog.valaindex 2c70794..f7a1adb 100644--- a/src/SaveDialog.vala+++ b/src/SaveDialog.vala@@ -21,7 +21,7 @@ using Cairo;  namespace Supplement { -class SaveDialog : FontDisplay {+public class SaveDialog : FontDisplay {  	public signal void finished (); diff --git a/src/SpinButton.vala b/src/SpinButton.valaindex 6b5dcb6..ada3936 100644--- a/src/SpinButton.vala+++ b/src/SpinButton.vala@@ -21,7 +21,7 @@ using Gdk;  namespace Supplement { -class SpinButton : Tool {+public class SpinButton : Tool {  	public signal void new_value_action (SpinButton selected); 	diff --git a/src/Supplement.vala b/src/Supplement.valaindex f649687..203e3e5 100644--- a/src/Supplement.vala+++ b/src/Supplement.vala@@ -17,10 +17,11 @@ 
 using Gtk;
 using Supplement;
+using Birdfont;
 
 namespace Supplement {
 
-internal class Supplement {
+public class Supplement {
 	internal static Argument args;
 	internal static bool experimental = false;
 	internal static bool show_coordinates = false;
@@ -31,7 +32,74 @@ internal class Supplement { 	internal static Font current_font;
 	internal static Glyph current_glyph;
 	
-	internal static Font get_current_font () {
+	public void init (string[] arg) {
+		int err_arg;
+		int i;
+		File font_file;
+		Argument args;
+		IdleSource idle;
+		string exec_path;
+
+		stdout.printf ("birdfont version %s\n", VERSION);
+		stdout.printf ("built on %s\n", BUILD_TIMESTAMP);
+		
+		args = new Argument.command_line (arg);
+
+		if (args.has_argument ("--help")) {
+			args.print_help ();
+			Process.exit (0);
+		}
+
+		err_arg = args.validate ();
+		if (err_arg != 0) {
+			stdout.printf (@"Unknown parameter $(arg [err_arg])\n\n");
+			args.print_help ();
+			Process.exit (0);
+		}
+
+		current_font = new Font ();
+		current_glyph = new Glyph ("");
+
+		experimental = args.has_argument ("--test");
+		show_coordinates = args.has_argument ("--show-coordinates");
+		fatal_wanings = args.has_argument ("--fatal-warning");
+		win32 = (arg[0].index_of (".exe") > -1) || arg[0] == "wine";
+		exec_path = "";
+
+		if (win32) {
+			// wine hack to get "." folder in win32 environment
+			i = arg[0].last_index_of ("\\");
+			
+			if (i != -1) {	
+				exec_path = arg[0];
+				exec_path = exec_path.substring (0, i);
+				exec_path = wine_to_unix_path (exec_path);			
+			}
+		} else {
+			exec_path = "./";
+		}
+		
+		Preferences preferences = new Preferences ();
+		preferences.load ();
+		
+		if (args.get_file () != "") {
+			font_file = File.new_for_path (args.get_file ());
+			
+			if (!font_file.query_exists ()) {
+				stderr.printf (@"File $(args.get_file ()) not found.");
+				Process.exit (-1);
+			}
+		}
+
+		if (fatal_wanings) {
+			LogLevelFlags levels = LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL | LogLevelFlags.LEVEL_WARNING;
+			Log.set_handler (null, levels, fatal_warning);
+		}
+		
+		preferences.set_last_file (get_current_font ().get_path ());
+	}
+	
+	public static Font get_current_font () {
 		return current_font;
 	}
 
diff --git a/src/TabBar.vala b/src/TabBar.valaindex 055509a..b46d4fd 100644--- a/src/TabBar.vala+++ b/src/TabBar.vala@@ -19,7 +19,7 @@ using Cairo;  namespace Supplement { -class TabBar : GLib.Object {+public class TabBar : GLib.Object { 	 	int width = 0; 	int height = 0;@@ -565,7 +565,7 @@ class TabBar : GLib.Object { 	} } -class Tab : GLib.Object {+public class Tab : GLib.Object {  	bool always_open; 	double width; diff --git a/src/Tool.vala b/src/Tool.valaindex 403fe0f..3a7f37b 100644--- a/src/Tool.vala+++ b/src/Tool.vala@@ -19,7 +19,7 @@ using Cairo;  namespace Supplement { -class Tool : GLib.Object {+public class Tool : GLib.Object { 	 	public double x = 0; 	public double y = 0;diff --git a/src/Toolbox.vala b/src/Toolbox.valaindex 8d90ecf..aadc439 100644--- a/src/Toolbox.vala+++ b/src/Toolbox.vala@@ -20,7 +20,7 @@ using Math;  namespace Supplement { -class Toolbox : GLib.Object  {+public class Toolbox : GLib.Object  { 	GlyphCanvas glyph_canvas; 	 	bool expanded = true;@@ -845,206 +845,4 @@ class ToolboxExpander : Expander { 	} } -class Expander : GLib.Object {-	-	public double x = 7;-	public double y = 5;--	public double w = 6;-	public double h = 5;-	-	public double margin = 0;-	-	protected double rotation = 0;-	protected double opacity = 0.5;-	-	protected bool active = false;-	protected bool open = false;--	public List<Tool> tool;--	bool persist = false;-	bool unique = false;-	-	public Expander () {-	}--	/** Returns true if tools can be used with the current canvas after-	 * they have been selectes and false if they are a commands to be executed.-	 */-	public bool is_persistent () {-		return persist;-	}--	/** Returns true if all other tools in thid expander should be deselected -	 * when a tool is selected.-	 */-	public bool is_unique () {-		return unique;-	}--	public void set_persistent (bool p) {-		persist = p;-	}--	public void set_unique (bool u) {-		unique = u;-	}-	-	private void update_tool_position () {-		int i = 0;-		double xt = x + 10;-		double yt = y - 4;-		foreach (var t in tool) {-			t.set_properties (xt, yt, w, h);-			-			if (i == 3) {-				yt += 31;-				i = 0;-				xt = x + 10;-			} else {-				i++;-				xt += w + 3 + 25;-			}-		}-	}-	-	public void set_offset (double ty) {-		y = ty;-		-		if (open) {-			update_tool_position ();-		}-	}-	-	public void add_tool (Tool t) {-		tool.append (t);-		update_tool_position ();-		-		t.select_action.connect ((selected) => {-				if (!selected.new_selection) {-					if (is_persistent ()) {-						selected.set_selected (true);-					} else {-						selected.set_selected (false);-					}-				}-			-				MainWindow.get_toolbox ().redraw ((int) x, (int) y, (int) w  + 300, (int) (h + margin));-			-				if (is_unique ()) {-					foreach (var deselected in tool) {-						if (selected.get_id () != deselected.get_id ()) {-							deselected.set_selected (false);-						}-					}-				}--				if (!is_persistent ()) {-						var time = new TimeoutSource(200);-						time.set_callback(() => {-							selected.set_selected (false);-							MainWindow.get_toolbox ().redraw ((int) x, (int) y, (int) w  + 300, (int) (h + margin));-							return false;-						});-						time.attach(null);-				}--				selected.new_selection = false;-			});-	}-	-	public bool is_over (double xp, double yp) {	-		return (x - 7/2.0 <= xp <= x + w  + 7/2.0 && y - 7/2.0<= yp <= y + w + 7/2.0);  -	}-	-	public bool set_active (bool a) {-		bool r = (active != a);-		opacity = (a) ? 1 : 0;-		active = a;-		return r;-	}-	-	public bool is_open () {-		return open;-	}-	-	public virtual bool set_open (bool o) {-		bool r = (open != o);-		rotation = (o) ? Math.PI_2 : 0;-		-		if (o) {-			margin = 35 * (int)((tool.length () / 4.0) + 1) ;-			rotation = Math.PI_2;			-			if (tool.length () % 4 == 0) {-				margin -= 35;-			}-		} else {-			margin = 0;-			rotation = 0; -		}-		-		open = o;-		return r;-	}-	-	public void draw (int wd, int hd, Context cr) {-		double lx, ly;-		double ih2 = 5.4 / 2;-		double iw2 = 5.4 / 2;-		-		// box-		cr.save ();-		cr.set_line_join (LineJoin.ROUND);-		cr.set_line_width(7);-		cr.set_source_rgba (176/255.0, 211/255.0, 230/255.0, opacity);-		cr.rectangle (x, y, w, h);-		cr.stroke ();-		cr.restore ();-		-		// arrow-		cr.save ();-		-		cr.translate (x + w/2, y + h/2);-		cr.rotate (rotation);--		cr.set_line_width (1);-		cr.set_source_rgba (0, 0, 0, opacity);--		cr.new_path ();-		cr.move_to (-iw2, -ih2);-		cr.line_to (iw2, 0);	-		cr.line_to (-iw2, +ih2);--		cr.close_path();-		cr.stroke ();-		cr.restore ();-		-		// separator-		cr.save ();-		lx = x + w + 7;-		ly = y + ih2;-		if (lx < wd) {-			cr.set_line_width(1);-			cr.set_source_rgba (0, 0, 0, 0.2);-			cr.move_to (lx, ly);-			cr.line_to (wd - w - x + 4, ly);	-			cr.stroke ();-		}-		cr.restore ();--	}-	-	public void draw_content (int w, int h, Context cr) {-		if (open) {-			cr.save ();-			foreach (var t in tool) {-				t.draw (cr);-			}-			cr.restore ();-		}-	}-	-}- }diff --git a/src/TooltipArea.vala b/src/TooltipArea.valaindex 7cecb1e..64b2a2d 100644--- a/src/TooltipArea.vala+++ b/src/TooltipArea.vala@@ -21,7 +21,7 @@ using Gtk;  namespace Supplement { -class TooltipArea : DrawingArea {+public class TooltipArea : DrawingArea {  	string tool_tip; diff --git a/src/UniRange.vala b/src/UniRange.valaindex f097bd9..fcfdc11 100644--- a/src/UniRange.vala+++ b/src/UniRange.vala@@ -15,33 +15,35 @@     along with this program.  If not, see <http://www.gnu.org/licenses/>. */ -namespace Supplement {	-	class UniRange : GLib.Object {-		-		public unichar start;-		public unichar stop;+namespace Supplement {+	+public class UniRange : GLib.Object {+	+	public unichar start;+	public unichar stop;+	+	public UniRange (unichar start, unichar stop) {+		this.start = start;+		this.stop = stop;+	}+	+	public unichar length () {+		return stop - start + 1;+	}++	public unichar get_char (unichar index) {+		unichar result = start + index; 		-		public UniRange (unichar start, unichar stop) {-			this.start = start;-			this.stop = stop;+		if (unlikely (index < 0)) {+			warning ("Index is negative in UniRange."); 		} 		-		public unichar length () {-			return stop - start + 1;-		}--		public unichar get_char (unichar index) {-			unichar result = start + index;-			-			if (unlikely (index < 0)) {-				warning ("Index is negative in UniRange.");-			}-			-			if (unlikely (!(start <= result <= stop))) {-				warning ("Index out of range in UniRange (%u <= %u <= %u) (index: %u)\n", start, result, stop, index);-			}-			-			return result;+		if (unlikely (!(start <= result <= stop))) {+			warning ("Index out of range in UniRange (%u <= %u <= %u) (index: %u)\n", start, result, stop, index); 		}+		+		return result; 	} }++}diff --git a/src/VersionList.vala b/src/VersionList.valaindex f41ae6c..ca36c64 100644--- a/src/VersionList.vala+++ b/src/VersionList.vala@@ -22,7 +22,7 @@ using Math;  namespace Supplement { -class VersionList : DropMenu {+public class VersionList : DropMenu { 	int versions = 1; 	int current_version = 0; 	public List<Glyph> glyphs = new List<Glyph> ();diff --git a/src/wscript b/src/wscriptindex 9e8e83e..3cbc135 100644--- a/src/wscript+++ b/src/wscript@@ -5,6 +5,7 @@ BIRDFONT = [ 	'BackgroundSelection.vala', 	'Birdfont.vala', 	'EotWriter.vala',+	'Expander.vala', 	'ExportTool.vala', 	'FontDisplay.vala', 	'CharDatabase.vala',@@ -23,7 +24,6 @@ BIRDFONT = [ 	'GlyphRange.vala', 	'GlyphTable.vala', 	'GridTool.vala',-	'GtkInterface.vala', 	'Icons.vala', 	'Kerning.vala',  	'KeyBindings.vala', @@ -62,14 +62,6 @@ BIRDFONT = [ 	'ZoomTool.vala', ] -BIRDFONT_MAIN = [-	'Main.vala'-]--BIRDFONT_EXPORT = [-	'BirdfontExport.vala'-]- PARAM = [ 	'--thread', 	'--disable-warnings',@@ -96,7 +88,7 @@ def build (bld): 	) 	 	bld (-		rule = 'valac -C ./src/birdfont.vapi ../src/Main.vala -X ../build/src/libbirdfont.so -X ./birdfont.h --pkg gtk+-2.0 --pkg libxml-2.0 --pkg gdk-2.0 --pkg webkit-1.0',+		rule = 'valac -C ./src/birdfont.vapi ../src/Main.vala ../src/GtkInterface.vala -X ../build/src/libbirdfont.so -X ./birdfont.h --pkg gtk+-2.0 --pkg libxml-2.0 --pkg gdk-2.0 --pkg webkit-1.0', 		name = 'main_c', 		target = '../Main.c', 		depends = 'libbirdfont'@@ -110,7 +102,7 @@ def build (bld): 	)  	bld (-		rule = 'gcc  ../build/Main.c -I../build/ -L  ../build/src -l birdfont -o ${TGT} \+		rule = 'gcc ../build/Main.c ../build/GtkInterface.c -I ../build/ -I ../build/src -L ../build/src -l birdfont -o ${TGT} \ 				$(pkg-config --cflags --libs glib-2.0) \ 				$(pkg-config --cflags --libs libxml-2.0) \ 				$(pkg-config --cflags --libs gio-2.0) \

Contact

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