# HG changeset patch # User Olaf Wintermann <olaf.wintermann@gmail.com> # Date 1740775358 -3600 # Node ID 069fca2a47c29b58dcccec1443ef572e1dc65f8e # Parent 5bc95a6228b0cfd4611e53a330a9b0a95f479e46 add ui_splitpane_set_visible (GTK) diff -r 5bc95a6228b0 -r 069fca2a47c2 ui/gtk/container.c --- a/ui/gtk/container.c Wed Feb 26 21:33:57 2025 +0100 +++ b/ui/gtk/container.c Fri Feb 28 21:42:38 2025 +0100 @@ -1044,6 +1044,8 @@ newobj->container = ui_splitpane_container(obj, pane0, orientation, max); uic_obj_add(obj, newobj); + g_object_set_data(G_OBJECT(pane0), "ui_splitpane", newobj->container); + return pane0; } @@ -1062,6 +1064,7 @@ ct->current_pane = pane; ct->orientation = orientation; ct->max = max; + ct->children = cxArrayListCreateSimple(CX_STORE_POINTERS, 4); return (UiContainer*)ct; } @@ -1073,6 +1076,8 @@ return; } + cxListAdd(s->children, widget); + if(s->pos == 0) { gtk_paned_set_start_child(GTK_PANED(s->current_pane), widget); s->pos++; @@ -1092,6 +1097,19 @@ } } +UIEXPORT void ui_splitpane_set_visible(UIWIDGET splitpane, int child_index, UiBool visible) { + UiSplitPaneContainer *ct = g_object_get_data(G_OBJECT(splitpane), "ui_splitpane"); + if(!ct) { + fprintf(stderr, "UI Error: not a splitpane\n"); + return; + } + + GtkWidget *w = cxListAt(ct->children, child_index); + if(w) { + gtk_widget_set_visible(w, visible); + } +} + /* -------------------- ItemList Container -------------------- */ static void remove_item(void *data, void *item) { diff -r 5bc95a6228b0 -r 069fca2a47c2 ui/gtk/container.h --- a/ui/gtk/container.h Wed Feb 26 21:33:57 2025 +0100 +++ b/ui/gtk/container.h Fri Feb 28 21:42:38 2025 +0100 @@ -36,6 +36,7 @@ #include <cx/allocator.h> #include <cx/hash_map.h> +#include <cx/list.h> #ifdef __cplusplus extern "C" { @@ -127,6 +128,7 @@ typedef struct UiSplitPaneContainer { UiContainer container; GtkWidget *current_pane; + CxList *children; UiOrientation orientation; int pos; int max; diff -r 5bc95a6228b0 -r 069fca2a47c2 ui/ui/container.h --- a/ui/ui/container.h Wed Feb 26 21:33:57 2025 +0100 +++ b/ui/ui/container.h Fri Feb 28 21:42:38 2025 +0100 @@ -262,6 +262,9 @@ #define ui_hsplitpane0(obj) for(ui_hsplitpane_create(obj, (UiSplitPaneArgs){ 0 });ui_container_finish(obj);ui_container_begin_close(obj)) #define ui_vsplitpane0(obj) for(ui_vsplitpane_create(obj, (UiSplitPaneArgs){ 0 });ui_container_finish(obj);ui_container_begin_close(obj)) +#define ui_hsplitpane_w(obj, w, ...) for(w = ui_hsplitpane_create(obj, (UiSplitPaneArgs){ __VA_ARGS__ });ui_container_finish(obj);ui_container_begin_close(obj)) +#define ui_vsplitpane_w(obj, w, ...) for(w = ui_vsplitpane_create(obj, (UiSplitPaneArgs){ __VA_ARGS__ });ui_container_finish(obj);ui_container_begin_close(obj)) + #define ui_tab(obj, label) for(ui_tab_create(obj, label);ui_container_finish(obj);ui_container_begin_close(obj)) #define ui_headerbar_start(obj) for(ui_headerbar_start_create(obj);ui_container_finish(obj);ui_container_begin_close(obj)) @@ -298,6 +301,7 @@ UIEXPORT UIWIDGET ui_hsplitpane_create(UiObject *obj, UiSplitPaneArgs args); UIEXPORT UIWIDGET ui_vsplitpane_create(UiObject *obj, UiSplitPaneArgs args); +UIEXPORT void ui_splitpane_set_visible(UIWIDGET splitpane, int child_index, UiBool visible); // box container layout functions UIEXPORT void ui_layout_fill(UiObject *obj, UiBool fill);