424,303 Members | 1,366 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,303 IT Pros & Developers. It's quick & easy.

How to show input in Text Entry to Text View in Glade (program coded using C)

P: 9
Hi everyone. I am creating a basic chat interface in Glade that contains only 3 widgets namely Text View, Text Entry and Button.

Like I said, it is very basic. However I am having a problem with the process of showing whatever the user inputs in the Text Entry to the Text View.

Here's part of my code:

Expand|Select|Wrap|Line Numbers
  1. void on_send_button_clicked (GtkButton *button, gpointer user_data)
  2. {
  3.     const char* input; 
  4.  
  5.     GtkTextView* view = (GtkTextView*) gtk_builder_get_object(builder,"textview1");
  6.     GtkEntry* entry = (GtkEntry*) gtk_builder_get_object (builder,"entry1");
  7.     input = gtk_entry_get_text(entry);
  8.     gtk_text_view_set_buffer(view, input);
  9. }
  10.  
  11.  
I know that this is wrong because in function gtk_text_view_set_buffer(), the parameter 'input' is of data type const char, but the function expects return type GtkTextBuffer. However, in order to obtain the string from text entry, I must use the function gtk_entry_get_text w/c returns a const char. So how do I make this work out?

Thank you in advance!
Jul 8 '10 #1
Share this Question
Share on Google+
3 Replies


100+
P: 687
What is "function expects return type GtkTextBuffer" ? Does it return it or takes as an argument? Abyway, I's look into the documentation to see if you can set GtkTextBuffer content to some string passed as char*. gtk_text_buffer_set_text
Jul 10 '10 #2

P: 9
Hey newb16, thanks for the reply but i've figured it out already. But to answer your question, it takes a variable of type GtkTextBuffer* (not GtkTextBuffer) as an argument. My mistake. :)
Jul 11 '10 #3

P: 1
hi rhen18
I also have a project about chat programm built by C language. Can you help me or send me any material you have about thi program.
Thanks you so much.
Wait for your reply!!
Mar 17 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.