Commit 89bb8b6
remove html canvas
Changed files (12)
modifiedbirdfont/GtkWindow.valamodifiedbirdfont/Main.valadeletedlayout/delete_backup.pngdeletedlayout/index.htmldeletedlayout/style.cssdeletedlayout/supplement.jsmodifiedlibbirdfont/CharDatabase.valamodifiedlibbirdfont/DescriptionTab.valamodifiedlibbirdfont/FontDisplay.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/MenuTab.valamodifiedlibbirdfont/Preview.vala
Diff
@@ -91,11 +91,8 @@ public class GtkWindow : Gtk.Window, NativeWindow { html_canvas.set_editable (true); MainWindow.get_tab_bar ().signal_tab_selected.connect ((f, tab) => {- File layout_dir;- File layout_uri; string uri = ""; FontDisplay fd = tab.get_display ();- bool html = fd.get_name () == "Preview"; MainWindow.glyph_canvas.set_current_glyph (fd); scrollbar.set_visible (fd.has_scrollbar ());@@ -105,86 +102,66 @@ public class GtkWindow : Gtk.Window, NativeWindow { description.canvas.set_visible (true); html_box.set_visible (false); glyph_canvas_area.set_visible (false);- } else if (html) {- layout_dir = FontDisplay.find_layout_dir ();- uri = fd.get_uri ();- - if (uri == "") {- layout_uri = layout_dir.get_child (fd.get_html_file ());- uri = FontDisplay.path_to_uri ((!) layout_uri.get_path ());- }- - if (fd.get_html () == "") {+ } else if (fd.get_name () == "Preview") {+ uri = Preview.get_uri ();++ // hack: force webkit to ignore cache in preview+ html_box.set_visible (false);+ glyph_canvas_area.set_visible (true);+ + try {+ DataInputStream dis = new DataInputStream (Preview.get_html_file ().read ());+ string? line;+ StringBuilder sb = new StringBuilder ();+ uint rid = Random.next_int ();+ Font font = BirdFont.get_current_font (); - if (fd.get_name () == "Preview") {- // hack: force webkit to ignore cache in preview -- html_box.set_visible (false);- glyph_canvas_area.set_visible (true);- - try {- Preview preview = (Preview) fd;- DataInputStream dis = new DataInputStream (preview.get_html_file ().read ());- string? line;- StringBuilder sb = new StringBuilder ();- uint rid = Random.next_int ();- Font font = BirdFont.get_current_font ();- - File preview_directory = BirdFont.get_preview_directory ();- - File f_ttf = font.get_folder ().get_child (@"$(font.get_full_name ()).ttf");- File f_eot = font.get_folder ().get_child (@"$(font.get_full_name ()).eot");- File f_svg = font.get_folder ().get_child (@"$(font.get_full_name ()).svg");-- if (f_ttf.query_exists ()) {- f_ttf.delete ();- }- - if (f_eot.query_exists ()) {- f_eot.delete ();- }- - if (f_svg.query_exists ()) {- f_svg.delete ();- }- - ExportTool.export_ttf_font (); - ExportTool.export_svg_font ();- - File r_ttf = preview_directory.get_child (@"$(font.get_full_name ())$rid.ttf");- File r_svg = preview_directory.get_child (@"$(font.get_full_name ())$rid.svg");- - if (BirdFont.win32) {- f_ttf.copy (r_ttf, FileCopyFlags.NONE);- }- - f_svg.copy (r_svg, FileCopyFlags.NONE);-- while ((line = dis.read_line (null)) != null) {- line = ((!) line).replace (@"$(font.get_full_name ()).ttf", @"$(FontDisplay.path_to_uri ((!) f_ttf.get_path ()))?$rid");- line = ((!) line).replace (@"$(font.get_full_name ()).eot", @"$(FontDisplay.path_to_uri ((!) f_eot.get_path ()))?$rid");- line = ((!) line).replace (@"$(font.get_full_name ()).svg", @"$(FontDisplay.path_to_uri ((!) f_svg.get_path ()))?$rid");- sb.append ((!) line);- }+ File preview_directory = BirdFont.get_preview_directory (); - html_canvas.load_html_string (sb.str, uri);- - } catch (Error e) {- warning (e.message);- warning ("Failed to load html into canvas.");- }- } else {- // normal way to load a uri for all other pages- html_canvas.load_uri (uri);- html_canvas.reload_bypass_cache (); + File f_ttf = font.get_folder ().get_child (@"$(font.get_full_name ()).ttf");+ File f_eot = font.get_folder ().get_child (@"$(font.get_full_name ()).eot");+ File f_svg = font.get_folder ().get_child (@"$(font.get_full_name ()).svg");++ if (f_ttf.query_exists ()) {+ f_ttf.delete (); } - } else {- html_canvas.load_html_string (fd.get_html (), uri);+ if (f_eot.query_exists ()) {+ f_eot.delete ();+ }+ + if (f_svg.query_exists ()) {+ f_svg.delete ();+ }+ + ExportTool.export_ttf_font (); + ExportTool.export_svg_font ();+ + File r_ttf = preview_directory.get_child (@"$(font.get_full_name ())$rid.ttf");+ File r_svg = preview_directory.get_child (@"$(font.get_full_name ())$rid.svg");+ + if (BirdFont.win32) {+ f_ttf.copy (r_ttf, FileCopyFlags.NONE);+ }+ + f_svg.copy (r_svg, FileCopyFlags.NONE);++ while ((line = dis.read_line (null)) != null) {+ line = ((!) line).replace (@"$(font.get_full_name ()).ttf", @"$(FontDisplay.path_to_uri ((!) f_ttf.get_path ()))?$rid");+ line = ((!) line).replace (@"$(font.get_full_name ()).eot", @"$(FontDisplay.path_to_uri ((!) f_eot.get_path ()))?$rid");+ line = ((!) line).replace (@"$(font.get_full_name ()).svg", @"$(FontDisplay.path_to_uri ((!) f_svg.get_path ()))?$rid");+ sb.append ((!) line);+ }+ + html_canvas.load_html_string (sb.str, uri);+ + } catch (Error e) {+ warning (e.message);+ warning ("Failed to load html into canvas."); } - html_box.set_visible (html);- glyph_canvas_area.set_visible (!html);+ html_box.set_visible (true);+ glyph_canvas_area.set_visible (false); description.canvas.set_visible (false); } else { html_box.set_visible (false);@@ -31,8 +31,8 @@ public static int main (string[] arg) { BirdFont.BirdFont birdfont = new BirdFont.BirdFont (); CharDatabaseParser db = new CharDatabaseParser (); unowned Thread<int> db_thread;- Mutex database_mutex = new Mutex ();- Cond main_loop_idle = new Cond ();+ Mutex database_mutex = Mutex ();+ Cond main_loop_idle = Cond (); bool in_idle = false; birdfont.init (arg, null);deleted file mode 100644Binary files a/layout/delete_backup.png and /dev/null differdeleted file mode 100644@@ -1,9 +0,0 @@-<html>-<head>- <script type="text/javascript" src="supplement.js"></script>- <style type="text/css">@import url("style.css");</style>-</head>-<body>-<h1>Supplement index</h1>-</body>-</html>deleted file mode 100644@@ -1,92 +0,0 @@-@charset "UTF-8";--.clearBoth { clear:both; }--body {-}--div {- font-size: 10pt;-}--div.content {- width: 100%;-}--div.heading {- width: 100%;- background-color: #BABABA; -}--div.menu_item {- width: 100%;- background-color: #CEDAE7; - color: #000000;- margin: 0 0 2px 0;- padding: 0 -3px 0 3px;- cursor: default;-}--div.menu_item:hover {- background-color: #E6ECF6; -}--div.inner_format_box {- float: left;- width: 210px;- padding: 0 0 0 0;- margin: 0 10px 0 0;- top: 50%;-}--div.one_line {- position: relative;- top: 100px;- overflow: hidden;- white-space: nowrap; -}--div.recent_font {- float: left;- overflow: hidden;- background-color: #EFEFEF; - width: 100px;- height: 120px;- margin: 5px 5px 5px 5px;- font-size: 10pt;- text-align: center;- padding: 10px 10px 10px 10px;- cursor: default;-}--div.recent_list {- margin: 10px 0 0 0; -}--h2 {- font-size: 12pt;- margin-left: 3px;- margin-bottom: 4px;-}--h3 {- font-size: 10pt;- margin-left: 3px;- margin-bottom: 4px;-}--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;-}deleted file mode 100644@@ -1,47 +0,0 @@-function call (command) {- document.title=command;- document.title='done';-}--// MenuTab text fields-function update_text_fields () {- mess = 'glyph_sequence:';- mess += document.getElementById('glyph_sequence').value;- call (mess); -}--// DescriptionTab text fields-function update_name_fields () {- mess = 'postscript_name:';- mess += document.getElementById('postscript_name').value;- call (mess);- - mess = 'name:';- mess += document.getElementById('name').value;- call (mess);- - mess = 'subfamily:';- mess += document.getElementById('subfamily').value;- call (mess);-- mess = 'full_name:';- mess += document.getElementById('full_name').value;- call (mess);-- mess = 'unique_identifier:';- mess += document.getElementById('unique_identifier').value;- call (mess);- - mess = 'version:';- mess += document.getElementById('version').value;- call (mess);-- mess = 'description:';- mess += document.getElementById('description').value;- call (mess);- - mess = 'copyright:';- mess += document.getElementById('copyright').value;- call (mess);- -}@@ -56,8 +56,8 @@ public class CharDatabase { } foreach (string i in index.get (s)) {- c = Font.to_unichar ("U+" + i.down ());- ucd_result.add_single (c);+ c = Font.to_unichar ("U+" + i.down ());+ ucd_result.add_single (c); } try {@@ -28,10 +28,6 @@ public class DescriptionTab : FontDisplay { public override string get_label () { return _("Description"); }-- public override string get_html () {- return "".dup ();- } } }@@ -22,10 +22,12 @@ public abstract class FontDisplay : GLib.Object { public signal void redraw_area (double x, double y, double w, double h); public virtual string get_name () {+ warning ("No name."); return ""; } public virtual string get_label () {+ warning ("No label."); return ""; } @@ -61,18 +63,6 @@ public abstract class FontDisplay : GLib.Object { return uri; }-- public virtual string get_uri () {- return "";- }- - public virtual string get_html_file () {- return "index.html";- }- - public virtual string get_html () {- return "";- } public virtual void draw (WidgetAllocation allocation, Context cr) { }@@ -114,15 +104,12 @@ public abstract class FontDisplay : GLib.Object { } public virtual void store_current_view () {- warning ("store_current_view not implemented for this class."); } public virtual void restore_last_view () {- warning ("restore_last_view not implemented for this class."); } public virtual void next_view () {- warning ("next_view not implemented for this class."); } public virtual void scroll_wheel_up (double x, double y) {@@ -134,11 +121,6 @@ public abstract class FontDisplay : GLib.Object { public virtual void undo () { } - public static File find_layout_dir () {- File f = find_file (null, "layout");- return f; - }- public static File find_file (string? dir, string name) { return SearchPaths.find_file (dir, name); }@@ -543,7 +543,11 @@ public class Glyph : FontDisplay { public override string get_name () { return name; }- ++ public override string get_label () {+ return name;+ }+ private void help_line_event (double x, double y) { bool m = false; @@ -45,10 +45,6 @@ public class MenuTab : FontDisplay { return "Menu"; } - public override string get_html () {- return "".dup ();- }- public static void select_overview () { if (suppress_event) { return;@@ -23,6 +23,10 @@ public class Preview : FontDisplay { return "Preview"; } + public override string get_label () {+ return _("Preview");+ }+ public override void selected_canvas () { } @@ -43,11 +47,11 @@ public class Preview : FontDisplay { return file; } - public new File get_html_file () {+ public static File get_html_file () { return get_file (); } - public override string get_uri () {+ public static string get_uri () { return path_to_uri ((!) get_html_file ().get_path ()); }