diff --git a/gtk_treeview_example b/gtk_treeview_example index 3d28613..aeaf159 100755 Binary files a/gtk_treeview_example and b/gtk_treeview_example differ diff --git a/main.c b/main.c index da9ed8b..639cbe6 100644 --- a/main.c +++ b/main.c @@ -165,6 +165,12 @@ void on_bind_factory (GtkListItemFactory *factory, GtkListItem *list_item, gpoin } } +void on_selection_changed (GtkSelectionModel* self, guint position, + guint n_items, gpointer user_data) +{ + printf("Cc\n"); +} + // Application activation callback void app_activate (GApplication *app, gpointer user_data) { @@ -190,9 +196,14 @@ void app_activate (GApplication *app, gpointer user_data) (GDestroyNotify)g_object_unref //(GDestroyNotify)free_tree_node ); - GtkNoSelection *selection_model = gtk_no_selection_new ( + GtkSingleSelection *selection_model = gtk_single_selection_new ( G_LIST_MODEL (tree_model)); + gtk_single_selection_set_autoselect(selection_model, FALSE); + gtk_single_selection_set_can_unselect(selection_model, TRUE); + g_signal_connect (selection_model, "selection-changed", + G_CALLBACK(on_selection_changed), NULL); + GtkWidget *list_view = gtk_list_view_new (selection_model, factory); gtk_window_set_child(GTK_WINDOW(window), list_view); @@ -215,8 +226,9 @@ int main (int argc, char **argv) add_child_node(A, B); add_child_node(B, C); add_child_node(C, D); - add_child_node(E, F); - add_child_node(F, G); + add_child_node(D, E); + add_child_node(E, E); + add_child_node(E, A); GtkApplication *app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE); g_signal_connect(app, "activate", G_CALLBACK(app_activate), NULL);