diff --git a/include/ui.h b/include/ui.h index d50807e..d7fd30f 100644 --- a/include/ui.h +++ b/include/ui.h @@ -110,11 +110,11 @@ void ui_toggle_sidebar(); /******************************************************************************/ /* T R E E - R E L A T E D E V E N T S */ /******************************************************************************/ -void on_tree_expander_toggled (GtkExpander *expander, 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_selection_changed (GtkSelectionModel* self, guint position, guint n_items, gpointer user_data); -void ui_create_tree (GtkWidget *target_widget); // TODO +void on_tree_expander_toggled (GtkExpander *expander, 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_selection_changed (GtkSelectionModel* self, guint position, guint n_items, gpointer user_data); +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 */ @@ -122,11 +122,11 @@ void ui_create_tree (GtkWidget *target_widget); // gboolean on_glarea_render (GtkGLArea *area, GdkGLContext * context); // TRUE to stop other handlers from being invoked for the event. // FALSE to propagate the event further. -void on_glarea_realize (GtkWidget *widget); -void on_glarea_unrealize (GtkWidget *widget); -void on_axis_value_change (GtkAdjustment *adjustment, gpointer data); -void on_close_window (GtkWidget *widget); -void gtk_window_destroy (GtkWindow* window); // (in application.c) TODO ? +void on_glarea_realize (GtkWidget *widget); +void on_glarea_unrealize (GtkWidget *widget); +void on_axis_value_change (GtkAdjustment *adjustment, gpointer data); +void on_close_window (GtkWidget *widget); +void gtk_window_destroy (GtkWindow* window); // (in application.c) TODO ? /******************************************************************************/ /* G R A P H I C S E S S I O N E V E N T S */ @@ -198,3 +198,52 @@ void ui_shutdown_all_graphic_stacks (void); * @returns bool, true if success */ 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); +} +*/ + diff --git a/src/ui/application.c b/src/ui/application.c index 59d2a52..6cb81ea 100644 --- a/src/ui/application.c +++ b/src/ui/application.c @@ -24,7 +24,7 @@ #include "../../include/ui.h" -#define COMMUTE 0 // 0 first design (2023) based on XML data +#define COMMUTE 1 // 0 first design (2023) based on XML data // 1 2024 May design, free of Builder & templates static int mode = 0; diff --git a/src/ui/events.c b/src/ui/events.c index d4c2724..d1ea4a9 100644 --- a/src/ui/events.c +++ b/src/ui/events.c @@ -115,8 +115,6 @@ void on_togglesidebar_action(GSimpleAction *action, g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self)); - printf("events on_togglesidebar_action() ------\n"); - ui_toggle_sidebar(); } diff --git a/src/ui/tree.c b/src/ui/tree.c index 5956ece..5efeb21 100644 --- a/src/ui/tree.c +++ b/src/ui/tree.c @@ -4,6 +4,7 @@ #include "../../include/display.h" #include "../../include/contain.h" #include "../../include/texts.h" +#include "../../include/tree.h" // https://docs.gtk.org/gtk4/visual_index.html < widgets gallery // https://docs.gtk.org/gtk4/section-text-widget.html @@ -11,15 +12,16 @@ // GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL -static struct TreeNode_t {gchar *text; struct TreeNode_t *child, *next;}; -static void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child); -static struct TreeNode_t *create_user_tree_node (const gchar* text){ +//static struct TreeNode_t {gchar *text; struct TreeNode_t *child, *next;}; +void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child); +struct TreeNode_t *create_user_tree_node (const gchar* text){ struct TreeNode_t *node = g_malloc0 (sizeof(struct TreeNode_t)); node->text = g_strdup (text); node->child = NULL; // if (0) printf("create_user_tree_node %s\n", text); return node; } + struct TreeNode_t *create_tree_node (const gchar* text) { struct TreeNode_t *node = g_malloc0 (sizeof(struct TreeNode_t)); diff --git a/src/ui/views.c b/src/ui/views.c index bbe2792..d3cefda 100644 --- a/src/ui/views.c +++ b/src/ui/views.c @@ -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 -GListModel* ui_tree_get_children_model (struct TreeNode_t *parent) +GListModel *ui_tree_get_children_model (struct TreeNode_t *parent) { struct TreeNode_t *child; @@ -81,7 +81,7 @@ GListModel* ui_tree_get_children_model (struct TreeNode_t *parent) } // 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 *parent = NULL; @@ -109,7 +109,7 @@ char* ui_tree_create_model_func (GObject *item, gpointer root) } static void print_widget_hierarchy(GtkWidget *widget){ - assert(widget); + assert(widget); printf("[src/ui/views.ui_create_tree (GtkWidget *w)] widgets hiercharchy : %s > %s > %s > %s > %s > %s > %s > %s\n",\ gtk_widget_get_name (GTK_WIDGET (gtk_widget_get_root (widget))),\ gtk_widget_get_name (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (widget)))))),\ @@ -138,7 +138,7 @@ void ui_create_tree (GtkWidget *target_widget) GtkWidget *list_view; GtkScrolledWindow *scrolled_window; - struct TreeNode_t *tree_root = create_tree_node("Declaration"); + struct TreeNode_t *tree_root = create_tree_node("Declaration"); let_us_create_a_complex_useless_and_expensive_tree (tree_root); model = gtk_string_list_new(NULL); diff --git a/src/ui/window.c b/src/ui/window.c index 9dbb886..0702fdf 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -225,14 +225,15 @@ void ui_close_internal_notification(void) void ui_toggle_sidebar(void) { int position = gtk_paned_get_position(window->main_paned); + int verbose = 0; if (position != 0) { gtk_paned_set_position (window->main_paned, 0); - printf("window ui_togglesidebar() ->||<-\n"); - gtk_button_set_icon_name (GTK_BUTTON (window->main_button_sidebar), "document-edit-symbolic"); + if (verbose) printf("window ui_togglesidebar() ->||<-\n"); + gtk_button_set_icon_name (GTK_BUTTON (window->main_button_sidebar), "sidebar-show-right-symbolic"); } else { - gtk_paned_set_position (window->main_paned, 400); - printf("window ui_togglesidebar() <|==|>\n"); - gtk_button_set_icon_name (GTK_BUTTON (window->main_button_sidebar), "system-run-symbolic"); + gtk_paned_set_position (window->main_paned, 300); + if (verbose) printf("window ui_togglesidebar() <|==|>\n"); + gtk_button_set_icon_name (GTK_BUTTON (window->main_button_sidebar), "sidebar-show-symbolic"); } }