WIP: cleaned (alittle more) > can now go on : gtk_tree_list_model_new()

This commit is contained in:
Jean Sirmai 2024-01-31 14:57:13 +01:00
parent 55f5dd461d
commit 561adc8b85
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 12 additions and 12 deletions

View File

@ -32,7 +32,8 @@ static void on_destroy (GtkWidget *widget, gpointer data) {if (data) g_print (da
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");
g_signal_connect (G_OBJECT (that_window), "destroy", G_CALLBACK(on_destroy),
"sand_box.c / on_activate_window_creation() > exit(0) closes window\n");
gtk_window_set_title (GTK_WINDOW(that_window), "Ignition !");
gtk_window_set_default_size (GTK_WINDOW(that_window), 180, 140);
GtkWidget *my_scrolling_thing = gtk_scrolled_window_new ();
@ -46,9 +47,8 @@ void on_activate_window_creation (GtkApplication *app, gpointer data)
static void on_setup_cb (GtkSignalListItemFactory *self, GtkListItem *my_list_item, gpointer user_data)
{
GtkWidget *my_label = gtk_label_new (NULL);
gtk_list_item_set_child (my_list_item, my_label);
/* Because gtk_list_item_set_child sunk the floating reference of my_label,
* releasing (unref) isn't necessary for my_label. */
gtk_list_item_set_child (my_list_item, my_label); // Because gtk_list_item_set_child sunk the floating reference of my_label,
// releasing (unref) isn't necessary for my_label.
}
static void on_bind_cb (GtkSignalListItemFactory *self, GtkListItem *my_list_item, gpointer user_data)
@ -68,14 +68,16 @@ static void on_selection_change (GtkStringList *my_selection_model, guint posit
g_list_model_get_n_items (G_LIST_MODEL (my_selection_model)),
g_list_model_get_item_type(G_LIST_MODEL (my_selection_model)),
position,
gtk_string_object_get_string (g_list_model_get_item (my_selection_model, position)),
gtk_string_object_get_string (g_list_model_get_item (G_LIST_MODEL (my_selection_model), position)),
n_items);
}
//-------------------------------------------------------------------------------------------------------------------------------------------
void on_activating_this_expander (GtkExpander *my_expander, gpointer my_data) {printf("on_activating exp. > %s\n", gtk_string_object_get_string (GTK_STRING_OBJECT(my_expander)));}
void gtk_expander_set_child (GtkExpander* expander, GtkWidget* child) {printf("gtk_expander_set_child () %s\n", gtk_string_object_get_string (GTK_STRING_OBJECT(child)));}
void on_activating_this_expander (GtkExpander *my_expander, gpointer my_data) {
printf("on_activating exp. > %s\n", gtk_string_object_get_string (GTK_STRING_OBJECT(my_expander)));}
void gtk_expander_set_child (GtkExpander* expander, GtkWidget* child) {
printf("gtk_expander_set_child () %s\n", gtk_string_object_get_string (GTK_STRING_OBJECT(child)));}
GListModel *my_item_create_func (gpointer item, gpointer user_data)
{
@ -108,18 +110,16 @@ static void and_now_let_s_climb_that_tree (GtkWidget *in_that_box)
if (1) { g_signal_connect (my_selection_model, "selection-changed", G_CALLBACK (on_selection_change), NULL);}
// GListModel *(* GtkTreeListModelCreateModelFunc) (GObject* item, gpointer user_data) // remplacerait gtk_string_list_new() ?
// https://docs.gtk.org/gtk4/callback.TreeListModelCreateModelFunc.html
// https://docs.gtk.org/gtk4/method.TreeListRow.set_expanded.html
GtkTreeListModel *my_tree_list_model = gtk_tree_list_model_new (G_LIST_MODEL (my_string_list), 1, 0, my_item_create_func, NULL, NULL); // my_string_list my_selection_model
GtkTreeListModel *my_tree_list_model = gtk_tree_list_model_new (G_LIST_MODEL (my_string_list), 1, 0, my_item_create_func, NULL, NULL);
int rank = 1; printf("in : GListModel *item_create_func (gpointer item,...) (line 80) (item n°%d is %s)\n",
rank, gtk_string_list_get_string (my_string_list, rank));
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
// GtkWidget *my_tree_view = gtk_tree_view_new (); next line : use my_tree_view instead of my_list_view ?
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (in_that_box), my_list_view);
}