port progressbar to new API (GTK) newapi

Thu, 15 Feb 2024 21:33:08 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 15 Feb 2024 21:33:08 +0100
branch
newapi
changeset 262
81778b9589d0
parent 261
b39f0e61fd99
child 263
a0ea718ab1d8

port progressbar to new API (GTK)

ui/gtk/display.c file | annotate | diff | comparison | revisions
--- a/ui/gtk/display.c	Thu Feb 15 21:31:15 2024 +0100
+++ b/ui/gtk/display.c	Thu Feb 15 21:33:08 2024 +0100
@@ -105,7 +105,7 @@
     return widget;
 }
 
-UIWIDGET ui_separator(UiObject *obj) {
+UIWIDGET ui_separator_deprecated(UiObject *obj) {
 #if UI_GTK3
     GtkWidget *widget = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
 #else
@@ -119,20 +119,12 @@
 
 /* ------------------------- progress bar ------------------------- */
 
-UIWIDGET ui_progressbar_deprecated(UiObject *obj, UiDouble *value) {
-    UiVar *var = malloc(sizeof(UiVar));
-    var->value = value;
-    var->type = UI_VAR_SPECIAL;
-    return ui_progressbar_var(obj, var);
-}
-
-UIWIDGET ui_progressbar_nv(UiObject *obj, char *varname) {
-    UiVar *var = uic_create_var(obj->ctx, varname, UI_VAR_DOUBLE);
-    return ui_progressbar_var(obj, var);
-}
-
-UIWIDGET ui_progressbar_var(UiObject *obj, UiVar *var) {
+UIWIDGET ui_progressbar_create(UiObject *obj, UiProgressbarArgs args) {
+    UiObject* current = uic_current_obj(obj);
+    
     GtkWidget *progressbar = gtk_progress_bar_new();
+    
+    UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_STRING);
     if(var && var->value) {
         UiDouble *value = var->value;
         value->get = ui_progressbar_get;
@@ -141,8 +133,8 @@
         gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar), 0.5);
     }
     
-    UiContainer *ct = uic_get_current_container(obj);
-    ct->add(ct, progressbar, FALSE);
+    UI_APPLY_LAYOUT1(current, args);
+    current->container->add(current->container, progressbar, FALSE);
     
     return progressbar;
 }

mercurial