Changeset 14885 in osm for applications
- Timestamp:
- 2009-05-04T01:04:49+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/webkit-image-gtk.c
r12328 r14885 1 /* There is no licence for this, I don't care what you do with it */ 1 2 #include <stdio.h> 2 3 #include <stdlib.h> 3 4 4 #include <webkit .h>5 #include <webkit/webkit.h> 5 6 6 7 #define WIDTH 2000 7 8 8 9 /* compile with: 9 gcc -W webkit-image-gtk.cpp `pkg-config --libs --cflags WebKitGtk gtk+-2.0`10 gcc `pkg-config --cflags --libs webkit-1.0` -o webkit-image-gtk webkit-image-gtk.c 10 11 */ 11 12 … … 13 14 on_finished (WebKitWebView *view, WebKitWebFrame *frame) 14 15 { 15 16 17 18 19 16 GdkPixmap *pixmap; 17 GdkColormap *cmap; 18 GdkPixbuf *pixbuf; 19 gchar *buffer; 20 gsize size; 20 21 21 22 23 24 22 pixmap = gtk_widget_get_snapshot (GTK_WIDGET (view), NULL); 23 cmap = gdk_colormap_get_system (); 24 pixbuf = gdk_pixbuf_get_from_drawable (NULL, GDK_DRAWABLE (pixmap), cmap, 25 0, 0, 0, 0, WIDTH, WIDTH); 25 26 26 27 gdk_pixbuf_save_to_buffer (pixbuf, &buffer, &size, "png", NULL, NULL); 27 28 28 29 fwrite (buffer, 1, size, stdout); 29 30 30 31 exit (1); 31 32 } 32 33 33 34 int main (int argc, char **argv) 34 35 { 35 36 36 GtkWidget *window; 37 GtkWidget *view; 37 38 38 39 39 if (argc != 2) 40 exit (20); 40 41 41 42 gtk_init (&argc, &argv); 42 43 43 /* Horribly hacky */ 44 window = gtk_window_new (GTK_WINDOW_POPUP); 45 gtk_window_set_opacity (GTK_WINDOW (window), 0.0); 44 window = gtk_window_new (GTK_WINDOW_POPUP); 46 45 47 view = webkit_web_view_new (); 48 webkit_web_view_open (WEBKIT_WEB_VIEW (view), argv[1]); 49 gtk_widget_set_size_request (view, WIDTH, WIDTH); 50 gtk_container_add (GTK_CONTAINER (window), view); 46 /* Check if compositing window manager is running, needs one for now */ 47 if (gtk_widget_is_composited (window)) 48 gtk_window_set_opacity (GTK_WINDOW (window), 0.0); 49 else 50 g_error ("This requires a compositing window manager for now"); 51 51 52 gtk_widget_show_all (window); 52 view = webkit_web_view_new (); 53 webkit_web_view_open (WEBKIT_WEB_VIEW (view), argv[1]); 54 gtk_widget_set_size_request (view, WIDTH, WIDTH); 55 gtk_container_add (GTK_CONTAINER (window), view); 53 56 54 g_signal_connect (G_OBJECT (view), "load-finished", 55 G_CALLBACK (on_finished), NULL); 57 gtk_widget_show_all (window); 56 58 57 gtk_main (); 58 return 0; 59 g_signal_connect (G_OBJECT (view), "load-finished", 60 G_CALLBACK (on_finished), NULL); 61 62 gtk_main (); 63 return 0; 59 64 }
Note:
See TracChangeset
for help on using the changeset viewer.