<div dir="ltr"><div class="gmail_extra"><div><div dir="ltr"><div dir="ltr"><div>ravi / Uli,<br><br></div>following modification fixed the issue:<br><br>static gboolean on_draw_event( GtkWidget *widget, cairo_t *cr, gpointer user_data )<br>
{<br> return FALSE;<br>}<br><br>main()<br>{<br> GtkDrawingArea *statistics;<br> cairo_surface_t *surface;<br> cairo_t *cr;<br> GtkWindow *main_window;<br><br><br> gtk_init( NULL, NULL );<br> statistics = (GtkDrawingArea*)gtk_drawing_area_new();<br>
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 120, 120);<br> cr = cairo_create ( surface );<br> g_signal_connect(G_OBJECT(statistics), "draw", G_CALLBACK(on_draw_event), NULL);<br> main_window = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);<br>
g_signal_connect(G_OBJECT(main_window),"destroy",G_CALLBACK(gtk_main_quit),NULL);<br> gtk_container_add (GTK_CONTAINER (main_window),(GtkWidget*)statistics);<br> gtk_widget_show_all((GtkWidget*)main_window);<br>
<br> puts(gtk_widget_is_drawable((GtkWidget*)statistics) ? "yes" : "no");<br> gtk_widget_draw( (GtkWidget*)statistics, cr );<br> cairo_surface_write_to_png( surface, "one.png" );<br>
<br> gtk_main();<br>}<br><br><br clear="all"></div>Thanks & Regards<br>--<br>Lokesh Chakka,<br>Mobile: 9731023458<br></div></div>
<br><br><div class="gmail_quote">On Tue, Aug 12, 2014 at 5:01 PM, RAVI NANJUNDAPPA <span dir="ltr"><<a href="mailto:nravi.n@samsung.com" target="_blank">nravi.n@samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hi,<br>
<br>
U can try this : This works fine for me.<br>
<br>
#include <cairo.h><br>
#include <gtk/gtk.h><br>
<br>
static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr,<br>
gpointer user_data)<br>
{<br>
gtk_widget_draw(widget, cr );<br>
return FALSE;<br>
<div>}<br>
<br>
main()<br>
{<br>
GtkDrawingArea *statistics;<br>
cairo_surface_t *surface;<br>
cairo_t *cr;<br>
GtkWindow *main_window;<br>
<br>
<br>
gtk_init( NULL, NULL );<br>
statistics = (GtkDrawingArea*)gtk_drawing_area_new();<br>
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 120, 120);<br>
cr = cairo_create ( surface );<br>
</div><div> cairo_surface_write_to_png( surface, "one.png" );<br>
main_window = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);<br>
<br>
</div> g_signal_connect(G_OBJECT(main_window), "draw", G_CALLBACK(on_draw_event), NULL);<br>
<div><br>
g_signal_connect(G_OBJECT(main_window),"destroy",G_CALLBACK(gtk_main_quit),NULL);<br>
gtk_container_add (GTK_CONTAINER (main_window),(GtkWidget*)statistics);<br>
<br>
gtk_widget_show_all((GtkWidget*)main_window);<br>
<br>
gtk_main();<br>
}<br>
<br>
</div>Thanks and Best Regards,<br>
N Ravi<br>
<br>
------- Original Message -------<br>
Sender : Lokesh Chakka<<a href="mailto:lvenkatakumarchakka@gmail.com" target="_blank">lvenkatakumarchakka@gmail.com</a>><br>
Date : Aug 12, 2014 13:24 (GMT+05:30)<br>
Title : [cairo] warning while executing gtk_widget_draw<br>
<br>
<br>
<br>
Hello,<br>
<div><br>
<br>
I have written one program and I am seeing the following warning:<br>
<br>
Gtk-CRITICAL **: gtk_widget_draw: assertion '!widget->priv->alloc_needed' failed<br>
<br>
</div>program is as follows:<br>
<div><br>
main()<br>
{<br>
GtkDrawingArea *statistics;<br>
cairo_surface_t *surface;<br>
cairo_t *cr;<br>
GtkWindow *main_window;<br>
<br>
<br>
gtk_init( NULL, NULL );<br>
statistics = (GtkDrawingArea*)gtk_drawing_area_new();<br>
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 120, 120);<br>
cr = cairo_create ( surface );<br>
gtk_widget_draw( (GtkWidget*)statistics, cr );<br>
</div><div> cairo_surface_write_to_png( surface, "one.png" );<br>
main_window = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);<br>
g_signal_connect(G_OBJECT(main_window),"destroy",G_CALLBACK(gtk_main_quit),NULL);<br>
gtk_container_add (GTK_CONTAINER (main_window),(GtkWidget*)statistics);<br>
gtk_widget_show_all((GtkWidget*)main_window);<br>
<br>
gtk_main();<br>
}<br>
<br>
<br>
</div><div><div>can some one please tell me the problem in the above program ?<br>
<br>
<br>
<br>
Thanks & Regards<br>
--<br>
Lokesh Chakka,<br>
Mobile: 9731023458</div></div></blockquote></div><br></div></div>