How to learn from examples ? window = do_listview_words(NULL); line 944 in main.c

This commit is contained in:
Jean Sirmai 2024-01-04 12:03:46 +01:00
parent 8107c7d2e3
commit 5a604fa05d
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 43 additions and 5 deletions

View File

@ -5,7 +5,9 @@
/* guix shell: Tout va bien ! Le shell a les bonnes variables d'environnement. */
/* jean@Project:~/Gem-Graph/gem-graph-client/tree (learning)/The_Gnome_way/gtk [env] $ cd builddir/ */
/* jean@Project:~/Gem-Graph/gem-graph-client/tree (learning)/The_Gnome_way/gtk/builddir [env] $ */
/* jean@Project:~/Gem-Graph/gem-graph-client/tree (learning)/The_Gnome_way/gtk/builddir [env] $ */
/* */
/* >>>>>>>>>>>>>>>>>> Modify line 944 in this file to run examples <<<<<<<<<<<<<<<<< */
/* */
/* jean@Project:~/Gem-Graph/gem-graph-client/tree...way/gtk/builddir [env] $ clear && meson compile && demos/gtk-demo/gtk4-demo */
/* */
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- A Session -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
@ -932,7 +934,17 @@ activate (GApplication *app)
// GtkFilter *filter;
// GSimpleAction *action;
window= do_tree_store(NULL);
/******************************************************************************/
/* */
/* W I N D O W = D O _ S O M E _ A P P L I C A T I O N _ E X A M P L E */
/* */
// window = do_tree_store(NULL);
window = do_listview_words(NULL);
/* */
/******************************************************************************/
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window));
/* builder = gtk_builder_new_from_resource ("/ui/main.ui"); */

View File

@ -8,11 +8,34 @@
/* */
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- A Session -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
/* */
/* >>>>>>>>>>>>>>>>>> Modify line 944 in the main file to run examples <<<<<<<<<<<<<<<<< */
/* */
/* */
/* jean@Project:~/Gem-Graph/gem-graph-client/tree (learning)/The_Gnome_way/gtk/builddir [env] $ ctrl D (avant de fermer builder) */
/* */
/****************************************************************************************************************************************/
/******************************************** The basic ideas behind list views: ************************************************/
/* */
/* The data for items is provided in the form of a model (containing objects) */
/* Widgets are created just for the viewable range of items */
/* Widgets can be recycled by binding them to different items */
/* Avoid iterating over all items in the model as much as possible, */
/* and just deal with the items in the visible range which are bound to widgets */
/* from https://blog.gtk.org/2020/06/07/scalable-lists-in-gtk-4/ */
/* */
/****************************************************************************************************************************************/
// GtkListItemFactory is the object that is tasked with creating widgets for the items in the model.
// One implementations of this factory, GtkBuilderListItemFactory, is using ui files as templates for the list item widgets.
// https://gitlab.gnome.org/GNOME/gtk/-/blob/main/demos/gtk-demo/listview_settings.ui
/* Lists/Application launcher #Keywords: GtkListItemFactory, GListModel
* This demo uses the GtkListView widget as a fancy application launcher. It is also a very small introduction to listviews.
* https://gitlab.gnome.org/GNOME/gtk/-/blob/main/demos/gtk-demo/listview_applauncher.c */
/************************************************** W I D G E T S ********************************************************/
@ -25,7 +48,8 @@
/* It provides a way to specify how temporary widgets should be configured for editing, get the new value, etc. */
/* _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/* _ _ _ _ _ _ _ _ _ _ _ _ _ _ T R E E _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/* https://toshiocp.github.io/Gtk4-tutorial/sec29.html <<< TODO */
/* */
/* https://toshiocp.github.io/Gtk4-tutorial/sec29.html <<< TODO */
/* https://docs.gtk.org/gtk4/ */
/* https://docs.gtk.org/gtk4/section-list-widget.html << (see below the "quick comparison chart of equivalent functionalities") */
/* https://docs.gtk.org/gtk4/class.TreeListModel.html */
@ -111,6 +135,8 @@
*
* GListModel is an interface that represents a mutable list of GObjects.
* https://gnome.pages.gitlab.gnome.org/libsoup/gio/GListModel.html
* https://docs.gtk.org/gio/iface.ListModel.html < +++
* https://blog.gtk.org/2020/09/08/on-list-models/
*
*............................................................................*/
@ -149,7 +175,7 @@ static TreeItem R[] = {{"A", A}, {"B", B}, {"C", C}, {NULL}};
static TreeItem O[] = {{"ROOT", R}, {NULL}}; // Artefact added for symmetry
static GListStore *create_node_recursive (GtkTreeStore *model, // GListStore* g_list_store_new (GType item_type)
static GListStore *create_node_recursive (GListModel *model, // GListStore* g_list_store_new (GType item_type)
TreeItem *current_item,
GtkTreeIter *iter_parent,
int depth)
@ -173,7 +199,7 @@ static GListStore *create_node_recursive (GtkTreeStore *model, // GListStore*
}
if (depth == 0)
return G_LIST_STORE(model); // can cast to GListModel or to GtkTreeStore ?
return G_LIST_MODEL(model); // can cast to GListModel or to GtkTreeStore ?
else
return NULL;
}