Re: gdk draw error...



i think the problem is that you should call
gtk_widget_realize(drawing_area);
before you try to paint on it (with the function mygrid).

alternatively, you should first make the drawing area visibe and then
call the function mygrid();


i hope it helps you

George Giaslas

On Wed, 4 Oct 2000, Woo-Sick Choi wrote:

> Hi all~
> 
> To compile source is no problem.
> but when it is excuted, I got an Error.
> 
> Error Message is :
> Gdk-CRITICAL **: file gdkdraw.c: line 471 (gdk_draw_segments): assertion
> `drawable != NULL' failed.
> 
> Below is my source :
> 
> #include <gtk/gtk.h>
> #include <stdio.h>
> 
> #define SPACING 10
> #define PADDING 0
> 
> void    print_and_quit(GtkButton *, gpointer );
> gboolean delete_event_handler(GtkWidget *, GdkEvent *, gpointer);
> void    mygrid(GtkWidget *);
> 
> void    print_and_quit(GtkButton *was_clicked, gpointer data)
> {
>         g_print(" quit \n");
>         gtk_main_quit();
> }
> 
> gboolean delete_event_handler(GtkWidget *widget, GdkEvent *event,
>                                 gpointer data)
> {
>         g_print(" Close \n");
>         return(FALSE);
> }
> 
> void mygrid(GtkWidget *where)
> {
>    GdkSegment grid[4] = { { 60,20  ,  60,100},  { 90,20  ,  90,100},
>                           { 35,50  ,  115,50},  { 35, 70  ,  115, 70} };
> 
>    GdkGC *plot_gc;
> 
>    plot_gc = GTK_WIDGET(where)->style->black_gc;
> 
>    gdk_draw_segments(GTK_WIDGET(where)->window, plot_gc, grid, 4);
> }
> 
> int main(argc, argv)
> int argc;
> char **argv;
> {
>         GtkWidget       *top_widget;
>         GtkWidget       *drawing_area, *vbox;
> 
>         gtk_init(&argc, &argv);
> 
>         top_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
>         vbox = gtk_vbox_new(FALSE, SPACING);
> 
>         drawing_area = gtk_drawing_area_new();
>         gtk_drawing_area_size(GTK_DRAWING_AREA(drawing_area), 200, 100);
> 
>         gtk_window_set_title(GTK_WINDOW(top_widget), "DRAW TEST");
> 
>         gtk_signal_connect(GTK_OBJECT(top_widget), "delete_event",
>                            GTK_SIGNAL_FUNC(delete_event_handler), NULL);
> 
>         gtk_signal_connect(GTK_OBJECT(top_widget), "destroy",
>                            GTK_SIGNAL_FUNC(print_and_quit), NULL);
> 
>         gtk_container_add(GTK_CONTAINER(top_widget), vbox);
>         gtk_box_pack_start(GTK_BOX(vbox), drawing_area, FALSE, FALSE,
> PADDING);
> 
>         grid(drawing_area);
> 
>         gtk_widget_show_all(top_widget);
> 
>         gtk_main();
> }
> 
>  I don't know what's the matter...
> 
> Help me Please...
> Thank you...
> 
> 
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
> 





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]