Created
May 26, 2010 17:39
-
-
Save remleduff/414786 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GtkOffscreenWindow* offscreenWindow; | |
GtkPixmap* snapshotWidget(GtkWidget* widget) { | |
// Caching doesn't work, must create a new one every time (the widget parameter is gtk_widget_destroy'ed by the caller) | |
// if (!offscreenWindow) | |
offscreenWindow = gtk_offscreen_window_new(); | |
gtk_container_add(offscreenWindow, widget); | |
gtk_widget_show(offscreenWindow); | |
force_draw(widget); | |
// This doesn't seem to make any difference | |
// force_draw(offscreenWindow); | |
GtkPixmap* result = gtk_offscreen_window_get_pixmap(offscreenWindow) | |
// Doesn't work | |
// gtk_widget_destroy(offscreenWindow); | |
return result; | |
} | |
void force_draw(GtkWidget* widget) { | |
gtk_widget_queue_draw(widget); | |
GdkWindow* window = gtk_widget_get_window(widget); | |
gdk_window_process_updates(window, true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment