diff options
author | Luke Iannini <lukeiannini@users.sourceforge.net> | 2008-06-18 21:06:16 +0000 |
---|---|---|
committer | Luke Iannini <lukeiannini@users.sourceforge.net> | 2008-06-18 21:06:16 +0000 |
commit | 2cad4eb23ee24a5aec84c223872f5b84ff3009d0 (patch) | |
tree | 5fd601074b3408f7b037939a4545e73280ec5135 /getpatchname/src | |
parent | f8ccc253ee14685c37952058ab3d9adb1704f8d3 (diff) |
getpatchname parent query capability and helpfile to match
svn path=/trunk/externals/postlude/; revision=10037
Diffstat (limited to 'getpatchname/src')
-rw-r--r-- | getpatchname/src/getpatchname.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/getpatchname/src/getpatchname.c b/getpatchname/src/getpatchname.c index c9116a8..72df3cc 100644 --- a/getpatchname/src/getpatchname.c +++ b/getpatchname/src/getpatchname.c @@ -1,4 +1,3 @@ - /* getpatchname - Returns the filename of the current patch * * Copyright (C) 2006 Jamie Bullock @@ -27,28 +26,38 @@ typedef struct _getpatchname { t_object x_obj; t_symbol *patch_name; t_outlet *outlet; + t_canvas *x_canvas; + int x_level; } t_getpatchname; void getpatchname_bang(t_getpatchname *x) { /* At some point we need to be to get the new patch name if it changes, couldn't make this work though */ - outlet_symbol(x->outlet, x->patch_name); + int i = x->x_level; + t_canvas* last = x->x_canvas; + + while (i>0) { + i--; + if (last->gl_owner) last = last->gl_owner; + } + + outlet_symbol(x->outlet, last->gl_name); } -void *getpatchname_new(void) +void *getpatchname_new(t_floatarg level) { t_getpatchname *x = (t_getpatchname *)pd_new(getpatchname_class); x->patch_name = canvas_getcurrent()->gl_name; + x->x_canvas = canvas_getcurrent(); x->outlet = outlet_new(&x->x_obj, &s_symbol); + x->x_level = level; return (void *)x; } void getpatchname_setup(void) { getpatchname_class = class_new(gensym("getpatchname"), (t_newmethod)getpatchname_new, - 0, sizeof(t_getpatchname), - CLASS_DEFAULT, 0); + 0, sizeof(t_getpatchname), 0, + A_DEFFLOAT, 0); class_addbang(getpatchname_class, getpatchname_bang); } - - |