GtkTextView/GtkTextBuffer



Here's my latest problem ;)

What I am creating is a GtkTextView into which the user of the program
can type. And when they press enter/return I want the contents of the
GtkTextView to be removed, and something done with it elsewhere..

I have read the api and tried to work out what I am doing.. but so far I
have had no success.


  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);

This I believe is correct to create a GtkTextView with associated
GtkTextBuffer, and then to connect a siganl to the textview. I believe I
am right in thinking that "activate" relates to the use of the
enter/return key. This calls the function sendToTerm(), and passes a
pointer to term (a VteWidget) as part of the function call, I hope.


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

        gint textLength= gtk_text_buffer_get_char_count(textBuffer);
        GtkTextIter *start = NULL, *end = NULL;
        char *textContent = gtk_text_buffer_get_text(textBuffer, start,
                                        end, FALSE);
        gtk_text_buffer_set_text(textBuffer, "", 0);
        vte_terminal_feed(VTE_TERMINAL(term), textContent,
                        (glong)textLength);
}

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?

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

-- 
                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.




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