webkitpdf.vala
authorAlan Knowles <alan@roojs.com>
Thu, 12 Nov 2015 03:11:43 +0000 (11:11 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 12 Nov 2015 03:11:43 +0000 (11:11 +0800)
webkitpdf.vala

index 23a3a9d..eee1ed1 100644 (file)
@@ -1 +1,54 @@
-asdfasdf
\ No newline at end of file
+
+//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;
+       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 },
+                       { 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 (Browser.opt_url == null) {
+                throw new OptionError.BAD_VALUE("missing url");
+            }
+                       if (Browser.opt_target_png == null) {
+                throw new OptionError.BAD_VALUE("missing png");
+            }
+            
+               } 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 Browser();
+        browser.show_all();
+        Gtk.main();
+        return 0;
+    }
+}
+
+
\ No newline at end of file