Commit 6ede714
preview tab
Changed files (4)
modifiedsrc/ExportTool.valamodifiedsrc/FontDisplay.valamodifiedsrc/MainWindow.valamodifiedsrc/wscript
Diff
@@ -40,6 +40,18 @@ class ExportTool : Tool { }); } + public static void export_all () {+ Font font = Supplement.get_current_font ();+ + if (font.get_ttf_export ()) {+ export_ttf_font ();+ }++ if (font.get_svg_export ()) {+ export_svg_font ();+ }+ }+ public void export_glyph_to_svg () { Glyph glyph = MainWindow.get_current_glyph (); @@ -160,7 +172,7 @@ class ExportTool : Tool { return (!) prefered_browser; } - public void generate_html_document (string html_file, Font font) throws Error {+ public static void generate_html_document (string html_file, Font font) throws Error { File file = File.new_for_path (html_file); DataOutputStream os = new DataOutputStream (file.create(FileCreateFlags.REPLACE_DESTINATION)); @@ -293,7 +305,7 @@ class ExportTool : Tool { } - public bool export_ttf_font () {+ public static bool export_ttf_font () { try { Font font = Supplement.get_current_font (); File file = font.get_folder ();@@ -317,7 +329,7 @@ class ExportTool : Tool { return true; } - public bool export_svg_font () {+ public static bool export_svg_font () { TooltipArea ta = MainWindow.get_tool_tip (); Font font = Supplement.get_current_font (); string file_name = @"$(font.get_name ()).svg";@@ -32,49 +32,6 @@ public abstract class FontDisplay : GLib.Object { List<string> property = new List<string> (); List<PropertyFunction> call = new List<PropertyFunction> (); - public void add_html_callback (string prop, PropertyFunction.PropertyCallback cb) {- PropertyFunction pf = new PropertyFunction ();- pf.call = cb;- property.append (prop);- call.append (pf);- }- - public void process_property (string prop) {- string k, v;- int i, j;- PropertyFunction cb;- - if (prop == "done") {- return;- }- - i = prop.index_of (":");- - return_if_fail (i > 0);- - k = prop.substring (0, i);- v = prop.substring (i + 1);- - j = 0;- - foreach (string p in property) {- if (p == k) {- break;- }- j++;- }- - if (j >= property.length ()) {- warning (@"key $k not found in property list");- return;- }- - cb = call.nth (j).data;- cb.call (v);- - print (@"Got $k -> $v\n");- }- /** Queue redraw area */ public signal void redraw_area (double x, double y, double w, double h); @@ -87,6 +44,10 @@ public abstract class FontDisplay : GLib.Object { return false; } + public virtual string get_uri () {+ return "";+ }+ public virtual string get_html_file () { return ""; }@@ -98,10 +59,10 @@ public abstract class FontDisplay : GLib.Object { public virtual void draw (Allocation allocation, Context cr) { } - public virtual void selected_canvas (){+ public virtual void selected_canvas () { } - public virtual void key_press (EventKey e){+ public virtual void key_press (EventKey e) { } public virtual void key_release (EventKey e) {@@ -179,6 +140,52 @@ public abstract class FontDisplay : GLib.Object { return f; }++ public void add_html_callback (string prop, PropertyFunction.PropertyCallback cb) {+ PropertyFunction pf = new PropertyFunction ();+ pf.call = cb;+ property.append (prop);+ call.append (pf);+ }+ + public void process_property (string prop) {+ string k, v;+ int i, j;+ PropertyFunction cb;+ + if (prop == "" || prop == "done") {+ return;+ }+ + i = prop.index_of (":");+ + if (i <= 0) {+ return;+ }+ + k = prop.substring (0, i);+ v = prop.substring (i + 1);+ + j = 0;+ + foreach (string p in property) {+ if (p == k) {+ break;+ }+ j++;+ }+ + if (j >= property.length ()) {+ warning (@"key $k not found in property list");+ return;+ }+ + cb = call.nth (j).data;+ cb.call (v);+ + print (@"Got $k -> $v\n");+ }+ } }@@ -87,18 +87,22 @@ public class MainWindow : Gtk.Window { glyph_canvas.set_current_glyph (fd); n = fd.is_html_canvas (); - if (n) { + if (n) { layout_dir = FontDisplay.find_layout_dir (); html_box.set_visible (n); glyph_canvas.set_visible (!n); - uri = @"file://$((!) layout_dir.get_path ())/$(fd.get_html_file ())"; - if (fd.get_html_file () != "") { - assert (fd.get_html () == ""); + uri = fd.get_uri (); + + if (uri == "") { + uri = @"file://$((!) layout_dir.get_path ())/$(fd.get_html_file ())"; + } + + if (fd.get_html () == "") { html_canvas.load_uri (uri); } else { html_canvas.load_html_string (fd.get_html (), uri); - } + } } else { html_box.set_visible (false); glyph_canvas.set_visible (true); @@ -150,6 +154,10 @@ public class MainWindow : Gtk.Window { show_all (); } + 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 }; @@ -36,6 +36,7 @@ SUPPLEMENT_MAIN = [ 'OverView.vala', 'Path.vala', 'PenTool.vala', + 'Preview.vala', 'ResizeTool.vala', 'SaveDialog.vala', 'Scrollbar.vala',