Changeset 21401 in osm for applications/editors/josm
- Timestamp:
- 2010-05-22T12:32:00+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/webkit-image-gtk.c
r16592 r21401 1 1 /* There is no licence for this, I don't care what you do with it */ 2 #include <stdio.h>3 2 #include <stdlib.h> 3 #include <unistd.h> 4 4 5 #include <gio/gunixoutputstream.h> 5 6 #include <webkit/webkit.h> 6 7 … … 8 9 9 10 /* compile with: 10 gcc -o webkit-image-gtk webkit-image-gtk.c `pkg-config --cflags --libs webkit-1.0` 11 */ 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 */ 12 14 13 15 static void 14 on_finished (WebKitWebView *view, WebKitWebFrame *frame) 16 on_finished (WebKitWebView *view, 17 WebKitWebFrame *frame, 18 GtkOffscreenWindow *window) 15 19 { 16 GdkPixmap *pixmap;17 GdkColormap *cmap;18 20 GdkPixbuf *pixbuf; 19 gchar *buffer; 20 gsize size; 21 GOutputStream *stream; 21 22 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); 23 pixbuf = gtk_offscreen_window_get_pixbuf (window); 26 24 27 gdk_pixbuf_save_to_buffer (pixbuf, &buffer, &size, "png", NULL, NULL); 28 29 fwrite (buffer, 1, size, stdout); 25 stream = g_unix_output_stream_new (STDOUT_FILENO, TRUE); 26 gdk_pixbuf_save_to_stream (pixbuf, stream, "png", NULL, NULL, NULL); 30 27 31 28 exit (1); 32 29 } 33 30 34 int main (int argc, char **argv) 31 int 32 main (int argc, 33 char **argv) 35 34 { 36 35 GtkWidget *window; … … 42 41 gtk_init (&argc, &argv); 43 42 44 window = gtk_window_new (GTK_WINDOW_POPUP); 45 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"); 43 window = gtk_offscreen_window_new (); 51 44 52 45 view = webkit_web_view_new (); 53 webkit_web_view_ open(WEBKIT_WEB_VIEW (view), argv[1]);46 webkit_web_view_load_uri (WEBKIT_WEB_VIEW (view), argv[1]); 54 47 gtk_widget_set_size_request (view, WIDTH, WIDTH); 55 48 gtk_container_add (GTK_CONTAINER (window), view); … … 57 50 gtk_widget_show_all (window); 58 51 59 g_signal_connect ( G_OBJECT (view), "load-finished",60 G_CALLBACK (on_finished), NULL);52 g_signal_connect (view, "load-finished", 53 G_CALLBACK (on_finished), window); 61 54 62 55 gtk_main ();
Note:
See TracChangeset
for help on using the changeset viewer.