GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GTK Text view (please help)

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
aliov
Familiar Face


Joined: 06 May 2007
Posts: 7

PostPosted: Sun May 06, 2007 12:20 pm    Post subject: GTK Text view (please help) Reply with quote

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.
Back to top
hydra
Familiar Face


Joined: 23 Jan 2007
Posts: 35

PostPosted: Sun May 06, 2007 1:33 pm    Post subject: Reply with quote

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
Back to top
aliov
Familiar Face


Joined: 06 May 2007
Posts: 7

PostPosted: Sun May 06, 2007 1:56 pm    Post subject: Reply with quote

Thank you for the quick reply your reply help me to do it.

Cheers.
Back to top
aliov
Familiar Face


Joined: 06 May 2007
Posts: 7

PostPosted: Sun May 06, 2007 2:28 pm    Post subject: Reply with quote

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.
Back to top
openldev
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 372
Location: State College, Pennsylvania

PostPosted: Sun May 06, 2007 2:49 pm    Post subject: Reply with quote

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.
Back to top
aliov
Familiar Face


Joined: 06 May 2007
Posts: 7

PostPosted: Sun May 06, 2007 3:28 pm    Post subject: Reply with quote

please ,can you provide me more details,

as a sample code can help me.

Thx in advance.
Back to top
openldev
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 372
Location: State College, Pennsylvania

PostPosted: Sun May 06, 2007 3:46 pm    Post subject: Reply with quote

Code: (Plaintext)
1
2
3
4
5
6
7
8
9
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);
Back to top
aliov
Familiar Face


Joined: 06 May 2007
Posts: 7

PostPosted: Sun May 06, 2007 4:10 pm    Post subject: Reply with quote

it 's still writing all the messages in the same line.

Any suggestion.

Thx.
Back to top
aliov
Familiar Face


Joined: 06 May 2007
Posts: 7

PostPosted: Sun May 06, 2007 4:29 pm    Post subject: Reply with quote

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,
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP