From 4b417fbb2b5f875a368255dbc4b34e9d24fbde80 Mon Sep 17 00:00:00 2001 From: neox Date: Sun, 11 Feb 2024 17:05:35 +0100 Subject: [PATCH] first commit --- Makefile | 13 ++++ gtk_treeview_example | Bin 0 -> 27416 bytes main.c | 166 +++++++++++++++++++++++++++++++++++++++++++ manifest.scm | 30 ++++++++ 4 files changed, 209 insertions(+) create mode 100644 Makefile create mode 100755 gtk_treeview_example create mode 100644 main.c create mode 100644 manifest.scm diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7c5c40f --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +CC = gcc +CFLAGS = `pkg-config --cflags gtk4` +LIBS = `pkg-config --libs gtk4` + +TARGET = gtk_treeview_example + +all: $(TARGET) + +$(TARGET): main.c + $(CC) -g $(CFLAGS) -o $(TARGET) main.c $(LIBS) + +clean: + rm -f $(TARGET) diff --git a/gtk_treeview_example b/gtk_treeview_example new file mode 100755 index 0000000000000000000000000000000000000000..7cf9d97d477d5a38a12cff81bca9b54c13494dd8 GIT binary patch literal 27416 zcmeHwcUV(P*Y5_T*yt!&16WWXgcbo?D1nG5NKw>-F(e@gkN_c68v-hb3ZjCdqKE|* z5%t&$SPo!A>{yN!H3%Yt1qI~J?1CYh_j{l3KKK5`=-zAAZ`PVwvu2Xao;@=xqkFk4 zD=8sFP)4R8kfWK*hU*cu6fcjUgg;?6 z@Z#hC21^@?zLf|77~f)eKXy^(PKH|6=@dOo;6eQ-Y#G!-w8 zphS7IfFAVAe;aUjBEEQeirS$D_a{M>@B*xOq8O`aNraed6)vLk!8I6Mn&2`3*MAe#WrXmqgY=WZh^Q7Gfp+VGYXG>Q z4`5vk!DR%lA>ir{u7Ti!Z4CVa>!S~@k>G*>>Jt|V{Fk?bpz^S;^5HoE{)Cei;7b+Y zz6$UlVCG$OXWk%7yLwC;XZMduR%9bp`lX1$J&#ApcAO zK28CCOF{l@1-OBNd=@E?U#UR8LV@2R6yPNa@cs(Q-K+qgrXU|+<{#U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#M-6jZz4ewA&$VmB$kfRfX5>_yv5-~>k zL`)!(aK(`bSrj4RlEF!nWN=z!Bv&j+z#(UsX_oNC37W=dMe`9dCqV@A!>B}zrNnZ@ z(ct*s9t;ztfhlMfRKR1A;Sz+5PKcAy=RsrsooI;3^^tVK^y`b^rhCJ6s0@KSTI18?3LPp?MO2@4*Mgg&v}sS4L$ zh}!|{2z^KB6YGv<0}P4~`o#JvGhC2ZF9k%s`w2OM z!u23z@qq_X5OvDS7+xY>`9|fmJ2+iS=GlGk4cFz6E^|L*ttBmjaytP8`qU+;GbJ{?44^+_ZennWU@1R)U>!`SX~X2Ba{ zG;9QSS$&!b4aI3DC_%P$8;0?O9>yU^9*D^56YE-@nqd;eIyFKb?^Xnh>;y5W-)$!T z9vj{K1aR;u)g#F37lBk+ePUe@@pnI9`^W}){SzQjR=*Z6zZUN}eYy?9av|D}$g>KJ(b`?UOSik5n8Gs-Vav1lEC-7R30Go)=C)P_5f7gZh z`z^5l!$9Z}?f4R4u>OQTalUZ#R4D!HTw;v-rBCGZ79_~(cdz53VHzZuC=&=hf_?;P zviih&Ba$K{)>VPN1{2eV>$_xwygp2p`-r0AfzFuLLcDzVbq0Uu p2z}!B3%Zx+JD3J`Kjnc@mfRPHoH^* +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Simplified TreeNode structure for demonstration purposes +struct TreeNode_t +{ + gchar *text; + struct TreeNode_t *child; + struct TreeNode_t *next; +}; + +struct TreeNode_t *root = NULL; + + +// Function to create a new TreeNode instance +struct TreeNode_t *create_tree_node (const gchar* text) +{ + struct TreeNode_t *node = g_malloc0 (sizeof(struct TreeNode_t)); + node->text = g_strdup(text); + node->child = NULL; + return node; +} + +// Function to add a child node to a parent node +void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child) +{ + struct TreeNode_t *cur; + + if (parent->child) { + cur = parent->child; + while (cur && cur->next) { + cur = cur->next; + } + cur->next = child; + } else { + parent->child = child; + } +} + +// Recursive function to free a TreeNode and its children +void free_tree_node (struct TreeNode_t *node) +{ + struct TreeNode_t *cur; + struct TreeNode_t *tmp; + + if (!node) return; + + // free siblings + cur = node; + while (cur) { + tmp = cur->next; + g_free(cur); + cur = tmp; + } + + // recursive free + free_tree_node(node->child); + g_free(node->text); + g_free(node); +} + +// Function to simulate getting a GListModel of children for a given TreeNode +GListModel* get_children_model (struct TreeNode_t *parent) +{ + struct TreeNode_t *child; + + GtkStringList *list = gtk_string_list_new(NULL); + + if (parent) { + child = parent->child; + while(child) { + gtk_string_list_append(list, child->text); + child = child->next; + } + } + return G_LIST_MODEL(list); +} + +// GtkTreeListModelCreateModelFunc callback implementation +GListModel* create_model_func(GObject *item, gpointer user_data) +{ + struct TreeNode_t *cur = root; + gchar *string = gtk_string_object_get_string(GTK_STRING_OBJECT(item)); + + if (strcmp(string, "Child 1")) { + cur = root->child; + } + else if (strcmp(string, "Child 2")) { + cur = root->child->next; + } else { + cur = NULL; + } + + return get_children_model(cur); +} + +void setup_factory (GtkListItemFactory *factory, GtkListItem *list_item, gpointer user_data) +{ + GtkWidget *label = gtk_label_new(NULL); + gtk_list_item_set_child(list_item, label); +} + +void bind_factory (GtkListItemFactory *factory, GtkListItem *list_item, gpointer user_data) +{ + GObject *item = gtk_list_item_get_item(list_item); + const gchar *text = gtk_string_object_get_string(GTK_STRING_OBJECT(item)); + GtkWidget *label = gtk_list_item_get_child(list_item); + gtk_label_set_text(GTK_LABEL(label), text); +} + +// Application activation callback +void app_activate (GApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new(GTK_APPLICATION(app)); + gtk_window_set_title(GTK_WINDOW(window), "GTK4 Tree Example"); + gtk_window_set_default_size(GTK_WINDOW(window), 400, 300); + + GtkStringList *model = gtk_string_list_new(NULL); + gtk_string_list_append(model, root->text); + + // Create a GtkTreeListModel + GtkTreeListModel *tree_model = gtk_tree_list_model_new( + G_LIST_MODEL(model), + TRUE, // Passthrough - False in actual usage with dynamic children retrieval + TRUE, // autoexpand + (GtkTreeListModelCreateModelFunc)create_model_func, + NULL, + NULL //(GDestroyNotify)free_tree_node + ); + + // Create and setup the list view and item factory + GtkListItemFactory *factory = gtk_signal_list_item_factory_new(); + g_signal_connect(factory, "setup", G_CALLBACK(setup_factory), NULL); + g_signal_connect(factory, "bind", G_CALLBACK(bind_factory), NULL); + + GtkWidget *list_view = gtk_list_view_new(GTK_SELECTION_MODEL(gtk_no_selection_new(tree_model)), factory); + + gtk_window_set_child(GTK_WINDOW(window), list_view); + gtk_widget_set_visible(window, TRUE); +} + +int main (int argc, char **argv) +{ + // Create a simple tree structure + root = create_tree_node("Root"); + add_child_node(root, create_tree_node("Child 1")); + add_child_node(root, create_tree_node("Child 2")); + GtkApplication *app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE); + g_signal_connect(app, "activate", G_CALLBACK(app_activate), NULL); + int status = g_application_run(G_APPLICATION(app), argc, argv); + g_object_unref(app); + free_tree_node(root); // Ensure to free the tree structure after the app has finished + return status; +} + diff --git a/manifest.scm b/manifest.scm new file mode 100644 index 0000000..c1ac365 --- /dev/null +++ b/manifest.scm @@ -0,0 +1,30 @@ +;; +;; Dépendances sous GNU Guix +;; + + +(specifications->manifest + (list + "bash" + "coreutils" + "gcc-toolchain" + "pkg-config" + "valgrind" + "findutils" + "gdb" + "make" + "gtk" + "libxml2" + "glu" + "glew" + "glfw" + "cglm" + "libepoxy" + "pango@1.90.0" + "xorgproto" + "glib" + "mesa-headers" + "mesa" + "libadwaita" + ) +)