diff -r 94d44bdcad3e -r 1a30bf64cb22 ui/gtk/display.c --- a/ui/gtk/display.c Sun Feb 25 21:57:49 2024 +0100 +++ b/ui/gtk/display.c Mon Feb 26 21:37:56 2024 +0100 @@ -148,3 +148,42 @@ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(d->obj), value); d->value = value; } + + +/* ------------------------- progress spinner ------------------------- */ + +UIWIDGET ui_progressspinner_create(UiObject* obj, UiProgressbarSpinnerArgs args) { + UiObject* current = uic_current_obj(obj); + + GtkWidget *spinner = gtk_spinner_new(); + + UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_INTEGER); + if(var && var->value) { + UiInteger *value = var->value; + value->get = ui_spinner_get; + value->set = ui_spinner_set; + value->obj = spinner; + ui_spinner_set(value, value->value); + } + + UI_APPLY_LAYOUT1(current, args); + current->container->add(current->container, spinner, FALSE); + + return spinner; +} + +int64_t ui_spinner_get(UiInteger *i) { + return i->value; +} + +void ui_spinner_set(UiInteger *i, int64_t value) { + i->value = value; + if(i->obj) { + GtkSpinner *spinner = GTK_SPINNER(i->obj); + if(value != 0) { + gtk_spinner_start(spinner); + } else { + gtk_spinner_stop(spinner); + } + } +}