Commit 02b8f7e
hacks to make things run better in wine force webkit to ignore cache
Changed files (10)
modifiedNEWSmodifiedREADMEmodifiedsrc/FontDisplay.valamodifiedsrc/MainWindow.valamodifiedsrc/MenuTab.valamodifiedsrc/Preview.valamodifiedsrc/Supplement.valamodifiedsrc/TabBar.valaaddedwin32/icon.rcmodifiedwin32/wscript
Diff
@@ -3,6 +3,7 @@ birdfont (0.2.0) stable; * TTF support * Desktop file and icon * Merge paths+ * Wine support Contributions by Alexandre Prokoudine and Johan Mattsson @@ -17,7 +18,5 @@ birdfont (0.1.1) stable; birdfont (0.1.0) stable; * First release-- -- Johan Mattsson <johan.mattsson.m@gmail.com> Thu Aug 23 22:08:35 CEST 2012--+ + -- Johan Mattsson <johan.mattsson.m@gmail.com> Fri Aug 24 02:03:29 CEST 2012@@ -32,9 +32,10 @@ all dependencies from Gregs repository as described here: http://greg.thehellings.com/2012/02/a-better-ubuntu-mingw-experience/ -You need wine and nsis windows installer as well+You need wine and nsis windows installer as well. Compile and build the installer with: ./waf configure --win32 --installer+./waf clean ./waf build --win32 --installer @@ -47,14 +47,24 @@ public abstract class FontDisplay : GLib.Object { public static string path_to_uri (string path) { int i; string uri = path;+ string wp; - uri = path.replace ("\\", "/");- i = uri.index_of (":");- - if (i != -1) {- uri = uri.substring (i + 2);+ if (Supplement.win32) {+ uri = path.replace ("\\", "/");+ i = uri.index_of (":");+ + if (i != -1) {+ uri = uri.substring (i + 2);+ }++ // wine uri hack+ wp = @"/home/$(Environment.get_user_name ())/.wine/drive_c/" + uri;+ + if (Icons.find_file (null, wp).query_exists ()) {+ uri = wp.substring (i);+ } }- + return @"file:///$uri"; } @@ -105,9 +105,11 @@ public class MainWindow : Gtk.Window { } if (fd.get_html () == "") { + html_canvas.load_html_string (fd.get_html (), uri); + html_canvas.reload_bypass_cache (); html_canvas.load_uri (uri); - print (@"URI: $uri\n"); - //html_canvas.reload_bypass_cache (); + + print (@"uri: $uri\n"); } else { html_canvas.load_html_string (fd.get_html (), uri); } @@ -185,7 +185,9 @@ foreach (Font font in recent_fonts) { c.append ("<div class=\"one_line\">"); c.append (fn); c.append ("</div>");- + + print (@"path_to_uri ((!) Supplement.get_thumbnail_directory ().get_path ()) $(path_to_uri ((!) Supplement.get_thumbnail_directory ().get_path ()))\n");+ c.append ("<img src=\""); c.append (path_to_uri ((!) Supplement.get_thumbnail_directory ().get_path ())); c.append ("/");@@ -32,7 +32,10 @@ class Preview : FontDisplay { return true; } + bool b = false;+ public override void selected_canvas () {+ WebView w = MainWindow.get_webview (); string uri = get_uri (); @@ -40,6 +43,26 @@ class Preview : FontDisplay { w.open (uri); w.reload_bypass_cache ();+ + // this is a hack forces webkit to reload the font and ignore cached data+ // it's only required on windows platform and in wine + if (Supplement.win32) {+ TimeoutSource idle = new TimeoutSource (0);+ idle.set_callback(() => {+ File layout_dir = FontDisplay.find_layout_dir ();+ File layout_uri = layout_dir.get_child (get_html_file ());+ w.load_html_string ("", path_to_uri ((!) layout_uri.get_path ()));+ return false;+ });+ idle.attach (null);+ + TimeoutSource idle2 = new TimeoutSource (500);+ idle2.set_callback(() => {+ w.load_uri (get_uri ());+ return false;+ });+ idle2.attach (null);+ } } public override string get_uri () {@@ -24,6 +24,7 @@ class Supplement { public static bool experimental; public static bool show_coordinates; public static bool fatal_wanings; + public static bool win32; static Font current_font; @@ -109,6 +110,7 @@ class Supplement { experimental = args.has_argument ("--test"); show_coordinates = args.has_argument ("--show-coordinates"); fatal_wanings = has_argument ("--fatal-warning"); + win32 = (arg[0].index_of (".exe") > -1); Preferences preferences = new Preferences (); preferences.load (); @@ -249,7 +249,21 @@ class TabBar : DrawingArea { return false; }- ++ public bool selected_open_tab_by_name (string t) {+ int i = 0;+ foreach (var n in tabs) {+ if (n.get_label () == t) {+ select_tab (i);+ return true;+ }+ + i++;+ }+ + return false;+ }+ public Tab get_selected_tab () { return tabs.nth (get_selected ()).data; }new file mode 100644@@ -0,0 +1 @@+id ICON "../win32/birdfont.ico"@@ -84,7 +84,10 @@ def configure(conf): def build(bld): bld.exec_command("mkdir -p build/supplement")- ++ bld(rule="windres ${SRC} -O coff -o ${TGT}", source="../win32/icon.rc", target="icon.res", always=True)+ bld(rule="mv ${SRC} ${TGT}", source="../win32/icon.res", target="../build/", name="icon", always=True)+ bld(rule="""i686-w64-mingw32-gcc -c ./src/*.c \ -s \ -mthreads \@@ -93,9 +96,11 @@ def build(bld): $(i686-w64-mingw32-pkg-config --cflags --libs gio-2.0) \ $(i686-w64-mingw32-pkg-config --cflags --libs libsoup-2.4) \ $(i686-w64-mingw32-pkg-config --cflags --libs gtk+-2.0) \- $(i686-w64-mingw32-pkg-config --cflags --libs webkit-1.0) && mv *.o win32/""", source="../build/src/Supplement.c", target="./Supplement.o", name="mingw compile");-- bld(rule="""i686-w64-mingw32-gcc ./win32/*.o \+ $(i686-w64-mingw32-pkg-config --cflags --libs webkit-1.0) && mv *.o win32/""", source="../build/src/Supplement.c", target="./Supplement.o", name="mingw compile", always=True);+ + bld(rule="""i686-w64-mingw32-gcc \+ ./win32/*.o \+ ./icon.res \ -s \ -Wl,-subsystem,windows \ -mthreads \@@ -103,7 +108,7 @@ def build(bld): -static -B static -lintl.dll -B static -l glib-2.0.dll -B static -l xml2.dll \ -B static -lgio-2.0.dll -B static -l soup-2.4.dll \ -B static -l webkitgtk-1.0.dll -B static -lgtk-win32-2.0.dll -B static -lgdk-win32-2.0.dll -B static -latk-1.0.dll -B static -lgio-2.0.dll -B static -lpangowin32-1.0.dll -B static -lpangocairo-1.0.dll -B static -lgdk_pixbuf-2.0.dll -B static -lpango-1.0.dll -B static -lcairo.dll -B static -lgobject-2.0.dll -B static -lgmodule-2.0.dll -B static -lgthread-2.0.dll -B static -lglib-2.0.dll \- -static -o birdfont.exe""", source="../build/src/Supplement.c", target="../birdfont.exe", depends_on='mingw compile', name="mingw link")+ -static -o birdfont.exe""", source="../build/src/Supplement.c", target="../birdfont.exe", depends_on=['mingw compile', 'icon'], name="mingw link", always=True) if bld.options.installer: copy_runtime_dependencies (bld)@@ -255,7 +260,7 @@ def copy_runtime_dependencies (bld): MINGW = "/usr/i686-w64-mingw32/sys-root/mingw" MINGW_BIN = MINGW + "/bin" - bld(rule="mv birdfont.exe supplement/", depends_on='mingw link')+ bld(rule="mv birdfont.exe supplement/", depends_on='mingw link', always=True) bld(rule="cp ../README supplement/") bld(rule="cp ../COPYING supplement/") bld(rule="cp ../NEWS supplement/")