Clone in a terminal:
Commit ae68a20
Johan Mattsson - 2012-12-07T14:04:40+00:00
ae68a2000b4773e075faf87a394c6c66babf1410johan.mattsson.m@gmail.com

keep editor tabs open in windows preview

Changed files (8)

Diff

diff --git a/src/DropMenu.vala b/src/DropMenu.valaindex 6cd5c86..f7387c9 100644--- a/src/DropMenu.vala+++ b/src/DropMenu.vala@@ -198,44 +198,4 @@ public class DropMenu : GLib.Object { 	} } -public class MenuAction : GLib.Object {-	public string label;-	public DropMenu.Selected action;-	public DropMenu? parent = null;-	public int index = -1;-	bool selected = false;-	-	public MenuAction (string label) {-		this.label = label;-	}-	-	public void set_selected (bool s) {-		selected = s;-	}-	-	public virtual void draw (double x, double y, Context cr) {-		if (selected) {-			cr.save ();-			cr.set_line_join (LineJoin.ROUND);-			cr.set_line_width (12);-			cr.set_source_rgba (102/255.0, 120/255.0, 149/255.0, 1);-			cr.rectangle (x - 2, y - 9, 88, 8);-			cr.fill_preserve ();-			cr.stroke ();-			cr.restore ();			-		}-		-		cr.save ();-		cr.set_source_rgba (1, 1, 1, 1);-		-		cr.set_font_size (12);-		cr.select_font_face ("Cantarell", FontSlant.NORMAL, FontWeight.NORMAL);-		-		cr.move_to (x, y);--		cr.show_text (label);-		cr.restore ();-	}-}- }diff --git a/src/ExportTool.vala b/src/ExportTool.valaindex 714fff6..97fcbc8 100644--- a/src/ExportTool.vala+++ b/src/ExportTool.vala@@ -361,9 +361,10 @@ os.put_string ( 		string export_command; 		 		if (Supplement.win32) {+			VersionList.set_suppress_signal (true); 			async = false; 		}-+		 		try { 			// create a copy of current font and use it in a separate  			// export thread@@ -409,6 +410,10 @@ os.put_string ( 			critical (@"$(e.message)"); 			done = false; 		}++		if (Supplement.win32) {+			VersionList.set_suppress_signal (false);+		} 		 		return done;		 	}diff --git a/src/Glyph.vala b/src/Glyph.valaindex 5faeb4b..2440a0b 100644--- a/src/Glyph.vala+++ b/src/Glyph.vala@@ -22,7 +22,7 @@ namespace Supplement {  public class Glyph : FontDisplay { -	public const double SCALE = 1.0;+	public static const double SCALE = 1.0;  	// Background image 	GlyphBackgroundImage? background_image = null;@@ -82,11 +82,10 @@ public class Glyph : FontDisplay { 	public unichar unichar_code = 0; 	 	List<Glyph> undo_list = new List<Glyph> ();-+	 	public List<Kerning> kerning = new List<Kerning> (); 	 	string glyph_sequence = "";-	 	bool open = true; 	 	public Glyph (string name, unichar unichar_code = 0) {@@ -1458,6 +1457,15 @@ public class Glyph : FontDisplay { 		return g; 	} +	public void reload () {+		Glyph g;+		Font f = Supplement.get_current_font ();+		+		if (f.has_glyph (name)) {+			set_glyph_data ((!) f.get_glyph (name));+		}+	}+ 	public override void undo () { 		Glyph g; 		@@ -1465,8 +1473,13 @@ public class Glyph : FontDisplay { 			return; 		} 		-		g = undo_list.last ().data;+		g = undo_list.last ().data;	+		set_glyph_data (g); 		+		undo_list.remove_link (undo_list.last ());+	}+	+	void set_glyph_data (Glyph g) { 		while (path_list.length () > 0) { 			path_list.remove_link (path_list.last ()); 		}@@ -1491,12 +1504,10 @@ public class Glyph : FontDisplay { 			add_active_path (p); 		} 		-		undo_list.remove_link (undo_list.last ());-		 		open_path (); 		close_path (); 		-		redraw_area (0, 0, allocation.width, allocation.height);+		redraw_area (0, 0, allocation.width, allocation.height);		 	} 	 	public ImageSurface get_thumbnail () {diff --git a/src/GtkWindow.vala b/src/GtkWindow.valaindex e354ff7..d0d1498 100644--- a/src/GtkWindow.vala+++ b/src/GtkWindow.vala@@ -65,9 +65,7 @@ public class GtkWindow : Gtk.Window, NativeWindow { 		 		html_box = new ScrolledWindow (null, null); 		html_box.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);-		 		html_box.add (html_canvas);-		 		html_canvas.set_editable (true); 		 		MainWindow.get_tab_bar ().signal_tab_selected.connect ((f, tab) => {diff --git a/src/MainWindow.vala b/src/MainWindow.valaindex e881138..9c2c4a1 100644--- a/src/MainWindow.vala+++ b/src/MainWindow.vala@@ -146,7 +146,7 @@ public class MainWindow { 	internal static void close_all_tabs () {
 		uint i = 0;
 		uint len = get_tab_bar ().get_length ();
-
+		
 		while (i < len) {
 			if (!get_tab_bar ().close_tab ((int) i)) {
 				i++;
diff --git a/src/TabBar.vala b/src/TabBar.valaindex b46d4fd..6364a12 100644--- a/src/TabBar.vala+++ b/src/TabBar.vala@@ -194,8 +194,8 @@ public class TabBar : GLib.Object { 		 		return_if_fail (i != -1); 	} -	-	public bool close_tab (int index, bool background_tab = false) {++	public bool close_tab (int index, bool background_tab = false) {	 		unowned List<Tab?>? lt; 		Tab t; 		@@ -262,6 +262,16 @@ public class TabBar : GLib.Object { 		return false; 	} +	public Tab? get_tab (string name) {+		foreach (var n in tabs) {+			if (n.get_label () == name) {+				return n;+			}+		}+		+		return null;+	}+ 	public bool selected_open_tab_by_name (string t) { 		int i = 0; 		foreach (var n in tabs) {@@ -382,15 +392,15 @@ public class TabBar : GLib.Object { 				continue; 			} 			+			// out of view 			if (offset + t.get_width () + 3 > width - 19) {-				// out of view 				first_tab++; 				scroll_to_tab (index); 				return; 			} +			// in view 			if (i == index) {-				// in view 				signal_selected (index); 				return; 			}@@ -421,7 +431,7 @@ public class TabBar : GLib.Object { 		int s = (tabs.length () == 0) ? 0 : selected + 1; 		 		if (tab_width < 0) {-			//cr.text_extents (display_item.get_name (), out te); // this is not a good estimation+			//cr.text_extents (display_item.get_name (), out te); // this is not a good estimation, pango might solve it 			//tab_width = te.width + 30; 			 			tab_width = 9 * display_item.get_name ().char_count ();@@ -565,33 +575,4 @@ public class TabBar : GLib.Object { 	} } -public class Tab : GLib.Object {--	bool always_open;-	double width; -	FontDisplay display;--	public Tab (FontDisplay glyph, double tab_width, bool always_open) {-		width = tab_width;-		this.display = glyph;-		this.always_open = always_open;-	}--	public bool has_close_button () {-		return !always_open;-	}--	public FontDisplay get_display () {-		return display;-	}-	-	public string get_label () {-		return display.get_name ();-	}-	-	public double get_width () {-		return width;-	}-}- }diff --git a/src/VersionList.vala b/src/VersionList.valaindex 18713b4..3ddc5ab 100644--- a/src/VersionList.vala+++ b/src/VersionList.vala@@ -24,6 +24,7 @@ public class VersionList : DropMenu { 	int versions = 1; 	int current_version = 0; 	public List<Glyph> glyphs = new List<Glyph> ();+	public static bool suppress_signal = false;  	public VersionList (Glyph? g = null) { 		base ("version");@@ -45,6 +46,10 @@ public class VersionList : DropMenu { 		} 	} 	+	public static void set_suppress_signal (bool s) {+		suppress_signal = s;+	}+	 	public Glyph get_current () { 		if (unlikely (current_version >= glyphs.length ())) { 			warning (@"current_version >= glyphs.length ($current_version >= $(glyphs.length ()))");@@ -62,7 +67,10 @@ public class VersionList : DropMenu { 	 	private void set_selected_item (MenuAction ma) { 		int i = ma.index;-		+		Tab? t;+		Tab tab;+		Font font = Supplement.get_current_font ();+					 		return_if_fail (0 <= i < glyphs.length ());  		current_version = i;@@ -71,9 +79,9 @@ public class VersionList : DropMenu { 		 		((!)ma.parent).deselect_all (); 		ma.set_selected (true);		-			+		 		if (!is_null (MainWindow.get_tab_bar ())) {-			MainWindow.get_tab_bar ().close_by_name (get_current ().name);			+			MainWindow.get_tab_bar ().close_by_name (get_current ().name); 		}	 	} 	@@ -85,13 +93,20 @@ public class VersionList : DropMenu {  		ma = add_item (_("Version") + @" $(versions - 1)"); 		ma.index = (int) glyphs.length () - 1;+		 		ma.action = (self) => {-			Font font = Supplement.get_current_font ();+			Font font;+			+			if (suppress_signal) {+				return;+			}+			+			font = Supplement.get_current_font (); 			set_selected_item (self); 			font.touch (); 		};-		-		if (selected) {++		if (selected && !suppress_signal) { 			set_selected_item (ma); 		} 	}diff --git a/src/wscript b/src/wscriptindex 96ae341..0b65d60 100644--- a/src/wscript+++ b/src/wscript@@ -30,6 +30,7 @@ BIRDFONT = [ 	'KeyBindings.vala',  	'Line.vala', 	'MainWindow.vala',+	'MenuAction.vala', 	'MenuTab.vala', 	'MergeTool.vala', 	'MoveTool.vala',@@ -52,6 +53,7 @@ BIRDFONT = [ 	'Svg.vala', 	'SvgFontFormatWriter.vala', 	'Preferences.vala',+	'Tab.vala', 	'TabBar.vala', 	'TestCases.vala',  	'TestSupplement.vala', 

Contact

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