aboutsummaryrefslogtreecommitdiff
path: root/canvas_name.c
blob: a8b93ebd0c48d81154ef1afc1942ad472338f6ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <string.h>
#include <m_pd.h>
#include <g_canvas.h>

#define DEBUG(x)

static t_class *canvas_name_class;

typedef struct _canvas_name
{
    t_object x_obj;
    t_symbol *x_canvas_name;
} t_canvas_name;

static void canvas_name_bang(t_canvas_name *x)
{
    outlet_symbol(x->x_obj.ob_outlet,x->x_canvas_name);
}

static void *canvas_name_new(void)
{
    t_canvas_name *x = (t_canvas_name *)pd_new(canvas_name_class);
    char buf[MAXPDSTRING];
    
    snprintf(buf,MAXPDSTRING,".x%lx.c",(long unsigned int)canvas_getcurrent());
    x->x_canvas_name = gensym(buf);
    
	outlet_new(&x->x_obj, &s_symbol);

    return(x);
}

void canvas_name_setup(void)
{
    canvas_name_class = class_new(gensym("canvas_name"),
        (t_newmethod)canvas_name_new, NULL,
        sizeof(t_canvas_name), 0, 0);

    class_addbang(canvas_name_class, (t_method)canvas_name_bang);
}