I have created a GtkTreeView (with the GTK_SELECTION_SINGLE property) and my objective is to invoke a callback function whenever a user selects a row. After a brief struggle I ALMOST have it working the way I want it to. The problem is that I get a callback when the row is "selected" (which I want), another callback when the previous row that was selected is automatically "deselected" (which I don't mind ignoring), and then finally ANOTHER callback for the row that was selected.
Here is a simplified example:
GtkTreeView *view = gtk_tree_view_new();
GtkTreeSelection *selection = gtk_tree_view_get_selection( view );
// Set up my view and attach to GtkListStore model
} /* create_tree_view() */
if (gtk_tree_model_get_iter(model, &iter, path))
/* Retrieve a value from the model... not really important for this example */
gtk_tree_model_get(model, &iter, POS_0, &value, -1);
/* Print something out to determine why this was called */
g_print ("%s is going to be selected.\n", value);
g_print ("%s is going to be unselected.\n", value);
} /* select_row_callback */
So my output from the above is:
Row-2 is going to be selected.
Row-1 is going to be unselected.
Row-2 is going to be selected. <== WHY??? This was already processed.
The last callback is undesirable, I have already processed the selection at this point. I guess I should add that this problem only occurs AFTER the first selection as it is related to the previous row being deselected.
I'd appreciate any input, advice, or insight.
Thanks in advance!