Clone in a terminal:
Commit 797d163
Johan Mattsson - 2013-01-28T13:27:29+00:00
797d1631e8889bf4ed23802e989bfd28e138bf2ajohan.mattsson.m@gmail.com

Use MacBook features on Linux

Changed files (3)

Diff

diff --git a/birdfont/GtkWindow.vala b/birdfont/GtkWindow.valaindex bc20361..238a70b 100644--- a/birdfont/GtkWindow.vala+++ b/birdfont/GtkWindow.vala@@ -752,20 +752,6 @@ public class GlyphCanvasArea : DrawingArea  { 	GlyphCanvas glyph_canvas; 	Gtk.Allocation alloc; -#if LINUX-	/* State on linux */-	public static const int STATE_SHIFT = 17;-	public static const int STATE_CTRL = 20;-	public static const int STATE_SHIFT_CTRL = 21;-	public static const int STATE_LEFT_LOGO = 80;-#else-	/* State on windows and mac */-	public static const int STATE_SHIFT = 1;-	public static const int STATE_CTRL = 4;-	public static const int STATE_SHIFT_CTRL = 5;-	public static const int STATE_LEFT_LOGO = 16;	-#endif- 	public GlyphCanvasArea (GlyphCanvas gc) { 		int event_flags; 		@@ -871,23 +857,17 @@ public class GlyphCanvasArea : DrawingArea  { 	}  	static void set_modifier (int k) {-		switch (k) {-			case STATE_SHIFT:-				KeyBindings.set_modifier (SHIFT);-				break;-			case STATE_CTRL:-				KeyBindings.set_modifier (CTRL);-				break;-			case STATE_SHIFT_CTRL:-				KeyBindings.set_modifier (SHIFT | CTRL);-				break;-			case STATE_LEFT_LOGO:-				KeyBindings.set_modifier (LOGO);-				break;-			default:-				KeyBindings.set_modifier (NONE);-				break;-		}		+		if (has_flag (k, ModifierType.MOD5_MASK)) {+			KeyBindings.set_modifier (LOGO);+		} else if (has_flag (k, ModifierType.SHIFT_MASK)) {+			KeyBindings.set_modifier (SHIFT);+		} else if (has_flag (k, ModifierType.CONTROL_MASK)) {+			KeyBindings.set_modifier (CTRL);+		} else if (has_flag (k, ModifierType.CONTROL_MASK | ModifierType.SHIFT_MASK)) {+			KeyBindings.set_modifier (SHIFT | CTRL);+		} else {+			KeyBindings.set_modifier (NONE);+		}  	} } diff --git a/libbirdfont/Argument.vala b/libbirdfont/Argument.valaindex 623a50b..ab6b108 100644--- a/libbirdfont/Argument.vala+++ b/libbirdfont/Argument.vala@@ -34,7 +34,7 @@ public class Argument : GLib.Object { 		} 	} 	-	/** returns 0 if valid or index the bad parameter. */ +	/** returns 0 if all arguments are valid or index of the invalid parameter. */  	public int validate () { 		string prev = ""; 		int i = 0;@@ -59,8 +59,14 @@ public class Argument : GLib.Object { 				a = expand_param (a); 			} 			-			// valid parameter-			if (a == "--exit" || a == "--slow" || a == "--help" || a == "--test" || a == "--fatal-warning" || a == "--show-coordinates") {+			// valid parameters+			if (a == "--exit" || +				a == "--slow" || +				a == "--help" ||+				a == "--test" || +				a == "--fatal-warning" || +				a == "--show-coordinates" || +				a == "--mac") { 				prev = a; 				i++; 				continue;@@ -186,6 +192,8 @@ public class Argument : GLib.Object { 				return "--fatal-warning"; 			case 'h':  				return "--help";+			case 'm': +				return "--mac"; 			case 's':  				return "--slow"; 			case 't': @@ -230,6 +238,7 @@ public class Argument : GLib.Object { 		print_padded ("-e, --exit", _("exit if a test case failes")); 		print_padded ("-f, --fatal-warning", _("treat warnings as fatal")); 		print_padded ("-h, --help", _("show this message"));+		print_padded ("-m, --mac", _("enable Machintosh customizations")); 		print_padded ("-s, --slow", _("sleep between each command in test suite")); 		print_padded ("-t, --test [TEST]", _("run test case")); 		diff --git a/libbirdfont/Supplement.vala b/libbirdfont/Supplement.valaindex ab1e785..53d892f 100644--- a/libbirdfont/Supplement.vala+++ b/libbirdfont/Supplement.vala@@ -44,7 +44,7 @@ public class Supplement { 		stdout.printf ("built on %s\n", BUILD_TIMESTAMP);
 		 #if MAC-		Supplement.mac = true;+		mac = true; #endif 		
 		init_gettext ();		
@@ -73,6 +73,8 @@ public class Supplement { 		show_coordinates = args.has_argument ("--show-coordinates");
 		fatal_wanings = args.has_argument ("--fatal-warning");
 		win32 = (arg[0].index_of (".exe") > -1) || arg[0] == "wine";
+		mac = args.has_argument ("--mac");
+		
 		exec_path = "";
 
 		if (win32) {
@@ -224,4 +226,8 @@ public bool is_null (void* n) { 	return n == null;
 }
 
+public bool has_flag (uint32 a, uint32 b) {
+	return (a & b) > 0;
+}
+
 }

Contact

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