//valac --vapidir=./vapi --pkg gtk+-3.0 --pkg webkit2gtk-3.0 --pkg libsoup-2.4 webkitpdf.vala BrowserWindow -o /usr/bin/wksnapshot public class webkitpdf { public static string? opt_url = null; public static uint opt_delay = 0; public static string opt_target_png = null; public static string opt_target_pdf = null; const OptionEntry[] options = { { "url", 0, 0, OptionArg.STRING, ref opt_url, "Url to grab", null }, { "delay", 0, 0, OptionArg.INT, ref opt_delay, "Delay before snapshot in seconds", null }, //{ "png", 0, 0, OptionArg.STRING, ref opt_target_png, "File to write (PNG)", null }, { "inject", 0, 0, OptionArg.STRING, ref opt_inject_js, "Inject Javascript", null }, { "pdf", 0, 0, OptionArg.STRING, ref opt_target_pdf, "File to write (PDF)", null }, { null } }; public static int main(string[] args) { Gtk.init(ref args); var opt_context = new OptionContext ("webkitpdf"); try { opt_context.set_help_enabled (true); opt_context.add_main_entries (options, null); opt_context.parse (ref args); if (webkitpdf.opt_url == null) { throw new OptionError.BAD_VALUE("missing url"); } //if (webkitpdf.opt_target_png == null) { // throw new OptionError.BAD_VALUE("missing png" file path); //} if (webkitpdf.opt_target_pdf == null) { throw new OptionError.BAD_VALUE("missing pdf file path"); } } catch (OptionError e) { stdout.printf ("error: %s\n", e.message); stdout.printf ("Run '%s --help' to see a full list of available command line options.\n %s", args[0], opt_context.get_help(true,null)); return 0; } var browser = new BrowserWindow(); browser.el.show_all(); Gtk.main(); return 0; } }