GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Oct 21, 2014 7:56 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: textview buffer
PostPosted: Sat Oct 27, 2007 11:09 pm 
Offline

Joined: Sat Oct 27, 2007 11:05 pm
Posts: 3
How do I load the data from a GTK Textview into a buffer? ( char*, for writing file)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 28, 2007 4:05 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
The text is stored in a text buffer, so you first retrieve the text view's GtkTextBuffer. Then, you get iterators pointing to the beginning and the end of the buffer, which are used as bounds when retrieving the text.

Code:
GtkTextBuffer *buffer;
GtkTextIter start, end;
gchar *text;

buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
gtk_text_buffer_get_start_iter (buffer, &start);
gtk_text_buffer_get_start_iter (buffer, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);

_________________
Andrew Krause

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


Top
 Profile  
 
 Post subject: textbuffer size
PostPosted: Sun Oct 28, 2007 7:55 pm 
Offline

Joined: Sat Oct 27, 2007 11:05 pm
Posts: 3
How do I get the total size of the text buffer?
I want to write the edited buffer into a file;


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 28, 2007 8:42 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
Code:
#include <string.h>
int length = strlen (text);

_________________
Andrew Krause

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2007 10:05 am 
Offline

Joined: Sat Oct 27, 2007 11:05 pm
Posts: 3
Ah, then I did it the right way :) I thought there was a bug, but there doesn't seem to be..
Thanks for the help!


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 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