Clone in a terminal:
Commit 4ecfcc3
Johan Mattsson - 2012-09-12T14:34:07+00:00
4ecfcc30fd11ee5892e562b83fa629bd493ff11bjohan.mattsson.m@gmail.com

remove Gtk from tool box and it's tools

Changed files (13)

Diff

diff --git a/src/BackgroundSelection.vala b/src/BackgroundSelection.valaindex e1ae6e2..068e53d 100644--- a/src/BackgroundSelection.vala+++ b/src/BackgroundSelection.vala@@ -154,26 +154,16 @@ class BackgroundSelection : FontDisplay { 	}  	private void add_image () {-		FileChooserDialog file_chooser;-		string file;-				-		try {-			file_chooser = new FileChooserDialog ("Add background image", MainWindow.get_current_window (), FileChooserAction.OPEN, Stock.CANCEL, ResponseType.CANCEL, Stock.OPEN, ResponseType.ACCEPT);-			file_chooser.set_current_folder_file (Supplement.get_current_font ().get_folder ());-			-			if (file_chooser.run () == ResponseType.ACCEPT) {-				// Fixa: Set file name relative to font folder-				file = file_chooser.get_filename ();+		string? file; -				Supplement.get_current_font ().add_background_image (file);-				MainWindow.get_glyph_canvas ().redraw ();				-			}+		file = MainWindow.file_chooser ("Add image"); -			file_chooser.destroy ();-		} catch (GLib.Error e) {-			warning (e.message);+		if (file != null) {+			Supplement.get_current_font ().add_background_image ((!) file); 		} 		+		MainWindow.get_glyph_canvas ().redraw ();				+		 		collect_background_images (); 	} diff --git a/src/Birdfont.vala b/src/Birdfont.valaindex 4077798..68d27f1 100644--- a/src/Birdfont.vala+++ b/src/Birdfont.vala@@ -65,8 +65,9 @@ public static int run_gui (string[] arg) { 	} 	 	Gtk.init (ref arg);-	MainWindow window = new MainWindow ("Birdfont");-	window.show_all ();+	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;diff --git a/src/Glyph.vala b/src/Glyph.valaindex 77add90..807940e 100644--- a/src/Glyph.vala+++ b/src/Glyph.vala@@ -623,8 +623,6 @@ class Glyph : FontDisplay { 				t.double_click_action (t, (int) e.button, (int) e.x, (int) e.y); 			} 		}-		-		MainWindow.hide_cursor (); 	}  	/** Insert new edit point for current path on the appropriate zoomdiff --git a/src/GlyphCanvas.vala b/src/GlyphCanvas.valaindex 3b10351..11c6a51 100644--- a/src/GlyphCanvas.vala+++ b/src/GlyphCanvas.vala@@ -47,12 +47,14 @@ class GlyphCanvas : DrawingArea  { 					bool ug = false;
 					
 					if (allocation.height % 2 != 0) {
-						MainWindow.toggle_expanded_margin_bottom ();
+						warning ("MainWindow.toggle_expanded_margin_bottom ();");
+						// MainWindow.toggle_expanded_margin_bottom ();
 						ug = true;
 					}
 					
 					if (allocation.width % 2 != 0) {
-						MainWindow.toggle_expanded_margin_right ();
+						warning ("MainWindow.toggle_expanded_margin_right ();");
+						// MainWindow.toggle_expanded_margin_right ();
 						ug = true;
 					}					
 					
diff --git a/src/Main.vala b/src/Main.valaindex e3c774c..0fb881d 100644--- a/src/Main.vala+++ b/src/Main.vala@@ -18,5 +18,7 @@ using Birdfont; 	 public static int main (string[] arg) {+	GtkWindow gtk_window = new GtkWindow ("Birdfont");+	gtk_window.show_all (); 	return run_gui (arg); }diff --git a/src/MainWindow.vala b/src/MainWindow.valaindex 00b56f8..20c8d77 100644--- a/src/MainWindow.vala+++ b/src/MainWindow.vala@@ -21,195 +21,49 @@ using WebKit; 
 namespace Supplement {
 
-internal class MainWindow : Gtk.Window {
+public interface NativeWindow : GLib.Object {
+	public abstract string? file_chooser (string title);
+	public abstract string? set_title (string title);
+}
 
-	HBox list_box;
-	HBox canvas_box;
+internal class MainWindow {
 	
-	WebView html_canvas;
-	ScrolledWindow html_box;
-		
-	static TabBar tabs;
-	VBox tab_box;
+	public static Toolbox tools;
+	public static GlyphCanvas glyph_canvas;
+	public static MainWindow singleton;
+	public static KeyBindings key_bindings;
+	public static MenuTab content;
+	public static TooltipArea tool_tip;
+	public static OverView over_view;	
+	public static TabBar tabs;
+	public static NativeWindow native_window;
 	
-	static Toolbox tools;
-	static GlyphCanvas glyph_canvas;
-	static MainWindow singleton;
-	static KeyBindings key_bindings;
-	static MenuTab content;
-	static TooltipArea tool_tip;
-		
-	static DrawingArea margin_bottom;
-	static DrawingArea margin_right;
-
-	static OverView over_view;
-
 	static List<uint> key_pressed = new List<uint> ();
 	
-	public MainWindow (string title) {
+	public MainWindow () {
 		singleton = this;
-		
+
 		key_bindings = new KeyBindings ();
-		
 		glyph_canvas = new GlyphCanvas ();
 		tools = new Toolbox (glyph_canvas);
 		tabs = new TabBar ();
 		content = new MenuTab ();
 		tool_tip = new TooltipArea ();
-
-		margin_bottom = new DrawingArea ();
-		margin_right = new DrawingArea ();
-	
-		margin_bottom.set_size_request (0, 0);
-		margin_right.set_size_request (0, 0);
-		
-		set_title (title);
-		
-		delete_event.connect (quit);
-		
-		set_size_and_position ();
-		
-		html_canvas = new WebView ();
-		WebKit.set_cache_model (CacheModel.DOCUMENT_VIEWER);
-		html_canvas.get_settings ().enable_default_context_menu = false;
-				
-		html_canvas.title_changed.connect ((p, s) => {
-			FontDisplay fd = get_current_display ();
-			fd.process_property (s);
-		});
-		
-		html_box = new ScrolledWindow (null, null);
-		html_box.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);
-		
-		html_box.add (html_canvas);
-		
-		html_canvas.set_editable (true);
-		
-		tabs.signal_tab_selected.connect ((f, tab) => {
-			bool n;
-			File layout_dir;
-			File layout_uri;
-			string uri;
-			int i;
-			FontDisplay fd = tab.get_display ();
-			
-			glyph_canvas.set_current_glyph (fd);
-			n = fd.is_html_canvas ();
-			
-			if (n) {
-				layout_dir = FontDisplay.find_layout_dir ();
-				uri = fd.get_uri ();
-				
-				if (uri == "") {
-					layout_uri = layout_dir.get_child (fd.get_html_file ());
-					uri = fd.path_to_uri ((!) layout_uri.get_path ());
-				}
-				
-				if (fd.get_html () == "") {
-					html_canvas.load_html_string (fd.get_html (), uri);	
-					html_canvas.reload_bypass_cache ();
-					html_canvas.load_uri (uri);
-				} else {
-					html_canvas.load_html_string (fd.get_html (), uri);
-				}
-				
-				html_box.set_visible (n);
-				glyph_canvas.set_visible (!n);
-			} else {
-				html_box.set_visible (false);
-				glyph_canvas.set_visible (true);
-			} 
-		});
-
-		// Hide this canvas when window is realized and flip canvas 
-		// visibility in tab selection signal.
-		html_canvas.expose_event.connect ((t, e) => {
-			glyph_canvas.set_visible (false);
-			return false;
-		});
-
 		over_view = new OverView();
-				
-		tabs.add_unique_tab (content, 60, true);
-		
-		tabs.select_tab_name ("Menu");
-
-		canvas_box = new HBox (false, 0);
-		canvas_box.pack_start (glyph_canvas, true, true, 0);
-		canvas_box.pack_start (html_box, true, true, 0);
-		
-		tab_box = new VBox (false, 0);
-		tab_box.pack_start (tabs, false, false, 0);	
-		
-		tab_box.pack_start (canvas_box, true, true, 0);
-
-		tab_box.pack_start (tool_tip, false, false, 0);
-		tab_box.pack_start (margin_bottom, false, false, 0);
-		
-		list_box = new HBox (false, 0);
-		list_box.pack_start (tab_box, true, true, 0);
-		list_box.pack_start (tools, false, false, 0);
-		list_box.pack_start (margin_right, false, false, 0);
+	}
 
-		add (list_box);
-				
-		key_snooper_install (global_key_bindings, null);
-		
-		add_events (EventMask.FOCUS_CHANGE_MASK);
-		
-		focus_in_event.connect ((t, e)=> {
-			key_bindings.reset ();
-			return true;
-		});
-		
-		set_icon_from_file ((!) Icons.find_icon ("window_icon.png").get_path ());
-		
-		show_all ();
+	public void set_native (NativeWindow nw) {
+		native_window = nw;
 	}
 
+/* // FIXA:
 	public static WebView get_webview () {
 		return singleton.html_canvas;
 	}
+*/
 
-	public static void hide_cursor () {
-		Pixmap pixmap = new Pixmap (null, 1, 1, 1);
-		Color color = { 0, 0, 0, 0 };
-		Cursor cursor = new Cursor.from_pixmap (pixmap, pixmap, color, color, 0, 0);
-
-		// Fixa: But why?
-		// (Supplement.exe:1300): Gdk-CRITICAL **: gdk_window_set_cursor: assertion `GDK_IS_WINDOW (window)' failed		
-		// singleton.frame.set_cursor (cursor);
-	}
-	
-	private void set_size_and_position () {
-		int w = Preferences.get_window_width();
-		int h = Preferences.get_window_height();
-		
-		set_default_size (w, h);
-		// move (10, 240);
-	}
-	
-	public bool quit () {
-		bool added;
-		SaveDialog s = new SaveDialog ();
-		
-		if (Supplement.get_current_font ().is_modified ()) {
-			added = tabs.add_unique_tab (s, 50);
-		} else {
-			added = false;
-		}
-		
-		if (!added) {
-			Supplement.get_current_font ().save_backup ();
-			Gtk.main_quit ();
-		}
-		
-		s.finished.connect (() => {
-			Supplement.get_current_font ().delete_backup ();
-			Gtk.main_quit ();
-		});
-		
-		return true;
+	internal static NativeWindow get_native () {
+		return native_window;
 	}
 	
 	internal static MainWindow get_current_window () {
@@ -303,6 +157,15 @@ internal class MainWindow : Gtk.Window { 		return 0;
 	}
 	
+	public static string? file_chooser (string title) {
+		return get_singleton ().native_window.file_chooser (title);
+	}
+	
+	public void set_title (string title) {
+		// FIXA:
+		// native_window.set_title (title);
+	}
+	
 	/** Reaload all paths and help lines from disk. */
 	internal static void clear_glyph_cache () {
 		Glyph g;
@@ -326,26 +189,6 @@ internal class MainWindow : Gtk.Window { 			}
 		}
 	}
-
-	internal static void toggle_expanded_margin_bottom () {
-		int w, h;
-		margin_bottom.get_size_request (out w, out h);
-		
-		if (h == 1) h = 2; 
-		else h = 1;
-		
-		margin_bottom.set_size_request (w, h);
-	}
-	
-	internal static void toggle_expanded_margin_right () {	
-		int w, h;
-		margin_right.get_size_request (out w, out h);
-
-		if (w == 1) w = 2; 
-		else w = 1;
-
-		margin_right.set_size_request (w, h);
-	}
 }
 
 }
diff --git a/src/MenuTab.vala b/src/MenuTab.valaindex 895eaf0..acabd53 100644--- a/src/MenuTab.vala+++ b/src/MenuTab.vala@@ -250,18 +250,8 @@ c.append (""" 		string f; 		bool saved = false; 		Font font = Supplement.get_current_font ();-		FileChooserDialog file_chooser = new FileChooserDialog ("Save", MainWindow.get_current_window (), FileChooserAction.SAVE, Stock.CANCEL, ResponseType.CANCEL, Stock.SAVE, ResponseType.ACCEPT); 		-		try {-			file_chooser.set_current_folder_file (font.get_folder ());-		} catch (GLib.Error e) {-			stderr.printf (e.message);-		}-		-		if (file_chooser.run () == ResponseType.ACCEPT) {	-			MainWindow.get_glyph_canvas ().redraw ();-			fn = file_chooser.get_filename ();-		}+		fn = MainWindow.file_chooser ("Save"); 		 		if (fn != null) { 			f = (!) fn;@@ -275,8 +265,6 @@ c.append (""" 			saved = true; 		} -		file_chooser.destroy ();-		 		return saved; 	} @@ -340,34 +328,19 @@ c.append (""" 	}  	private static void load_new_font () {-		string? fn;-		FileChooserDialog file_chooser = new FileChooserDialog ("Open font file", MainWindow.get_current_window (), FileChooserAction.OPEN, Stock.CANCEL, ResponseType.CANCEL, Stock.OPEN, ResponseType.ACCEPT);+		string? fn = MainWindow.file_chooser ("load"); 		Font f = Supplement.get_current_font (); 		-		try {-			file_chooser.set_current_folder_file (f.get_folder ());-		} catch (GLib.Error e) {-			stderr.printf (e.message);-		}-		-		if (file_chooser.run () == ResponseType.ACCEPT) {	-			MainWindow.get_glyph_canvas ().redraw ();-	-			fn = file_chooser.get_filename ();--			if (fn != null) {-				f.delete_backup ();-				-				MainWindow.clear_glyph_cache ();-				MainWindow.close_all_tabs ();-				f.load ((!)fn);-				-				MainWindow.get_singleton ().set_title (f.get_name ());-				select_overview ();		-			}+		if (fn != null) {+			f.delete_backup ();+			+			MainWindow.clear_glyph_cache ();+			MainWindow.close_all_tabs ();+			f.load ((!)fn);+			+			MainWindow.get_singleton ().set_title (f.get_name ());+			select_overview ();		 		}-		-		file_chooser.destroy (); 	} 	 	public static void show_kerning_context () {diff --git a/src/Preferences.vala b/src/Preferences.valaindex ad9537b..ac7f909 100644--- a/src/Preferences.vala+++ b/src/Preferences.vala@@ -82,15 +82,16 @@ internal class Preferences { 		int h = int.parse (get ("window_height")); 		return (h == 0) ? 500 : h; 	}-		+	 	public static void update_window_size () {-		int w, h;+/*		int w, h; 		MainWindow.get_current_window ().get_size (out w, out h); 		 		set ("window_width", @"$w"); 		set ("window_height", @"$h");+*/ 	}-+	 	public static void load () { 		File app_dir = Supplement.get_settings_directory (); 		File settings = app_dir.get_child ("settings");diff --git a/src/Preview.vala b/src/Preview.valaindex 13bf9d1..49819c3 100644--- a/src/Preview.vala+++ b/src/Preview.vala@@ -33,6 +33,7 @@ class Preview : FontDisplay { 	}  	public override void selected_canvas () {+/* 		WebView w = MainWindow.get_webview (); 		string uri = get_uri (); 		File new_dest;@@ -63,6 +64,7 @@ class Preview : FontDisplay { 			}); 			t2.attach (null); 		}+*/ 	}  	public override string get_uri () {diff --git a/src/SpinButton.vala b/src/SpinButton.valaindex 06f7721..6b5dcb6 100644--- a/src/SpinButton.vala+++ b/src/SpinButton.vala@@ -203,14 +203,14 @@ class SpinButton : Tool { 		return @"$deka.$deci$centi$milli"; 	} -	public override void draw (Allocation allocation, Context cr) {+	public override void draw (Context cr) { 		double xt = x + 3 + w; 		double yt = y + h + 17;  		double text_x = -4.5; 		double text_y = 11; -		base.draw (allocation, cr);+		base.draw (cr); 	 		cr.save (); 	diff --git a/src/Tool.vala b/src/Tool.valaindex feb2689..5a782a4 100644--- a/src/Tool.vala+++ b/src/Tool.vala@@ -16,8 +16,6 @@ */  using Cairo;-using Gtk;-using Gdk;  namespace Supplement { @@ -190,7 +188,7 @@ class Tool : GLib.Object { 		return ret; 	} 		-	public virtual void draw (Allocation allocation, Context cr) {+	public virtual void draw (Context cr) { 		double xt = x + 3 + w; 		double yt = y + h + 17; diff --git a/src/Toolbox.vala b/src/Toolbox.valaindex bf334d9..fcf8ca3 100644--- a/src/Toolbox.vala+++ b/src/Toolbox.vala@@ -15,14 +15,12 @@     along with this program.  If not, see <http://www.gnu.org/licenses/>. */ -using Gtk;-using Gdk; using Cairo; using Math;  namespace Supplement { -class Toolbox : DrawingArea {+class Toolbox : GLib.Object  { 	GlyphCanvas glyph_canvas; 	 	bool expanded = true;@@ -39,21 +37,19 @@ class Toolbox : DrawingArea { 	BackgroundTool move_background; 	CutBackgroundTool cut_background; 	-	Tool press_tool = new Tool (null); // activate the pressed button on release+	public Tool press_tool = new Tool (null); // activate the pressed button on release 	 	public SpinButton background_scale = new SpinButton (); 	public SpinButton precision; 	+	public signal void redraw (int x, int y, int w, int h);+	+	public int allocation_width = 0;+	public int allocation_height = 0;+	 	public Toolbox (GlyphCanvas main_glyph_canvas) { 		glyph_canvas = main_glyph_canvas;-		-		set_size_request (158, 100); -		leave_notify_event.connect ((t, e)=> {-			reset_active_tool ();-			return true;-		});-		 		toolbox_expander = new ToolboxExpander (); 		 		add_expander (toolbox_expander);@@ -101,9 +97,9 @@ class Toolbox : DrawingArea {  		Tool insert_point_on_path = new Tool ("insert_point_on_path", "Add new point on path", 'n'); 		insert_point_on_path.select_action.connect ((self) => {-				select_draw_tool ();-				pen_tool.begin_from_new_point_on_path ();-			});+			select_draw_tool ();+			pen_tool.begin_from_new_point_on_path ();+		}); 		draw_tool_modifiers.add_tool (insert_point_on_path); 		 		if (Supplement.experimental) {@@ -117,20 +113,20 @@ class Toolbox : DrawingArea {  		Tool tie_editpoint_tool = new Tool ("tie_point", "Tie curve handles for selected edit point", 'w'); 		tie_editpoint_tool.select_action.connect ((self) => {-				EditPoint ep;-				bool tie;-				-				select_draw_tool ();-				-				ep = pen_tool.selected_corner;-				tie = !ep.tie_handles;+			EditPoint ep;+			bool tie;+			+			select_draw_tool ();+			+			ep = pen_tool.selected_corner;+			tie = !ep.tie_handles; -				if (tie) {-					ep.process_tied_handle ();-				}-				-				ep.set_tie_handle (tie);				-			});+			if (tie) {+				ep.process_tied_handle ();+			}+			+			ep.set_tie_handle (tie);				+		}); 		draw_tool_modifiers.add_tool (tie_editpoint_tool);	  		Tool tie_x_or_y = new Tool ("tie_x_or_y", "Tie coordinates to previous edit point", 'q');@@ -162,7 +158,7 @@ class Toolbox : DrawingArea { 			select_tool (precision); 			 			Preferences.set ("precision", self.get_display_value ());-			MainWindow.get_toolbox ().queue_draw_area ((int) precision.x, (int) precision.y, 70, 70);+			redraw ((int) precision.x, (int) precision.y, 70, 70); 		}); 		 		precision.set_min (0.001);@@ -176,14 +172,14 @@ class Toolbox : DrawingArea { 		 		Tool reverse_path_tool = new Tool ("reverse_path", "Create counter from outline", 'r'); 		reverse_path_tool.select_action.connect ((self) => {-				Glyph g = MainWindow.get_current_glyph ();-				-				foreach (Path p in g.active_paths) {-					p.reverse ();-				}+			Glyph g = MainWindow.get_current_glyph (); 			-				g.redraw_area (0, 0, g.allocation.width, g.allocation.height);-			});+			foreach (Path p in g.active_paths) {+				p.reverse ();+			}+		+			g.redraw_area (0, 0, g.allocation.width, g.allocation.height);+		}); 		path_tool_modifiers.add_tool (reverse_path_tool);  		Tool move_layer = new Tool ("move_layer", "Move to path to bottom layer", 'd');@@ -211,34 +207,34 @@ class Toolbox : DrawingArea {  		Tool custom_character_set = new Tool ("custom_character_set", "Show default characters set", 'r', CTRL); 		custom_character_set.select_action.connect ((self) => {-				MainWindow.get_tab_bar ().add_unique_tab (new OverView (), 75, false);-				OverView o = MainWindow.get_overview ();-				GlyphRange gr = new GlyphRange ();-				gr.use_default_range ();-				o.set_glyph_range (gr);-				MainWindow.get_tab_bar ().select_tab_name ("Overview");-			});+			MainWindow.get_tab_bar ().add_unique_tab (new OverView (), 75, false);+			OverView o = MainWindow.get_overview ();+			GlyphRange gr = new GlyphRange ();+			gr.use_default_range ();+			o.set_glyph_range (gr);+			MainWindow.get_tab_bar ().select_tab_name ("Overview");+		}); 		characterset_tools.add_tool (custom_character_set);  		Tool avalilable_characters = new Tool ("available_characters", "Show characters in font", 'd', CTRL); 		avalilable_characters.select_action.connect ((self) => {-				MainWindow.get_tab_bar ().add_unique_tab (new OverView (), 75, false);-				OverView o = MainWindow.get_overview ();-				o.display_all_available_glyphs ();-				MainWindow.get_tab_bar ().select_tab_name ("Overview");-			});+			MainWindow.get_tab_bar ().add_unique_tab (new OverView (), 75, false);+			OverView o = MainWindow.get_overview ();+			o.display_all_available_glyphs ();+			MainWindow.get_tab_bar ().select_tab_name ("Overview");+		}); 		characterset_tools.add_tool (avalilable_characters);  		Tool delete_glyph = new Tool ("delete_selected_glyph", "Delete selected glyph"); 		delete_glyph.select_action.connect ((self) => {-					OverView o = MainWindow.get_overview ();-					-					if (MainWindow.get_current_display () is OverView) {-						o.delete_selected_glyph ();-					}-					-					MainWindow.get_tab_bar ().select_tab_name ("Overview");-			});+			OverView o = MainWindow.get_overview ();+			+			if (MainWindow.get_current_display () is OverView) {+				o.delete_selected_glyph ();+			}+			+			MainWindow.get_tab_bar ().select_tab_name ("Overview");+		}); 		characterset_tools.add_tool (delete_glyph); 						 		if (Supplement.has_argument ("--test")) {@@ -297,31 +293,31 @@ class Toolbox : DrawingArea {  		Tool xheight_help_lines = new Tool ("show_xheight_helplines", "Show help lines for x-height and baseline", 'x'); 		xheight_help_lines.select_action.connect ((self) => {-				Glyph g = MainWindow.get_current_glyph ();-				bool v = !g.get_xheight_lines_visible ();-				g.set_xheight_lines_visible (v);-				self.set_selected (v);-				MainWindow.get_glyph_canvas ().redraw ();-				-				if (v && !help_lines.is_selected ()) {-					select_tool (help_lines);-				}-				-			});+			Glyph g = MainWindow.get_current_glyph ();+			bool v = !g.get_xheight_lines_visible ();+			g.set_xheight_lines_visible (v);+			self.set_selected (v);+			MainWindow.get_glyph_canvas ().redraw ();+			+			if (v && !help_lines.is_selected ()) {+				select_tool (help_lines);+			}+			+		}); 		guideline_tools.add_tool (xheight_help_lines);  		Tool background_help_lines = new Tool ("background_help_lines", "Show help lines at top and bottom margin", 't'); 		background_help_lines.select_action.connect ((self) => {-				Glyph g = MainWindow.get_current_glyph ();-				bool v = !g.get_margin_lines_visible ();-				g.set_margin_lines_visible (v);-				self.set_selected (v);-				MainWindow.get_glyph_canvas ().redraw ();-				-				if (v && !help_lines.is_selected ()) {-					select_tool (help_lines);-				}-			});+			Glyph g = MainWindow.get_current_glyph ();+			bool v = !g.get_margin_lines_visible ();+			g.set_margin_lines_visible (v);+			self.set_selected (v);+			MainWindow.get_glyph_canvas ().redraw ();+			+			if (v && !help_lines.is_selected ()) {+				select_tool (help_lines);+			}+		}); 		guideline_tools.add_tool (background_help_lines);  		Tool new_grid = new GridTool ("new_grid");@@ -330,16 +326,16 @@ class Toolbox : DrawingArea { 		// Zoom tools  		Tool zoom_in = new Tool ("zoom_in", "zoom in", '+', CTRL); 		zoom_in.select_action.connect ((self) => {-				zoom_tool.store_current_view ();-				glyph_canvas.get_current_display ().zoom_in ();-			});+			zoom_tool.store_current_view ();+			glyph_canvas.get_current_display ().zoom_in ();+		}); 		view_tools.add_tool (zoom_in);  		Tool zoom_out = new Tool ("zoom_out", "Zoom out", '-', CTRL); 		zoom_out.select_action.connect ((self) => {-				zoom_tool.store_current_view ();-				glyph_canvas.get_current_display ().zoom_out ();-			});+			zoom_tool.store_current_view ();+			glyph_canvas.get_current_display ().zoom_out ();+		}); 		view_tools.add_tool (zoom_out);  		Tool reset_zoom = new Tool ("zoom_1_1", "Zoom to scale 1:1", '0', CTRL);@@ -352,41 +348,41 @@ class Toolbox : DrawingArea {  		Tool full_glyph = new Tool ("full_glyph", "Show full glyph", 'f'); 		full_glyph.select_action.connect((self) => {-				zoom_tool.store_current_view ();-				zoom_tool.zoom_full_glyph ();-			});+			zoom_tool.store_current_view ();+			zoom_tool.zoom_full_glyph ();+		}); 		view_tools.add_tool (full_glyph);  		Tool zoom_boundries = new Tool ("zoom_boundries", "Zoom in at region boundries", 'v'); 		zoom_boundries.select_action.connect((self) => {-				zoom_tool.store_current_view ();-				glyph_canvas.get_current_display ().zoom_max ();-			});+			zoom_tool.store_current_view ();+			glyph_canvas.get_current_display ().zoom_max ();+		}); 		view_tools.add_tool (zoom_boundries);  		Tool zoom_bg = new Tool ("zoom_background_image", "Zoom in background image", 'b'); 		zoom_bg.select_action.connect((self) => {-				if (MainWindow.get_current_glyph ().get_background_image () != null) {-					zoom_tool.store_current_view ();					-					glyph_canvas.get_current_display ().reset_zoom ();-					-					zoom_tool.zoom_full_background_image ();-					-					glyph_canvas.queue_draw_area(0, 0, glyph_canvas.allocation.width, glyph_canvas.allocation.height);-				}-			});+			if (MainWindow.get_current_glyph ().get_background_image () != null) {+				zoom_tool.store_current_view ();					+				glyph_canvas.get_current_display ().reset_zoom ();+				+				zoom_tool.zoom_full_background_image ();+				+				glyph_canvas.queue_draw_area(0, 0, glyph_canvas.allocation.width, glyph_canvas.allocation.height);+			}+		}); 		view_tools.add_tool (zoom_bg);  		Tool zoom_prev = new Tool ("prev", "Previous view", 'j', CTRL); 		zoom_prev.select_action.connect((self) => {-				zoom_tool.previous_view ();-			});+			zoom_tool.previous_view ();+		}); 		view_tools.add_tool (zoom_prev);  		Tool zoom_next = new Tool ("next", "Next view", 'l', CTRL); 		zoom_next.select_action.connect((self) => {-				zoom_tool.next_view ();-			});+			zoom_tool.next_view ();+		}); 		view_tools.add_tool (zoom_next); 				 		// background tools@@ -422,10 +418,10 @@ class Toolbox : DrawingArea { 		 		Tool show_bg = new Tool ("show_background", "Show background image"); 		show_bg.select_action.connect ((self) => {-				Glyph g = MainWindow.get_current_glyph ();-				g.set_background_visible (!g.get_background_visible ());-				MainWindow.get_glyph_canvas ().redraw ();-			});+			Glyph g = MainWindow.get_current_glyph ();+			g.set_background_visible (!g.get_background_visible ());+			MainWindow.get_glyph_canvas ().redraw ();+		}); 		background_tools.add_tool (show_bg);  		Tool bg_selection = new Tool ("insert_background", "Insert new background image");@@ -448,6 +444,7 @@ class Toolbox : DrawingArea { 			 			tp.show_text (""); 		});+		 		bg_selection.set_show_background (true); 		background_tools.add_tool (bg_selection); 		@@ -467,7 +464,6 @@ class Toolbox : DrawingArea { 				b = (!) bg; 				b.set_contrast (background_contrast.get_value ()); 			}-			 		}); 		 		// Fixa: background_tools.add_tool (background_contrast);@@ -543,42 +539,7 @@ class Toolbox : DrawingArea { 		 		trace.set_persistent (false); 		trace.set_unique (false);-		-		button_press_event.connect ((se, e)=> {-			foreach (var exp in expanders) {-				foreach (Tool t in exp.tool) {-					if (t.is_over (e.x, e.y)) {-						t.panel_press_action (t, e.button, e.x, e.y);-						press_tool = t;-					}-				}-			}-			-			return true;-		});	-				-		button_release_event.connect ((se, e)=> {-			release (e.button, e.x, e.y);-			return true;-		}); -		motion_notify_event.connect ((sen, e)=> {-			move (e.x, e.y);-			return true;-		});-		-		expose_event.connect ((t, e)=> {-				Allocation allocation;-				get_allocation (out allocation);-				-				Context cw = cairo_create(get_window());-				draw (allocation, cw);-				-				return true;-			});-		-		add_events (EventMask.BUTTON_PRESS_MASK | EventMask.BUTTON_RELEASE_MASK | EventMask.POINTER_MOTION_MASK | EventMask.LEAVE_NOTIFY_MASK);-		 		update_expanders (); 		reset_active_tool (); @@ -601,10 +562,22 @@ class Toolbox : DrawingArea { 			 			return false; 		});+		 		idle.attach (null); 	} 	-	private void release (uint button, double x, double y) {+	public void press (uint button, double x, double y) {+		foreach (var exp in expanders) {+			foreach (Tool t in exp.tool) {+				if (t.is_over (x, y)) {+					t.panel_press_action (t, button, x, y);+					press_tool = t;+				}+			}+		}+	}+	+	public void release (uint button, double x, double y) { 		foreach (var exp in expanders) { 			if (exp.is_over (x, y)) { 				exp.set_open (! exp.is_open ());					@@ -615,9 +588,7 @@ class Toolbox : DrawingArea {  				update_expanders (); 				-				Allocation allocation;-				get_allocation (out allocation);-				queue_draw_area ((int) exp.x - 10, (int) exp.y - 10, allocation.width, (int) (allocation.height - exp.y + 10));+				redraw ((int) exp.x - 10, (int) exp.y - 10, allocation_width, (int) (allocation_height - exp.y + 10)); 			} 			 			if (exp.is_open ()) {@@ -640,7 +611,7 @@ class Toolbox : DrawingArea { 		select_tool_by_name ("pen_tool"); 	} 	-	private void move (double x, double y) {+	public void move (double x, double y) { 		bool update; 		bool a; 		foreach (var exp in expanders) {@@ -648,7 +619,7 @@ class Toolbox : DrawingArea { 			update = exp.set_active (a); 			 			if (update) {-				queue_draw_area ((int) exp.x - 10, (int) exp.y - 10, (int) (exp.x + exp.w + 10), (int) (exp.y + exp.h + 10));+				MainWindow.get_toolbox ().redraw ((int) exp.x - 10, (int) exp.y - 10, (int) (exp.x + exp.w + 10), (int) (exp.y + exp.h + 10)); 			} 			 			if (exp.is_open ()) {@@ -664,7 +635,7 @@ class Toolbox : DrawingArea { 					} 					 					if (update) {-						queue_draw_area (0, 0, allocation.width, allocation.height);+						MainWindow.get_toolbox ().redraw (0, 0, allocation_width, allocation_height); 					} 					 					t.panel_move_action (t, x, y);@@ -684,7 +655,7 @@ class Toolbox : DrawingArea { 		 		grid_expander.set_open (true); 		update_expanders ();-		MainWindow.get_toolbox ().queue_draw_area (0, 0, allocation.width, allocation.height);		+		redraw (0, 0, allocation_width, allocation_height);		 	} 	 	public void parse_grid (string spin_button_value) {@@ -713,7 +684,7 @@ class Toolbox : DrawingArea { 		grid_expander.set_open (true); 		update_expanders (); 		-		MainWindow.get_toolbox ().queue_draw_area (0, 0, allocation.width, allocation.height);+		redraw (0, 0, allocation_width, allocation_height); 		 		select_tool (grid_width); 		grid_width.set_active (false);@@ -739,7 +710,7 @@ class Toolbox : DrawingArea { 		} 		 		update_expanders ();-		MainWindow.get_toolbox ().queue_draw_area (0, 0, allocation.width, allocation.height);+		redraw (0, 0, allocation_width, allocation_height); 	}  	public void reset_active_tool () {@@ -759,15 +730,6 @@ class Toolbox : DrawingArea { 			} 		} 		-		// FIXA:-		/*-		foreach (Tool t in MainWindow.get_content_display ().tools) {-			if (t.is_active ()) {-				return t;-			}	-		}-		*/-		 		return null; 	} @@ -790,7 +752,7 @@ class Toolbox : DrawingArea { 					tool.select_action (tool); // execute command 					 					if (update) {							-						queue_draw_area ((int) exp.x - 10, (int) exp.y - 10, allocation.width, (int) (allocation.height - exp.y + 10));+						redraw ((int) exp.x - 10, (int) exp.y - 10, allocation_width, (int) (allocation_height - exp.y + 10)); 					} 					 					if (exp == draw_tools || t == move_background || t == cut_background) {@@ -841,29 +803,29 @@ class Toolbox : DrawingArea { 		expanders.append (e); 	} 	-	private void draw_expanders (Allocation allocation, Context cr) {+	private void draw_expanders (int w, int h, Context cr) { 		foreach (Expander e in expanders) {-			e.draw (allocation, cr);+			e.draw (w, h, cr); 			if (e.is_open ()) {-				e.draw_content (allocation, cr);+				e.draw_content (w, h, cr); 			} 		} 	} 	-	public void draw (Allocation allocation, Context cr) { +	public void draw (int w, int h, Context cr) {  		cr.save (); 		-		cr.rectangle(0, 0, allocation.width, allocation.height);+		cr.rectangle(0, 0, w, h); 		cr.set_line_width(0); 		cr.set_source_rgba(124/255.0, 124/255.0, 124/255.0, 1); 		cr.fill(); -		cr.rectangle(0, 0, 1, allocation.height);+		cr.rectangle(0, 0, 1, h); 		cr.set_line_width(0); 		cr.set_source_rgba(0/255.0, 0/255.0, 0/255.0, 1); 		cr.fill(); -		draw_expanders (allocation, cr);+		draw_expanders (w, h, cr); 		 		cr.restore (); 	}@@ -873,19 +835,22 @@ class Toolbox : DrawingArea { 	} 	 	public void maximize () {-		Allocation a;+/*		Allocation a; 		get_allocation (out a); 		expanded = true; 		toolbox_expander.set_open (expanded); 		set_size_request (158, a.height);+*/ 	} 	 	public void minimize () {+/* 		Allocation a; 		get_allocation (out a); 		expanded = false; 		toolbox_expander.set_open (expanded); 		set_size_request (18, a.height);	+*/ 	} } @@ -987,7 +952,7 @@ class Expander : GLib.Object { 					} 				} 			-				MainWindow.get_toolbox ().queue_draw_area ((int) x, (int) y, (int) w  + 300, (int) (h + margin));+				MainWindow.get_toolbox ().redraw ((int) x, (int) y, (int) w  + 300, (int) (h + margin)); 			 				if (is_unique ()) { 					foreach (var deselected in tool) {@@ -1001,7 +966,7 @@ class Expander : GLib.Object { 						var time = new TimeoutSource(200); 						time.set_callback(() => { 							selected.set_selected (false);-							MainWindow.get_toolbox ().queue_draw_area ((int) x, (int) y, (int) w  + 300, (int) (h + margin));+							MainWindow.get_toolbox ().redraw ((int) x, (int) y, (int) w  + 300, (int) (h + margin)); 							return false; 						}); 						time.attach(null);@@ -1045,7 +1010,7 @@ class Expander : GLib.Object { 		return r; 	} 	-	public void draw (Allocation allocation, Context cr) {+	public void draw (int wd, int hd, Context cr) { 		double lx, ly; 		double ih2 = 5.4 / 2; 		double iw2 = 5.4 / 2;@@ -1081,22 +1046,22 @@ class Expander : GLib.Object { 		cr.save (); 		lx = x + w + 7; 		ly = y + ih2;-		if (lx < allocation.width) {+		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 (allocation.width - w - x + 4, ly);	+			cr.line_to (wd - w - x + 4, ly);	 			cr.stroke (); 		} 		cr.restore ();  	} 	-	public void draw_content (Allocation allocation, Context cr) {+	public void draw_content (int w, int h, Context cr) { 		if (open) { 			cr.save (); 			foreach (var t in tool) {-				t.draw (allocation, cr);+				t.draw (cr); 			} 			cr.restore (); 		}diff --git a/src/wscript b/src/wscriptindex b61c2d8..29b7edd 100644--- a/src/wscript+++ b/src/wscript@@ -24,6 +24,7 @@ BIRDFONT = [ 	'GlyphRange.vala', 	'GlyphTable.vala', 	'GridTool.vala',+	'GtkInterface.vala', 	'Icons.vala', 	'Kerning.vala',  	'KeyBindings.vala', 

Contact

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