Index: src/plugins/query/dlg_search.c =================================================================== --- src/plugins/query/dlg_search.c (revision 10334) +++ src/plugins/query/dlg_search.c (revision 10335) @@ -1,4 +1,4 @@ -/* +/*7 * COPYRIGHT * * cschem - modular/flexible schematics editor - query @@ -36,6 +36,8 @@ #include #include #include +#include +#include #include #include #include @@ -64,7 +66,7 @@ typedef struct{ RND_DAD_DECL_NOINIT(dlg) - int wexpr_str, wwizard, wact, wscope; + int wexpr_str, wwizard, wact, wscope, wscope_label, wfollow; int wrowbox[MAX_ROW]; int wexpr[MAX_ROW][MAX_COL]; /* expression framed box */ int wexpr_lab[MAX_ROW][MAX_COL]; /* the label within the expression box */ @@ -138,6 +140,42 @@ rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, ctx->wexpr_str, !wen); } +static void update_scope(search_ctx_t *ctx) +{ + rnd_hid_attr_val_t hv; + rnd_design_t *ctx_hl = rnd_gui->get_dad_design(ctx->dlg_hid_ctx); + rnd_project_t *prj = ctx_hl->project; + char *freeme = NULL; + + if (ctx_hl != NULL) { + switch(ctx->dlg[ctx->wscope].val.lng) { + case 0: + if (ctx_hl->loadname != NULL) + hv.str = ctx_hl->loadname; + else + hv.str = ""; + break; + case 1: + if (prj->loadname != NULL) { + freeme = rnd_dirname(prj->loadname); + hv.str = rnd_basename(freeme); + } + else + hv.str = ""; + break; + default: + hv.str = ""; + break; + } + } + else + hv.str = ""; + + rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->wscope_label, &hv); + rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, ctx->wfollow, 0); + free(freeme); +} + /* look up row and col for a widget attr in a [row][col] widget idx array; returns 0 on success */ static int rc_lookup(search_ctx_t *ctx, int w[MAX_ROW][MAX_COL], rnd_hid_attribute_t *attr, int *row, int *col) { @@ -485,7 +523,13 @@ } } +static void search_scope_chg_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) +{ + search_ctx_t *ctx = caller_data; + update_scope(ctx); +} + static const char *icon_del[] = { "5 5 2 1", " c None", @@ -529,6 +573,19 @@ RND_DAD_LABEL(ctx->dlg, "Scope:"); RND_DAD_ENUM(ctx->dlg, search_scopes); ctx->wscope = RND_DAD_CURRENT(ctx->dlg); + RND_DAD_CHANGE_CB(ctx->dlg, search_scope_chg_cb); + RND_DAD_BEGIN_VBOX(ctx->dlg); + RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_TIGHT); + RND_DAD_LABEL(ctx->dlg, ""); + ctx->wscope_label = RND_DAD_CURRENT(ctx->dlg); + RND_DAD_BEGIN_HBOX(ctx->dlg); + RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_TIGHT); + RND_DAD_LABEL(ctx->dlg, "Follow:"); + RND_DAD_BOOL(ctx->dlg); + ctx->wfollow = RND_DAD_CURRENT(ctx->dlg); + RND_DAD_DEFAULT_NUM(ctx->dlg, 0); + RND_DAD_END(ctx->dlg); + RND_DAD_END(ctx->dlg); RND_DAD_END(ctx->dlg); RND_DAD_BEGIN_VBOX(ctx->dlg); RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_FRAME | RND_HATF_EXPFILL | RND_HATF_SCROLL); @@ -601,6 +658,7 @@ ctx->visible[0][0] = 1; update_vis(ctx); + update_scope(ctx); search_recompile(ctx); }