Clone in a terminal:
Commit f4765ed
Johan Mattsson - 2012-12-25T20:06:31+00:00
f4765ed0d84c7ca2ff67287a05667ca0e0272b63johan.mattsson.m@gmail.com

remove wscript and copy paths to clipboard

Changed files (7)

Diff

diff --git a/birdfont/GtkWindow.vala b/birdfont/GtkWindow.valaindex b2e5758..8051e10 100644--- a/birdfont/GtkWindow.vala+++ b/birdfont/GtkWindow.vala@@ -39,8 +39,10 @@ public class GtkWindow : Gtk.Window, NativeWindow { 	GlyphCanvasArea glyph_canvas_area; 	 	static List<uint> key_pressed = new List<uint> ();-	Clipboard clipboard; 	+	Clipboard clipboard;+	string clipboard_svg = "";+		 	public GtkWindow (string title) { 		((Gtk.Window)this).set_title ("Birdfont"); 	}@@ -237,11 +239,33 @@ public class GtkWindow : Gtk.Window, NativeWindow { 		Atom target; 		target = Atom.intern_static_string ("image/svg+xml"); 		selection_data = clipboard.wait_for_contents (target);+		+		if (is_null (selection_data) || is_null (selection_data.data)) {+			return "";+		}+		 		return (string) selection_data.data; 	}--	public void set_clipboard (string data) {-		clipboard.set_text (data, -1);+	+	public void set_clipboard (string svg) {+		//clipboard.set_text (data, -1);+		TargetEntry t = { "image/svg+xml", 0, 0 };+		TargetEntry[] targets = { t };+		clipboard_svg = svg;+		clipboard.set_with_owner (targets,+		+			// obtain clipboard data +			(clipboard, selection_data, info, owner) => {+				Atom type;+				uchar[] data = (uchar[])(!)((GtkWindow*)owner)->clipboard_svg.to_utf8 ();+				type = Atom.intern_static_string ("image/svg+xml");+				selection_data.set (type, 0, data);+			},+			+			// clear clipboard data+			(clipboard, user_data) => {+			},+			this); 	} 	 	MenuBar create_menu () {diff --git a/libbirdfont/ClipTool.vala b/libbirdfont/ClipTool.valaindex a56b9aa..aa16d5b 100644--- a/libbirdfont/ClipTool.vala+++ b/libbirdfont/ClipTool.vala@@ -28,13 +28,14 @@ public class ClipTool : Tool { 		FontDisplay fd = MainWindow.get_current_display (); 		string gc; 		Glyph g = MainWindow.get_current_glyph ();-+		string svg;+		 		glyph = null;  		while (path.length () > 0) { 			path.remove_link (path.first ()); 		}-					+		 		if (fd is OverView) { 			gc = overview.get_selected_char (); 			glyph = font.get_glyph (gc);@@ -48,6 +49,9 @@ public class ClipTool : Tool { 			if (path.length () == 0) { 				glyph = g.copy (); 			}+			+			svg = ExportTool.export_current_glyph_to_string ();+			MainWindow.get_singleton ().native_window.set_clipboard (svg); 		}  	}@@ -73,7 +77,8 @@ public class ClipTool : Tool { 				font.add_glyph ((!) destination); 			} 		}-		++		// paste from clipboard		 		if (fd is Glyph) { 			destination = (Glyph) fd; @@ -83,25 +88,10 @@ public class ClipTool : Tool { 			 			((!)destination).store_undo_state (); 			-			if (glyph != null) {-				foreach (Path p in ((!)glyph).path_list) {-					inserted = p.copy ();-					((!)destination).add_path (inserted);-				}-			}--			foreach (Path p in path) {-				inserted = p.copy ();-				((!)destination).add_path (inserted);-			}-			-			((!)destination).update_view ();-		}-		-		// paste from clipboard-		if (fd is Glyph) { 			svg = MainWindow.get_singleton ().native_window.get_clipboard (); 			ImportSvg.import_svg (svg);+			+			((!)destination).update_view (); 		} 	} diff --git a/libbirdfont/ExportTool.vala b/libbirdfont/ExportTool.valaindex 5b8066b..a22ef12 100644--- a/libbirdfont/ExportTool.vala+++ b/libbirdfont/ExportTool.vala@@ -43,6 +43,46 @@ public class ExportTool : Tool { 		}); 	} +	public static string export_current_glyph_to_string () {+		Glyph glyph = MainWindow.get_current_glyph ();+		Font font = Supplement.get_current_font ();+		FontDisplay fd = MainWindow.get_current_display ();+		string glyph_svg;+		string name;+		int pid = 0;+		+		name = glyph.get_name ();+		StringBuilder s = new StringBuilder ();+		+		s.append ("""<?xml version="1.0" standalone="no"?>+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >+<svg """);++		s.append (@"xmlns=\"http://www.w3.org/2000/svg\"\n");+		s.append (@"\twidth=\"$(glyph.get_width () / Glyph.SCALE)\"\n");+		s.append (@"\theight=\"$(glyph.get_height () / Glyph.SCALE)\"\n");+		s.append (@"\tid=\"glyph_$(name)\"\n");+		s.append (@"\tversion=\"1.1\">\n");+		+		s.append (@"\n");+		+		s.append (@"<g id=\"$(name)\">\n");++		glyph_svg = "";+		foreach (Path p in glyph.path_list) {+			glyph_svg += Svg.to_svg_path (p, glyph);+		}++		s.append (@"<path ");+		s.append (@"style=\"fill:#000000;stroke-width:0px\" ");+		s.append (@"d=\"$(glyph_svg)\" id=\"path_$(name)$(pid++)\" />\n");+	+		s.append ("</g>\n");+		s.append ("</svg>");+	+		return s.str;+	}+	 	public static void export_current_glyph () { 		Glyph glyph = MainWindow.get_current_glyph (); 		Font font = Supplement.get_current_font ();@@ -53,7 +93,6 @@ public class ExportTool : Tool { 		File file; 		DataOutputStream os; 		string name;-		int pid = 0;  		name = glyph.get_name (); 				@@ -75,34 +114,9 @@ public class ExportTool : Tool { 				file.delete (); 			} 			-			os = new DataOutputStream (file.create(FileCreateFlags.REPLACE_DESTINATION));	-		-			os.put_string (-"""<?xml version="1.0" standalone="no"?>-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >-<svg """);--			os.put_string (@"xmlns=\"http://www.w3.org/2000/svg\"\n");-			os.put_string (@"\twidth=\"$(glyph.get_width () / Glyph.SCALE)\"\n");-			os.put_string (@"\theight=\"$(glyph.get_height () / Glyph.SCALE)\"\n");-			os.put_string (@"\tid=\"glyph_$(name)\"\n");-			os.put_string (@"\tversion=\"1.1\">\n");-			-			os.put_string (@"\n");-			-			os.put_string (@"<g id=\"$(name)\">\n");--			glyph_svg = "";-			foreach (Path p in glyph.path_list) {-				glyph_svg += Svg.to_svg_path (p, glyph);-			}--			os.put_string (@"<path ");-			os.put_string (@"style=\"fill:#000000;stroke-width:0px\" ");-			os.put_string (@"d=\"$(glyph_svg)\" id=\"path_$(name)$(pid++)\" />\n");-		-			os.put_string ("""</g>			-</svg>""");+			glyph_svg = export_current_glyph_to_string ();+			os = new DataOutputStream (file.create(FileCreateFlags.REPLACE_DESTINATION));+			os.put_string (glyph_svg); 	 		} catch (Error e) { 			stderr.printf (@"Export \"$svg_file\" \n");diff --git a/libbirdfont/MainWindow.vala b/libbirdfont/MainWindow.valaindex c00409c..db86fdf 100644--- a/libbirdfont/MainWindow.vala+++ b/libbirdfont/MainWindow.vala@@ -31,7 +31,7 @@ public class MainWindow { 
 	public MainWindow () {
 		singleton = this;
-
+		
 		key_bindings = new KeyBindings ();
 		glyph_canvas = new GlyphCanvas ();
 		tools = new Toolbox (glyph_canvas);
diff --git a/libbirdfont/Supplement.vala b/libbirdfont/Supplement.valaindex 03a0686..b1aff13 100644--- a/libbirdfont/Supplement.vala+++ b/libbirdfont/Supplement.vala@@ -204,7 +204,7 @@ public class Supplement { 	}	
 }
 
-internal bool is_null (void* n) {
+public bool is_null (void* n) {
 	return n == null;
 }
 
diff --git a/linux/wscript b/linux/wscriptdeleted file mode 100644index ee8768c..0000000--- a/linux/wscript+++ /dev/null@@ -1,12 +0,0 @@-def build (bld):-	bld (-		rule = 'gzip -9 -c ../linux/birdfont.1  > ${TGT}',-		target = '../build/birdfont.1.gz'-	)-		-	bld (-		rule = 'gzip -9 -c ../linux/birdfont-export.1 > ${TGT}',-		target = '../build/birdfont-export.1.gz'-	)--	bld.install_files('${PREFIX}/share/man/man1/', ['../build/birdfont.1.gz', '../build/birdfont-export.1.gz'])diff --git a/wscript b/wscriptdeleted file mode 100644index 89ee36d..0000000--- a/wscript+++ /dev/null@@ -1,177 +0,0 @@-import time;
-import os
-
-VERSION = '0.8'
-APPNAME = 'birdfont'
-
-top = '.'
-out = 'build'
-
-def options(opt):
-	opt.load('compiler_c')
-	opt.load('vala')
-	opt.add_option('--win32', action='store_true', default=False, help='Crosscompile for Windows')
-	opt.add_option('--installer', action='store_true', default=False, help='Create Windows installer')
-	opt.add_option('--noconfig', action='store_true', default=False, help="Don't write Config.vala")
-	opt.add_option('--translations', action='store_true', default=False, help="Update translation template (.pot file)")
-   
-def configure(conf):
-	conf.load('compiler_c vala')
-	conf.check_vala(min_version=(0,17,3))
-	
-	conf.check_cfg(package='cairo', uselib_store='CAIRO', mandatory=1, args='--cflags --libs')
-	conf.check_cfg(package='gdk-pixbuf-2.0',  uselib_store='PIXBUF', mandatory=1, args='--cflags --libs')
-	conf.check_cfg(package='gio-2.0',  uselib_store='GIO', atleast_version='2.16.0', mandatory=1, args='--cflags --libs')
-	conf.check_cfg(package='glib-2.0', uselib_store='GLIB',atleast_version='2.16.0', mandatory=1, args='--cflags --libs')
-	conf.check_cfg(package='gtk+-2.0', uselib_store='GTK', atleast_version='2.16.0', mandatory=1, args='--cflags --libs')
-	conf.check_cfg(package='libxml-2.0', uselib_store='XML', mandatory=1, args='--cflags --libs')
-	conf.check_cfg(package='webkit-1.0', uselib_store='WEB', mandatory=1, args='--cflags --libs')
-	conf.check_cfg(package='libsoup-2.4', uselib_store='SOUP', mandatory=1, args='--cflags --libs')
-	
-	conf.env.append_unique('VALAFLAGS', ['--thread', '--pkg', 'webkit-1.0', '--enable-experimental', '--enable-experimental-non-null', '--vapidir=../../'])
-
-	conf.find_program('ldconfig', var='LDCONFIG', mandatory=False)
-
-	conf.define('GETTEXT_PACKAGE', 'birdfont')
-
-	if conf.options.win32 :
-		conf.recurse('win32')
-
-def pre (bld):
-	bld.env.VERSION = VERSION
-	
-	if not bld.options.noconfig and bld.cmd == 'build':
-		write_config (bld)
-
-def post (bld):
-	bld.exec_command ('${LDCONFIG}')
-				
-def build(bld):
-	bld.env.VERSION = VERSION
-	
-	bld.add_pre_fun(pre)
-	bld.add_post_fun(post)
-
-	bld.recurse('libbirdfont')
-	bld.recurse('birdfont')
-	bld.recurse('birdfont-export')
-
-	start_dir = bld.path.find_dir('./')
-	bld.install_files('${PREFIX}/share/birdfont/', start_dir.ant_glob('layout/*'), cwd=start_dir, relative_trick=True)
-	bld.install_files('${PREFIX}/share/birdfont/', start_dir.ant_glob('icons/*'), cwd=start_dir, relative_trick=True)
-	
-	bld.install_files('${PREFIX}/share/applications/', ['linux/birdfont.desktop'])
-	bld.install_files('${PREFIX}/share/icons/hicolor/48x48/apps/', ['linux/birdfont.png'])
-
-	bld.install_files('${PREFIX}/share/applications/', ['linux/birdfont.desktop'])
-
-	bld.recurse('linux')
-
-	if bld.options.win32:
-		bld.recurse('win32')
-
-	if bld.options.translations:
-		update_translations (bld)
-	
-	compile_translations (bld)
-
-def update_translations (bld):
-	for file in os.listdir('./po'):
-		if file == "birdfont.pot": continue
-	
-		loc = file.replace (".po", "")
-		d = "../po/" + loc + ".po"
-
-		bld (
-			rule = "wget -O " + loc + ".po.zip http://pootle.locamotion.org/" + loc + "/birdfont/export/zip",
-			name = "download translations",
-			always = True
-		)
-
-		bld (
-			rule = "unzip " + loc + ".po.zip ",
-			depends = "unzip translations",
-			always = True
-		)	
-				
-		bld (
-			rule = "mv " + loc + ".po " + d,
-			depends = "unzip translations",
-			always = True
-		)		
-
-	bld (
-		rule = "xgettext --language=C# --keyword=_ --add-comments=/ --from-code=utf-8 --output=../po/birdfont.pot ../libbirdfont/*.vala ../birdfont/*.vala ../birdfont-export/*.vala",
-		name = "update pot",
-		always = True
-	)
-			
-	for file in os.listdir('./po'):
-		if file == "birdfont.pot": continue
-	
-		loc = file.replace (".po", "")
-		d = "../po/" + loc + ".po"
-
-		bld (
-			rule = "msgmerge " + d + " ../po/birdfont.pot > " + loc + ".po.new",
-			depends = "update pot",
-			name = "merge pot " + loc,
-			always = True
-		)		
-
-		bld (
-			rule = "mv """ + loc + ".po.new " + d,
-			depends = "merge pot " + loc,
-			always = True
-		)		
-		
-
-def compile_translations (bld):
-
-	for file in os.listdir('./po'):
-		if file == "birdfont.pot": continue
-		
-		loc = file.replace (".po", "")
-		
-		bld (
-			rule = "mkdir -p locale/" + loc + "/LC_MESSAGES/",
-			name = loc,
-		)
-		
-		bld (
-			rule = "msgfmt --output=${TGT} ${SRC}",
-			depends = loc,
-			source = "./po/" + loc + ".po",
-			target = 'locale/'  + loc + '/LC_MESSAGES/birdfont.mo'
-		)
-		
-		bld.install_files(
-			'${PREFIX}/share/locale/' + loc + '/LC_MESSAGES/', 
-			['build/locale/'  + loc + '/LC_MESSAGES/birdfont.mo']
-		)
-	
-def write_config (cfg):
-	print ("Writing Config.vala")	
-
-	f = open('./libbirdfont/Config.vala', 'w+')
-	f.write("// Don't edit this file – it's generated by wscript\n")
-	f.write("namespace Supplement {\n")
-	
-	f.write("	internal static const string VERSION = \"")
-	f.write(VERSION)
-	f.write("\"");
-	f.write(";\n")
-
-	localtime = time.asctime( time.localtime(time.time()))
-	
-	f.write("	internal static const string BUILD_TIMESTAMP = \"")
-	f.write(localtime)
-	f.write("\"");
-	f.write(";\n")
-
-	f.write("	internal static const string PREFIX = \"")
-	f.write(cfg.options.prefix)
-	f.write("\"");
-	f.write(";\n")
-			
-	f.write("}");

Contact

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