]> uap-core.de Git - mizunara.git/commitdiff
update toolkit
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 30 Jan 2025 20:40:13 +0000 (21:40 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 30 Jan 2025 20:40:13 +0000 (21:40 +0100)
ui/common/types.c
ui/gtk/list.c
ui/gtk/window.c
ui/ui/container.h
ui/ui/toolkit.h

index 7a7a722a1dfc91b6df85c4e47d9fad99d68a621d..4138c607e56bc44708e267488b29e4145bf47103 100644 (file)
@@ -231,6 +231,8 @@ UiModel* ui_model_copy(UiContext *ctx, UiModel* model) {
     for (int i = 0; i < model->columns; i++) {
         newmodel->titles[i] = model->titles[i] ? cx_strdup_a(a, cx_str(model->titles[i])).ptr : NULL;
     }
+    newmodel->columnsize = cxCalloc(a, model->columns, sizeof(int));
+    memcpy(newmodel->columnsize, model->columnsize, model->columns*sizeof(int));
 
     return newmodel;
 }
@@ -239,6 +241,7 @@ void ui_model_free(UiContext *ctx, UiModel *mi) {
     const CxAllocator* a = ctx ? ctx->allocator : cxDefaultAllocator;
     cxFree(a, mi->types);
     cxFree(a, mi->titles);
+    cxFree(a, mi->columnsize);
     cxFree(a, mi);
 }
 
index 50eb6e5d3343706d1aac4338a8bc4e214a775923..eb411cf295cbfb6fcbec7a14aa9a42bfb06e861b 100644 (file)
@@ -388,6 +388,13 @@ UIWIDGET ui_table_create(UiObject *obj, UiListArgs args) {
         GtkColumnViewColumn *column = gtk_column_view_column_new(model->titles[i], factory);
         gtk_column_view_column_set_resizable(column, true);
         gtk_column_view_append_column(GTK_COLUMN_VIEW(view), column);
+        
+        int size = model->columnsize[i];
+        if(size > 0) {
+            gtk_column_view_column_set_fixed_width(column, size);
+        } else if(size < 0) {
+            gtk_column_view_column_set_expand(column, TRUE);
+        }
     }
     
     // bind listview to list
@@ -614,8 +621,8 @@ static GtkListStore* create_list_store(UiList *list, UiModel *model) {
                     }
                     case UI_INTEGER: {
                         g_value_init(&value, G_TYPE_INT);
-                        int *intptr = data;
-                        g_value_set_int(&value, *intptr);
+                        intptr_t intptr = (intptr_t)data;
+                        g_value_set_int(&value, (int)intptr);
                         break;
                     }
                     case UI_ICON: {
index 0928ee1a198a336db6adc2ea53e5a9a18cb76699..0120ea5f977904a5ac488a016ab6bd8c97d40f44 100644 (file)
@@ -168,13 +168,14 @@ static UiObject* create_window(const char *title, void *window_data, UiBool side
     GtkWidget *content_box = ui_gtk_vbox_new(0);
     BOX_ADD_EXPAND(GTK_BOX(vbox), content_box);
     
+    GtkWidget *sidebar_headerbar = NULL; 
     if(sidebar) {
         GtkWidget *splitview = adw_overlay_split_view_new();
         adw_application_window_set_content(ADW_APPLICATION_WINDOW(obj->widget), splitview);
         
         GtkWidget *sidebar_toolbar_view = adw_toolbar_view_new();
         adw_overlay_split_view_set_sidebar(ADW_OVERLAY_SPLIT_VIEW(splitview), sidebar_toolbar_view);
-        GtkWidget *sidebar_headerbar = adw_header_bar_new();
+        sidebar_headerbar = adw_header_bar_new();
         adw_toolbar_view_add_top_bar(ADW_TOOLBAR_VIEW(sidebar_toolbar_view), sidebar_headerbar);
         
         adw_overlay_split_view_set_content(ADW_OVERLAY_SPLIT_VIEW(splitview), toolbar_view);
@@ -184,8 +185,25 @@ static UiObject* create_window(const char *title, void *window_data, UiBool side
         adw_application_window_set_content(ADW_APPLICATION_WINDOW(obj->widget), toolbar_view);
     }
     
-
     GtkWidget *headerbar = adw_header_bar_new();
+    
+    const char *show_title = ui_get_property("ui.gtk.window.showtitle");
+    if(show_title) {
+        if(!strcmp(show_title, "main") && sidebar) {
+            adw_header_bar_set_show_title(ADW_HEADER_BAR(sidebar_headerbar), FALSE);
+        } else if(!strcmp(show_title, "sidebar")) {
+            adw_header_bar_set_show_title(ADW_HEADER_BAR(headerbar), FALSE);
+        } else if(!strcmp(show_title, "false")) {
+            adw_header_bar_set_show_title(ADW_HEADER_BAR(sidebar_headerbar), FALSE);
+            adw_header_bar_set_show_title(ADW_HEADER_BAR(headerbar), FALSE);
+        } else {
+            fprintf(stderr, "Unknown value '%s' for property ui.gtk.window.showtitle\n", show_title);
+            adw_header_bar_set_show_title(ADW_HEADER_BAR(sidebar_headerbar), FALSE);
+        }
+    } else {
+        adw_header_bar_set_show_title(ADW_HEADER_BAR(headerbar), FALSE);
+    }
+    
     adw_toolbar_view_add_top_bar(ADW_TOOLBAR_VIEW(toolbar_view), headerbar);
     g_object_set_data(G_OBJECT(obj->widget), "ui_headerbar", headerbar);
     
index 3d194bbe291f83a8d2bb9a1b6e48eb8027ea07b7..dda4867a259912de8c91944be0e52533f50d72e6 100644 (file)
@@ -289,7 +289,13 @@ UIEXPORT UiTabbedPane* ui_tabbed_document_view(UiObject *obj);
 UIEXPORT UiObject* ui_document_tab(UiTabbedPane *view);
 
 
+#ifdef UI_GTK
 typedef UIWIDGET (*ui_createwidget_func)(UiObject *obj, UiWidgetArgs args, void *userdata);
+#elif defined(UI_MOTIF)
+typedef UIWIDGET (*ui_createwidget_func)(UiObject *obj, UiWidgetArgs args, void *userdata, Widget parent, Arg *a, int n);
+#elif defined(UI_COCOA)
+typedef UIWIDGET (*ui_createwidget_func)(UiObject *obj, UiWidgetArgs args, void *userdata);
+#endif
 UIEXPORT UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs args);
 
 #define ui_customwidget(obj, create_widget, userdata, ...) ui_customwidget_create(obj, create_widget, userdata, (UiWidgetArgs) { __VA_ARGS__ })
index d72390930fba7e51b5ef83207485465657855ff6..66973c384eec87f07d00c0630617b788e1b9a66b 100644 (file)
@@ -42,6 +42,7 @@ typedef void* UIWINDOW; // NSWindow*
 typedef void* UIMENU;   // NSMenu*
 
 #elif UI_GTK2 || UI_GTK3 || UI_GTK4
+#define UI_GTK
 
 #include <gtk/gtk.h>
 #define UIWIDGET GtkWidget*