Re: warning while executing gtk_widget_draw

Lokesh Chakka <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <CACh--sh=HQd-GVb3uOGBq3MnygK7fxMgcOx6cpvAxwWqdeApAA@mail.gmail.com>
ravi / Uli,

following modification fixed the issue:

static gboolean on_draw_event( GtkWidget *widget, cairo_t *cr, gpointer
user_data )
{
    return FALSE;
}

main()
{
    GtkDrawingArea *statistics;
    cairo_surface_t *surface;
    cairo_t *cr;
    GtkWindow *main_window;


    gtk_init( NULL, NULL );
    statistics = (GtkDrawingArea*)gtk_drawing_area_new();
    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 120, 120);
    cr = cairo_create ( surface );
    g_signal_connect(G_OBJECT(statistics), "draw",
G_CALLBACK(on_draw_event), NULL);
    main_window = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);

g_signal_connect(G_OBJECT(main_window),"destroy",G_CALLBACK(gtk_main_quit),NULL);
    gtk_container_add (GTK_CONTAINER (main_window),(GtkWidget*)statistics);
    gtk_widget_show_all((GtkWidget*)main_window);

    puts(gtk_widget_is_drawable((GtkWidget*)statistics) ? "yes" : "no");
    gtk_widget_draw( (GtkWidget*)statistics, cr );
    cairo_surface_write_to_png( surface, "one.png" );

    gtk_main();
}


Thanks & Regards
--
Lokesh Chakka,
Mobile: 9731023458


On Tue, Aug 12, 2014 at 5:01 PM, RAVI NANJUNDAPPA <[email protected]>
wrote:

> Hi,
>
> U can try this : This works fine for me.
>
> #include <cairo.h>
> #include <gtk/gtk.h>
>
> static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr,
>     gpointer user_data)
> {
> gtk_widget_draw(widget, cr );
>   return FALSE;
> }
>
> main()
> {
>     GtkDrawingArea *statistics;
>     cairo_surface_t *surface;
>     cairo_t *cr;
>     GtkWindow *main_window;
>
>
>     gtk_init( NULL, NULL );
>     statistics = (GtkDrawingArea*)gtk_drawing_area_new();
>     surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 120, 120);
>     cr = cairo_create ( surface );
>     cairo_surface_write_to_png( surface, "one.png" );
>     main_window = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);
>
>   g_signal_connect(G_OBJECT(main_window), "draw",
> G_CALLBACK(on_draw_event), NULL);
>
>
> g_signal_connect(G_OBJECT(main_window),"destroy",G_CALLBACK(gtk_main_quit),NULL);
>     gtk_container_add (GTK_CONTAINER (main_window),(GtkWidget*)statistics);
>
>     gtk_widget_show_all((GtkWidget*)main_window);
>
>     gtk_main();
> }
>
> Thanks and Best Regards,
> N Ravi
>
> ------- Original Message -------
> Sender : Lokesh Chakka<[email protected]>
> Date : Aug 12, 2014 13:24 (GMT+05:30)
> Title : [cairo] warning while executing gtk_widget_draw
>
>
>
> Hello,
>
>
> I have written one program and I am seeing the following warning:
>
> Gtk-CRITICAL **: gtk_widget_draw: assertion '!widget->priv->alloc_needed'
> failed
>
> program is as follows:
>
> main()
> {
>     GtkDrawingArea *statistics;
>     cairo_surface_t *surface;
>     cairo_t *cr;
>     GtkWindow *main_window;
>
>
>     gtk_init( NULL, NULL );
>     statistics = (GtkDrawingArea*)gtk_drawing_area_new();
>     surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 120, 120);
>     cr = cairo_create ( surface );
>     gtk_widget_draw( (GtkWidget*)statistics, cr );
>     cairo_surface_write_to_png( surface, "one.png" );
>     main_window = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);
>
> g_signal_connect(G_OBJECT(main_window),"destroy",G_CALLBACK(gtk_main_quit),NULL);
>     gtk_container_add (GTK_CONTAINER (main_window),(GtkWidget*)statistics);
>     gtk_widget_show_all((GtkWidget*)main_window);
>
>     gtk_main();
> }
>
>
> can some one please tell me the problem in the above program ?
>
>
>
> Thanks & Regards
> --
> Lokesh Chakka,
> Mobile: 9731023458
>

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.