WIP: GtkTreeListModel *my_tree_list_model = gtk_tree_list_model_new (...) (110)

This commit is contained in:
Jean Sirmai 2024-01-29 22:51:09 +01:00
parent 22d127d1c0
commit 2d64975c22
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 30 additions and 35 deletions

View File

@ -27,7 +27,21 @@
#include "../../include/base.h"
#include "../../include/ui.h"
static void and_now_let_s_climb_that_tree (GtkWidget *in_that_box);
static void on_destroy (GtkWidget *widget, gpointer data) {if (data) g_print (data); exit(0);}
void on_activate_window_creation (GtkApplication *app, gpointer data)
{
GtkWidget *that_window = gtk_application_window_new (gtk_application_new ("org.gtk.test", 0));
g_signal_connect (G_OBJECT (that_window), "destroy", G_CALLBACK(on_destroy), "exit(0) closes window\n");
gtk_window_set_title (GTK_WINDOW(that_window), "Gloups ! Who am I ? Oooh...");
gtk_window_set_default_size (GTK_WINDOW(that_window), 300, 300);
GtkWidget *my_scrolling_thing = gtk_scrolled_window_new ();
gtk_window_set_child (GTK_WINDOW (that_window), my_scrolling_thing);
gtk_widget_show (that_window);
and_now_let_s_climb_that_tree (my_scrolling_thing);
if (data) {g_print (data); g_print (" and is displayed by [sand_box.c / on_activate_window_creation()]\n");}
}
//-------------------------------------------------------------------------------------------------------------------------------------------
static void on_setup_cb (GtkSignalListItemFactory *self, GtkListItem *my_list_item, gpointer user_data)
{
@ -48,7 +62,7 @@ static void on_bind_cb (GtkSignalListItemFactory *self, GtkListItem *my_list_ite
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 = %ld\
position (premier élement ayant changé d'état) = %2d %7s\
nombre d'éléments ayant changé d'état = %2d\n",
g_list_model_get_n_items (my_selection_model),
@ -58,15 +72,17 @@ static void on_selection_change (GtkSelectionModel* my_selection_model, guint p
n_items );
}
static void on_activating_this_expander (GtkExpander *my_expander, gpointer my_data) {printf("%s\n", gtk_expander_get_label (my_expander));}
//-------------------------------------------------------------------------------------------------------------------------------------------
void on_activating_this_expander (GtkExpander *my_expander, gpointer my_data) {printf("on_activating > %s\n", gtk_string_object_get_string (my_expander));}
void gtk_expander_set_child (GtkExpander* expander, GtkWidget* child) {printf("gtk_expander_set_child () %s\n", gtk_string_object_get_string (child));}
GListModel *item_create_func (gpointer item, gpointer user_data)
{
GtkWidget *my_expander = gtk_expander_new ("my_expander");
gtk_expander_set_child (my_expander, NULL); // *child); how to ?
if (0) on_activating_this_expander (my_expander, NULL); // gpointer user_data) The “activate” signal
printf("%s ", gtk_string_object_get_string(item));
GtkWidget *my_expander = gtk_expander_new (item);
/* gtk_expander_set_child (my_expander, NULL); */
/* on_activating_this_expander (my_expander, NULL); */
return NULL;
}
@ -79,8 +95,8 @@ static void and_now_let_s_climb_that_tree (GtkWidget *in_that_box)
GtkMultiSelection *my_selection_model = gtk_multi_selection_new (G_LIST_MODEL (my_string_list));
if (gtk_single_selection_get_selected_item (my_selection_model))
gtk_selection_model_selection_changed (my_selection_model, 0, 1);
/* if (gtk_single_selection_get_selected_item (my_selection_model)) */
/* gtk_selection_model_selection_changed (my_selection_model, 0, 1); */
GtkListItemFactory *my_list_item_factory = gtk_signal_list_item_factory_new ();
g_signal_connect (my_list_item_factory, "setup", G_CALLBACK (on_setup_cb), NULL);
@ -91,39 +107,18 @@ static void and_now_let_s_climb_that_tree (GtkWidget *in_that_box)
// GListModel *(* GtkTreeListModelCreateModelFunc) (GObject* item, gpointer user_data) // remplacerait gtk_string_list_new() ?
// https://docs.gtk.org/gtk4/callback.TreeListModelCreateModelFunc.html
GtkTreeListModel *my_tree_list_model =
gtk_tree_list_model_new (my_selection_model,
1,
1,
item_create_func,
NULL,
NULL);
GtkTreeListModel *my_tree_list_model = gtk_tree_list_model_new (my_selection_model, 1, 1, item_create_func, NULL, NULL);
printf("\n");
GtkWidget *my_list_view = gtk_list_view_new (GTK_SELECTION_MODEL (my_selection_model), my_list_item_factory);
// GtkWidget *my_tree_view = gtk_tree_view_new ();
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (in_that_box), my_list_view); // use my_tree_view instead of my_list_view
// gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (in_that_box), gtk_tree_view_new ()); // use my_tree_view instead of my_list_view
}
//-------------------------------------------------------------------------------------------------------------------------------------------
void on_activate_window_creation (GtkApplication *app, gpointer data)
{
GtkWidget *that_window = gtk_application_window_new (gtk_application_new ("org.gtk.test", 0));
g_signal_connect (G_OBJECT (that_window), "destroy", G_CALLBACK(on_destroy), "exit(0) closes window\n");
gtk_window_set_title (GTK_WINDOW(that_window), "Gloups ! Who am I ? Oooh...");
gtk_window_set_default_size (GTK_WINDOW(that_window), 300, 300);
GtkWidget *my_scrolling_thing = gtk_scrolled_window_new ();
gtk_window_set_child (GTK_WINDOW (that_window), my_scrolling_thing);
gtk_widget_show (that_window);
and_now_let_s_climb_that_tree (my_scrolling_thing);
if (data) {g_print (data); g_print (" and is displayed by [sand_box.c / on_activate_window_creation()]\n");}
}
//----------------------------------------------------------------| mes notes.
//----------------------------------------------------------------| mes notes. |---------------------------------------------
// guix shell -m manifest.scm && pkg-config --libs gtk4 make clean && clear && time make run
//
@ -138,4 +133,4 @@ void on_activate_window_creation (GtkApplication *app, gpointer data)
// https://docs.gtk.org/gtk4/section-list-widget.html
// https://www.typeerror.org/docs/gtk~4.0/ https://www.typeerror.org/docs/gtk~4.0/gtktreemodel
// https://docs.gtk.org/#user-interface https://docs.gtk.org/gtk4/ https://docs.gtk.org/glib/ https://docs.gtk.org/gio/
//