115 |
115 |
116 // unbind all vars |
116 // unbind all vars |
117 UcxMapIterator i = ucx_map_iterator(docctx->vars); |
117 UcxMapIterator i = ucx_map_iterator(docctx->vars); |
118 UiVar *var; |
118 UiVar *var; |
119 UCX_MAP_FOREACH(key, var, i) { |
119 UCX_MAP_FOREACH(key, var, i) { |
|
120 uic_save_var(var); |
120 if(var->from) { |
121 if(var->from) { |
121 // restore old root bound var val |
122 // restore old root bound var val |
122 var->from->value = var->from->orig_val; |
123 var->from->value = var->from->orig_val; |
123 var->from->orig_val = NULL; |
124 var->from->orig_val = NULL; |
124 // copy |
125 // copy |
230 default: fprintf(stderr, "uic_copy_binding: wtf!\n"); break; |
231 default: fprintf(stderr, "uic_copy_binding: wtf!\n"); break; |
231 case UI_VAR_SPECIAL: break; |
232 case UI_VAR_SPECIAL: break; |
232 case UI_VAR_INTEGER: { |
233 case UI_VAR_INTEGER: { |
233 UiInteger *f = from->value; |
234 UiInteger *f = from->value; |
234 UiInteger *t = to->value; |
235 UiInteger *t = to->value; |
235 if(!copytodoc) { |
|
236 f->value = f->get(f); |
|
237 } |
|
238 uic_int_copy(f, t); |
236 uic_int_copy(f, t); |
239 if(t->value != 0) { |
237 if(t->value != 0) { |
240 t->set(t, t->value); |
238 t->set(t, t->value); |
241 } |
239 } |
242 break; |
240 break; |
243 } |
241 } |
244 case UI_VAR_STRING: { |
242 case UI_VAR_STRING: { |
245 UiString *f = from->value; |
243 UiString *f = from->value; |
246 UiString *t = to->value; |
244 UiString *t = to->value; |
247 uic_string_copy(f, t); |
245 uic_string_copy(f, t); |
248 if(!copytodoc) { |
246 char *tvalue = t->value.ptr ? t->value.ptr : ""; |
249 f->value = f->get(f); |
247 t->set(t, tvalue); |
250 } else { |
|
251 char *tvalue = t->value ? t->value : ""; |
|
252 t->set(t, tvalue); |
|
253 } |
|
254 |
|
255 break; |
248 break; |
256 } |
249 } |
257 case UI_VAR_TEXT: { |
250 case UI_VAR_TEXT: { |
258 UiText *f = from->value; |
251 UiText *f = from->value; |
259 UiText *t = to->value; |
252 UiText *t = to->value; |
260 uic_text_copy(f, t); |
253 uic_text_copy(f, t); |
261 if(!copytodoc) { |
254 char *tvalue = t->value.ptr ? t->value.ptr : ""; |
262 f->value = f->get(f); |
255 t->set(t, tvalue); |
263 } else { |
256 t->setposition(t, t->pos); |
264 char *tvalue = t->value ? t->value : ""; |
|
265 t->set(t, tvalue); |
|
266 t->setposition(t, t->pos); |
|
267 } |
|
268 break; |
257 break; |
269 } |
258 } |
270 case UI_VAR_LIST: { |
259 case UI_VAR_LIST: { |
271 UiList *f = from->value; |
260 UiList *f = from->value; |
272 UiList *t = to->value; |
261 UiList *t = to->value; |
274 t->update(t, -1); |
263 t->update(t, -1); |
275 } |
264 } |
276 case UI_VAR_RANGE: { |
265 case UI_VAR_RANGE: { |
277 UiRange *f = from->value; |
266 UiRange *f = from->value; |
278 UiRange *t = to->value; |
267 UiRange *t = to->value; |
279 if(!copytodoc) { |
|
280 f->value = f->get(f); |
|
281 } |
|
282 uic_range_copy(f, t); |
268 uic_range_copy(f, t); |
283 t->setextent(t, t->extent); |
269 t->setextent(t, t->extent); |
284 t->setrange(t, t->min, t->max); |
270 t->setrange(t, t->min, t->max); |
285 t->set(t, t->value); |
271 t->set(t, t->value); |
286 } |
272 } |
289 if(copytodoc) { |
275 if(copytodoc) { |
290 to->from = from; |
276 to->from = from; |
291 |
277 |
292 from->orig_val = from->value; |
278 from->orig_val = from->value; |
293 from->value = to->value; |
279 from->value = to->value; |
|
280 } |
|
281 } |
|
282 |
|
283 void uic_save_var(UiVar *var) { |
|
284 switch(var->type) { |
|
285 case UI_VAR_INTEGER: uic_int_save(var->value); break; |
|
286 case UI_VAR_STRING: uic_string_save(var->value); break; |
|
287 case UI_VAR_TEXT: uic_text_save(var->value); break; |
|
288 case UI_VAR_LIST: break; |
|
289 case UI_VAR_RANGE: uic_range_save(var->value); break; |
294 } |
290 } |
295 } |
291 } |
296 |
292 |
297 void uic_unbind_var(UiVar *var) { |
293 void uic_unbind_var(UiVar *var) { |
298 switch(var->type) { |
294 switch(var->type) { |