WIP: GtkTreeListModel *gtk_tree_list_model_new(...){} < how to ?
This commit is contained in:
parent
c416927cd9
commit
8cbf759e0b
|
@ -0,0 +1,108 @@
|
|||
|
||||
Constructor GtkTreeListModelnew ===========================================
|
||||
|
||||
|
||||
−> Declaration --------------------------------------------------------------
|
||||
|
||||
GtkTreeListModel*
|
||||
gtk_tree_list_model_new (
|
||||
GListModel* root,
|
||||
gboolean passthrough,
|
||||
gboolean autoexpand,
|
||||
GtkTreeListModelCreateModelFunc create_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy
|
||||
)
|
||||
|
||||
|
||||
−> Description --------------------------------------------------------------
|
||||
|
||||
Creates a new empty GtkTreeListModel displaying root with all rows collapsed.
|
||||
|
||||
|
||||
−> Parameters ---------------------------------------------------------------
|
||||
|
||||
. root . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
Type: GObject
|
||||
The GListModel to use as root.
|
||||
The called function takes ownership of the data,
|
||||
and is responsible for freeing it.
|
||||
|
||||
|
||||
. passthrough . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
Type: gboolean
|
||||
TRUE to pass through items from the models.
|
||||
|
||||
|
||||
. autoexpand . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
Type: gboolean
|
||||
TRUE to set the autoexpand property and expand the root model.
|
||||
|
||||
|
||||
. create_func . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
Type: GtkTreeListModelCreateModelFunc
|
||||
Function to call to create the GListModel for the children of an item.
|
||||
|
||||
|
||||
. user_data . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
Type: gpointer
|
||||
Data to pass to create_func.
|
||||
The argument can be NULL.
|
||||
The data is owned by the caller of the function.
|
||||
|
||||
|
||||
. user_destroy . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
Type: GDestroyNotify
|
||||
Function to call to free user_data.
|
||||
|
||||
|
||||
−> Return value -------------------------------------------------------------
|
||||
|
||||
Type: GtkTreeListModel
|
||||
A newly created GtkTreeListModel.
|
||||
The caller of the function takes ownership of the data,
|
||||
and is responsible for freeing it.
|
||||
|
||||
|
||||
>>> https://docs.gtk.org/gtk4/ctor.TreeListModel.new.html <<<
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Method Gio Conditions list ================================================
|
||||
|
||||
|
||||
−> Declaration --------------------------------------------------------------
|
||||
|
||||
gchar** g_conditions_list (GConditions* conditions)
|
||||
|
||||
−> Description -------------------------------------------------------------
|
||||
|
||||
Gets the list of conditions.
|
||||
The list is the list of strings for which it is not an error to call g_conditions_get().
|
||||
There is little reason to call this function from “normal” code,
|
||||
since you should already know what conditions are in your schema.
|
||||
This function may still be useful there for introspection reasons, however.
|
||||
You should free the return value with g_strfreev() when you are done with it.
|
||||
|
||||
|
||||
−> Return value ------------------------------------------------------------
|
||||
|
||||
Type: An array of utf8
|
||||
A list of the conditions values and parents, in no defined order.
|
||||
The array is NULL-terminated.
|
||||
The caller of the method takes ownership of the data,
|
||||
and is responsible for freeing it.
|
||||
Each element is a NUL terminated UTF-8 string.
|
||||
|
||||
from >>> https://docs.gtk.org/gio/method.Settings.list_children.html <<<
|
113
src/ui/tree.c
113
src/ui/tree.c
|
@ -42,6 +42,13 @@ struct _TreeItem
|
|||
TreeItem *children;
|
||||
};
|
||||
|
||||
void // https://docs.gtk.org/gtk4/method.StringList.take.html
|
||||
gtk_string_list_take (
|
||||
GtkStringList* self,
|
||||
char* string
|
||||
)
|
||||
{}
|
||||
|
||||
// tree data
|
||||
static TreeItem E[] = {NULL}, F[] = {NULL}, G[] = {NULL}, H[] = {NULL};
|
||||
static TreeItem I[] = {NULL}, K[] = {NULL}, N[] = {NULL}, M[] = {NULL};
|
||||
|
@ -52,6 +59,37 @@ static TreeItem A[] = {{"D", D}, {NULL}}, B[] = {{"E", E}, {NULL}};
|
|||
static TreeItem R[] = {{"A", A}, {"B", B}, {"C", C}, {NULL}};
|
||||
static TreeItem O[] = {{"ROOT", R}, {NULL}}; // Artefact added for symmetry
|
||||
|
||||
|
||||
static void
|
||||
setup_listitem_cb (GtkListItemFactory *factory,
|
||||
GtkListItem *list_item)
|
||||
{
|
||||
GtkWidget *label = gtk_label_new ("");
|
||||
gtk_list_item_set_child (list_item, label);
|
||||
|
||||
|
||||
//factory = gtk_signal_list_item_factory_new ();
|
||||
//GListModel my_model = NULL;
|
||||
//view = gtk_list_view_new (model, factory);
|
||||
|
||||
//g_signal_connect (factory, "setup", setup_listitem_cb, NULL);
|
||||
//g_signal_connect (factory, "bind", bind_listitem_cb, NULL);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
bind_listitem_cb_complex (GtkListItemFactory *factory,
|
||||
GtkListItem *list_item)
|
||||
{
|
||||
GtkWidget *label;
|
||||
TreeItem *obj;
|
||||
|
||||
label = gtk_list_item_get_child (list_ite
|
||||
obj = gtk_list_item_get_item (list_item);
|
||||
gtk_label_set_label (GTK_LABEL (label),
|
||||
my_object_get_string (obj));
|
||||
}
|
||||
|
||||
static GtkWidget *my_tree_view;
|
||||
static GListModel *my_Glist_model = NULL;
|
||||
|
||||
|
@ -146,6 +184,75 @@ static void any_user_function (GtkSignalListItemFactory *self, GtkListItem *list
|
|||
// If your “bind” handler connects to signals on the item or does other things that require cleanup,
|
||||
// you can use the “unbind” signal to do that cleanup. The “setup” signal has a similar counterpart called “teardown”.
|
||||
|
||||
static GListModel *create_settings_model (gpointer item,
|
||||
gpointer unused)
|
||||
{
|
||||
GSettings *settings = item;
|
||||
char **schemas;
|
||||
GListStore *result;
|
||||
guint i;
|
||||
|
||||
schemas = g_settings_list_children (settings);
|
||||
|
||||
if (schemas == NULL || schemas[0] == NULL)
|
||||
{
|
||||
g_free (schemas);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = g_list_store_new (G_TYPE_SETTINGS); // G_TYPE_STRING
|
||||
for (i = 0; schemas[i] != NULL; i++)
|
||||
{
|
||||
GSettings *child = g_settings_get_child (settings, schemas[i]);
|
||||
g_list_store_append (result, child);
|
||||
g_object_unref (child);
|
||||
}
|
||||
|
||||
g_strfreev (schemas);
|
||||
|
||||
return G_LIST_MODEL (result);
|
||||
}
|
||||
|
||||
GtkTreeListModel*
|
||||
gtk_tree_list_model_new (
|
||||
GListModel* root,
|
||||
gboolean passthrough,
|
||||
gboolean autoexpand,
|
||||
GtkTreeListModelCreateModelFunc create_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy
|
||||
)
|
||||
{}
|
||||
|
||||
// GListModel truc; gtk_tree_list_model_new(&truc)
|
||||
// GListModel *truc; gtk_tree_list_model_new(truc,0,0,NULL,NULL,NULL);
|
||||
|
||||
typedef struct _GListModel GListModel;
|
||||
|
||||
struct GListModelInterface {
|
||||
GTypeInterface g_iface;
|
||||
GType (* get_item_type) (GListModel *list);
|
||||
guint (* get_n_items) (GListModel *list);
|
||||
gpointer (* get_item) (GListModel *list,
|
||||
guint position);
|
||||
};
|
||||
|
||||
/*
|
||||
* Parameters :
|
||||
* list the GListModel that changed
|
||||
* position the position at which list changed
|
||||
* removed the number of items removed
|
||||
* added the number of items added
|
||||
* user_data user data set when the signal handler was connected.
|
||||
* Flags: Run Last
|
||||
*/
|
||||
void
|
||||
user_function (GListModel *list,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added,
|
||||
gpointer user_data)
|
||||
{}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -156,11 +263,17 @@ static void any_user_function (GtkSignalListItemFactory *self, GtkListItem *list
|
|||
// https://gnome.pages.gitlab.gnome.org/libsoup/gio/GListModel.html
|
||||
// https://blog.gtk.org/2020/09/05/a-primer-on-gtklistview/ <<< Factory mechanism
|
||||
// https://docs.gtk.org/gtk4/class.ListItemFactory.html <<<
|
||||
<<<<<<< HEAD
|
||||
// https://www.typeerror.org/docs/gtk~4.0/gtksignallistitemfactory
|
||||
// https://developer-old.gnome.org/gtk4/stable/GtkListView.html <<< copy that !
|
||||
=======
|
||||
>>>>>>> afc2bd0 (WIP: GtkTreeListModel *gtk_tree_list_model_new(...){} < how to ?)
|
||||
// https://docs.gtk.org/gtk4/class.ListItem.html
|
||||
// https://docs.gtk.org/gtk4/ctor.TreeListModel.new.html ***
|
||||
// https://blog.gtk.org/2020/06/08/more-on-lists-in-gtk-4/ ***
|
||||
// https://gitlab.gnome.org/GNOME/gtk/-/blob/main/demos/gtk-demo/listview_settings.c GtkBuilder *builder; (line 216)
|
||||
// https://discourse.gnome.org/t/how-can-i-get-the-expanded-collapsed-items-in-the-new-gtktreelistmodel-implementation/16824
|
||||
<<<<<<< HEAD
|
||||
// https://developer-old.gnome.org/gtk4/stable/GtkSignalListItemFactory.html
|
||||
=======
|
||||
>>>>>>> afc2bd0 (WIP: GtkTreeListModel *gtk_tree_list_model_new(...){} < how to ?)
|
||||
|
|
Loading…
Reference in New Issue