From 57ee77780defbc45765b1e36e02e13aa9fa45ba4 Mon Sep 17 00:00:00 2001 From: Albert Graef <aggraef@gmail.com> Date: Fri, 9 Apr 2021 20:21:52 +0200 Subject: [PATCH] pddplink: handle symbol input on the 1st inlet. As discussed on the mailing list, it's useful to allow symbol inputs (other than bang) on pddplink's inlet, to make it easier to invoke pddplink on a variable symbol (filename, patch, URL) value. Note that for backward compatibility, a dummy filename argument is still needed. Please check the updated help patch for details and an example. --- externals/pddp/pddplink.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/externals/pddp/pddplink.c b/externals/pddp/pddplink.c index 7120241ca..2dbd422ab 100644 --- a/externals/pddp/pddplink.c +++ b/externals/pddp/pddplink.c @@ -221,13 +221,22 @@ static t_pd *pddplink_pdtarget(t_pddplink *x) return ((t_pd *)x); /* internal error */ } -static void pddplink_anything(t_pddplink *x, t_symbol *s, int ac, t_atom *av) +static void pddplink_symbol(t_pddplink *x, t_symbol *s) { if (x->x_ishit) { - startpost("pddplink: internal error (%s", (s ? s->s_name : "")); - postatom(ac, av); - post(")"); + post("pddplink: internal error (%s)", (s ? s->s_name : "")); + } + else + { + if (s == &s_) return; // nothing to see here, move along... + x->x_ishit = 1; + char final_name[FILENAME_MAX]; + sys_expandpathelems(s->s_name, final_name); + gui_vmess("gui_pddplink_open", "ss", + final_name, + x->x_dirsym->s_name); + x->x_ishit = 0; } } @@ -426,14 +435,14 @@ void pddplink_setup(void) sizeof(t_pddplink), CLASS_NOINLET | CLASS_PATCHABLE, A_GIMME, 0); - class_addanything(pddplink_class, pddplink_anything); + class_addsymbol(pddplink_class, pddplink_symbol); class_setwidget(pddplink_class, &pddplink_widgetbehavior); pddplinkbox_class = class_new(gensym("pddplink"), 0, (t_method)pddplink_free, sizeof(t_pddplink), 0, A_GIMME, 0); class_addbang(pddplinkbox_class, pddplink_bang); - class_addanything(pddplinkbox_class, pddplink_anything); + class_addsymbol(pddplinkbox_class, pddplink_symbol); class_addmethod(pddplinkbox_class, (t_method)pddplink_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); -- GitLab