source: osm/applications/editors/josm/webgrabber/webkit-image-gtk.c@ 24969

Last change on this file since 24969 was 24718, checked in by stoecker, 14 years ago

cleanup due to plugin integration

File size: 1.2 KB
Line 
1/* There is no licence for this, I don't care what you do with it */
2#include <stdlib.h>
3#include <unistd.h>
4
5#include <gio/gunixoutputstream.h>
6#include <webkit/webkit.h>
7
8#define WIDTH 2000
9
10/* compile with:
11 * gcc -o webkit-image-gtk webkit-image-gtk.c `pkg-config --cflags --libs webkit-1.0 gio-unix-2.0`
12 * Requires GTK+ 2.20 and WebKitGtk+ 1.1.1
13 */
14
15static void
16on_finished (WebKitWebView *view,
17 WebKitWebFrame *frame,
18 GtkOffscreenWindow *window)
19{
20 GdkPixbuf *pixbuf;
21 GOutputStream *stream;
22
23 pixbuf = gtk_offscreen_window_get_pixbuf (window);
24
25 stream = g_unix_output_stream_new (STDOUT_FILENO, TRUE);
26 gdk_pixbuf_save_to_stream (pixbuf, stream, "png", NULL, NULL, NULL);
27
28 exit (1);
29}
30
31int
32main (int argc,
33 char **argv)
34{
35 GtkWidget *window;
36 GtkWidget *view;
37
38 if (argc != 2)
39 exit (20);
40
41 gtk_init (&argc, &argv);
42
43 window = gtk_offscreen_window_new ();
44
45 view = webkit_web_view_new ();
46 webkit_web_view_load_uri (WEBKIT_WEB_VIEW (view), argv[1]);
47 gtk_widget_set_size_request (view, WIDTH, WIDTH);
48 gtk_container_add (GTK_CONTAINER (window), view);
49
50 gtk_widget_show_all (window);
51
52 g_signal_connect (view, "load-finished",
53 G_CALLBACK (on_finished), window);
54
55 gtk_main ();
56 return 0;
57}
Note: See TracBrowser for help on using the repository browser.