Re: Help me about this "drawable" error
- From: Manuel Menal <mmenal ifrance com>
- To: GTK Application Development List <gtk-app-devel-list gnome org>
- Subject: Re: Help me about this "drawable" error
- Date: Fri, 10 Nov 2000 14:34:04 +0100
Jung-Wuk Hong wrote:
JWH> Hi
JWH> I wrote a function to write text on popup window. However it doesn't work
JWH> correctly.
JWH> I met the error drawable!=NULL.
JWH> Please help me about this problem.
JWH> In main.c, this callback is connected like this "gtk_signal_connect( button1,
JWH> "clicked", show_property, NULL);
JWH> Although I could see the button generated in this callback....
That's a quite common error. You cannot access to the GdkWindow of a
widget before widgets and his parents (here, vbox and property_window)
are realized, means they are attached with a parent (except for a
window) and shown. Here, you just should change the order of the
lines. A function like this :
void show_property(GtkButton *but)
{
GtkWidget *property_window;
GtkWidget *button;
GtkWidget *vbox, *plot_area;
GdkFont *font;
property_window = gtk_window_new (GTK_WINDOW_POPUP); /* make init image
window */
gtk_window_set_position (GTK_WINDOW (property_window), GTK_WIN_POS_CENTER);
gtk_widget_show (property_window);
vbox = gtk_vbox_new(FALSE, NO_SPACING);
gtk_container_add( GTK_CONTAINER( property_window ), vbox );
gtk_widget_show (vbox);
plot_area = gtk_drawing_area_new();
gtk_box_pack_start( GTK_BOX(vbox), plot_area, FALSE, FALSE, NO_PADDING );
gtk_widget_show (plot_area);
gtk_drawing_area_size( GTK_DRAWING_AREA(plot_area), 300, 200 );
font = gdk_font_load ("-*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*");
gdk_draw_text(GTK_WIDGET(plot_area)->window, font,
GTK_WIDGET(plot_area)->style->black_gc, 10,10, "abc",15);
button = gtk_button_new_with_label("OK");
gtk_box_pack_start( GTK_BOX(vbox), button, FALSE, FALSE, NO_PADDING );
gtk_widget_show (button);
}
... should avoid you this warning.
JWH> Thanks
JWH> J. Hong
[cut]
Hope it helps,
--
mmenal
____ _ _ _
__ __ _ __ __ __ / ___| ___ _ _ | | ( )_ __ _ ___ __ | |
(o- \ \/ /(_)\ \/ / _ \ | | _ /'_ \| | | | | | | | '_ \| | | \ \/ / | |
/\ \ / | | \ / | __/ | |_| | | | | |_| | | |__| | | | | |_| |> < |_|
L_/_ \/ |_| \/ \___| \_____|_| |_|\__,_/ |____|_|_| |_|\__,_/_/\_\ (_)
______________________________________________________________________________
Vous avez un site perso ?
2 millions de francs à gagner sur i(france) !
Webmasters : ZE CONCOURS ! http://www.ifrance.com/_reloc/concours.emailif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]