intercepting input to a textview



I have just started to tinker with glade and gtk.

I have created a gnome-app with a textview, and connected a callback
to the textview::insert_at_cursor signal. However, it does not appear
to be the right place to do what I want. 

I tried to modify what gets inserted. Modifying the parameter to the
callback (the value pointed to) has no effect. No big surprise really,
because if that were to be possible there should also be a way of
specifying a new length of the insertion, and even a way of allocating
a larger buffer. 

Just to see how I can make something happen, I tried to insert
something else: 

void
on_textview1_insert_at_cursor          (GtkTextView     *textview,
                                        gchar           *arg1,
                                        gpointer         user_data)
{
  if (*arg1 == '/') {
    gtk_text_buffer_insert_at_cursor
      (gtk_text_view_get_buffer(textview), "=", 1);
  }
}

But when I run the application, nothing special happens. If I type
something at the keyboard it all appears in the textview. If I type a
/, a / appears and nothing else.

How comes? 

How is this callback supposed to be used? What can one do in it?

If I want to intercept the data and modify it in some way, which
signal should I connect to? I tend to think that I should try some
signal of the textbuffer rather than of the textview, is that right?

If so, it appears not to be any way to do it using glade, because the
textbuffer does not appear in the widget hierarchy. (Well, it isn't a
widget, but it has signals and it would be nice to use the elegant
glade interface to do it.)

I wish I could find a description of these things. Reading the entire
source code is a bit overwhelming, and it takes some time too. Is
there anything out there?  The html doc that comes with the library
generally fails to say anything more about the signals than just the
signal name.

Regards, Enrique



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