Discussion:
[Glade-users] Problem with gtk_text_view and gtk_text_buffer...
SBBG
2005-05-01 10:26:04 UTC
Permalink
Hello,
I got a problem while using Gtk Text View, I 'm trying to set the
text view's content according to a text buffer. And ONLY show the
content of the text buffer, thus I choose the function
"gtk_text_view_set_buffer." But somehow, while executing, the console
keep showing that :

Gtk-CRITICAL **: gtk_text_buffer_set_text: assertion
`GTK_IS_TEXT_BUFFER (buffer)' failed

and set text to text view failed, too. OOPS!!
Following is the code where shxt happened:

void refresh( char *memU, char *regU, GtkTextView *memView,
GtkTextView *regView )
{
GtkTextBuffer *memBuffer=NULL;
GtkTextBuffer *regBuffer=NULL;
gtk_text_buffer_set_text( memBuffer, memU, -1 );
gtk_text_buffer_set_text( regBuffer, regU, -1 );
gtk_text_view_set_buffer( GTK_TEXT_VIEW(memView), memBuffer );
gtk_text_view_set_buffer( GTK_TEXT_VIEW(regView), regBuffer );
}

I've checked the GTK+ Reference Manual for the prototype of
gtk_text_view_set_buffer for many times, But I just can't figure out
what's wrong. May anyone give a hand? Thanks a lot!!
Vivien Malerba
2005-05-02 08:05:23 UTC
Permalink
Post by SBBG
Hello,
I got a problem while using Gtk Text View, I 'm trying to set the
text view's content according to a text buffer. And ONLY show the
content of the text buffer, thus I choose the function
"gtk_text_view_set_buffer." But somehow, while executing, the console
Gtk-CRITICAL **: gtk_text_buffer_set_text: assertion
`GTK_IS_TEXT_BUFFER (buffer)' failed
and set text to text view failed, too. OOPS!!
void refresh( char *memU, char *regU, GtkTextView *memView,
GtkTextView *regView )
{
GtkTextBuffer *memBuffer=NULL;
GtkTextBuffer *regBuffer=NULL;
gtk_text_buffer_set_text( memBuffer, memU, -1 );
gtk_text_buffer_set_text( regBuffer, regU, -1 );
gtk_text_view_set_buffer( GTK_TEXT_VIEW(memView), memBuffer );
gtk_text_view_set_buffer( GTK_TEXT_VIEW(regView), regBuffer );
}
The problem is you call gtk_text_buffer_set_text() with a NULL 1st argument.
You should instead have something as:

memBuffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(memView));
gtk_text_buffer_set_text( memBuffer, memU, -1 );

and the same for regView.

Vivien
kappa
2005-05-03 21:30:21 UTC
Permalink
Hello Glade-Users!


I'm writing an educational game for learning geography.
I need to display some map from file(for example Europe) and after
moving mouse cursor
over some country, I need that country to highlight and after moving the
cursor out of the country
area, the country region should be darker again.

1) I don't know the tehniques for doing such things. Should I use some
black-and-white masks
for each country to know which area to highlight?

2) I have problems with drawing on the GtkImage area when I read-in some
image (with 'gtk_image_set_from_file')
I used the description from:
http://www.klaban.torun.pl/help/GtkTutor/gtk_tut-23.html
but I can draw only on the area, where 'gtk_image_set_from_file' didn't
put any pixel. It seems like the
data from file were put at the screen after my drawing(??)


I don't know if I explained those problems good enough.
If You know any better place to ask that questions, tell me please.
I would be grateful for any help!


Regards,
kappa
John Coppens
2005-05-04 01:06:50 UTC
Permalink
On Tue, 03 May 2005 23:30:21 +0200
Post by kappa
Hello Glade-Users!
I'm writing an educational game for learning geography.
I need to display some map from file(for example Europe) and after
moving mouse cursor
over some country, I need that country to highlight and after moving
the cursor out of the country
area, the country region should be darker again.
1) I don't know the tehniques for doing such things. Should I use some
black-and-white masks
for each country to know which area to highlight?
I'd suggest using gnome_canvas. You can then add another layer (image)
which can be even half-transparent to mask the other countries - or even
a lot of layers at the beginning and hide/show the layers one by one.
Post by kappa
2) I have problems with drawing on the GtkImage area when I read-in
some image (with 'gtk_image_set_from_file')
http://www.klaban.torun.pl/help/GtkTutor/gtk_tut-23.html
but I can draw only on the area, where 'gtk_image_set_from_file' didn't
put any pixel. It seems like the
data from file were put at the screen after my drawing(??)
Again, I'd suggest using the canvas, which will give you the possibility
to draw on another layer, which makes it easier to clear if necessary.

Check the GTK+ / Gnome Application Development, chapter on GnomeCanvas.

John
kappa
2005-05-04 07:51:27 UTC
Permalink
Post by John Coppens
I'd suggest using gnome_canvas. You can then add another layer (image)
which can be even half-transparent to mask the other countries - or even
a lot of layers at the beginning and hide/show the layers one by one.
Again, I'd suggest using the canvas, which will give you the possibility
to draw on another layer, which makes it easier to clear if necessary.
It would be great if I could use it, but is it portable? I forgot to
add, that I need to be able to compile project
under MS Windows also.


kappa

Loading...