RE: [gtk-list] Problem with text widget
- From: "O'CONNOR, Steve" <SOCONNOR baea com au>
- To: "'gtk-list redhat com'" <gtk-list redhat com>
- Subject: RE: [gtk-list] Problem with text widget
- Date: Fri, 5 Jun 1998 10:16:45 +0930
I think that you have hit the common problem of not realizing the widget
before use.
I dont think that there is a single programmer using GTK that has not
run into this problem. Think of it as a rite of passage rather than any
stupidity on your part. I will attempt to
explain the subtle nature of this problem ....
------------------------------------------------
Unrelated NOTE -
Any complaints that GDK/GTK produce display the opposite .
ie - GDK asserts that (gdk_window_ref != NULL), so if gdk_window_ref
is NULL, then
you get the message window != NULL coming up as a comlpaint.
This can be
a little confusing the first time around.
----------------------------------------------------------
Now, on the subject of realizing Widgets ...
When you create Windows and Widgets in GTK, the structures to hold
them are all
created, but the actual cooresponding XWindow objects are not
created yet. As soon
as you do a gtk_widget_show (), or otherwise display the window,
all of the XWindow
peer objects are created, and the widgets become useable.
Note however, that between the first declaration of the widget, and
the drawing of the
widget, the actual widget exists in a phantasmal state of limbo. If
you call any routines
that try and do useful things with this widget during the state of
limbo, GDK will
complain that the 'window' is NULL. So, it looks to me like you are
trying to set the
text in the field BEFORE the field is drawn.
Finally, it is quite valid, and desireable to initialize widgets
before displaying them by
doing a set_text, setting fonts and colours, etc. To do this, call
gtk_widget_realize()
on the top-level window widget, and the magic peer Xwindow objects
will be created
but not displayed yet. This makes all the widgets in that window
usable, so you can
then init them before display.
If you have any more problems, please post the snippet of code that you
are having problems with (just 10-20 lines or so should do)
cheers
Steve O'Connor
> -----Original Message-----
> From: Rouat manu [SMTP:er@viking.oleane.com]
> Sent: Thursday, 4 June 1998 08:41
> To: GTK mailing list
> Subject: [gtk-list] Problem with text widget
>
> Hello,
>
> I hope my question isn't too dumb - I haven't had time to go through
> the list archive (and I'm very new at writing code with widgets too)
>
> In an app I'm writing, I use a text widget to display some
> messages . The code for that widget is very close to the example
> for that widget, nothing unusual I think.
>
> This works - things get bad when I try to actually display some
> text in there, with the usual gtk_text_insert command.
> On startup, the window 'explodes' and I get a whole bunch of:
>
> ** WARNING **: file gdkwindow.c: line 665 (gdk_window_ref): "window !=
> NULL"
>
> ** WARNING **: file gtkstyle.c: line 266 (gtk_style_attach): "window
> !=
> NULL"
>
> ** WARNING **: file gdkwindow.c: line 665 (gdk_window_ref): "window !=
> NULL"
>
>
> etc.. and it sigsevs.
> It looks like I need to set some kind of attributes or something?
> I've tried to use gtk_text_freeze/thaw , but that didn't help.
>
> I've looked at the code of some apps like gEdit and testgtk,
> but I couldn't spot the magic line(s).
>
> Any help appreciated of course. I'm using gtk-1.0.1 .
>
> Regards,
>
> manu
>
> --
> "In The Beginning Was The Word. Then Came The Fucking Word Processor.
> Then Came the Thought Processor. Then came The Death Of Literature.
> And So It Goes." The Poet - Hyperion
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com <
> /dev/null
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]