ui/gtk/display.c

branch
newapi
changeset 262
81778b9589d0
parent 261
b39f0e61fd99
child 266
37d5b49b1c91
equal deleted inserted replaced
261:b39f0e61fd99 262:81778b9589d0
103 ct->add(ct, widget, TRUE); 103 ct->add(ct, widget, TRUE);
104 104
105 return widget; 105 return widget;
106 } 106 }
107 107
108 UIWIDGET ui_separator(UiObject *obj) { 108 UIWIDGET ui_separator_deprecated(UiObject *obj) {
109 #if UI_GTK3 109 #if UI_GTK3
110 GtkWidget *widget = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); 110 GtkWidget *widget = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
111 #else 111 #else
112 GtkWidget *widget = gtk_hseparator_new(); 112 GtkWidget *widget = gtk_hseparator_new();
113 #endif 113 #endif
117 return widget; 117 return widget;
118 } 118 }
119 119
120 /* ------------------------- progress bar ------------------------- */ 120 /* ------------------------- progress bar ------------------------- */
121 121
122 UIWIDGET ui_progressbar_deprecated(UiObject *obj, UiDouble *value) { 122 UIWIDGET ui_progressbar_create(UiObject *obj, UiProgressbarArgs args) {
123 UiVar *var = malloc(sizeof(UiVar)); 123 UiObject* current = uic_current_obj(obj);
124 var->value = value; 124
125 var->type = UI_VAR_SPECIAL;
126 return ui_progressbar_var(obj, var);
127 }
128
129 UIWIDGET ui_progressbar_nv(UiObject *obj, char *varname) {
130 UiVar *var = uic_create_var(obj->ctx, varname, UI_VAR_DOUBLE);
131 return ui_progressbar_var(obj, var);
132 }
133
134 UIWIDGET ui_progressbar_var(UiObject *obj, UiVar *var) {
135 GtkWidget *progressbar = gtk_progress_bar_new(); 125 GtkWidget *progressbar = gtk_progress_bar_new();
126
127 UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_STRING);
136 if(var && var->value) { 128 if(var && var->value) {
137 UiDouble *value = var->value; 129 UiDouble *value = var->value;
138 value->get = ui_progressbar_get; 130 value->get = ui_progressbar_get;
139 value->set = ui_progressbar_set; 131 value->set = ui_progressbar_set;
140 value->obj = progressbar; 132 value->obj = progressbar;
141 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar), 0.5); 133 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar), 0.5);
142 } 134 }
143 135
144 UiContainer *ct = uic_get_current_container(obj); 136 UI_APPLY_LAYOUT1(current, args);
145 ct->add(ct, progressbar, FALSE); 137 current->container->add(current->container, progressbar, FALSE);
146 138
147 return progressbar; 139 return progressbar;
148 } 140 }
149 141
150 double ui_progressbar_get(UiDouble *d) { 142 double ui_progressbar_get(UiDouble *d) {

mercurial