WIP: unbind_cb() and teardown_cb() seems to have no effect. Why ?
This commit is contained in:
parent
8094259bb2
commit
a54454556a
|
@ -45,15 +45,20 @@ static void bind_cb (GtkSignalListItemFactory *self, GtkListItem *my_list_item,
|
||||||
gtk_label_set_text (GTK_LABEL (my_label), gtk_string_object_get_string (my_string_object));
|
gtk_label_set_text (GTK_LABEL (my_label), gtk_string_object_get_string (my_string_object));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_selection_change (GtkSelectionModel* self, guint position, guint n_items, gpointer user_data)
|
static void unbind_cb (GtkSignalListItemFactory *self, GtkListItem *listitem, GtkSelectionModel *my_selection_model)
|
||||||
|
{printf("list size = %d\n", g_list_model_get_n_items (my_selection_model));}
|
||||||
|
static void teardown_cb (GtkSignalListItemFactory *self, GtkListItem *listitem, gpointer user_data) {}
|
||||||
|
/* GtkListItem instance will be destroyed soon. You don't need to set the child to NULL. */
|
||||||
|
|
||||||
|
static void on_selection_change (GtkSelectionModel* my_selection_model, guint position, guint n_items, gpointer user_data)
|
||||||
{
|
{
|
||||||
printf("list size = %d item type = %d\
|
printf("list size = %d item type = %d\
|
||||||
position (premier élement ayant changé d'état) = %2d %7s\
|
position (premier élement ayant changé d'état) = %2d %7s\
|
||||||
nombre d'éléments ayant changé d'état = %2d\n",
|
nombre d'éléments ayant changé d'état = %2d\n",
|
||||||
g_list_model_get_n_items (self),
|
g_list_model_get_n_items (my_selection_model),
|
||||||
g_list_model_get_item_type(self),
|
g_list_model_get_item_type(my_selection_model),
|
||||||
position,
|
position,
|
||||||
gtk_string_object_get_string(g_list_model_get_item(self, position)),
|
gtk_string_object_get_string(g_list_model_get_item(my_selection_model, position)),
|
||||||
n_items );
|
n_items );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +79,15 @@ static void and_now_let_s_climb_that_tree (GtkWidget *in_that_box)
|
||||||
GtkListItemFactory *my_factory = gtk_signal_list_item_factory_new ();
|
GtkListItemFactory *my_factory = gtk_signal_list_item_factory_new ();
|
||||||
g_signal_connect (my_factory, "setup", G_CALLBACK (setup_cb), NULL);
|
g_signal_connect (my_factory, "setup", G_CALLBACK (setup_cb), NULL);
|
||||||
g_signal_connect (my_factory, "bind", G_CALLBACK (bind_cb), NULL);
|
g_signal_connect (my_factory, "bind", G_CALLBACK (bind_cb), NULL);
|
||||||
g_signal_connect (my_selection_model, "selection-changed", G_CALLBACK (on_selection_change), NULL);
|
if (0) g_signal_connect (my_selection_model, "selection-changed", G_CALLBACK (on_selection_change), NULL);
|
||||||
|
g_signal_connect (my_factory, "unbind", G_CALLBACK (unbind_cb), my_selection_model);
|
||||||
|
g_signal_connect (my_factory, "teardown", G_CALLBACK (teardown_cb), NULL);
|
||||||
|
|
||||||
|
/* GtkWidget *treeview; */
|
||||||
|
/* treeview = gtk_tree_view_new_with_model (my_selection_model); */
|
||||||
|
/* gtk_widget_set_vexpand (treeview, TRUE); */
|
||||||
|
/* gtk_tree_view_set_search_column (GTK_TREE_VIEW (treeview), */
|
||||||
|
/* COLUMN_DESCRIPTION); */
|
||||||
|
|
||||||
GtkWidget *my_list_view = gtk_list_view_new (GTK_SELECTION_MODEL (my_selection_model), my_factory);
|
GtkWidget *my_list_view = gtk_list_view_new (GTK_SELECTION_MODEL (my_selection_model), my_factory);
|
||||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (in_that_box), my_list_view);
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (in_that_box), my_list_view);
|
||||||
|
@ -96,10 +109,16 @@ void on_activate_window_creation (GtkApplication *app, gpointer data) {
|
||||||
if (data) {g_print (data); g_print (" and is displayed by [sand_box.c / on_activate_window_creation()]\n");}
|
if (data) {g_print (data); g_print (" and is displayed by [sand_box.c / on_activate_window_creation()]\n");}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------- notes
|
//----------------------------------------------------------------| mes notes.
|
||||||
|
|
||||||
// guix shell -m manifest.scm && pkg-config --libs gtk4 make clean && clear && time make run
|
// guix shell -m manifest.scm && pkg-config --libs gtk4 make clean && clear && time make run
|
||||||
// my local widgets examples are in user/jean/01/GTK4/tree (learning)/The_Gnome_way/demos/gtk-demo
|
// my local widgets examples are in user/jean/01/GTK4/tree (learning)/The_Gnome_way/demos/gtk-demo
|
||||||
|
//
|
||||||
|
// tout ce qui commence par gtk... est un widget ex: "my_selection_model" est un widget ??
|
||||||
|
// factory = GtkSignalListItemFactory(setup_cb, bind_cb) <<<
|
||||||
|
// gtk_widget_set_visible(...) <<<
|
||||||
|
//
|
||||||
|
// GtkColumnView
|
||||||
|
//
|
||||||
// https://toshiocp.github.io/Gtk4-tutorial/sec29.html
|
// https://toshiocp.github.io/Gtk4-tutorial/sec29.html
|
||||||
// factory = GtkSignalListItemFactory(setup_cb, bind_cb)
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue