Quick question : Regarding GtkTextMark



Hello List,

    I am am having following problem and a probable solution to the
problem with small suggestions needed.

Problem:
========

I want to identify the line number in text area wherever I click in.

Solution:

I use following code to get it working

gboolean detectButton(GtkWidget *w, GdkEventButton *event, gpointer data)
{

    GtkTextIter iter;
    int line_no;
    if(event->button == 1) /* left button is pressed */
    {
        gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(text_buffer),
&iter,
gtk_text_buffer_get_insert(GTK_TEXT_BUFFER(text_buffer)));

        line_no = gtk_text_iter_get_line(&iter);

    }
}

This works fine for the first time, but once the mark is set every time
I left click in text buffer at different lines, I get the same initial
line no which was at the first time. 

Another interesting thing. If let say first time its displaying line no
as 4 and then I insert any line in between 1 to 4 and then if i click
anywhere in between 1 to 4 I get the line_no as 5. I know for sure that
once I set mark its just being there and not moving it and I dont know
how to remove it since I guess its a standard "insert" mark which cannot
be deleted. I am not sure about removal.

Any suggestions in code would be very much appriciated.

Thanks in advance,
Vikram
========================================
Vikram S Bartakke
Grad Student (CS Dept)
University of New Mexico
Albuquerque, NM 87131
========================================



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