Re: GtkTextView/GtkTextBuffer



On Sun, 2002-12-15 at 17:54, Havoc Pennington wrote:
On Sun, Dec 15, 2002 at 03:11:26PM +0000, Azrael wrote:  

  inputBuffer2 = gtk_text_buffer_new(NULL);
  textview7 = gtk_text_view_new_with_buffer(inputBuffer2);

  gtk_widget_show (textview7);
  gtk_container_add (GTK_CONTAINER (scrolledwindow14), textview7);
  gtk_signal_connect (GTK_OBJECT (textview7), "activate",
                      G_CALLBACK(sendToTerm), term);

You should have gotten an error message printed when you ran your
program that GtkTextView has no "activate" signal.

Pressing enter in GtkTextView starts a new line, it's a multi-line
control. The single-line control with an activate signal is GtkEntry.

In that case how do I get an input box that visually takes up more than
one line, but that responds to an enter key?
i.e. Like the input part of gaim's chat window.
I assumed this was a GtkTextView

void sendToTerm(GtkWidget *textArea, GtkWidget *term)
{
        GtkTextBuffer *textBuffer = gtk_text_view_get_buffer(textArea);

        gint textLength= gtk_text_buffer_get_char_count(textBuffer);

This is wrong; textLength as accepted by vte_terminal_feed() should be
in bytes, not characters.
 
This is my code currently for sendToTerm() and brings me to several
questions. Firstly I can not work out how I am supposed to obtain the
START and END points of the text in my GtkTextView/Buffer .. but I
/assume/ that I can use 0 for start, and the result of textLength for
END. However these are only ints/gints, and they should be of type
GtkTextIter. Am I missing some obvious function? Assuming I can get this
start/end point, is the above ok?

gtk_text_buffer_get_bounds()
 
I have added a g_print() to the sendToTerm() function, and it is not
being called at all by use of enter/return key in the GtkTextView, so I
think there must be something wrong with my signal_connect, perhaps it
shouldn't be "activate" at all.. or something else is wrong?

Any advice is most welcome, many thanks

Always read your error messages. ;-)

Havoc
-- 
                Azrael

           ("\''/").___..--'''"-._          
           `0_ O  )   `-.  (     ).`-.__.`) 
           (_Y_.)'  ._   )  `._ `. ``-..-'  
         _..`--'_..-_/  /--'_.' .'          
        ((i).-''  ((i).'  (((.-'         
   
Of all God's creatures there is only one that cannot be made the slave
of the lash. That one is the cat. If man could be crossed with a cat it
would improve man, but it would deteriorate the cat. 

ICQ#52944566




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]