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.

if (gtk_tree_model_get_iter(model, &iter, path))
{
/* Retrieve a value from the model... not really important for this example */
gchar *value;
gtk_tree_model_get(model, &iter, POS_0, &value, -1);

/* Print something out to determine why this was called */
if (!path_currently_selected)
{
g_print ("%s is going to be selected.\n", value);
}
else
{
g_print ("%s is going to be unselected.\n", value);
}

g_free(value);

} /* select_row_callback */
[/code]

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.

Who is online

Users browsing this forum: No registered users and 5 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum