2024-04-27 16:16:21 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <gtk-4.0/gtk/gtk.h>
|
2024-05-08 07:50:04 +02:00
|
|
|
|
2024-04-29 23:43:04 +02:00
|
|
|
#include "warm.h"
|
|
|
|
#include "cold.h"
|
2024-05-10 06:19:20 +02:00
|
|
|
#include "display.h"
|
|
|
|
#include "contain.h"
|
2024-05-08 23:43:23 +02:00
|
|
|
#include "texts.h"
|
2024-04-29 23:43:04 +02:00
|
|
|
|
2024-04-30 18:59:44 +02:00
|
|
|
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
|
2024-05-10 23:14:45 +02:00
|
|
|
// https://docs.gtk.org/gtk4/section-text-widget.html
|
2024-05-08 23:43:23 +02:00
|
|
|
// https://docs.gtk.org/gtk4/class.Widget.html#height-for-width-geometry-management
|
2024-05-06 23:29:54 +02:00
|
|
|
// GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL
|
|
|
|
|
2024-05-08 23:43:23 +02:00
|
|
|
|
2024-05-15 11:41:58 +02:00
|
|
|
static void on_experimental_tree_bind_factory (GtkSignalListItemFactory *factory,
|
|
|
|
GObject* object,
|
|
|
|
gpointer user_data);
|
|
|
|
|
2024-05-15 08:03:32 +02:00
|
|
|
static void on_experimental_expander_toggled(GtkExpander *expander, gpointer user_data){
|
|
|
|
gtk_expander_set_expanded (expander, gtk_expander_get_expanded (expander));
|
2024-05-15 10:52:50 +02:00
|
|
|
printf("> %s\n", gtk_expander_get_label (user_data));
|
2024-05-15 08:03:32 +02:00
|
|
|
}
|
|
|
|
|
2024-05-15 11:41:58 +02:00
|
|
|
void on_experimental_tree_setup_factory (GtkSignalListItemFactory *factory,
|
|
|
|
GObject* object,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkWidget* expander = gtk_expander_new (NULL);
|
|
|
|
gtk_list_item_set_child (GTK_LIST_ITEM(object), expander);
|
|
|
|
printf("[on_experimental_tree_setup_factory] here is an expander\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void create_experimental_tree (GtkBox *experimental_box){
|
|
|
|
GtkSignalListItemFactory *factory = GTK_SIGNAL_LIST_ITEM_FACTORY (gtk_signal_list_item_factory_new ());
|
|
|
|
g_signal_connect (factory, "setup", G_CALLBACK(on_experimental_tree_setup_factory), NULL);
|
|
|
|
g_signal_connect (factory, "bind", G_CALLBACK(on_experimental_tree_bind_factory), NULL);
|
2024-05-15 06:46:11 +02:00
|
|
|
|
2024-05-15 07:29:30 +02:00
|
|
|
GtkExpander *hello = GTK_EXPANDER (gtk_expander_new ("hello !"));
|
|
|
|
gtk_expander_set_expanded (GTK_EXPANDER (hello), TRUE);
|
|
|
|
gtk_widget_set_margin_start (GTK_WIDGET (hello), 0);
|
2024-05-15 08:22:48 +02:00
|
|
|
g_signal_connect (hello, "activate", G_CALLBACK (on_experimental_expander_toggled), hello);
|
2024-05-15 07:29:30 +02:00
|
|
|
gtk_box_append (experimental_box, GTK_WIDGET (hello));
|
|
|
|
|
|
|
|
GtkExpander *it_s_me = GTK_EXPANDER (gtk_expander_new ("it's me !"));
|
|
|
|
gtk_expander_set_expanded (GTK_EXPANDER (it_s_me), FALSE);
|
|
|
|
gtk_widget_set_margin_start(GTK_WIDGET (it_s_me), 20);
|
2024-05-15 10:52:50 +02:00
|
|
|
g_signal_connect (it_s_me, "activate", G_CALLBACK (on_experimental_expander_toggled), it_s_me);
|
2024-05-15 07:29:30 +02:00
|
|
|
gtk_box_append (experimental_box, GTK_WIDGET (it_s_me));
|
2024-05-15 06:46:11 +02:00
|
|
|
}
|
|
|
|
|
2024-05-15 11:41:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void on_experimental_tree_bind_factory (GtkSignalListItemFactory *factory,
|
|
|
|
GObject* object,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
// GObject *item;
|
|
|
|
const gchar *text;
|
|
|
|
GtkTreeListRow *row;
|
|
|
|
GtkListItem *list_item;
|
|
|
|
GtkWidget *expander;
|
|
|
|
|
|
|
|
list_item= GTK_LIST_ITEM(object);
|
|
|
|
row = gtk_list_item_get_item(list_item);
|
|
|
|
if (row != NULL) {
|
|
|
|
text = gtk_string_object_get_string(GTK_STRING_OBJECT(gtk_tree_list_row_get_item(row)));
|
|
|
|
expander = gtk_list_item_get_child(list_item);
|
|
|
|
gtk_expander_set_label(GTK_EXPANDER(expander), text);
|
|
|
|
|
|
|
|
// Disconnect previous signal handlers to avoid stacking them
|
|
|
|
// TODO g_signal_handlers_disconnect_by_func(expander, G_CALLBACK(on_tree_expander_toggled), row);
|
|
|
|
|
|
|
|
// Connect the signal handler
|
|
|
|
// TODO g_signal_connect(expander, "activate", G_CALLBACK(on_tree_expander_toggled), row);
|
|
|
|
|
|
|
|
gtk_widget_set_margin_start(expander, gtk_tree_list_row_get_depth(row)*20);
|
|
|
|
gboolean is_expanded = gtk_tree_list_row_get_expanded(row);
|
|
|
|
printf("[on_experimental_tree_bind_factory] here is %s content and expander is %d\n",
|
|
|
|
text,
|
|
|
|
is_expanded);
|
|
|
|
} else {
|
|
|
|
printf("[on_tree_bind_factory] here is NON content\n");
|
|
|
|
}
|
|
|
|
}
|