Sun, 07 Dec 2025 12:09:04 +0100
add webview width/height args and add gtk function for widget size requests
| ui/gtk/image.c | file | annotate | diff | comparison | revisions | |
| ui/gtk/text.c | file | annotate | diff | comparison | revisions | |
| ui/gtk/webview.c | file | annotate | diff | comparison | revisions | |
| ui/gtk/widget.c | file | annotate | diff | comparison | revisions | |
| ui/gtk/widget.h | file | annotate | diff | comparison | revisions | |
| ui/ui/webview.h | file | annotate | diff | comparison | revisions |
--- 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();
--- 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;
--- 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));
--- 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;
--- 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