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

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

cleanup due to plugin integration

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