WIP: joujou avec les selections
This commit is contained in:
parent
b4eaa6f316
commit
97732da285
Binary file not shown.
18
main.c
18
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
|
// Application activation callback
|
||||||
void app_activate (GApplication *app, gpointer user_data)
|
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
|
(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));
|
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);
|
GtkWidget *list_view = gtk_list_view_new (selection_model, factory);
|
||||||
|
|
||||||
gtk_window_set_child(GTK_WINDOW(window), list_view);
|
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(A, B);
|
||||||
add_child_node(B, C);
|
add_child_node(B, C);
|
||||||
add_child_node(C, D);
|
add_child_node(C, D);
|
||||||
add_child_node(E, F);
|
add_child_node(D, E);
|
||||||
add_child_node(F, G);
|
add_child_node(E, E);
|
||||||
|
add_child_node(E, A);
|
||||||
|
|
||||||
GtkApplication *app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE);
|
GtkApplication *app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE);
|
||||||
g_signal_connect(app, "activate", G_CALLBACK(app_activate), NULL);
|
g_signal_connect(app, "activate", G_CALLBACK(app_activate), NULL);
|
||||||
|
|
Loading…
Reference in New Issue