File: dlg_pref_conf.c

package info (click to toggle)
pcb-rnd 2.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 35,428 kB
  • sloc: ansic: 249,627; yacc: 5,981; sh: 5,748; makefile: 3,595; awk: 2,704; lex: 1,094; python: 519; lisp: 169; xml: 128; tcl: 67; perl: 34; javascript: 6; ruby: 5
file content (497 lines) | stat: -rw-r--r-- 16,769 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
/*
 *                            COPYRIGHT
 *
 *  pcb-rnd, interactive printed circuit board design
 *  Copyright (C) 2018,2019 Tibor 'Igor2' Palinkas
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *  Contact:
 *    Project page: http://repo.hu/projects/pcb-rnd
 *    lead developer: http://repo.hu/projects/pcb-rnd/contact.html
 *    mailing list: pcb-rnd (at) list.repo.hu (send "subscribe")
 */

/* Preferences dialog, conf tree tab */

#include "dlg_pref.h"
#include <librnd/core/conf.h>
#include "conf_core.h"
#include <librnd/core/misc_util.h>

static const char *pref_conf_get_val(const lht_node_t *nd, const rnd_conf_native_t *nat, int idx);
#include "dlg_pref_confedit.c"

/* how many chars per line in conf node description (determines window width vs.
   window height */
#define DESC_WRAP_WIDTH 50

static const char *type_tabs[RND_CFN_max+2] = /* MUST MATCH rnd_conf_native_type_t */
	{"STRING", "BOOLEAN", "INTEGER", "REAL", "COORD", "UNIT", "COLOR", "LIST", "invalid", NULL};

static int conf_tree_cmp(const void *v1, const void *v2)
{
	const htsp_entry_t **e1 = (const htsp_entry_t **) v1, **e2 = (const htsp_entry_t **) v2;
	return strcmp((*e1)->key, (*e2)->key);
}

static void setup_tree(pref_ctx_t *ctx)
{
	char *cell[2] = {NULL};
	rnd_hid_attribute_t *attr = &ctx->dlg[ctx->conf.wtree];
	rnd_hid_tree_t *tree = attr->wdata;
	htsp_entry_t *e;
	htsp_entry_t **sorted;
	int num_paths, n;
	char path[1024];

	/* alpha sort keys for the more consistend UI */
	for(e = htsp_first(rnd_conf_fields), num_paths = 0; e; e = htsp_next(rnd_conf_fields, e))
		num_paths++;
	sorted = malloc(sizeof(htsp_entry_t *) * num_paths);
	for(e = htsp_first(rnd_conf_fields), n = 0; e; e = htsp_next(rnd_conf_fields, e), n++)
		sorted[n] = e;
	qsort(sorted, num_paths, sizeof(htsp_entry_t *), conf_tree_cmp);

	for(n = 0; n < num_paths; n++) {
		char *basename, *bnsep;
		rnd_hid_row_t *parent;
		rnd_conf_native_t *nat;

		e = sorted[n];
		if (strlen(e->key) > sizeof(path) - 1) {
			rnd_message(RND_MSG_WARNING, "Warning: can't create config item for %s: path too long\n", e->key);
			continue;
		}
		strcpy(path, e->key);
		basename = strrchr(path, '/');
		if ((basename == NULL) || (basename == path)) {
			rnd_message(RND_MSG_WARNING, "Warning: can't create config item for %s: invalid path (node in root)\n", e->key);
			continue;
		}
		bnsep = basename;
		*basename = '\0';
		basename++;

		parent = rnd_dad_tree_mkdirp(tree, path, NULL);
		if (parent == NULL) {
			rnd_message(RND_MSG_WARNING, "Warning: can't create config item for %s: invalid path\n", e->key);
			continue;
		}
		
		nat = e->value;
		if (nat->array_size > 1) {
			int i;
			*bnsep = '/';
			parent = rnd_dad_tree_mkdirp(tree, path, NULL);
			for(i = 0; i < nat->array_size; i++) {
				cell[0] = rnd_strdup_printf("[%d]", i);
				rnd_dad_tree_append_under(attr, parent, cell);
			}
		}
		else {
			cell[0] = rnd_strdup(basename);
			rnd_dad_tree_append_under(attr, parent, cell);
		}
	}
	free(sorted);
}

static const char *pref_conf_get_val(const lht_node_t *nd, const rnd_conf_native_t *nat, int idx)
{
	lht_node_t *ni;

	switch (nd->type) {
		case LHT_TEXT: return nd->data.text.value; break;
		case LHT_LIST:
			if (nat->array_size > 1) {
				int idx2 = idx;
				for(ni = nd->data.list.first; ni != NULL; ni = ni->next) {
					if (idx2 == 0) {
						if (ni->type == LHT_TEXT)
							return ni->data.text.value;
						return "<invalid array item type>";
					}
					idx2--;
				}
			}
			return "<list>";
		case LHT_HASH:         return "<hash>"; break;
		case LHT_TABLE:        return "<table>"; break;
		case LHT_SYMLINK:      return "<symlink>"; break;
		case LHT_INVALID_TYPE: return "<invalid>"; break;
	}
	return "<invalid-type>";
}

static void setup_intree(pref_ctx_t *ctx, rnd_conf_native_t *nat, int idx)
{
	rnd_conf_role_t n;
	rnd_hid_attribute_t *attr = &ctx->dlg[ctx->conf.wintree];
	rnd_hid_tree_t *tree = attr->wdata;
	rnd_hid_row_t *r;

	rnd_dad_tree_clear(tree);

	for(n = 0; n < RND_CFR_max_real; n++) {
		char *cell[5]= {NULL};
		cell[0] = rnd_strdup(rnd_conf_role_name(n));
		if (nat != NULL) {
			lht_node_t *nd;
			long prio = rnd_conf_default_prio[n];
			rnd_conf_policy_t pol = RND_POL_OVERWRITE;

			nd = rnd_conf_lht_get_at_mainplug(n, nat->hash_path, 1, 0);
			if (nd != NULL) { /* role, prio, policy, value */
				rnd_conf_get_policy_prio(nd, &pol, &prio);
				cell[1] = rnd_strdup_printf("%ld", prio);
				cell[2] = rnd_strdup(rnd_conf_policy_name(pol));
				cell[3] = rnd_strdup(pref_conf_get_val(nd, nat, idx));
			}
		}
		r = rnd_dad_tree_append(attr, NULL, cell);
		r->user_data2.lng = n;
	}
}

static const char *print_conf_val(rnd_conf_native_type_t type, const rnd_confitem_t *val, char *buf, int sizebuf)
{
	const char *ret = buf;

	*buf = '\0';
	switch(type) {
		case RND_CFN_STRING:   if (*val->string != NULL) ret = *val->string; break;
		case RND_CFN_BOOLEAN:  strcpy(buf, *val->boolean ? "true" : "false"); break;
		case RND_CFN_INTEGER:  sprintf(buf, "%ld", *val->integer); break;
		case RND_CFN_REAL:     sprintf(buf, "%f", *val->real); break;
		case RND_CFN_COORD:    rnd_snprintf(buf, sizebuf, "%mH\n%mm\n%ml", *val->coord, *val->coord, *val->coord); break;
		case RND_CFN_UNIT:     strcpy(buf, (*val->unit)->suffix); break;
		case RND_CFN_COLOR:    strcpy(buf, val->color->str); break;
		case RND_CFN_LIST:     strcpy(buf, "<list>"); break;
		case RND_CFN_HLIST:    strcpy(buf, "<hlist>"); break;
		case RND_CFN_max:      strcpy(buf, "<invalid-type>"); break;
	}
	return ret;
}

static void dlg_conf_select_node(pref_ctx_t *ctx, const char *path, rnd_conf_native_t *nat, int idx)
{
	rnd_hid_attr_val_t hv;
	char *tmp, buf[128];
	const char *rolename;
	lht_node_t *src;

	if ((path != NULL) && (nat == NULL))
		nat = rnd_conf_get_field(path);

	if ((path == NULL) && (nat != NULL))
		path = nat->hash_path;

	ctx->conf.selected_nat = nat;
	ctx->conf.selected_idx = idx;

	if (nat == NULL) {
		hv.str = "";
		rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->conf.wname, &hv);
		rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->conf.wdesc, &hv);
		setup_intree(ctx, NULL, 0);

		hv.lng = RND_CFN_max;
		rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->conf.wnattype, &hv);

		return;
	}

	hv.str = path == NULL ? "" : path;
	rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->conf.wname, &hv);

	tmp = rnd_strdup(nat->description);
	rnd_text_wrap(tmp, DESC_WRAP_WIDTH, '\n', ' ');
	hv.str = tmp;
	rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->conf.wdesc, &hv);
	free(tmp);

	/* display lht value */
	setup_intree(ctx, nat, idx);

	/* display native value */
	hv.lng = nat->type;
	rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->conf.wnattype, &hv);

	if ((nat->type == RND_CFN_LIST) || (nat->type == RND_CFN_HLIST)) {
		/* non-default: lists are manually loaded */
		rnd_hid_attribute_t *attr = &ctx->dlg[ctx->conf.wnatval[nat->type]];
		rnd_hid_tree_t *tree = attr->wdata;
		rnd_conf_listitem_t *n;
		char *cell[4];

		rnd_dad_tree_clear(tree);
		for (n = rnd_conflist_first(&nat->val.list[idx]); n != NULL; n = rnd_conflist_next(n)) {
			const char *strval;
			rolename = rnd_conf_role_name(rnd_conf_lookup_role(n->prop.src));
			if (nat->type == RND_CFN_HLIST)
				strval = n->name;
			else
				strval = print_conf_val(n->type, &n->val, buf, sizeof(buf));

			cell[0] = rolename == NULL ? rnd_strdup("") : rnd_strdup(rolename);
			cell[1] = rnd_strdup_printf("%ld", n->prop.prio);
			cell[2] = rnd_strdup(strval);
			cell[3] = 0;
			rnd_dad_tree_append(attr, NULL, cell);
		}
		return;
	}

	/* default: set the value of the given node from hv loaded above */
	hv.str = print_conf_val(nat->type, &nat->val, buf, sizeof(buf));
	rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->conf.wnatval[nat->type], &hv);

	src = nat->prop[idx].src;
	if (src != NULL) {
		rolename = rnd_conf_role_name(rnd_conf_lookup_role(nat->prop[idx].src));
		hv.str = tmp = rnd_strdup_printf("prio: %d role: %s\nsource: %s:%d.%d", nat->prop[idx].prio, rolename, src->file_name, src->line, src->col);
	}
	else
		hv.str = tmp = rnd_strdup_printf("prio: %d\nsource: <not saved>", nat->prop[idx].prio);
	rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->conf.wsrc[nat->type], &hv);
	free(tmp);

	return;
}

static void dlg_conf_select_node_cb(rnd_hid_attribute_t *attrib, void *hid_ctx, rnd_hid_row_t *row)
{
	rnd_hid_tree_t *tree = attrib->wdata;
	char *end, *end2;
	rnd_conf_native_t *nat;

	if (row == NULL) { /* deselect */
		dlg_conf_select_node((pref_ctx_t *)tree->user_ctx, NULL, NULL, 0);
		return;
	}

	end = strrchr(row->path, '/');
	if ((end != NULL) && (end[1] == '[')) {
		int idx = strtol(end+2, &end2, 10);
		/* if last segment is an [integer], it is an array */
		if (*end2 == ']') {
			char tmp[1024];
			int len = end - row->path;
			if ((len <= 0) || (len > sizeof(tmp)-1)) {
				rnd_message(RND_MSG_WARNING, "Warning: can't show array item %s: path too long\n", row->path);
				return;
			}
			memcpy(tmp, row->path, len);
			tmp[len] = '\0';
			dlg_conf_select_node((pref_ctx_t *)tree->user_ctx, tmp, NULL, idx);
		}
		return;
	}

	/* non-array selection */
	nat = rnd_conf_get_field(row->path);
	if ((nat != NULL) && (nat->array_size > 1)) { /* array head: do not display for now */
		dlg_conf_select_node((pref_ctx_t *)tree->user_ctx, NULL, NULL, 0);
		return;
	}
	dlg_conf_select_node((pref_ctx_t *)tree->user_ctx, row->path, nat, 0);
}


void pcb_pref_dlg_conf_changed_cb(pref_ctx_t *ctx, rnd_conf_native_t *cfg, int arr_idx)
{
	if (ctx->conf.selected_nat == cfg)
		dlg_conf_select_node(ctx, NULL, cfg, ctx->conf.selected_idx);
}


static void pcb_pref_dlg_conf_filter_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr_inp)
{
	pref_ctx_t *ctx = caller_data;
	rnd_hid_attribute_t *attr;
	rnd_hid_tree_t *tree;
	const char *text;
	int have_filter_text;

	attr = &ctx->dlg[ctx->conf.wtree];
	tree = attr->wdata;
	text = attr_inp->val.str;
	have_filter_text = (*text != '\0');

	/* hide or unhide everything */
	rnd_dad_tree_hide_all(tree, &tree->rows, have_filter_text);

	if (have_filter_text) /* unhide hits and all their parents */
		rnd_dad_tree_unhide_filter(tree, &tree->rows, 0, text);

	rnd_dad_tree_update_hide(attr);
}


static void build_natval(pref_ctx_t *ctx)
{
	static const char *hdr_nat[] = {"role", "prio", "value", NULL};

	RND_DAD_BEGIN_TABBED(pref_ctx.dlg, type_tabs);
		RND_DAD_COMPFLAG(pref_ctx.dlg, RND_HATF_EXPFILL | RND_HATF_HIDE_TABLAB);
		ctx->conf.wnattype = RND_DAD_CURRENT(ctx->dlg);
		RND_DAD_BEGIN_VBOX(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "Data type: string");
			RND_DAD_LABEL(ctx->dlg, "role/prio");
				ctx->conf.wsrc[0] = RND_DAD_CURRENT(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "(data)");
				ctx->conf.wnatval[0] = RND_DAD_CURRENT(ctx->dlg);
		RND_DAD_END(ctx->dlg);
		RND_DAD_BEGIN_VBOX(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "Data type: boolean");
			RND_DAD_LABEL(ctx->dlg, "role/prio");
				ctx->conf.wsrc[1] = RND_DAD_CURRENT(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "(data)");
				ctx->conf.wnatval[1] = RND_DAD_CURRENT(ctx->dlg);
		RND_DAD_END(ctx->dlg);
		RND_DAD_BEGIN_VBOX(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "Data type: integer");
			RND_DAD_LABEL(ctx->dlg, "role/prio");
				ctx->conf.wsrc[2] = RND_DAD_CURRENT(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "(data)");
				ctx->conf.wnatval[2] = RND_DAD_CURRENT(ctx->dlg);
		RND_DAD_END(ctx->dlg);
		RND_DAD_BEGIN_VBOX(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "Data type: real");
			RND_DAD_LABEL(ctx->dlg, "role/prio");
				ctx->conf.wsrc[3] = RND_DAD_CURRENT(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "(data)");
				ctx->conf.wnatval[3] = RND_DAD_CURRENT(ctx->dlg);
		RND_DAD_END(ctx->dlg);
		RND_DAD_BEGIN_VBOX(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "Data type: coord");
			RND_DAD_LABEL(ctx->dlg, "role/prio");
				ctx->conf.wsrc[4] = RND_DAD_CURRENT(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "(data)");
				ctx->conf.wnatval[4] = RND_DAD_CURRENT(ctx->dlg);
		RND_DAD_END(ctx->dlg);
		RND_DAD_BEGIN_VBOX(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "Data type: unit");
			RND_DAD_LABEL(ctx->dlg, "role/prio");
				ctx->conf.wsrc[5] = RND_DAD_CURRENT(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "(data)");
				ctx->conf.wnatval[5] = RND_DAD_CURRENT(ctx->dlg);
		RND_DAD_END(ctx->dlg);
		RND_DAD_BEGIN_VBOX(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "Data type: color");
			RND_DAD_LABEL(ctx->dlg, "role/prio");
				ctx->conf.wsrc[6] = RND_DAD_CURRENT(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "(data)");
				ctx->conf.wnatval[6] = RND_DAD_CURRENT(ctx->dlg);
		RND_DAD_END(ctx->dlg);
		RND_DAD_BEGIN_VBOX(ctx->dlg);
			RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL);
			RND_DAD_LABEL(ctx->dlg, "Data type: list of strings");
			ctx->conf.wsrc[7] = -1;
			RND_DAD_TREE(ctx->dlg, 3, 0, hdr_nat); /* input state */
				RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL | RND_HATF_SCROLL);
				ctx->conf.wnatval[7] = RND_DAD_CURRENT(ctx->dlg);
		RND_DAD_END(ctx->dlg);
		RND_DAD_BEGIN_VBOX(ctx->dlg);
			RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL);
			RND_DAD_LABEL(ctx->dlg, "Data type: list of hash subtrees");
			ctx->conf.wsrc[8] = -1;
			RND_DAD_TREE(ctx->dlg, 3, 0, hdr_nat); /* input state */
				RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL | RND_HATF_SCROLL);
				ctx->conf.wnatval[8] = RND_DAD_CURRENT(ctx->dlg);
		RND_DAD_END(ctx->dlg);
		RND_DAD_BEGIN_VBOX(ctx->dlg);
			RND_DAD_LABEL(ctx->dlg, "(no conf node selected)");
			ctx->conf.wnatval[9] = RND_DAD_CURRENT(ctx->dlg);
		RND_DAD_END(ctx->dlg);
	RND_DAD_END(ctx->dlg);
}

void pcb_dlg_pref_conf_create(pref_ctx_t *ctx)
{
	static const char *hdr_intree[] = {"role", "prio", "policy", "value", NULL};

	RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL);
	RND_DAD_BEGIN_HPANE(ctx->dlg);
		RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL);
		ctx->conf.wmainp = RND_DAD_CURRENT(ctx->dlg);

		/* left: tree */
		RND_DAD_BEGIN_VBOX(ctx->dlg);
			RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL);
			RND_DAD_TREE(ctx->dlg, 1, 1, NULL);
				RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL | RND_HATF_SCROLL);
				ctx->conf.wtree = RND_DAD_CURRENT(ctx->dlg);
				RND_DAD_TREE_SET_CB(ctx->dlg, selected_cb, dlg_conf_select_node_cb);
				RND_DAD_TREE_SET_CB(ctx->dlg, ctx, ctx);
			RND_DAD_STRING(ctx->dlg);
				RND_DAD_HELP(ctx->dlg, "Filter text:\nlist conf nodes with\nmatching name only");
				RND_DAD_CHANGE_CB(ctx->dlg, pcb_pref_dlg_conf_filter_cb);
				ctx->conf.wfilter = RND_DAD_CURRENT(ctx->dlg);
		RND_DAD_END(ctx->dlg);

		/* right: details */
		RND_DAD_BEGIN_VPANE(ctx->dlg);
			RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL);
			
			/* right/top: conf file */
			RND_DAD_BEGIN_VBOX(ctx->dlg);
				RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_FRAME);
				RND_DAD_LABEL(ctx->dlg, "");
					ctx->conf.wname = RND_DAD_CURRENT(ctx->dlg);
				RND_DAD_LABEL(ctx->dlg, "");
					ctx->conf.wdesc = RND_DAD_CURRENT(ctx->dlg);
				RND_DAD_LABEL(ctx->dlg, "INPUT: configuration node (\"file\" version)");
				RND_DAD_TREE(ctx->dlg, 4, 0, hdr_intree); /* input state */
					ctx->conf.wintree = RND_DAD_CURRENT(ctx->dlg);
				RND_DAD_BEGIN_HBOX(ctx->dlg);
					RND_DAD_BUTTON(ctx->dlg, "Edit selected...");
						RND_DAD_CHANGE_CB(ctx->dlg, pref_conf_edit_cb);
					RND_DAD_BUTTON(ctx->dlg, "Remove selected");
						RND_DAD_CHANGE_CB(ctx->dlg, pref_conf_del_cb);
				RND_DAD_END(ctx->dlg);
			RND_DAD_END(ctx->dlg);

			/* right/bottom: native file */
			RND_DAD_BEGIN_VBOX(ctx->dlg);
				RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL | RND_HATF_FRAME);
				RND_DAD_LABEL(ctx->dlg, "NATIVE: in-memory conf node after the merge");
				build_natval(ctx);

			RND_DAD_END(ctx->dlg);
		RND_DAD_END(ctx->dlg);
	RND_DAD_END(ctx->dlg);

	setup_tree(ctx);
	setup_intree(ctx, NULL, 0);
}

void pcb_dlg_pref_conf_open(pref_ctx_t *ctx, const char *tabarg)
{
	rnd_hid_attr_val_t hv;
	hv.dbl = 0.25;
	rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->conf.wmainp, &hv);

	if (tabarg != NULL) {
		rnd_hid_attr_val_t hv;
		hv.str = rnd_strdup(tabarg);
		rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->conf.wfilter, &hv);
		pcb_pref_dlg_conf_filter_cb(ctx->dlg_hid_ctx, ctx, &ctx->dlg[ctx->conf.wfilter]);
		rnd_dad_tree_expcoll(&ctx->dlg[ctx->conf.wtree], NULL, 1, 1);
	}
}