fix progressbar using the wrong var type (GTK) newapi

Fri, 16 Feb 2024 19:24:52 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 16 Feb 2024 19:24:52 +0100
branch
newapi
changeset 266
37d5b49b1c91
parent 265
3756725aeaf4
child 267
79dd183dd4cb

fix progressbar using the wrong var type (GTK)

application/main.c file | annotate | diff | comparison | revisions
ui/gtk/display.c file | annotate | diff | comparison | revisions
--- a/application/main.c	Fri Feb 16 19:17:30 2024 +0100
+++ b/application/main.c	Fri Feb 16 19:24:52 2024 +0100
@@ -36,6 +36,7 @@
 typedef struct {
     UiString *str1;
     UiString *str2;
+    UiDouble *progress;
 } MyDocument;
 
 MyDocument *doc1;
@@ -60,6 +61,7 @@
     UiContext *docctx = ui_document_context(doc);
     doc->str1 = ui_string_new(docctx, "str1");
     doc->str1 = ui_string_new(docctx, "str2");
+    doc->progress = ui_double_new(docctx, "progress");
     return doc;
 }
 
@@ -67,11 +69,14 @@
     
     UiObject *obj = ui_window("Test", NULL);
     
+    MyDocument *doc = create_doc();
+    ui_attach_document(obj->ctx, doc);
+    
     ui_button(obj, .label = "Test Button", .icon = "application-x-generic");
     ui_togglebutton(obj, .label = "Toggle");
     ui_checkbox(obj, .label = "Checkbox");
     
-    ui_grid(obj, .fill = 1) {
+    ui_grid(obj, .fill = 1, .spacing = 5) {
         ui_button(obj, .label = "cell1", .hexpand = TRUE);
         ui_button(obj, .label = "cell2");
         ui_newline(obj);
@@ -83,7 +88,10 @@
         ui_newline(obj);
         
         ui_spinner(obj, .step = 5);
+        ui_newline(obj);
         
+        ui_progressbar(obj, .colspan = 2, .varname = "progress");
+        ui_set(doc->progress, 0.75);
     }
     
     ui_show(obj);
--- a/ui/gtk/display.c	Fri Feb 16 19:17:30 2024 +0100
+++ b/ui/gtk/display.c	Fri Feb 16 19:24:52 2024 +0100
@@ -124,7 +124,7 @@
     
     GtkWidget *progressbar = gtk_progress_bar_new();
     
-    UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_STRING);
+    UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_DOUBLE);
     if(var && var->value) {
         UiDouble *value = var->value;
         value->get = ui_progressbar_get;

mercurial