webkitpdf.vala
[app.webkitpdf] / webkitpdf.vala
1
2 //valac --vapidir=./vapi --pkg gtk+-3.0 --pkg webkit2gtk-3.0 --pkg libsoup-2.4 webkitpdf.vala BrowserWindow -o /usr/bin/wksnapshot
3  
4 public class webkitpdf {
5  
6     public static string? opt_url = null;
7         public static uint opt_delay = 0;
8         public static string opt_target_png = null;
9         const OptionEntry[] options = {
10                 
11                         
12                         { "url", 0, 0, OptionArg.STRING, ref opt_url, "Url to grab", null },
13                         { "delay", 0, 0, OptionArg.INT, ref opt_delay, "Delay before snapshot in seconds", null },
14                         { "png", 0, 0, OptionArg.STRING, ref opt_target_png, "File to write (PNG)", null },
15                         { null }
16         };
17     public static int main(string[] args) {
18         Gtk.init(ref args);
19  
20  
21         var opt_context = new OptionContext ("webkitpdf");
22                 
23                 
24                 try {
25                         opt_context.set_help_enabled (true);
26                         opt_context.add_main_entries (options, null);
27                         opt_context.parse (ref args);
28                         
29             if (Browser.opt_url == null) {
30                 throw new OptionError.BAD_VALUE("missing url");
31             }
32                         if (Browser.opt_target_png == null) {
33                 throw new OptionError.BAD_VALUE("missing png");
34             }
35             
36                 } catch (OptionError e) {
37                         stdout.printf ("error: %s\n", e.message);
38                         stdout.printf ("Run '%s --help' to see a full list of available command line options.\n %s", 
39                                          args[0], opt_context.get_help(true,null));
40                         return 0;
41                 }
42  
43  
44         var browser = new Browser();
45         browser.show_all();
46  
47         Gtk.main();
48  
49         return 0;
50     }
51 }
52
53
54