gdk draw error...



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...






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