Index: trunk/src/gui_act.c =================================================================== --- trunk/src/gui_act.c (revision 11446) +++ trunk/src/gui_act.c (revision 11447) @@ -1548,7 +1548,7 @@ attr[1].default_val.int_value = ly->comb & PCB_LYC_SUB; attr[2].default_val.int_value = ly->comb & PCB_LYC_AUTO; - ar = pcb_gui->attribute_dialog(attr,sizeof(attr)/sizeof(attr[0]), rv, "edit layer properies", "Edit the properties of a logical layer"); + ar = pcb_gui->attribute_dialog(attr,sizeof(attr)/sizeof(attr[0]), rv, "edit layer properies", "Edit the properties of a logical layer", NULL); if (ar == 0) { pcb_layer_combining_t comb = 0; @@ -1659,7 +1659,7 @@ attr[0].default_val.str_value = pcb_strdup(g->name); - ar = pcb_gui->attribute_dialog(attr,sizeof(attr)/sizeof(attr[0]), rv, "edit layer properies", "Edit the properties of a logical layer"); + ar = pcb_gui->attribute_dialog(attr,sizeof(attr)/sizeof(attr[0]), rv, "edit layer properies", "Edit the properties of a logical layer", NULL); if (ar == 0) { if (strcmp(g->name, attr[0].default_val.str_value) != 0) { Index: trunk/src/hid.h =================================================================== --- trunk/src/hid.h (revision 11446) +++ trunk/src/hid.h (revision 11447) @@ -427,8 +427,7 @@ may use it for a tooltip or text in a dialog box, or a help string. */ - int (*attribute_dialog) (pcb_hid_attribute_t * attrs_, - int n_attrs_, pcb_hid_attr_val_t * results_, const char *title_, const char *descr_); + int (*attribute_dialog)(pcb_hid_attribute_t * attrs_, int n_attrs_, pcb_hid_attr_val_t * results_, const char *title_, const char *descr_, void *caller_data); /* Disable or enable a widget of an active attribute dialog */ int (*att_dlg_widget_state)(void *hid_ctx, int idx, pcb_bool enabled); Index: trunk/src/hid_attrib.h =================================================================== --- trunk/src/hid_attrib.h (revision 11446) +++ trunk/src/hid_attrib.h (revision 11447) @@ -67,7 +67,7 @@ /* Advanced API: may not be available in all HIDs; supported by hid_gtk */ int changed; /* 0 for initial values, 1 on user change */ - void (*change_cb)(void *hid_ctx, pcb_hid_attribute_t *attr); /* called upon value change by the user */ + void (*change_cb)(void *hid_ctx, void *caller_data, pcb_hid_attribute_t *attr); /* called upon value change by the user */ void *user_data; /* ignored; the caller is free to use it */ }; Index: trunk/src/hid_dad.h =================================================================== --- trunk/src/hid_dad.h (revision 11446) +++ trunk/src/hid_dad.h (revision 11447) @@ -46,11 +46,11 @@ free(table ## _result); \ } while(0) -#define PCB_DAD_RUN(table, title, descr) \ +#define PCB_DAD_RUN(table, title, descr, caller_data) \ do { \ if (table ## _result == NULL) \ PCB_DAD_ALLOC_RESULT(table); \ - pcb_gui->attribute_dialog(table, table ## _len, table ## _result, title, descr); \ + pcb_gui->attribute_dialog(table, table ## _len, table ## _result, title, descr, caller_data); \ } while(0) /* Return the index of the item currenty being edited */ Index: trunk/src/hid_nogui.c =================================================================== --- trunk/src/hid_nogui.c (revision 11446) +++ trunk/src/hid_nogui.c (revision 11447) @@ -363,7 +363,7 @@ return pcb_strdup(answer); } -static int nogui_attribute_dialog(pcb_hid_attribute_t * attrs, int n_attrs, pcb_hid_attr_val_t * results, const char *title, const char *descr) +static int nogui_attribute_dialog(pcb_hid_attribute_t * attrs, int n_attrs, pcb_hid_attr_val_t * results, const char *title, const char *descr, void *caller_data) { CRASH("attribute_dialog"); } Index: trunk/src/select_act.c =================================================================== --- trunk/src/select_act.c (revision 11446) +++ trunk/src/select_act.c (revision 11447) @@ -64,7 +64,7 @@ attrs[1].enumerations = methods; attrs[1].default_val.int_value = results[1].int_value; - pcb_gui->attribute_dialog(attrs, nattr, results, "Find element", "Find element by name"); + pcb_gui->attribute_dialog(attrs, nattr, results, "Find element", "Find element by name", NULL); *method = results[1].int_value; if (results[0].str_value == NULL) Index: trunk/src_plugins/dialogs/dlg_layer_binding.c =================================================================== --- trunk/src_plugins/dialogs/dlg_layer_binding.c (revision 11446) +++ trunk/src_plugins/dialogs/dlg_layer_binding.c (revision 11447) @@ -131,7 +131,7 @@ } PCB_DAD_END(dlg); - PCB_DAD_RUN(dlg, "layer_binding", "Layer bindings"); + PCB_DAD_RUN(dlg, "layer_binding", "Layer bindings", &ctx); PCB_DAD_FREE(dlg); free(ctx.widx); Index: trunk/src_plugins/dialogs/dlg_test.c =================================================================== --- trunk/src_plugins/dialogs/dlg_test.c (revision 11446) +++ trunk/src_plugins/dialogs/dlg_test.c (revision 11447) @@ -22,7 +22,7 @@ static const char dlg_test_syntax[] = "dlg_test()\n"; static const char dlg_test_help[] = "test the attribute dialog"; -static void pcb_act_attr_chg(void *hid_ctx, pcb_hid_attribute_t *attr); +static void pcb_act_attr_chg(void *hid_ctx, void *caller_data, pcb_hid_attribute_t *attr); static int attr_idx, attr_idx2; static int pcb_act_dlg_test(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y) { @@ -52,13 +52,13 @@ PCB_DAD_CHANGE_CB(foo, pcb_act_attr_chg); PCB_DAD_END(foo); - PCB_DAD_RUN(foo, "dlg_test", "attribute dialog test"); + PCB_DAD_RUN(foo, "dlg_test", "attribute dialog test", NULL); PCB_DAD_FREE(foo); return 0; } -static void pcb_act_attr_chg(void *hid_ctx, pcb_hid_attribute_t *attr) +static void pcb_act_attr_chg(void *hid_ctx, void *caller_data, pcb_hid_attribute_t *attr) { static pcb_hid_attr_val_t val; static pcb_bool st; Index: trunk/src_plugins/export_ps/ps.c =================================================================== --- trunk/src_plugins/export_ps/ps.c (revision 11446) +++ trunk/src_plugins/export_ps/ps.c (revision 11447) @@ -1520,9 +1520,7 @@ ps_calib_attribute_list[0].default_val.str_value = pcb_strdup("lpr"); } - if (pcb_gui-> - attribute_dialog(ps_calib_attribute_list, 1, vals, _("Print Calibration Page"), - _("Generates a printer calibration page"))) + if (pcb_gui->attribute_dialog(ps_calib_attribute_list, 1, vals, _("Print Calibration Page"), _("Generates a printer calibration page"), NULL)) return; if (use_command || strchr(vals[0].str_value, '|')) { Index: trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/dialogs/dialogs.c =================================================================== --- trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/dialogs/dialogs.c (revision 11446) +++ trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/dialogs/dialogs.c (revision 11447) @@ -87,5 +87,5 @@ else hid->result = calloc(sizeof(pcb_hid_attribute_t), hid->attr_num); - return pcb_gui->attribute_dialog(hid->attr, hid->attr_num, hid->result, title, descr); + return pcb_gui->attribute_dialog(hid->attr, hid->attr_num, hid->result, title, descr, NULL); } Index: trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/manage_scripts.c =================================================================== --- trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/manage_scripts.c (revision 11446) +++ trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/manage_scripts.c (revision 11447) @@ -68,7 +68,7 @@ if (operations != NULL) attr_make_enum(&attr[1], "operation", "Choose what to do with the script", operations, *operation); - res = pcb_gui->attribute_dialog(attr, 1 + (operations != NULL), result, "GPMI manage scripts - select script", "Select one of the scripts already loaded"); + res = pcb_gui->attribute_dialog(attr, 1 + (operations != NULL), result, "GPMI manage scripts - select script", "Select one of the scripts already loaded", NULL); /* free scrl slots before return */ for(s = scrl; *s != NULL; s++) @@ -149,7 +149,7 @@ attr_make_enum(&attr[0], "module", "Select a GPMI module to interpret the script", modules, default_mod); - if (pcb_gui->attribute_dialog(attr, 1, result, "GPMI manage scripts - select module", "Select one of GPMI modules to interpret the script")) + if (pcb_gui->attribute_dialog(attr, 1, result, "GPMI manage scripts - select module", "Select one of GPMI modules to interpret the script", NULL)) return NULL; if (result[0].int_value < 0) @@ -173,7 +173,7 @@ attr_make_label_str(&attr[0], "File name: ", i->name, "File name of the script (if not absolute, it's relative to the config file)"); attr_make_label_str(&attr[1], "GPMI module: ", i->module_name, "Name of the GPMI module that is interpreting the script"); attr_make_label_str(&attr[2], "Config file: ", cf, "Name of config file that requested the script to be loaded "); - pcb_gui->attribute_dialog(attr, 3, result, "GPMI manage scripts - script details", "Displaying detailed info on a script already loaded"); + pcb_gui->attribute_dialog(attr, 3, result, "GPMI manage scripts - script details", "Displaying detailed info on a script already loaded", NULL); free((char *)attr[0].name); free((char *)attr[1].name); free((char *)attr[2].name); Index: trunk/src_plugins/hid_batch/batch.c =================================================================== --- trunk/src_plugins/hid_batch/batch.c (revision 11446) +++ trunk/src_plugins/hid_batch/batch.c (revision 11447) @@ -273,7 +273,7 @@ } static int -batch_attribute_dialog(pcb_hid_attribute_t * attrs_, int n_attrs_, pcb_hid_attr_val_t * results_, const char *title_, const char *descr_) +batch_attribute_dialog(pcb_hid_attribute_t * attrs_, int n_attrs_, pcb_hid_attr_val_t * results_, const char *title_, const char *descr_, void *caller_data) { return 0; } Index: trunk/src_plugins/hid_lesstif/dialogs.c =================================================================== --- trunk/src_plugins/hid_lesstif/dialogs.c (revision 11446) +++ trunk/src_plugins/hid_lesstif/dialogs.c (revision 11447) @@ -624,6 +624,7 @@ Widget *wl; Widget **btn; /* enum value buttons */ pcb_hid_attr_val_t *results; + void *caller_data; unsigned inhibit_valchg:1; } lesstif_attr_dlg_t; @@ -702,7 +703,7 @@ return; attribute_dialog_readres(ctx, widx); - ctx->attrs[widx].change_cb(ctx, &ctx->attrs[widx]); + ctx->attrs[widx].change_cb(ctx, ctx->caller_data, &ctx->attrs[widx]); } /* returns the index of HATT_END where the loop had to stop */ @@ -924,7 +925,7 @@ return -1; } -int lesstif_attribute_dialog(pcb_hid_attribute_t * attrs, int n_attrs, pcb_hid_attr_val_t * results, const char *title, const char *descr) +int lesstif_attribute_dialog(pcb_hid_attribute_t * attrs, int n_attrs, pcb_hid_attr_val_t * results, const char *title, const char *descr, void *caller_data) { Widget dialog, topform, main_tbl; int i, rv; @@ -934,6 +935,7 @@ ctx.results = results; ctx.n_attrs = n_attrs; ctx.actual_nattrs = 0; + ctx.caller_data = caller_data; ctx.inhibit_valchg = 0; for (i = 0; i < n_attrs; i++) { @@ -1115,7 +1117,7 @@ } opts = printer->get_export_options(&n); vals = (pcb_hid_attr_val_t *) calloc(n, sizeof(pcb_hid_attr_val_t)); - if (lesstif_attribute_dialog(opts, n, vals, "Print", "")) { + if (lesstif_attribute_dialog(opts, n, vals, "Print", "", NULL)) { free(vals); return 1; } @@ -1152,7 +1154,7 @@ printer->calibrate(0.0, 0.0); if (pcb_gui->attribute_dialog(printer_calibrate_attrs, 3, printer_calibrate_values, - "Printer Calibration Values", "Enter calibration values for your printer")) + "Printer Calibration Values", "Enter calibration values for your printer", NULL)) return 1; printer->calibrate(printer_calibrate_values[1].real_value, printer_calibrate_values[2].real_value); return 0; @@ -1229,7 +1231,7 @@ opts = printer->get_export_options(&n); vals = (pcb_hid_attr_val_t *) calloc(n, sizeof(pcb_hid_attr_val_t)); - if (lesstif_attribute_dialog(opts, n, vals, "Export", NULL)) { + if (lesstif_attribute_dialog(opts, n, vals, "Export", NULL, NULL)) { free(vals); return 1; } Index: trunk/src_plugins/hid_lesstif/main.c =================================================================== --- trunk/src_plugins/hid_lesstif/main.c (revision 11446) +++ trunk/src_plugins/hid_lesstif/main.c (revision 11447) @@ -3402,7 +3402,7 @@ extern void lesstif_report_dialog(const char *title, const char *msg); -extern int lesstif_attribute_dialog(pcb_hid_attribute_t *attrs, int n_attrs, pcb_hid_attr_val_t *results, const char *title, const char *descr); +extern int lesstif_attribute_dialog(pcb_hid_attribute_t *attrs, int n_attrs, pcb_hid_attr_val_t *results, const char *title, const char *descr, void *caller_data); extern int lesstif_att_dlg_widget_state(void *hid_ctx, int idx, pcb_bool enabled); extern int lesstif_att_dlg_set_value(void *hid_ctx, int idx, const pcb_hid_attr_val_t *val); Index: trunk/src_plugins/hid_remote/remote.c =================================================================== --- trunk/src_plugins/hid_remote/remote.c (revision 11446) +++ trunk/src_plugins/hid_remote/remote.c (revision 11447) @@ -364,7 +364,7 @@ } static int -remote_attribute_dialog(pcb_hid_attribute_t * attrs_, int n_attrs_, pcb_hid_attr_val_t * results_, const char *title_, const char *descr_) +remote_attribute_dialog(pcb_hid_attribute_t * attrs_, int n_attrs_, pcb_hid_attr_val_t * results_, const char *title_, const char *descr_, void *caller_data) { return 0; } Index: trunk/src_plugins/lib_gtk_common/act_print.c =================================================================== --- trunk/src_plugins/lib_gtk_common/act_print.c (revision 11446) +++ trunk/src_plugins/lib_gtk_common/act_print.c (revision 11447) @@ -92,7 +92,7 @@ if (pcb_gui->attribute_dialog(printer_calibrate_attrs, 3, printer_calibrate_values, - _("Printer Calibration Values"), _("Enter calibration values for your printer"))) + _("Printer Calibration Values"), _("Enter calibration values for your printer"), NULL)) return 1; printer->calibrate(printer_calibrate_values[1].real_value, printer_calibrate_values[2].real_value); return 0; Index: trunk/src_plugins/lib_gtk_common/dlg_attribute.c =================================================================== --- trunk/src_plugins/lib_gtk_common/dlg_attribute.c (revision 11446) +++ trunk/src_plugins/lib_gtk_common/dlg_attribute.c (revision 11447) @@ -58,10 +58,11 @@ pcb_hid_attr_val_t *results; GtkWidget **wl; int n_attrs; + void *caller_data; unsigned inhibit_valchg:1; } attr_dlg_t; -#define change_cb(ctx, dst) do { if (dst->change_cb != NULL) dst->change_cb(ctx, dst); } while(0) +#define change_cb(ctx, dst) do { if (dst->change_cb != NULL) dst->change_cb(ctx, ctx->caller_data, dst); } while(0) static void set_flag_cb(GtkToggleButton *button, pcb_hid_attribute_t *dst) { @@ -510,8 +511,7 @@ return -1; } -int ghid_attribute_dialog(GtkWidget * top_window, pcb_hid_attribute_t * attrs, int n_attrs, pcb_hid_attr_val_t * results, - const char *title, const char *descr) +int ghid_attribute_dialog(GtkWidget * top_window, pcb_hid_attribute_t * attrs, int n_attrs, pcb_hid_attr_val_t * results, const char *title, const char *descr, void *caller_data) { GtkWidget *dialog; GtkWidget *content_area; @@ -524,6 +524,7 @@ ctx.results = results; ctx.n_attrs = n_attrs; ctx.wl = calloc(sizeof(GtkWidget *), n_attrs); + ctx.caller_data = caller_data; ctx.inhibit_valchg = 0; dialog = gtk_dialog_new_with_buttons(_(title), Index: trunk/src_plugins/lib_gtk_common/dlg_attribute.h =================================================================== --- trunk/src_plugins/lib_gtk_common/dlg_attribute.h (revision 11446) +++ trunk/src_plugins/lib_gtk_common/dlg_attribute.h (revision 11447) @@ -1,7 +1,7 @@ #include #include "hid.h" -int ghid_attribute_dialog(GtkWidget *top_window, pcb_hid_attribute_t * attrs, int n_attrs, pcb_hid_attr_val_t * results, const char *title, const char *descr); +int ghid_attribute_dialog(GtkWidget *top_window, pcb_hid_attribute_t * attrs, int n_attrs, pcb_hid_attr_val_t * results, const char *title, const char *descr, void *caller_data); int ghid_att_dlg_widget_state(void *hid_ctx, int idx, pcb_bool enabled); Index: trunk/src_plugins/lib_gtk_common/dlg_library_param.c =================================================================== --- trunk/src_plugins/lib_gtk_common/dlg_library_param.c (revision 11446) +++ trunk/src_plugins/lib_gtk_common/dlg_library_param.c (revision 11447) @@ -311,7 +311,7 @@ free(parahlp); } -void attr_change_cb(void *hid_xtx, pcb_hid_attribute_t *attr) +void attr_change_cb(void *hid_ctx, void *caller_data, pcb_hid_attribute_t *attr) { int idx; pcb_gtk_library_param_cb_ctx_t *ctx = attr->user_data; @@ -444,9 +444,9 @@ res[n] = attrs[n].default_val; if (dirty) /* had to replace the filter text, make it effective */ - attr_change_cb(NULL, &attrs[0]); + attr_change_cb(NULL, NULL, &attrs[0]); - if (ghid_attribute_dialog(GTK_WINDOW_TOPLEVEL, attrs, numattr, res, "Parametric footprint edition", descr) == 0) + if (ghid_attribute_dialog(GTK_WINDOW_TOPLEVEL, attrs, numattr, res, "Parametric footprint edition", descr, NULL) == 0) sres = gen_cmd(entry->name, attrs, res, numattr, ctx.first_optional); else sres = NULL; /* cancel */ Index: trunk/src_plugins/lib_gtk_common/dlg_print.c =================================================================== --- trunk/src_plugins/lib_gtk_common/dlg_print.c (revision 11446) +++ trunk/src_plugins/lib_gtk_common/dlg_print.c (revision 11447) @@ -61,7 +61,7 @@ } /* non-zero means cancel was picked */ - if (ghid_attribute_dialog(top_window, attr, n, results, _("PCB Print Layout"), pcb_exporter->description)) + if (ghid_attribute_dialog(top_window, attr, n, results, _("PCB Print Layout"), pcb_exporter->description, NULL)) return; } Index: trunk/src_plugins/lib_gtk_hid/glue_hid.c =================================================================== --- trunk/src_plugins/lib_gtk_hid/glue_hid.c (revision 11446) +++ trunk/src_plugins/lib_gtk_hid/glue_hid.c (revision 11447) @@ -374,10 +374,9 @@ return pcb_gtk_fileselect(ghid_port.top_window, title, descr, default_file, default_ext, history_tag, flags); } -static int ghid_attribute_dialog_(pcb_hid_attribute_t * attrs, int n_attrs, pcb_hid_attr_val_t * results, const char *title, - const char *descr) +static int ghid_attribute_dialog_(pcb_hid_attribute_t * attrs, int n_attrs, pcb_hid_attr_val_t * results, const char *title, const char *descr, void *caller_data) { - return ghid_attribute_dialog(ghid_port.top_window, attrs, n_attrs, results, title, descr); + return ghid_attribute_dialog(ghid_port.top_window, attrs, n_attrs, results, title, descr, caller_data); } static void ghid_show_item(void *item) Index: trunk/src_plugins/lib_polyhelp/polyhelp.c =================================================================== --- trunk/src_plugins/lib_polyhelp/polyhelp.c (revision 11446) +++ trunk/src_plugins/lib_polyhelp/polyhelp.c (revision 11447) @@ -490,7 +490,7 @@ attrs[4].type = PCB_HATT_BOOL; attrs[4].default_val.int_value = results[4].int_value; - if (pcb_gui->attribute_dialog(attrs, nattr, results, "Polygon hatch", "Hatch a polygon") != 0) + if (pcb_gui->attribute_dialog(attrs, nattr, results, "Polygon hatch", "Hatch a polygon", NULL) != 0) return 1; period = results[0].coord_value;