GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Apr 16, 2014 7:32 am

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: GTK Text view (please help)
PostPosted: Sun May 06, 2007 12:20 pm 
Offline
Familiar Face

Joined: Sun May 06, 2007 12:12 pm
Posts: 14
Hi all,

I want to use GTK text view ,to show some messages during the run of a program.


GtkWidget *text_buffer;
GtkTextBuffer *buff;
Gtk.TextIter start;
text_buffer=gtk_text_view_new();
gtk_text_view_set_editable(GTK_TEXT_VIEW(text_buffer),FALSE);
buff=gtk_text_view_get_buffer (GTK_TEXT_VIEW(text_buffer));
gtk_text_buffer_get_start_iter(buff,&start);
gtk_text_buffer_insert(buff,&start,"Hello",-1);

But each time i do a gtk_text_buffer_insert the inserted comment displayed only in the same line, My question is how i can display another comment in another line of my gtk text view ?

or if there is another solution to use another widget for example to display some comment in the text!.

Cheers.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 06, 2007 1:33 pm 
Offline
Familiar Face

Joined: Tue Jan 23, 2007 6:13 pm
Posts: 34
Use gtk_text_buffer_insert_at_cursor().
Simply calls gtk_text_buffer_insert(), using the current cursor position as the insertion point.
Here you are some additional information.
http://developer.gnome.org/doc/API/2.0/gtk/GtkTextBuffer.html#gtk-text-buffer-insert-at-cursor


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 06, 2007 1:56 pm 
Offline
Familiar Face

Joined: Sun May 06, 2007 12:12 pm
Posts: 14
Thank you for the quick reply your reply help me to do it.

Cheers.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 06, 2007 2:28 pm 
Offline
Familiar Face

Joined: Sun May 06, 2007 12:12 pm
Posts: 14
No i was wrong,

I didn't solve my problem if i call gtk_text_buffer_inset_at_cursor twice the second insersion will be in the same line,so how to move the cursor to the next line and do the insertion.

The text is not editable just used to show some messages.


Cheers.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 06, 2007 2:49 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
It sounds like your message is just continually appended to the text buffer. You'll need to insert a new line character, and then use gtk_text_iter_forward_line() to move to the next line.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 06, 2007 3:28 pm 
Offline
Familiar Face

Joined: Sun May 06, 2007 12:12 pm
Posts: 14
please ,can you provide me more details,

as a sample code can help me.

Thx in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 06, 2007 3:46 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
Code:
GtkTextBuffer *buffer;
GtkTextIter iter;
gchar *text;

buffer = gtk_text_view_get_buffer (view);
text = g_strconcat (your_message, "\n", NULL);
gtk_text_buffer_get_end_iter (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, text, -1);
g_free (text);

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 06, 2007 4:10 pm 
Offline
Familiar Face

Joined: Sun May 06, 2007 12:12 pm
Posts: 14
it 's still writing all the messages in the same line.

Any suggestion.

Thx.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 06, 2007 4:29 pm 
Offline
Familiar Face

Joined: Sun May 06, 2007 12:12 pm
Posts: 14
I'm sorry, since i'm not compiling in my computer,i'm compiling on another one using secure shell,it takes time to install new binaries.that's why it ran the old one now the one which i made with your help.


Problem solved,

Thx very much for your support
Cheers,


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group