# HG changeset patch # User Olaf Wintermann # Date 1765105744 -3600 # Node ID 7016bcb8d38b4e9ed8190d5ff3dcea1d2bdff8bc # Parent 687f43736aef8b6d8da79adac3fb87c7d2913272 add webview width/height args and add gtk function for widget size requests diff -r 687f43736aef -r 7016bcb8d38b ui/gtk/image.c --- a/ui/gtk/image.c Sun Dec 07 12:02:58 2025 +0100 +++ b/ui/gtk/image.c Sun Dec 07 12:09:04 2025 +0100 @@ -30,6 +30,7 @@ #include "container.h" #include "menu.h" +#include "widget.h" #include "../common/context.h" #include "../common/object.h" @@ -68,19 +69,13 @@ GtkWidget *toplevel; GtkWidget *widget = drawingarea; - if(args->width > 0 || args->height > 0) { - int width = args->width; - int height = args->height; - if(width == 0) { - width = -1; - } - if(height == 0) { - height = -1; - } - gtk_widget_set_size_request(drawingarea, width, height); - } else { - gtk_widget_set_size_request(drawingarea, 100, 100); + int width = args->width; + int height = args->height; + if(width == 0 && height == 0) { + width = 100; + height = 100; } + ui_widget_size_request(drawingarea, width, height); #if GTK_MAJOR_VERSION < 4 GtkWidget *eventbox = gtk_event_box_new(); diff -r 687f43736aef -r 7016bcb8d38b ui/gtk/text.c --- a/ui/gtk/text.c Sun Dec 07 12:02:58 2025 +0100 +++ b/ui/gtk/text.c Sun Dec 07 12:09:04 2025 +0100 @@ -144,17 +144,7 @@ GTK_POLICY_AUTOMATIC); // GTK_POLICY_ALWAYS SCROLLEDWINDOW_SET_CHILD(scroll_area, text_area); - if(args->width > 0 || args->height > 0) { - int width = args->width; - int height = args->height; - if(width == 0) { - width = -1; - } - if(height == 0) { - height = -1; - } - gtk_widget_set_size_request(scroll_area, width, height); - } + ui_widget_size_request(scroll_area, args->width, args->height); // font and padding //PangoFontDescription *font; diff -r 687f43736aef -r 7016bcb8d38b ui/gtk/webview.c --- a/ui/gtk/webview.c Sun Dec 07 12:02:58 2025 +0100 +++ b/ui/gtk/webview.c Sun Dec 07 12:09:04 2025 +0100 @@ -30,6 +30,7 @@ #include "container.h" #include "webview.h" +#include "widget.h" #ifdef UI_WEBVIEW @@ -38,6 +39,8 @@ ui_set_name_and_style(webview, args->name, args->style_class); + ui_widget_size_request(webview, args->width, args->height); + UiVar *var = uic_widget_var(obj->ctx, obj->ctx, args->value, args->varname, UI_VAR_GENERIC); if(var) { WebViewData *data = malloc(sizeof(WebViewData)); diff -r 687f43736aef -r 7016bcb8d38b ui/gtk/widget.c --- a/ui/gtk/widget.c Sun Dec 07 12:02:58 2025 +0100 +++ b/ui/gtk/widget.c Sun Dec 07 12:09:04 2025 +0100 @@ -31,7 +31,20 @@ #include "../common/object.h" -UIEXPORT UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs *args) { +void ui_widget_size_request(UIWIDGET w, int width, int height) { + if(width > 0 || height > 0) { + if(width == 0) { + width = -1; + } + if(height == 0) { + height = -1; + } + gtk_widget_set_size_request(w, width, height); + } +} + + +UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs *args) { UIWIDGET widget = create_widget(obj, args, userdata); UiContainerPrivate *ct = (UiContainerPrivate*)obj->container_end; diff -r 687f43736aef -r 7016bcb8d38b ui/gtk/widget.h --- a/ui/gtk/widget.h Sun Dec 07 12:02:58 2025 +0100 +++ b/ui/gtk/widget.h Sun Dec 07 12:09:04 2025 +0100 @@ -35,7 +35,12 @@ extern "C" { #endif - +/* + * Sets a widget width/height. + * + * If wdith or height is 0, the dimension is not changed + */ +void ui_widget_size_request(UIWIDGET w, int width, int height); #ifdef __cplusplus diff -r 687f43736aef -r 7016bcb8d38b ui/ui/webview.h --- a/ui/ui/webview.h Sun Dec 07 12:02:58 2025 +0100 +++ b/ui/ui/webview.h Sun Dec 07 12:09:04 2025 +0100 @@ -60,6 +60,8 @@ int margin_bottom; int colspan; int rowspan; + int width; + int height; const char *name; const char *style_class;