1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
void create_tree_view()
{
GtkTreeView *view = gtk_tree_view_new();
GtkTreeSelection *selection = gtk_tree_view_get_selection( view );
...
// Set up my view and attach to GtkListStore model
...
gtk_tree_selection_set_select_function
(
selection,
select_row_callback,
NULL,
NULL
);
...
} /* create_tree_view() */
gboolean select_row_callback
(
GtkTreeSelection *selection,
GtkTreeModel *model,
GtkTreePath *path,
gboolean path_currently_selected,
gpointer data
)
{
GtkTreeIter iter;
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 */
|