Which signal to select text



This is probably a newbie question, but I can't find an answer in the
documentation.

I have the following setup:

GtkScrolledWindow
    GtkTextView (called Code_Text)
        GtkTextBuffer (called code_textbuffer)

The textbuffer holds several lines of disassembled code (the code
window). What I want to do is be able to click on a line to select it.
Currently I do it like this:

++++
g_signal_connect(code_textbuffer, "mark_set", Code_clicked, NULL);

...

void Code_clicked(void)
{
...
  gtk_text_buffer_get_iter_at_mark(code_textbuffer,
     &iter, gtk_text_buffer_get_insert(code_textbuffer));
...
++++

It *sort* of works, but there are problems. When I click in the
Code_Text window I get multiple calls to Code_clicked and when I click
somewhere else in the main window I sometimes get Code_clicked invoked
as well. Finally, if I ever set a mark in the buffer I have to deal with
yet another call to Code_clicked. Clearly, using "mark_set" signal on
the textbuffer is not the right approach.

My question is what signal on what instance should I use to allow me to
detect a click in the code window and determine where it is? I'm quite
prepared to change the widget hierarchy to make it work. If anyone wants
more info, just ask.

Thanks in advance for any help.

  Justin.


-- 
  Justin Clancy
  cassini fastmail fm

-- 
http://www.fastmail.fm - Access your email from home and the web




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