WIP: comparing 'tree.c' to 'views.c' (should be the same ?)

This commit is contained in:
Jean Sirmai 2024-05-29 23:26:13 +02:00
parent 9e71a8b615
commit 7a961998f6
Signed by: jean
GPG Key ID: FB3115C340E057E3
6 changed files with 75 additions and 25 deletions

View File

@ -114,7 +114,7 @@ void on_tree_expander_toggled (GtkExpander *expander,
void on_tree_setup_factory (GtkSignalListItemFactory *factory, GObject* object, gpointer user_data); void on_tree_setup_factory (GtkSignalListItemFactory *factory, GObject* object, gpointer user_data);
void on_tree_bind_factory (GtkSignalListItemFactory *factory, GObject* object, gpointer user_data); void on_tree_bind_factory (GtkSignalListItemFactory *factory, GObject* object, gpointer user_data);
void on_tree_selection_changed (GtkSelectionModel* self, guint position, guint n_items, gpointer user_data); void on_tree_selection_changed (GtkSelectionModel* self, guint position, guint n_items, gpointer user_data);
void ui_create_tree (GtkWidget *target_widget); // TODO void ui_create_tree (GtkWidget *target_widget); // in views.c TODO
/******************************************************************************/ /******************************************************************************/
/* G R A P H I C I N I T - C L O S E */ /* G R A P H I C I N I T - C L O S E */
@ -198,3 +198,52 @@ void ui_shutdown_all_graphic_stacks (void);
* @returns bool, true if success * @returns bool, true if success
*/ */
bool ui_update_axis_stack (GtkWidget *container_widget, int axis, int value); bool ui_update_axis_stack (GtkWidget *container_widget, int axis, int value);
/*
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;
}
// pourquoi je n'arrive pas à le déplacer ici ?
// l'initialisation de « struct TreeNode_t * » depuis « int »
// transforme un entier en pointeur sans transtypage
static void let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root) {
struct TreeNode_t *a = create_tree_node("We, the people");add_child_node(tree_root, a);
struct TreeNode_t *b = create_tree_node("in Order to"); add_child_node(tree_root, b);
struct TreeNode_t *c = create_tree_node("do establish"); add_child_node(tree_root, c);
struct TreeNode_t *aa = create_tree_node("aware of"); add_child_node(a, aa);
struct TreeNode_t *aaa = create_tree_node("our rights"); add_child_node(aa, aaa);
struct TreeNode_t *aab = create_tree_node("our duties"); add_child_node(aa, aab);
struct TreeNode_t *aaaa = create_tree_node("read"); add_child_node(aaa, aaaa);
struct TreeNode_t *aaab = create_tree_node("write"); add_child_node(aaa, aaab);
struct TreeNode_t *aaac = create_tree_node("copy"); add_child_node(aaa, aaac);
struct TreeNode_t *aaad = create_tree_node("edit"); add_child_node(aaa, aaad);
struct TreeNode_t *aaaba= create_tree_node("code"); add_child_node(aaab, aaaba);
struct TreeNode_t *aaabb= create_tree_node("language"); add_child_node(aaab, aaabb);
struct TreeNode_t *aaabc= create_tree_node("any art..."); add_child_node(aaab, aaabc);
struct TreeNode_t *aaadb= create_tree_node("publish"); add_child_node(aaac, aaadb);
struct TreeNode_t *aaada= create_tree_node("create"); add_child_node(aaad, aaada);
struct TreeNode_t *aaba = create_tree_node("learn"); add_child_node(aab, aaba);
struct TreeNode_t *aabb = create_tree_node("help"); add_child_node(aab, aabb);
struct TreeNode_t *ba = create_tree_node("promote"); add_child_node(b, ba);
struct TreeNode_t *bb = create_tree_node("individual"); add_child_node(b, bb);
struct TreeNode_t *bc = create_tree_node("and common"); add_child_node(b, bc);
struct TreeNode_t *bca = create_tree_node("education"); add_child_node(bc, bca);
struct TreeNode_t *bcb = create_tree_node("mutual"); add_child_node(bc, bcb);
struct TreeNode_t *bcc = create_tree_node("support"); add_child_node(bc, bcc);
struct TreeNode_t *bcd = create_tree_node("health"); add_child_node(bc, bcd);
struct TreeNode_t *bcda = create_tree_node("mental"); add_child_node(bcd, bcda);
struct TreeNode_t *bcdb = create_tree_node("physical"); add_child_node(bcd, bcdb);
struct TreeNode_t *ca = create_tree_node("free"); add_child_node(c, ca);
struct TreeNode_t *cb = create_tree_node("code"); add_child_node(c, cb);
struct TreeNode_t *cc = create_tree_node("access"); add_child_node(c, cc);
}
*/

View File

@ -24,7 +24,7 @@
#include "../../include/ui.h" #include "../../include/ui.h"
#define COMMUTE 0 // 0 first design (2023) based on <gemgraph.ui> XML data #define COMMUTE 1 // 0 first design (2023) based on <gemgraph.ui> XML data
// 1 2024 May design, free of Builder & templates // 1 2024 May design, free of Builder & templates
static int mode = 0; static int mode = 0;

View File

@ -115,8 +115,6 @@ void on_togglesidebar_action(GSimpleAction *action,
g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self)); g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self));
printf("events on_togglesidebar_action() ------\n");
ui_toggle_sidebar(); ui_toggle_sidebar();
} }

View File

@ -4,6 +4,7 @@
#include "../../include/display.h" #include "../../include/display.h"
#include "../../include/contain.h" #include "../../include/contain.h"
#include "../../include/texts.h" #include "../../include/texts.h"
#include "../../include/tree.h"
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery // https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
// https://docs.gtk.org/gtk4/section-text-widget.html // https://docs.gtk.org/gtk4/section-text-widget.html
@ -11,15 +12,16 @@
// GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL // GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL
static struct TreeNode_t {gchar *text; struct TreeNode_t *child, *next;}; //static struct TreeNode_t {gchar *text; struct TreeNode_t *child, *next;};
static void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child); void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child);
static struct TreeNode_t *create_user_tree_node (const gchar* text){ struct TreeNode_t *create_user_tree_node (const gchar* text){
struct TreeNode_t *node = g_malloc0 (sizeof(struct TreeNode_t)); struct TreeNode_t *node = g_malloc0 (sizeof(struct TreeNode_t));
node->text = g_strdup (text); node->text = g_strdup (text);
node->child = NULL; // if (0) printf("create_user_tree_node %s\n", text); node->child = NULL; // if (0) printf("create_user_tree_node %s\n", text);
return node; return node;
} }
struct TreeNode_t *create_tree_node (const gchar* text) struct TreeNode_t *create_tree_node (const gchar* text)
{ {
struct TreeNode_t *node = g_malloc0 (sizeof(struct TreeNode_t)); struct TreeNode_t *node = g_malloc0 (sizeof(struct TreeNode_t));

View File

@ -55,7 +55,7 @@ static void free_tree_node (struct TreeNode_t *node)
} }
// Function to simulate getting a GListModel of children for a given TreeNode // Function to simulate getting a GListModel of children for a given TreeNode
GListModel* ui_tree_get_children_model (struct TreeNode_t *parent) GListModel *ui_tree_get_children_model (struct TreeNode_t *parent)
{ {
struct TreeNode_t *child; struct TreeNode_t *child;
@ -81,7 +81,7 @@ GListModel* ui_tree_get_children_model (struct TreeNode_t *parent)
} }
// GtkTreeListModelCreateModelFunc callback implementation // GtkTreeListModelCreateModelFunc callback implementation
char* ui_tree_create_model_func (GObject *item, gpointer root) char *ui_tree_create_model_func (GObject *item, gpointer root)
{ {
struct TreeNode_t *cur = (struct TreeNode_t *)root; struct TreeNode_t *cur = (struct TreeNode_t *)root;
struct TreeNode_t *parent = NULL; struct TreeNode_t *parent = NULL;

View File

@ -225,14 +225,15 @@ void ui_close_internal_notification(void)
void ui_toggle_sidebar(void) void ui_toggle_sidebar(void)
{ {
int position = gtk_paned_get_position(window->main_paned); int position = gtk_paned_get_position(window->main_paned);
int verbose = 0;
if (position != 0) { if (position != 0) {
gtk_paned_set_position (window->main_paned, 0); gtk_paned_set_position (window->main_paned, 0);
printf("window ui_togglesidebar() ->||<-\n"); if (verbose) printf("window ui_togglesidebar() ->||<-\n");
gtk_button_set_icon_name (GTK_BUTTON (window->main_button_sidebar), "document-edit-symbolic"); gtk_button_set_icon_name (GTK_BUTTON (window->main_button_sidebar), "sidebar-show-right-symbolic");
} else { } else {
gtk_paned_set_position (window->main_paned, 400); gtk_paned_set_position (window->main_paned, 300);
printf("window ui_togglesidebar() <|==|>\n"); if (verbose) printf("window ui_togglesidebar() <|==|>\n");
gtk_button_set_icon_name (GTK_BUTTON (window->main_button_sidebar), "system-run-symbolic"); gtk_button_set_icon_name (GTK_BUTTON (window->main_button_sidebar), "sidebar-show-symbolic");
} }
} }