Commit 702716a
valid uris for windows paths
Changed files (6)
modifiedlayout/style.cssmodifiedsrc/FontDisplay.valamodifiedsrc/MainWindow.valamodifiedsrc/MenuTab.valamodifiedsrc/Preview.valamodifiedsrc/SaveDialog.vala
Diff
@@ -78,5 +78,17 @@ h3 { } input.text {+ border: 1px solid #bebebe;+ background: #FFF; width: 100%; }++input.button {+ border: 1px solid #dedede;+ background: #efefef;+}++input.checkbox {+ border: 1px solid #dedede;+ background: #efefef;+}@@ -44,6 +44,20 @@ public abstract class FontDisplay : GLib.Object { return false; } + public static string path_to_uri (string path) {+ int i;+ string uri = path;+ + uri = path.replace ("\\", "/");+ i = uri.index_of (":");+ + if (i != -1) {+ uri = uri.substring (i + 2);+ }+ + return @"file:///$uri";+ }+ public virtual string get_uri () { return ""; }@@ -84,6 +84,7 @@ public class MainWindow : Gtk.Window { File layout_dir; File layout_uri; string uri; + int i; FontDisplay fd = tab.get_display (); glyph_canvas.set_current_glyph (fd); @@ -98,11 +99,9 @@ public class MainWindow : Gtk.Window { if (uri == "") { layout_uri = layout_dir.get_child (fd.get_html_file ()); - uri = @"file://$((!) layout_uri.get_path ())"; + uri = fd.path_to_uri ((!) layout_uri.get_path ()); } - print (@"base uri: $uri\n"); - if (fd.get_html () == "") { html_canvas.load_uri (uri); } else { @@ -63,6 +63,7 @@ class MenuTab : FontDisplay { }); add_html_callback ("load", (val) => {+ print (@"Load: $val\n"); load_font (val); }); @@ -109,6 +110,7 @@ class MenuTab : FontDisplay { public override string get_html () { Font f = Supplement.get_current_font (); StringBuilder c = new StringBuilder ();+ string fn; propagate_recent_files (); @@ -140,14 +142,14 @@ class MenuTab : FontDisplay { <div class="content"> <form> <h3>Formats</h3>- <input type="checkbox" id="svg" checked="checked" onchange="update_export_settings ();"/> SVG<br />- <input type="checkbox" id="ttf" checked="checked" onchange="update_export_settings ();"/> TTF<br />+ <input class="checkbox" type="checkbox" id="svg" checked="checked" onchange="update_export_settings ();"/> SVG<br />+ <input class="checkbox" type="checkbox" id="ttf" checked="checked" onchange="update_export_settings ();"/> TTF<br /> <h3>Name</h3> <input class="text" type="text" id="fontname" value=""" + "\"" + f.get_name () + "\"" + """ onchange="update_export_settings ();"/><br /> - <input type="button" value="Export" id="export_button" onclick="call ('export:fonts');"/>- <input type="button" value="Preview" id="preview_button" onclick="call ('preview:fonts');"/><br />+ <input class="button" type="button" value="Export" id="export_button" onclick="call ('export:fonts');"/>+ <input class="button" type="button" value="Preview" id="preview_button" onclick="call ('preview:fonts');"/><br /> </form> </div> </div>@@ -158,23 +160,22 @@ class MenuTab : FontDisplay { <div class="heading"><h2>Recent files</h2></div> """); -string fn; foreach (Font font in recent_fonts) { fn = (!) font.font_file; fn = fn.substring (fn.replace ("\\", "/").last_index_of ("/") + 1); - c.append ("""<div class="recent_font" """ + "onclick=\"call ('load:" + (!) font.font_file + "');\">");+ c.append ("""<div class="recent_font" """ + "onclick=\"call ('load:" + ((!) font.font_file).replace ("\\", "\\\\") + "');\">"); c.append ("<div class=\"one_line\">"); c.append (fn); c.append ("</div>"); c.append ("<img src=\"");- c.append ((!) Supplement.get_thumbnail_directory ().get_path ());+ c.append (path_to_uri ((!) Supplement.get_thumbnail_directory ().get_path ())); c.append ("/"); c.append (fn); c.append (@".png?$(Random.next_int ())\" alt=\"\"><br /><br />");-+ c.append ("</div>\n"); } @@ -184,7 +185,6 @@ c.append (""" </body> </html> """);- return c.str; } @@ -47,8 +47,10 @@ class Preview : FontDisplay { if (!file.query_exists ()) { ExportTool.generate_html_document ((!)file.get_path (), font); }+ + print (@"uri $(path_to_uri ((!)file.get_path ()))\n"); - return @"file://$((!)file.get_path ())";+ return path_to_uri ((!)file.get_path ()); } } }@@ -81,10 +81,10 @@ class SaveDialog : FontDisplay { <p>""" + fn + """</p> <form>- <input type="button" value="Save" id="save" onclick="call ('save_dialog:save');"/>- <input type="button" value="Save as" id="save_as" onclick="call ('save_dialog:save_as');"/>- <input type="button" value="Discard" id="discard" onclick="call ('save_dialog:discard');"/>- <input type="button" value="Cancel" id="cancel" onclick="call ('save_dialog:cancel');"/>+ <input class="button" type="button" value="Save" onclick="call ('save_dialog:save');"/>+ <input class="button" type="button" value="Save as" onclick="call ('save_dialog:save_as');"/>+ <input class="button" type="button" value="Discard" onclick="call ('save_dialog:discard');"/>+ <input class="button" type="button" value="Cancel" onclick="call ('save_dialog:cancel');"/> <br /> </form> </div>