Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 35940) +++ trunk/scconfig/Rev.h (revision 35941) @@ -1 +1 @@ -static const int myrev = 35938; +static const int myrev = 35941; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 35940) +++ trunk/scconfig/Rev.tab (revision 35941) @@ -1,4 +1,4 @@ -35938 configure moving generic part of diag to librnd 3.1.0 +35941 configure moving generic part of diag and preferences dialog to librnd 3.1.0 35866 configure diag plugin generalization for librnd move 35849 configure preferences dialog generalization 35621 configure ar_extern: new module for freerouting.cli Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 35940) +++ trunk/src/Makefile.dep (revision 35941) @@ -266,11 +266,7 @@ ../src_plugins/dialogs/dlg_obj_list.c \ ../src_plugins/dialogs/dlg_netlist.c \ ../src_plugins/dialogs/dlg_printcalib.c \ - ../src_plugins/dialogs/dlg_view.h ../src_plugins/dialogs/dlg_pref.h \ - ../src_plugins/dialogs/dlg_pref_win.h \ - ../src_plugins/dialogs/dlg_pref_key.h \ - ../src_plugins/dialogs/dlg_pref_menu.h \ - ../src_plugins/dialogs/dlg_pref_conf.h \ + ../src_plugins/dialogs/dlg_view.h \ ../src_plugins/dialogs/adialogs_conf.h \ ../src_plugins/dialogs/conf_internal.c \ ../src_plugins/dialogs/adialogs_conf_fields.h @@ -386,15 +382,7 @@ ../src_plugins/dialogs/dlg_lib_pstk.h \ ../src_plugins/dialogs/dlg_padstack.h ../src_plugins/dialogs/dlg_pref.o: ../src_plugins/dialogs/dlg_pref.c \ - ../config.h ../src_plugins/dialogs/dlg_pref.h \ - ../src_plugins/dialogs/dlg_pref_win.h \ - ../src_plugins/dialogs/dlg_pref_key.h \ - ../src_plugins/dialogs/dlg_pref_menu.h \ - ../src_plugins/dialogs/dlg_pref_conf.h \ - ../src_plugins/dialogs/dlg_pref_win.c \ - ../src_plugins/dialogs/dlg_pref_key.c \ - ../src_plugins/dialogs/dlg_pref_menu.c \ - ../src_plugins/dialogs/dlg_pref_conf.c \ + ../config.h \ ../src_plugins/dialogs/dlg_pref_confedit.c board.h vtroutestyle.h \ attrib.h global_typedefs.h layer.h globalconst.h obj_common.h flag.h \ data_parent.h obj_arc_list.h obj_arc.h obj_line_list.h obj_line.h \ @@ -402,10 +390,6 @@ obj_gfx_list.h obj_gfx.h layer_grp.h rats_patch.h board.h ../src_plugins/dialogs/dlg_pref_apptab.o: \ ../src_plugins/dialogs/dlg_pref_apptab.c ../config.h \ - ../src_plugins/dialogs/dlg_pref.h ../src_plugins/dialogs/dlg_pref_win.h \ - ../src_plugins/dialogs/dlg_pref_key.h \ - ../src_plugins/dialogs/dlg_pref_menu.h \ - ../src_plugins/dialogs/dlg_pref_conf.h \ ../src_plugins/dialogs/dlg_pref_general.c \ ../src_plugins/dialogs/dlg_pref_board.c board.h vtroutestyle.h attrib.h \ global_typedefs.h layer.h globalconst.h obj_common.h flag.h \ Index: trunk/src/board.c =================================================================== --- trunk/src/board.c (revision 35940) +++ trunk/src/board.c (revision 35941) @@ -428,3 +428,13 @@ { return pcb_stack_thickness(pcb, namespace, flags, 0, rnd_true, pcb->LayerGroups.len-1, rnd_true, PCB_LYT_COPPER | PCB_LYT_SUBSTRATE); } + +void pcb_board_changed_lib_ev(rnd_hidlib_t *hidlib, void *user_data, int argc, rnd_event_arg_t argv[]) +{ + pcb_board_changed(1); +} + +void pcb_board_init(void) +{ + rnd_event_bind(RND_EVENT_DESIGN_META_CHANGED_LIB, pcb_board_changed_lib_ev, NULL, NULL); +} Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 35940) +++ trunk/src/main.c (revision 35941) @@ -347,6 +347,7 @@ extern void pcb_undo_act_init2(void); extern void pcb_draw_init(void); extern void pcb_draw_uninit(void); +extern void pcb_board_init(void); void pcb_main_init_actions(void) { @@ -381,6 +382,7 @@ conf_core_uninit_pre(); + pcb_board_init(); pcb_draw_uninit(); pcb_brave_uninit(); pcb_polygon_uninit(); Index: trunk/src_plugins/dialogs/dlg_pref_confedit.c =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_confedit.c (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_confedit.c (nonexistent) @@ -1,490 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 2018,2020 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 -> edit conf node (input side) popup */ - -#include - -TODO("This should be removed before the librnd move") -#include "board.h" - -#define is_read_only(ctx) rnd_conf_is_read_only(ctx->role) - -typedef struct { - RND_DAD_DECL_NOINIT(dlg) - - rnd_conf_native_t *nat; - int idx; - rnd_conf_role_t role; - - int wnewval, winsa; -} confedit_ctx_t; - -static void pref_conf_edit_close_cb(void *caller_data, rnd_hid_attr_ev_t ev) -{ - pref_ctx_t *ctx = caller_data; - RND_DAD_FREE(ctx->dlg); - free(ctx); -} - -/* Returns true if the value being edited is not yet created in the conf tree */ -static int confedit_node_is_uninitialized(confedit_ctx_t *ctx) -{ - return (rnd_conf_lht_get_at(ctx->role, ctx->nat->hash_path, 0) == NULL); -} - -static void confedit_brd2dlg(confedit_ctx_t *ctx) -{ - rnd_hid_attr_val_t hv; - lht_node_t *nl, *nd = rnd_conf_lht_get_at(ctx->role, ctx->nat->hash_path, 1); - const char *val; - - if (ctx->idx >= ctx->nat->array_size) - return; /* shouldn't ever happen - we have checked this before creating the dialog! */ - - val = pref_conf_get_val(nd, ctx->nat, ctx->idx); - - switch(ctx->nat->type) { - case RND_CFN_STRING: - hv.str = val; - rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->wnewval, &hv); - break; - case RND_CFN_BOOLEAN: - case RND_CFN_INTEGER: - hv.lng = atoi(val); - rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->wnewval, &hv); - break; - case RND_CFN_REAL: - hv.dbl = strtod(val, NULL); - rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->wnewval, &hv); - break; - case RND_CFN_COORD: - hv.crd = rnd_get_value(val, NULL, NULL, NULL); - rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->wnewval, &hv); - break; - case RND_CFN_UNIT: - { - const rnd_unit_t *u = rnd_get_unit_struct(val); - if (u != NULL) - hv.lng = u - rnd_units; - else - hv.lng = -1; - rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->wnewval, &hv); - } - break; - case RND_CFN_COLOR: - hv.clr = ctx->nat->val.color[ctx->idx]; - rnd_color_load_str(&hv.clr, val); - rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->wnewval, &hv); - break; - case RND_CFN_LIST: - { - rnd_hid_attribute_t *attr = &ctx->dlg[ctx->wnewval]; - rnd_hid_tree_t *tree = attr->wdata; - - rnd_dad_tree_clear(tree); - if (nd->type != LHT_LIST) - return; - for(nl = nd->data.list.first; nl != NULL; nl = nl->next) { - char *cell[2] = {NULL}; - if (nl->type == LHT_TEXT) - cell[0] = rnd_strdup(nl->data.text.value); - rnd_dad_tree_append(attr, NULL, cell); - } - } - break; - case RND_CFN_HLIST: -/* rnd_message(RND_MSG_ERROR, "ERROR: can not import hash lists on GUI\n");*/ - /* Nothing to do, for now it's just a bunch of buttons */ - break; - case RND_CFN_max: - rnd_message(RND_MSG_ERROR, "ERROR: invalid conf node type\n"); - break; - } -} - -static void pref_conf_editval_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *trigger_attr) -{ - rnd_hidlib_t *hidlib = rnd_gui->get_dad_hidlib(hid_ctx); - confedit_ctx_t *ctx = caller_data; - rnd_hid_attribute_t *attr; - char buf[128]; - const char *val = buf; - - if (ctx->idx >= ctx->nat->array_size) - return; /* shouldn't ever happen - we have checked this before creating the dialog! */ - - attr = &ctx->dlg[ctx->wnewval]; - - switch(ctx->nat->type) { - case RND_CFN_STRING: val = attr->val.str; break; - case RND_CFN_BOOLEAN: - case RND_CFN_INTEGER: sprintf(buf, "%ld", attr->val.lng); break; - case RND_CFN_REAL: sprintf(buf, "%f", attr->val.dbl); break; - case RND_CFN_COORD: rnd_snprintf(buf, sizeof(buf), "%.08$mH", attr->val.crd); break; - case RND_CFN_UNIT: - if ((attr->val.lng < 0) || (attr->val.lng >= rnd_get_n_units(0))) - return; - val = rnd_units[attr->val.lng].suffix; - break; - case RND_CFN_COLOR: val = attr->val.clr.str; break; - case RND_CFN_LIST: - { - rnd_hid_attribute_t *attr = &ctx->dlg[ctx->wnewval]; - rnd_hid_tree_t *tree = attr->wdata; - rnd_hid_row_t *r; - lht_node_t *nd = rnd_conf_lht_get_at(ctx->role, ctx->nat->hash_path, 0); - - if (nd == NULL) { - rnd_message(RND_MSG_ERROR, "Internal error: can't copy back to non-existing list!\n"); - return; - } - - if (nd->type != LHT_LIST) { - rnd_message(RND_MSG_ERROR, "Internal error: can't copy back list into non-list!\n"); - return; - } - - /* empty the list so that we insert to an empty list which is overwriting the list */ - while(nd->data.list.first != NULL) - lht_tree_del(nd->data.list.first); - - for(r = gdl_first(&tree->rows); r != NULL; r = gdl_next(&tree->rows, r)) { - lht_node_t *n = lht_dom_node_alloc(LHT_TEXT, NULL); - lht_dom_list_append(nd, n); - n->data.text.value = rnd_strdup(r->cell[0]); - } - rnd_conf_makedirty(ctx->role); - rnd_conf_update(ctx->nat->hash_path, ctx->idx); - } - return; - case RND_CFN_HLIST: - case RND_CFN_max: - return; - } - - if (val == NULL) - val = ""; - rnd_conf_set(ctx->role, ctx->nat->hash_path, ctx->idx, val, RND_POL_OVERWRITE); - - if ((ctx->role == RND_CFR_USER) || (ctx->role == RND_CFR_PROJECT)) - rnd_conf_save_file(hidlib, NULL, (hidlib == NULL ? NULL : hidlib->filename), ctx->role, NULL); - else if (ctx->role == RND_CFR_DESIGN) - pcb_board_set_changed_flag(PCB, 1); - - rnd_gui->invalidate_all(rnd_gui); -} - -static void pref_conf_editval_del_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *trigger_attr) -{ - confedit_ctx_t *ctx = caller_data; - rnd_hid_attribute_t *attr = &ctx->dlg[ctx->wnewval]; - rnd_hid_row_t *r = rnd_dad_tree_get_selected(attr); - - if (r != NULL) { - rnd_dad_tree_remove(attr, r); - pref_conf_editval_cb(hid_ctx, caller_data, trigger_attr); - } -} - -static void pref_conf_editval_edit(void *hid_ctx, confedit_ctx_t *ctx, rnd_hid_attribute_t *attr, rnd_hid_row_t *r) -{ - rnd_hidlib_t *hidlib = rnd_gui->get_dad_hidlib(hid_ctx); - char *nv = rnd_hid_prompt_for(hidlib, "list item value:", r->cell[0], "Edit config list item"); - if (nv == NULL) - return; - - if (rnd_dad_tree_modify_cell(attr, r, 0, rnd_strdup(nv)) == 0) - pref_conf_editval_cb(hid_ctx, ctx, attr); -} - -static void pref_conf_editval_edit_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *trigger_attr) -{ - confedit_ctx_t *ctx = caller_data; - rnd_hid_attribute_t *attr = &ctx->dlg[ctx->wnewval]; - rnd_hid_row_t *r = rnd_dad_tree_get_selected(attr); - - if (r != NULL) - pref_conf_editval_edit(hid_ctx, ctx, attr, r); -} - -static void pref_conf_editval_ins_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *trigger_attr) -{ - confedit_ctx_t *ctx = caller_data; - rnd_hid_attribute_t *attr = &ctx->dlg[ctx->wnewval]; - rnd_hid_row_t *r = rnd_dad_tree_get_selected(attr); - char *cols[] = {NULL, NULL}; - - cols[0] = rnd_strdup(""); - - if (trigger_attr == &ctx->dlg[ctx->winsa]) - r = rnd_dad_tree_append(attr, r, cols); - else - r = rnd_dad_tree_insert(attr, r, cols); - if (r != NULL) - pref_conf_editval_edit(hid_ctx, ctx, attr, r); -} - -static void pref_conf_editval_hlist_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *trigger_attr) -{ - rnd_hidlib_t *hidlib = rnd_gui->get_dad_hidlib(hid_ctx); - confedit_ctx_t *ctx = caller_data; - rnd_actionva(hidlib, ctx->nat->gui_edit_act, - rnd_conf_role_name(ctx->role), ctx->nat->hash_path, trigger_attr->val.str, - NULL); -} - - -static void pref_conf_edit_dlg(rnd_conf_native_t *nat, long idx, rnd_conf_role_t role, rnd_conflist_t *hlist, rnd_bool modal) -{ - rnd_hid_dad_buttons_t clbtn[] = {{"Close", 0}, {NULL, 0}}; - confedit_ctx_t *ctx; - int b[4] = {0}; - - ctx = calloc(sizeof(confedit_ctx_t), 1); - ctx->nat = nat; - ctx->idx = idx; - ctx->role = role; - - RND_DAD_BEGIN_VBOX(ctx->dlg); - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL); - - RND_DAD_LABEL(ctx->dlg, ctx->nat->hash_path); - - switch(ctx->nat->type) { - case RND_CFN_STRING: - RND_DAD_STRING(ctx->dlg); - ctx->wnewval = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_BUTTON(ctx->dlg, "apply"); - RND_DAD_CHANGE_CB(ctx->dlg, pref_conf_editval_cb); - b[0] = RND_DAD_CURRENT(ctx->dlg); - break; - case RND_CFN_BOOLEAN: - RND_DAD_BOOL(ctx->dlg); - ctx->wnewval = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_CHANGE_CB(ctx->dlg, pref_conf_editval_cb); - break; - case RND_CFN_INTEGER: - RND_DAD_INTEGER(ctx->dlg); - ctx->wnewval = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_MINMAX(ctx->dlg, -(1<<30), +(1<<30)); - RND_DAD_BUTTON(ctx->dlg, "apply"); - RND_DAD_CHANGE_CB(ctx->dlg, pref_conf_editval_cb); - b[0] = RND_DAD_CURRENT(ctx->dlg); - break; - case RND_CFN_REAL: - RND_DAD_REAL(ctx->dlg); - ctx->wnewval = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_MINMAX(ctx->dlg, -(1<<30), +(1<<30)); - RND_DAD_BUTTON(ctx->dlg, "apply"); - RND_DAD_CHANGE_CB(ctx->dlg, pref_conf_editval_cb); - b[0] = RND_DAD_CURRENT(ctx->dlg); - break; - case RND_CFN_COORD: - RND_DAD_COORD(ctx->dlg); - ctx->wnewval = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_MINMAX(ctx->dlg, -RND_MM_TO_COORD(1000), +RND_MM_TO_COORD(1000)); - RND_DAD_BUTTON(ctx->dlg, "apply"); - RND_DAD_CHANGE_CB(ctx->dlg, pref_conf_editval_cb); - b[0] = RND_DAD_CURRENT(ctx->dlg); - break; - case RND_CFN_UNIT: - RND_DAD_UNIT(ctx->dlg, 0x3fff); - ctx->wnewval = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_CHANGE_CB(ctx->dlg, pref_conf_editval_cb); - break; - case RND_CFN_COLOR: - RND_DAD_COLOR(ctx->dlg); - ctx->wnewval = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_CHANGE_CB(ctx->dlg, pref_conf_editval_cb); - break; - case RND_CFN_LIST: - RND_DAD_BEGIN_VBOX(ctx->dlg); - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL); - RND_DAD_TREE(ctx->dlg, 1, 0, NULL); - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL | RND_HATF_SCROLL); - ctx->wnewval = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_BUTTON(ctx->dlg, "Edit..."); - RND_DAD_CHANGE_CB(ctx->dlg, pref_conf_editval_edit_cb); - b[0] = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_BUTTON(ctx->dlg, "Del"); - RND_DAD_CHANGE_CB(ctx->dlg, pref_conf_editval_del_cb); - b[1] = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_BUTTON(ctx->dlg, "Insert before"); - RND_DAD_CHANGE_CB(ctx->dlg, pref_conf_editval_ins_cb); - b[2] = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_BUTTON(ctx->dlg, "Insert after"); - RND_DAD_CHANGE_CB(ctx->dlg, pref_conf_editval_ins_cb); - b[3] = ctx->winsa = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_END(ctx->dlg); - RND_DAD_END(ctx->dlg); - break; - case RND_CFN_HLIST: - { - gdl_iterator_t it; - rnd_conf_listitem_t *i; - - if (hlist == NULL) { - RND_DAD_LABEL(ctx->dlg, "ERROR: hlist not available"); - break; - } - - RND_DAD_BEGIN_VBOX(ctx->dlg); - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL | RND_HATF_SCROLL); - rnd_conflist_foreach(hlist, &it, i) { - lht_node_t *rule = i->prop.src; - RND_DAD_BUTTON(ctx->dlg, rule->name); - RND_DAD_CHANGE_CB(ctx->dlg, pref_conf_editval_hlist_cb); - } - RND_DAD_END(ctx->dlg); - } - break; - case RND_CFN_max: - RND_DAD_LABEL(ctx->dlg, "ERROR: invalid conf node type"); - } - - if (is_read_only(ctx)) { - RND_DAD_LABEL(ctx->dlg, "NOTE: this value is read-only"); - RND_DAD_HELP(ctx->dlg, "Config value with this config role\ncan not be modified.\nPlease pick another config role\nand try to edit or create\nthe value there!\n(If that role has higher priority,\nthat value will override this one)"); - } - else if (confedit_node_is_uninitialized(ctx)) { - RND_DAD_LABEL(ctx->dlg, "NOTE: change the value to create the config node"); - RND_DAD_HELP(ctx->dlg, "This config node does not exist\non the selected role.\nTo create it, change the value.\nSpecial case for boolean values:\nto create an unticked value,\nfirst tick then untick the checkbox."); - } - - RND_DAD_BUTTON_CLOSES(ctx->dlg, clbtn); - RND_DAD_END(ctx->dlg); - - RND_DAD_NEW("pref_confedit", ctx->dlg, "pcb-rnd conf item", ctx, modal, pref_conf_edit_close_cb); - - if (is_read_only(ctx)) { - int n; - rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, ctx->wnewval, 0); - for(n = 0; n < sizeof(b) / sizeof(b[0]); n++) - if (b[n] != 0) - rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, b[n], 0); - } - - - confedit_brd2dlg(ctx); -} - - -static void pref_conf_edit_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) -{ - pref_ctx_t *pctx = caller_data; - rnd_hid_row_t *r; - - if (pctx->conf.selected_nat == NULL) { - rnd_message(RND_MSG_ERROR, "You need to select a conf leaf node to edit\nTry the tree on the left.\n"); - return; - } - - r = rnd_dad_tree_get_selected(&pctx->dlg[pctx->conf.wintree]); - if (r == NULL) { - rnd_message(RND_MSG_ERROR, "You need to select a role (upper right list)\n"); - return; - } - - if (pctx->conf.selected_idx >= pctx->conf.selected_nat->array_size) { - rnd_message(RND_MSG_ERROR, "Internal error: array index out of bounds\n"); - return; - } - - if (pctx->conf.selected_nat->type == RND_CFN_HLIST) { - if (pctx->conf.selected_nat->gui_edit_act == NULL) { - rnd_message(RND_MSG_ERROR, "ERROR: can not edit hash lists on GUI\n"); - return; - } - } - - pref_conf_edit_dlg(pctx->conf.selected_nat, pctx->conf.selected_idx, r->user_data2.lng, pctx->conf.selected_nat->val.list, rnd_false); -} - -const char pcb_acts_dlg_confval_edit[] = "dlg_confval_edit(path, idx, role, [modal])\n"; -const char pcb_acth_dlg_confval_edit[] = "Present a dialog box for editing the value of a conf node at path."; -fgw_error_t pcb_act_dlg_confval_edit(fgw_arg_t *res, int argc, fgw_arg_t *argv) -{ - const char *path, *srole, *smodal = NULL; - rnd_bool modal; - long idx; - rnd_conf_native_t *nat; - rnd_conf_role_t role; - - RND_ACT_CONVARG(1, FGW_STR, dlg_confval_edit, path = argv[1].val.str); - RND_ACT_CONVARG(2, FGW_LONG, dlg_confval_edit, idx = argv[2].val.nat_long); - RND_ACT_CONVARG(3, FGW_STR, dlg_confval_edit, srole = argv[3].val.str); - RND_ACT_MAY_CONVARG(4, FGW_STR, dlg_confval_edit, smodal = argv[4].val.str); - - nat = rnd_conf_get_field(path); - if (nat == NULL) { - rnd_message(RND_MSG_ERROR, "ERROR: no such config path: '%s'\n", path); - return -1; - } - - - modal = rnd_istrue(smodal); - role = rnd_conf_role_parse(srole); - if (role == RND_CFR_invalid) { - rnd_message(RND_MSG_ERROR, "ERROR: no such config role: '%s'\n", srole); - return -1; - } - - pref_conf_edit_dlg(nat, idx, role, NULL, modal); - RND_ACT_IRES(0); - return 0; -} - - -static void pref_conf_del_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) -{ - pref_ctx_t *pctx = caller_data; - rnd_hid_row_t *r; - - if (pctx->conf.selected_nat == NULL) { - rnd_message(RND_MSG_ERROR, "You need to select a conf leaf node to remove\nTry the tree on the left.\n"); - return; - } - - r = rnd_dad_tree_get_selected(&pctx->dlg[pctx->conf.wintree]); - if (r == NULL) { - rnd_message(RND_MSG_ERROR, "You need to select a role (upper right list)\n"); - return; - } - - if (pctx->conf.selected_idx >= pctx->conf.selected_nat->array_size) { - rnd_message(RND_MSG_ERROR, "Internal error: array index out of bounds\n"); - return; - } - - if (rnd_conf_is_read_only(r->user_data2.lng)) { - rnd_message(RND_MSG_ERROR, "Role is read-only, can not remove item\n"); - return; - } - - rnd_conf_del(r->user_data2.lng, pctx->conf.selected_nat->hash_path, pctx->conf.selected_idx); -} Index: trunk/src_plugins/dialogs/dlg_pref_menu.c =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_menu.c (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_menu.c (nonexistent) @@ -1,224 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 2020 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, menu tab */ - -#include "dlg_pref.h" -#include -#include - -extern conf_dialogs_t dialogs_conf; - -#define GET_ROW(ctx) \ - rnd_hid_attribute_t *lattr= &((pref_ctx_t *)ctx)->dlg[((pref_ctx_t *)ctx)->menu.wlist]; \ - rnd_hid_row_t *r = rnd_dad_tree_get_selected(lattr); \ - -#define GET_ROW_AND_MENU(ctx) \ - GET_ROW(ctx) \ - rnd_menu_patch_t *m; \ - if (r == NULL) {rnd_message(RND_MSG_ERROR, "Select a menu file first\n"); return; } \ - m = r->user_data; \ - if (m == NULL) {rnd_message(RND_MSG_ERROR, "Invalid menu file selection\n"); return; } \ - -/* Update button states: disable or enable them depending on what kind of - menu patch row is selected from the list */ -static void pref_menu_btn_update(pref_ctx_t *ctx) -{ - rnd_menu_patch_t *m; - GET_ROW(ctx); - - if ((r == NULL) || (r->user_data == NULL)) { - rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, ctx->menu.wunload, 0); - rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, ctx->menu.wreload, 0); - rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, ctx->menu.wexport, 0); - return; - } - - m = r->user_data; - rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, ctx->menu.wunload, 1); - rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, ctx->menu.wreload, m->has_file); - rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, ctx->menu.wexport, 1); -} - -static void pref_menu_brd2dlg(pref_ctx_t *ctx) -{ - rnd_hid_attribute_t *attr; - rnd_hid_tree_t *tree; - rnd_hid_row_t *r; - char *cursor_path = NULL, *cell[6]; - long n; - - attr = &ctx->dlg[ctx->menu.wlist]; - tree = attr->wdata; - - /* remember cursor */ - r = rnd_dad_tree_get_selected(attr); - if (r != NULL) - cursor_path = rnd_strdup(r->cell[0]); - - /* remove existing items */ - rnd_dad_tree_clear(tree); - - /* add all items */ - for(n = 0; n < rnd_menu_sys.patches.used; n++) { - rnd_menu_patch_t *m = rnd_menu_sys.patches.array[n]; - rnd_hid_row_t *row; - const char *fn = m->cfg.doc->root->file_name; - - cell[0] = rnd_strdup_printf("%ld", m->uid); - cell[1] = rnd_strdup((n == 0 ? "base " : "addon")); - cell[2] = rnd_strdup_printf("%d", m->prio); - cell[3] = rnd_strdup_printf("%s", m->cookie); - cell[4] = rnd_strdup_printf("%s", fn == NULL ? "" : fn); - cell[5] = NULL; - - row = rnd_dad_tree_append(attr, NULL, cell); - row->user_data = m; - } - - /* restore cursor */ - if (cursor_path != NULL) { - rnd_hid_attr_val_t hv; - hv.str = cursor_path; - rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->menu.wlist, &hv); - free(cursor_path); - } - pref_menu_btn_update(ctx); -} - -void pcb_dlg_pref_menu_open(pref_ctx_t *ctx) -{ - pref_menu_brd2dlg(ctx); -} - -void pcb_dlg_pref_menu_close(pref_ctx_t *ctx) -{ -} - -static void menu_select(rnd_hid_attribute_t *attrib, void *hid_ctx, rnd_hid_row_t *row) -{ - rnd_hid_attr_val_t hv; - rnd_hid_tree_t *tree = attrib->wdata; - pref_ctx_t *ctx = tree->user_ctx; - rnd_menu_patch_t *m; - - if ((row == NULL) || (row->user_data == NULL)) { - hv.str = ""; - rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->menu.wdesc, &hv); - return; - } - - m = row->user_data; - hv.str = m->desc == NULL ? "" : m->desc; - rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->menu.wdesc, &hv); - - pref_menu_btn_update(ctx); -} - - - -static void pref_menu_load(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) -{ - char *fn = rnd_hid_fileselect(rnd_gui, "menu patch load", "Load a menu patch to file", "menu_patch.lht", "lht", NULL, "menu_patch_load", RND_HID_FSD_READ, NULL); - if (fn == NULL) - return; - if (rnd_hid_menu_load(rnd_gui, NULL, "preferences", 300, fn, 1, NULL, "User reuqested load through the preferences dialog") == NULL) - rnd_message(RND_MSG_ERROR, "Failed to load/parse menu file '%s' - menu file not loaded\n", fn); - free(fn); -} - -static void pref_menu_unload(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) -{ - GET_ROW_AND_MENU(caller_data); - rnd_hid_menu_unload_patch(rnd_gui, m); -} - -static void pref_menu_reload(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) -{ - const char *fn; - GET_ROW_AND_MENU(caller_data); - - fn = m->cfg.doc->root->file_name; - rnd_hid_menu_merge_inhibit_inc(); - if (rnd_hid_menu_load(rnd_gui, NULL, m->cookie, m->prio, fn, 1, NULL, m->desc) == NULL) - rnd_message(RND_MSG_ERROR, "Failed to load/parse menu file '%s' - menu file not reloaded\n", fn); - else - rnd_hid_menu_unload_patch(rnd_gui, m); - rnd_hid_menu_merge_inhibit_dec(); -} - -static void pref_menu_export(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) -{ - FILE *f; - char *fn; - GET_ROW_AND_MENU(caller_data); - - fn = rnd_hid_fileselect(rnd_gui, "menu patch export", "Export a menu patch to file for debugging", "menu_patch.lht", "lht", NULL, "menu_patch_export", RND_HID_FSD_MAY_NOT_EXIST, NULL); - if (fn == NULL) - return; - - f = rnd_fopen(NULL, fn, "w"); - lht_dom_export(m->cfg.doc->root, f, ""); - fclose(f); - free(fn); -} - -#define NONPERS "\nNon-persistent: the file not will be loaded automatically\nafter pcb-rnd is restarted" - -void pcb_dlg_pref_menu_create(pref_ctx_t *ctx) -{ - static const char *hdr[] = {"uid", "type", "prio", "cookie", "file name", NULL}; - - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL); - RND_DAD_TREE(ctx->dlg, 5, 0, hdr); - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL | RND_HATF_SCROLL); - ctx->menu.wlist = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_TREE_SET_CB(ctx->dlg, selected_cb, menu_select); - RND_DAD_TREE_SET_CB(ctx->dlg, ctx, ctx); - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_LABEL(ctx->dlg, "Description:"); - RND_DAD_LABEL(ctx->dlg, ""); - ctx->menu.wdesc = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_END(ctx->dlg); - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_BUTTON(ctx->dlg, "Load..."); - ctx->menu.wload = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_CHANGE_CB(ctx->dlg, pref_menu_load); - RND_DAD_HELP(ctx->dlg, "Load a new menu (patch) file" NONPERS); - RND_DAD_BUTTON(ctx->dlg, "Unload"); - ctx->menu.wunload = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_CHANGE_CB(ctx->dlg, pref_menu_unload); - RND_DAD_HELP(ctx->dlg, "Remove the selected menu (patch) from the menu system" NONPERS); - RND_DAD_BUTTON(ctx->dlg, "Reload"); - ctx->menu.wreload = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_CHANGE_CB(ctx->dlg, pref_menu_reload); - RND_DAD_HELP(ctx->dlg, "Reload the menu file from disk\nand re-merge the menu system"); - RND_DAD_BUTTON(ctx->dlg, "Export..."); - ctx->menu.wexport = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_CHANGE_CB(ctx->dlg, pref_menu_export); - RND_DAD_HELP(ctx->dlg, "Export menu file to disk\n(useful for debuggin)"); - RND_DAD_END(ctx->dlg); -} Index: trunk/src_plugins/dialogs/dlg_pref_menu.h =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_menu.h (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_menu.h (nonexistent) @@ -1,10 +0,0 @@ -#ifndef PCB_DLG_PREF_MENU_H -#define PCB_DLG_PREF_MENU_H - -typedef struct { - int wlist, wdesc, wload, wunload, wreload, wexport; -} pref_menu_t; - -void pcb_dlg_pref_menu_create(pref_ctx_t *ctx); - -#endif Index: trunk/src_plugins/dialogs/dlg_pref_key.c =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_key.c (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_key.c (nonexistent) @@ -1,259 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 2020 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, key translation tab */ - -#include "dlg_pref.h" -#include -#include -#include -#include - -static void pref_key_brd2dlg(pref_ctx_t *ctx) -{ - rnd_hid_attribute_t *attr; - rnd_hid_tree_t *tree; - rnd_hid_row_t *row, *r; - rnd_conf_native_t *nat = rnd_conf_get_field("editor/translate_key"); - char *cursor_path = NULL, *cell[3]; - gdl_iterator_t it; - rnd_conf_listitem_t *kt; - - if ((pref_ctx.key.lock) || (!pref_ctx.active)) - return; - - attr = &ctx->dlg[ctx->key.wlist]; - tree = attr->wdata; - - /* remember cursor */ - r = rnd_dad_tree_get_selected(attr); - if ((r != NULL) && (nat != NULL)) - cursor_path = rnd_strdup(r->cell[0]); - - /* remove existing items */ - rnd_dad_tree_clear(tree); - - if (nat == NULL) - return; - - /* add all items */ - rnd_conflist_foreach(nat->val.list, &it, kt) { - cell[0] = rnd_strdup(kt->name); - cell[1] = rnd_strdup(kt->payload); - row = rnd_dad_tree_append(attr, NULL, cell); - row->user_data = kt; - } - - /* restore cursor */ - if (cursor_path != NULL) { - rnd_hid_attr_val_t hv; - hv.str = cursor_path; - rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->menu.wlist, &hv); - free(cursor_path); - } -} - -static lht_node_t *pref_key_mod_pre(pref_ctx_t *ctx) -{ -/* rnd_hid_attribute_t *attr = &ctx->dlg[ctx->key.wlist]; - rnd_hid_tree_t *tree = attr->wdata;*/ - lht_node_t *lst, *m; - rnd_conf_role_t save; - - save = ctx->role; - ctx->role = RND_CFR_USER; - m = Rnd_pref_dlg2conf_pre(ctx); - if (m == NULL) { - ctx->role = save; - return NULL; - } - - ctx->key.lock++; - /* get the list and clean it */ - - lst = lht_tree_path_(m->doc, m, "editor/translate_key", 1, 0, NULL); - if (lst == NULL) - rnd_conf_set(RND_CFR_USER, "editor/translate_key", 0, "", RND_POL_OVERWRITE); - lst = lht_tree_path_(m->doc, m, "editor/translate_key", 1, 0, NULL); - ctx->role = save; - - assert(lst != NULL); - return lst; -} - -static void pref_key_mod_post(pref_ctx_t *ctx) -{ -/* rnd_hid_attribute_t *attr = &ctx->dlg[ctx->key.wlist]; - rnd_hid_tree_t *tree = attr->wdata;*/ - rnd_conf_role_t save; - - save = ctx->role; - ctx->role = RND_CFR_USER; - - rnd_conf_update("editor/translate_key", -1); - rnd_conf_makedirty(ctx->role); /* low level lht_dom_node_alloc() wouldn't make user config to be saved! */ - - Rnd_pref_dlg2conf_post(ctx); - - ctx->role = save; - ctx->key.lock--; -} - - -void pcb_dlg_pref_key_open(pref_ctx_t *ctx) -{ - pref_key_brd2dlg(ctx); -} - -static void pref_key_remove(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *battr) -{ - rnd_hid_attribute_t *attr = &pref_ctx.dlg[pref_ctx.key.wlist]; - rnd_hid_tree_t *tree = attr->wdata; - rnd_hid_row_t *r, *row = rnd_dad_tree_get_selected(attr); - lht_node_t *nd, *lst = pref_key_mod_pre(&pref_ctx); - - if ((row == NULL) || (lst == NULL)) - return; - - for(nd = lst->data.list.first, r = gdl_first(&tree->rows); r != NULL; r = gdl_next(&tree->rows, r), nd = nd->next) { - if (r == row) { - rnd_dad_tree_remove(attr, r); - lht_tree_del(nd); - break; - } - } - - pref_key_mod_post(&pref_ctx); -} - -/*** key detector GUI ***/ - -typedef struct { - RND_DAD_DECL_NOINIT(dlg) - int wkdesc, wtdesc; -} kd_ctx_t; - -static kd_ctx_t kd; - -void dummy_expose_cb(rnd_hid_attribute_t *attrib, rnd_hid_preview_t *prv, rnd_hid_gc_t gc, const rnd_hid_expose_ctx_t *e) -{ -} - -rnd_bool key_press_cb(rnd_hid_attribute_t *attrib, rnd_hid_preview_t *prv, rnd_bool release, rnd_hid_cfg_mod_t mods, unsigned short int key_raw, unsigned short int key_tr) -{ - rnd_hid_attr_val_t hv; - char *desc; - - if (release) - return 0; - - desc = rnd_hid_cfg_keys_gen_desc(mods, key_raw, 0); - if (desc == NULL) { -/* Can't do this yet because mods are passed on too: - rnd_message(RND_MSG_ERROR, "Failed to recognize that key (%d %d)\n", key_raw, key_tr);*/ - return 0; - } - hv.str = desc; - rnd_gui->attr_dlg_set_value(kd.dlg_hid_ctx, kd.wkdesc, &hv); - - free(desc); - return 0; -} - -static void pref_key_append(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *battr) -{ - rnd_hid_dad_buttons_t clbtn[] = {{"Cancel", -1}, {"add", 0}, {NULL, 0}}; - rnd_hid_attribute_t *attr = &pref_ctx.dlg[pref_ctx.key.wlist]; - lht_node_t *nd, *lst = pref_key_mod_pre(&pref_ctx); - rnd_box_t vbox = {0, 0, RND_MM_TO_COORD(55), RND_MM_TO_COORD(55)}; - int res; - - if (lst == NULL) - return; - - RND_DAD_BEGIN_VBOX(kd.dlg); - RND_DAD_COMPFLAG(kd.dlg, RND_HATF_EXPFILL); - RND_DAD_BEGIN_HBOX(kd.dlg); - RND_DAD_LABEL(kd.dlg, "Key pressed:"); - RND_DAD_STRING(kd.dlg); - kd.wkdesc = RND_DAD_CURRENT(kd.dlg); - RND_DAD_HELP(kd.dlg, "Enter a key description here\nTypical examples: t or Altw\nOr use the key detection box on the right"); - RND_DAD_PREVIEW(kd.dlg, dummy_expose_cb, NULL, key_press_cb, NULL, &vbox, 20, 20, NULL); - RND_DAD_COMPFLAG(kd.dlg, RND_HATF_FRAME); - RND_DAD_HELP(kd.dlg, "Click here then press a key and it will be filled in automatically"); - RND_DAD_END(kd.dlg); - RND_DAD_BEGIN_HBOX(kd.dlg); - RND_DAD_LABEL(kd.dlg, "Translated to:"); - RND_DAD_STRING(kd.dlg); - kd.wtdesc = RND_DAD_CURRENT(kd.dlg); - RND_DAD_HELP(kd.dlg, "Enter a key description here\nTypical examples: t or |"); - RND_DAD_END(kd.dlg); - RND_DAD_BUTTON_CLOSES(kd.dlg, clbtn); - RND_DAD_END(kd.dlg); - - RND_DAD_NEW("pref_key_set", kd.dlg, "set key translation", NULL, rnd_true, NULL); - res = RND_DAD_RUN(kd.dlg); - - if (res == 0) { - const char *k1 = kd.dlg[kd.wkdesc].val.str, *k2 = kd.dlg[kd.wtdesc].val.str; - char *cell[3]; - - cell[0] = rnd_strdup(k1); - cell[1] = rnd_strdup(k2); - cell[2] = NULL; - rnd_dad_tree_append(attr, NULL, cell); - - nd = lht_dom_node_alloc(LHT_TEXT, k1); - nd->data.text.value = rnd_strdup(k2); - lht_dom_list_append(lst, nd); - } - - pref_key_mod_post(&pref_ctx); - - RND_DAD_FREE(kd.dlg); -} - - -void pcb_dlg_pref_key_create(pref_ctx_t *ctx) -{ - static const char *hdr[] = {"pressed", "translated to", NULL}; - - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL); - - RND_DAD_BEGIN_VBOX(ctx->dlg); - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_FRAME | RND_HATF_EXPFILL); - RND_DAD_TREE(ctx->dlg, 3, 0, hdr); - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL | RND_HATF_SCROLL); - ctx->key.wlist = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_END(ctx->dlg); - - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_BUTTON(ctx->dlg, "Remove"); - RND_DAD_CHANGE_CB(ctx->dlg, pref_key_remove); - RND_DAD_BUTTON(ctx->dlg, "Add new..."); - RND_DAD_CHANGE_CB(ctx->dlg, pref_key_append); - RND_DAD_END(ctx->dlg); -} Index: trunk/src_plugins/dialogs/dlg_pref_win.c =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_win.c (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_win.c (nonexistent) @@ -1,195 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 2018 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, window geometry tab */ - -#include "dlg_pref.h" -#include -#include -#include -#include - -extern conf_dialogs_t dialogs_conf; - -static void pref_win_brd2dlg(pref_ctx_t *ctx) -{ - RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, ctx->win.wmaster, lng, rnd_conf.editor.auto_place); - RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, ctx->win.wboard, lng, dialogs_conf.plugins.dialogs.auto_save_window_geometry.to_design); - RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, ctx->win.wproject, lng, dialogs_conf.plugins.dialogs.auto_save_window_geometry.to_project); - RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, ctx->win.wuser, lng, dialogs_conf.plugins.dialogs.auto_save_window_geometry.to_user); -} - -void pcb_dlg_pref_win_open(pref_ctx_t *ctx) -{ - pref_win_brd2dlg(ctx); -} - -void pcb_dlg_pref_win_close(pref_ctx_t *ctx) -{ -} - -static void pref_win_master_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) -{ - pref_ctx_t *ctx = caller_data; - rnd_conf_setf(ctx->role, "editor/auto_place", -1, "%d", attr->val.lng); - pref_win_brd2dlg(ctx); -} - -static void pref_win_board_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) -{ - pref_ctx_t *ctx = caller_data; - rnd_conf_setf(ctx->role, "plugins/dialogs/auto_save_window_geometry/to_design", -1, "%d", attr->val.lng); - pref_win_brd2dlg(ctx); -} - -static void pref_win_project_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) -{ - pref_ctx_t *ctx = caller_data; - - if (Rnd_pref_dlg2conf_pre(ctx) == NULL) - return; - - rnd_conf_setf(ctx->role, "plugins/dialogs/auto_save_window_geometry/to_project", -1, "%d", attr->val.lng); - - Rnd_pref_dlg2conf_post(ctx); - - pref_win_brd2dlg(ctx); -} - -static void pref_win_user_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) -{ - pref_ctx_t *ctx = caller_data; - rnd_conf_setf(ctx->role, "plugins/dialogs/auto_save_window_geometry/to_user", -1, "%d", attr->val.lng); - pref_win_brd2dlg(ctx); -} - - -static void pref_win_board_now_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) -{ - rnd_wplc_save_to_role(rnd_gui->get_dad_hidlib(hid_ctx), RND_CFR_USER); -} - -static void pref_win_project_now_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) -{ - rnd_wplc_save_to_role(rnd_gui->get_dad_hidlib(hid_ctx), RND_CFR_USER); -} - -static void pref_win_user_now_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) -{ - rnd_wplc_save_to_role(rnd_gui->get_dad_hidlib(hid_ctx), RND_CFR_USER); -} - -static void pref_win_file_now_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) -{ - char *fname; - - fname = rnd_hid_fileselect(rnd_gui, "Save window geometry to...", - "Pick a file for saving window geometry to.\n", - "win_geo.lht", ".lht", NULL, "wingeo", RND_HID_FSD_MAY_NOT_EXIST, NULL); - - if (fname == NULL) - return; - - if (rnd_wplc_save_to_file(rnd_gui->get_dad_hidlib(hid_ctx), fname) != 0) - rnd_message(RND_MSG_ERROR, "Error saving window geometry to '%s'\n", fname); -} - - -void pcb_dlg_pref_win_create(pref_ctx_t *ctx) -{ - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL); - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_FRAME); - RND_DAD_LABEL(ctx->dlg, "Load window geometry and enable window placement:"); - RND_DAD_BOOL(ctx->dlg); - RND_DAD_HELP(ctx->dlg, "When enabled, pcb-rnd will load window geometry from config files\nand try to resize and place windows accordingly.\nSizes can be saved once (golden arrangement)\nor at every exit (retrain last setup),\nsee below."); - ctx->win.wmaster = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_CHANGE_CB(ctx->dlg, pref_win_master_cb); - RND_DAD_END(ctx->dlg); - RND_DAD_BEGIN_VBOX(ctx->dlg); - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_FRAME); - RND_DAD_LABEL(ctx->dlg, "Save window geometry to..."); - RND_DAD_BEGIN_TABLE(ctx->dlg, 2); - - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL); - RND_DAD_END(ctx->dlg); - RND_DAD_LABEL(ctx->dlg, "... in the design (board) file"); - RND_DAD_END(ctx->dlg); - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_BUTTON(ctx->dlg, "now"); - RND_DAD_CHANGE_CB(ctx->dlg, pref_win_board_now_cb); - RND_DAD_LABEL(ctx->dlg, "before close:"); - RND_DAD_BOOL(ctx->dlg); - ctx->win.wboard = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_CHANGE_CB(ctx->dlg, pref_win_board_cb); - RND_DAD_END(ctx->dlg); - - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL); - RND_DAD_END(ctx->dlg); - RND_DAD_LABEL(ctx->dlg, "... in the project file"); - RND_DAD_END(ctx->dlg); - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_BUTTON(ctx->dlg, "now"); - RND_DAD_CHANGE_CB(ctx->dlg, pref_win_project_now_cb); - RND_DAD_LABEL(ctx->dlg, "before close:"); - RND_DAD_BOOL(ctx->dlg); - ctx->win.wproject = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_CHANGE_CB(ctx->dlg, pref_win_project_cb); - RND_DAD_END(ctx->dlg); - - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL); - RND_DAD_END(ctx->dlg); - RND_DAD_LABEL(ctx->dlg, "... in the user config"); - RND_DAD_END(ctx->dlg); - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_BUTTON(ctx->dlg, "now"); - RND_DAD_CHANGE_CB(ctx->dlg, pref_win_user_now_cb); - RND_DAD_LABEL(ctx->dlg, "before close:"); - RND_DAD_BOOL(ctx->dlg); - ctx->win.wuser = RND_DAD_CURRENT(ctx->dlg); - RND_DAD_CHANGE_CB(ctx->dlg, pref_win_user_cb); - RND_DAD_END(ctx->dlg); - - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL); - RND_DAD_END(ctx->dlg); - RND_DAD_LABEL(ctx->dlg, "... in a custom file"); - RND_DAD_END(ctx->dlg); - RND_DAD_BEGIN_HBOX(ctx->dlg); - RND_DAD_BUTTON(ctx->dlg, "now"); - RND_DAD_CHANGE_CB(ctx->dlg, pref_win_file_now_cb); - RND_DAD_END(ctx->dlg); - - RND_DAD_END(ctx->dlg); - RND_DAD_END(ctx->dlg); -} Index: trunk/src_plugins/dialogs/dlg_pref_key.h =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_key.h (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_key.h (nonexistent) @@ -1,11 +0,0 @@ -#ifndef PCB_DLG_PREF_KEY_H -#define PCB_DLG_PREF_KEY_H - -typedef struct { - int wlist; - int lock; -} pref_key_t; - -void pcb_dlg_pref_key_create(pref_ctx_t *ctx); - -#endif Index: trunk/src_plugins/dialogs/dlg_pref_win.h =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_win.h (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_win.h (nonexistent) @@ -1,10 +0,0 @@ -#ifndef PCB_DLG_PREF_WIN_H -#define PCB_DLG_PREF_WIN_H - -typedef struct { - int wmaster, wboard, wproject, wuser; -} pref_win_t; - -void pcb_dlg_pref_win_create(pref_ctx_t *ctx); - -#endif Index: trunk/src_plugins/dialogs/dlg_pref_conf.c =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_conf.c (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_conf.c (nonexistent) @@ -1,496 +0,0 @@ -/* - * 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 -#include - -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 ""; - } - idx2--; - } - } - return ""; - case LHT_HASH: return ""; break; - case LHT_TABLE: return ""; break; - case LHT_SYMLINK: return ""; break; - case LHT_INVALID_TYPE: return ""; break; - } - return ""; -} - -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, ""); break; - case RND_CFN_HLIST: strcpy(buf, ""); break; - case RND_CFN_max: strcpy(buf, ""); 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: ", 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); - } -} - - Index: trunk/src_plugins/dialogs/dlg_pref_conf.h =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_conf.h (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_conf.h (nonexistent) @@ -1,19 +0,0 @@ -#ifndef PCB_DLG_PREF_CONF_H -#define PCB_DLG_PREF_CONF_H - -#include - -typedef struct { - int wtree, wintree, wdesc, wname, wmainp, wnattype, wfilter; - int wnatval[RND_CFN_max+1], wsrc[RND_CFN_max+1]; - rnd_conf_native_t *selected_nat; - int selected_idx; -} pref_conf_t; - -void pcb_dlg_pref_conf_close(pref_ctx_t *ctx); -void pcb_dlg_pref_conf_create(pref_ctx_t *ctx); -void pcb_dlg_pref_conf_open(pref_ctx_t *ctx, const char *tabarg); - -void pcb_pref_dlg_conf_changed_cb(pref_ctx_t *ctx, rnd_conf_native_t *cfg, int arr_idx); /* global conf change */ - -#endif Index: trunk/src_plugins/dialogs/Plug.tmpasm =================================================================== --- trunk/src_plugins/dialogs/Plug.tmpasm (revision 35940) +++ trunk/src_plugins/dialogs/Plug.tmpasm (revision 35941) @@ -12,7 +12,6 @@ $(PLUGDIR)/dialogs/dlg_library.o $(PLUGDIR)/dialogs/dlg_loadsave.o $(PLUGDIR)/dialogs/dlg_padstack.o - $(PLUGDIR)/dialogs/dlg_pref.o $(PLUGDIR)/dialogs/dlg_pref_apptab.o $(PLUGDIR)/dialogs/dlg_view.o @] Index: trunk/src_plugins/dialogs/dialogs.c =================================================================== --- trunk/src_plugins/dialogs/dialogs.c (revision 35940) +++ trunk/src_plugins/dialogs/dialogs.c (revision 35941) @@ -35,6 +35,7 @@ #include #include "funchash_core.h" #include +#include /* from lib_hid_common */ extern conf_dialogs_t dialogs_conf; @@ -60,7 +61,6 @@ #include "dlg_printcalib.c" #include "dlg_view.h" -#include "dlg_pref.h" #include "adialogs_conf.h" #include "conf_internal.c" @@ -67,14 +67,8 @@ conf_adialogs_t adialogs_conf; -extern const char pcb_acts_dlg_confval_edit[]; -extern const char pcb_acth_dlg_confval_edit[]; -extern fgw_error_t pcb_act_dlg_confval_edit(fgw_arg_t *res, int argc, fgw_arg_t *argv); - - rnd_action_t dialogs_action_list[] = { {"dlg_test", pcb_act_dlg_test, dlg_test_help, dlg_test_syntax}, - {"dlg_confval_edit", pcb_act_dlg_confval_edit, pcb_acth_dlg_confval_edit, pcb_acts_dlg_confval_edit}, {"LayerBinding", pcb_act_LayerBinding, pcb_acth_LayerBinding, pcb_acts_LayerBinding}, {"FlagEdit", pcb_act_FlagEdit, pcb_acth_FlagEdit, pcb_acts_FlagEdit}, {"PadstackEdit", pcb_act_PadstackEdit, pcb_acth_PadstackEdit, pcb_acts_PadstackEdit}, @@ -84,7 +78,6 @@ {"PrintGUI", pcb_act_PrintGUI, pcb_acth_PrintGUI, pcb_acts_PrintGUI}, {"GroupPropGui", pcb_act_GroupPropGui, pcb_acth_GroupPropGui, pcb_acts_GroupPropGui}, {"LayerPropGui", pcb_act_LayerPropGui, pcb_acth_LayerPropGui, pcb_acts_LayerPropGui}, - {"Preferences", pcb_act_Preferences, pcb_acth_Preferences, pcb_acts_Preferences}, {"pstklib", pcb_act_pstklib, pcb_acth_pstklib, pcb_acts_pstklib}, {"UndoDialog", pcb_act_UndoDialog, pcb_acth_UndoDialog, pcb_acts_UndoDialog}, {"NetlistDialog", pcb_act_NetlistDialog, pcb_acth_NetlistDialog, pcb_acts_NetlistDialog}, @@ -111,7 +104,7 @@ pcb_dlg_netlist_uninit(); pcb_dlg_undo_uninit(); pcb_dlg_pstklib_uninit(); - pcb_dlg_pref_uninit(); + rnd_dlg_pref_uninit(); rnd_remove_actions_by_cookie(dialogs_cookie); pcb_view_dlg_uninit(); pcb_dlg_fontsel_uninit(); @@ -134,7 +127,7 @@ rnd_conf_reg_intern(adialogs_conf_internal); RND_REGISTER_ACTIONS(dialogs_action_list, dialogs_cookie) - pcb_dlg_pref_init(pcb_dlg_pref_tab, pcb_dlg_pref_first_init); + rnd_dlg_pref_init(pcb_dlg_pref_tab, pcb_dlg_pref_first_init); pcb_dlg_pstklib_init(); pcb_dlg_undo_init(); pcb_dlg_netlist_init(); Index: trunk/src_plugins/dialogs/dlg_pref_apptab.c =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_apptab.c (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_apptab.c (revision 35941) @@ -28,7 +28,7 @@ #include "config.h" -#include "dlg_pref.h" +#include /* application tabs */ #undef PREF_TAB Index: trunk/src_plugins/dialogs/dlg_pref_board.c =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_board.c (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_board.c (revision 35941) @@ -26,9 +26,9 @@ /* Preferences dialog, board tab */ -#include "dlg_pref.h" #include #include +#include #include "board.h" #include "event.h" #include "conf_core.h" Index: trunk/src_plugins/dialogs/dlg_pref_color.c =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_color.c (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_color.c (revision 35941) @@ -26,8 +26,8 @@ /* Preferences dialog, color tab */ -#include "dlg_pref.h" #include +#include #include "conf_core.h" typedef struct { @@ -84,12 +84,12 @@ pref_ctx_t *ctx = caller_data; const char *path = attr->user_data; - if (Rnd_pref_dlg2conf_pre(ctx) == NULL) + if (Rnd_pref_dlg2conf_pre(&PCB->hidlib, ctx) == NULL) return; rnd_conf_setf(ctx->role, path, -1, "%s", attr->val.clr.str); - Rnd_pref_dlg2conf_post(ctx); + Rnd_pref_dlg2conf_post(&PCB->hidlib, ctx); rnd_gui->invalidate_all(rnd_gui); } @@ -100,12 +100,12 @@ DEF_TABDATA; int idx = (int *)attr->user_data - tabdata->wlayer; - if (Rnd_pref_dlg2conf_pre(ctx) == NULL) + if (Rnd_pref_dlg2conf_pre(&PCB->hidlib, ctx) == NULL) return; rnd_conf_setf(ctx->role, "appearance/color/layer", idx, "%s", attr->val.clr.str); - Rnd_pref_dlg2conf_post(ctx); + Rnd_pref_dlg2conf_post(&PCB->hidlib, ctx); } Index: trunk/src_plugins/dialogs/dlg_pref_general.c =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_general.c (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_general.c (revision 35941) @@ -26,7 +26,8 @@ /* Preferences dialog, general tab */ -#include "dlg_pref.h" +#include +#include "board.h" static pref_confitem_t perf_topwin[] = { {"Alternate window layout to\nallow smaller size", "appearance/compact", 0, NULL}, @@ -48,21 +49,21 @@ { pref_ctx_t *ctx = caller_data; - if (Rnd_pref_dlg2conf_pre(ctx) == NULL) + if (Rnd_pref_dlg2conf_pre(&PCB->hidlib, ctx) == NULL) return; - pcb_pref_dlg2conf_table(ctx, perf_topwin, attr); - pcb_pref_dlg2conf_table(ctx, perf_backup, attr); - pcb_pref_dlg2conf_table(ctx, perf_cli, attr); + rnd_pref_dlg2conf_table(ctx, perf_topwin, attr); + rnd_pref_dlg2conf_table(ctx, perf_backup, attr); + rnd_pref_dlg2conf_table(ctx, perf_cli, attr); - Rnd_pref_dlg2conf_post(ctx); + Rnd_pref_dlg2conf_post(&PCB->hidlib, ctx); } void pcb_dlg_pref_general_close(pref_ctx_t *ctx) { - pcb_pref_conflist_remove(ctx, perf_topwin); - pcb_pref_conflist_remove(ctx, perf_backup); - pcb_pref_conflist_remove(ctx, perf_cli); + rnd_pref_conflist_remove(ctx, perf_topwin); + rnd_pref_conflist_remove(ctx, perf_backup); + rnd_pref_conflist_remove(ctx, perf_cli); } void pcb_dlg_pref_general_create(pref_ctx_t *ctx) @@ -71,7 +72,7 @@ RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_FRAME); RND_DAD_LABEL(ctx->dlg, "Top window layout"); RND_DAD_BEGIN_TABLE(ctx->dlg, 2); - pcb_pref_create_conftable(ctx, perf_topwin, pref_general_dlg2conf); + rnd_pref_create_conftable(ctx, perf_topwin, pref_general_dlg2conf); RND_DAD_END(ctx->dlg); RND_DAD_END(ctx->dlg); @@ -79,7 +80,7 @@ RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_FRAME); RND_DAD_LABEL(ctx->dlg, "Backup"); RND_DAD_BEGIN_TABLE(ctx->dlg, 2); - pcb_pref_create_conftable(ctx, perf_backup, pref_general_dlg2conf); + rnd_pref_create_conftable(ctx, perf_backup, pref_general_dlg2conf); RND_DAD_END(ctx->dlg); RND_DAD_END(ctx->dlg); @@ -87,7 +88,7 @@ RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_FRAME); RND_DAD_LABEL(ctx->dlg, "Command line entry"); RND_DAD_BEGIN_TABLE(ctx->dlg, 2); - pcb_pref_create_conftable(ctx, perf_cli, pref_general_dlg2conf); + rnd_pref_create_conftable(ctx, perf_cli, pref_general_dlg2conf); RND_DAD_END(ctx->dlg); RND_DAD_END(ctx->dlg); } Index: trunk/src_plugins/dialogs/dlg_pref_layer.c =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_layer.c (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_layer.c (revision 35941) @@ -26,8 +26,8 @@ /* Preferences dialog, board tab */ -#include "dlg_pref.h" #include +#include #include "conf_core.h" #include "stub_draw.h" Index: trunk/src_plugins/dialogs/dlg_pref_lib.c =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_lib.c (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_lib.c (revision 35941) @@ -27,11 +27,11 @@ /* Preferences dialog, library tab */ #include -#include "dlg_pref.h" #include #include "conf_core.h" #include #include +#include typedef struct pref_libhelp_ctx_s { RND_DAD_DECL_NOINIT(dlg) @@ -161,7 +161,7 @@ rnd_hid_row_t *r; - m = Rnd_pref_dlg2conf_pre(ctx); + m = Rnd_pref_dlg2conf_pre(&PCB->hidlib, ctx); if (m == NULL) return; @@ -187,7 +187,7 @@ rnd_conf_update("rc/library_search_paths", -1); rnd_conf_makedirty(ctx->role); /* low level lht_dom_node_alloc() wouldn't make user config to be saved! */ - Rnd_pref_dlg2conf_post(ctx); + Rnd_pref_dlg2conf_post(&PCB->hidlib, ctx); tabdata->lock--; } Index: trunk/src_plugins/dialogs/dlg_pref_sizes.c =================================================================== --- trunk/src_plugins/dialogs/dlg_pref_sizes.c (revision 35940) +++ trunk/src_plugins/dialogs/dlg_pref_sizes.c (revision 35941) @@ -27,8 +27,8 @@ /* Preferences dialog, sizes tab */ #include "board.h" -#include "dlg_pref.h" #include +#include #include "conf_core.h" #include "drc.h" @@ -80,12 +80,12 @@ { pref_ctx_t *ctx = caller_data; - if (Rnd_pref_dlg2conf_pre(ctx) == NULL) + if (Rnd_pref_dlg2conf_pre(&PCB->hidlib, ctx) == NULL) return; - pcb_pref_dlg2conf_table(ctx, limit_sizes, attr); + rnd_pref_dlg2conf_table(ctx, limit_sizes, attr); - Rnd_pref_dlg2conf_post(ctx); + Rnd_pref_dlg2conf_post(&PCB->hidlib, ctx); } static void pref_isle_brd2dlg(rnd_conf_native_t *cfg, int arr_idx) @@ -111,7 +111,7 @@ void pcb_dlg_pref_sizes_close(pref_ctx_t *ctx) { - pcb_pref_conflist_remove(ctx, limit_sizes); + rnd_pref_conflist_remove(ctx, limit_sizes); } void pcb_dlg_pref_sizes_create(pref_ctx_t *ctx) @@ -144,7 +144,7 @@ RND_DAD_LABEL(ctx->dlg, "Limiting sizes (not DRC)"); RND_DAD_LABEL(ctx->dlg, "(Used when the code needs to figure the absolute global smallest value)"); RND_DAD_BEGIN_TABLE(ctx->dlg, 2); - pcb_pref_create_conftable(ctx, limit_sizes, pref_sizes_limit_dlg2conf); + rnd_pref_create_conftable(ctx, limit_sizes, pref_sizes_limit_dlg2conf); RND_DAD_END(ctx->dlg); RND_DAD_BEGIN_TABLE(ctx->dlg, 2);