Index: trunk/src/stub_draw.c =================================================================== --- trunk/src/stub_draw.c (revision 7097) +++ trunk/src/stub_draw.c (revision 7098) @@ -91,6 +91,8 @@ dummy_draw_text(gc, "Can't render the font selector: the draw_fontsel plugin is not compiled and/or not loaded"); } +static *dummy_fontsel_text; + void (*pcb_stub_draw_fontsel)(pcb_hid_gc_t gc) = dummy_draw_fontsel; pcb_bool (*pcb_stub_draw_fontsel_mouse_ev)(void *widget, pcb_hid_mouse_ev_t kind, pcb_coord_t x, pcb_coord_t y) = dummy_mouse; - +pcb_text_t **pcb_stub_draw_fontsel_text_obj = &dummy_fontsel_text; Index: trunk/src/stub_draw.h =================================================================== --- trunk/src/stub_draw.h (revision 7097) +++ trunk/src/stub_draw.h (revision 7098) @@ -31,6 +31,7 @@ #include "hid.h" #include "pcb_bool.h" +#include "global_typedefs.h" /* fab */ extern int (*pcb_stub_draw_fab_overhang)(void); @@ -44,5 +45,6 @@ /* fontsel */ extern void (*pcb_stub_draw_fontsel)(pcb_hid_gc_t gc); extern pcb_bool (*pcb_stub_draw_fontsel_mouse_ev)(void *widget, pcb_hid_mouse_ev_t kind, pcb_coord_t x, pcb_coord_t y); +extern pcb_text_t **pcb_stub_draw_fontsel_text_obj; #endif Index: trunk/src_plugins/draw_fontsel/draw_fontsel.c =================================================================== --- trunk/src_plugins/draw_fontsel/draw_fontsel.c (revision 7097) +++ trunk/src_plugins/draw_fontsel/draw_fontsel.c (revision 7098) @@ -100,6 +100,8 @@ int font_new_y1, font_new_y2; int font_del_y1, font_del_y2; +pcb_text_t *fontsel_txt = NULL; + static void pcb_draw_font(pcb_hid_gc_t gc, pcb_font_t *f, int x, int *y) { char txt[256]; @@ -106,11 +108,12 @@ pcb_text_t *t; const char *nm; int y_old = *y; + pcb_font_id_t target_fid = (fontsel_txt == NULL) ? conf_core.design.text_font_id : fontsel_txt->fid; nm = (f->name == NULL) ? "" : f->name; pcb_snprintf(txt, sizeof(txt), "#%d [abc ABC 123] %s", f->id, nm); - dchkbox(gc, x-4, *y, (f->id == conf_core.design.text_font_id)); + dchkbox(gc, x-4, *y, (f->id == target_fid)); pcb_gui->set_color(gc, "#000000"); t = dtext(x, *y, 200, f->id, txt); @@ -182,9 +185,14 @@ ymm = PCB_COORD_TO_MM(y); fid = lookup_fid_for_coord(ymm); if (fid >= 0) { - char sval[128]; - sprintf(sval, "%ld", fid); - conf_set(CFR_DESIGN, "design/text_font_id", 0, sval, POL_OVERWRITE); + if (fontsel_txt == NULL) { + char sval[128]; + sprintf(sval, "%ld", fid); + conf_set(CFR_DESIGN, "design/text_font_id", 0, sval, POL_OVERWRITE); + } + else { + fontsel_txt->fid = fid; + } return 1; } else if ((ymm >= font_new_y1) && (ymm <= font_new_y2)) { @@ -212,6 +220,7 @@ { pcb_stub_draw_fontsel = pcb_draw_fontsel; pcb_stub_draw_fontsel_mouse_ev = pcb_mouse_fontsel; + pcb_stub_draw_fontsel_text_obj = &fontsel_txt; return hid_draw_fontsel_uninit; } Index: trunk/src_plugins/lib_gtk_common/dlg_fontsel.c =================================================================== --- trunk/src_plugins/lib_gtk_common/dlg_fontsel.c (revision 7097) +++ trunk/src_plugins/lib_gtk_common/dlg_fontsel.c (revision 7098) @@ -58,6 +58,7 @@ GtkWidget *vbox; pcb_layer_id_t lid; pcb_gtk_dlg_fontsel_t *ctx; + pcb_text_t *old_txt; if (txt == NULL) { if (dlg_fontsel_global_latch) /* do not open the global font selector twice */ @@ -64,7 +65,16 @@ return; dlg_fontsel_global_latch = 1; } + else { + if (!modal) { + pcb_message(PCB_MSG_ERROR, "text-targeted fontsel dialogs must be modal because of the global-var API on the txt object.\n"); + return; + } + } + old_txt = *pcb_stub_draw_fontsel_text_obj; + *pcb_stub_draw_fontsel_text_obj = txt; + ctx = malloc(sizeof(pcb_gtk_dlg_fontsel_t)); ctx->txt = txt; @@ -97,4 +107,5 @@ gtk_widget_show_all(w); gtk_window_set_modal(GTK_WINDOW(dialog), modal); + *pcb_stub_draw_fontsel_text_obj = old_txt; }