"SfR Fresh" - the SfR Freeware/Shareware Archive 
Member "Gtk-Perl-0.7009/Bonobo/xs/BonoboEmbeddable.xs" of archive Gtk-Perl-0.7009.tar.gz:
As a special service "SfR Fresh" has tried to format the requested source page into HTML format using source code syntax highlighting with prefixed line numbers.
Alternatively you can here view or download the uninterpreted source code file.
That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
1
2 #include "EXTERN.h"
3 #include "perl.h"
4 #include "XSUB.h"
5
6 #include "PerlBonoboInt.h"
7
8 #include "GtkDefs.h"
9 #include "MiscTypes.h"
10 #include "BonoboDefs.h"
11
12 /* FIXME: leaks of args */
13
14 static BonoboView *
15 generic_view_factory (BonoboEmbeddable *embeddable, const Bonobo_ViewFrame view_frame, void *closure) {
16 AV * args = (AV*)closure;
17 SV *handler = * av_fetch(args, 0, 0);
18 int i;
19 SV * result;
20 BonoboView * bview = NULL;
21 dSP;
22
23 ENTER;
24 SAVETMPS;
25 PUSHMARK(SP);
26 XPUSHs(sv_2mortal(newSVGtkObjectRef(GTK_OBJECT(embeddable), 0)));
27 XPUSHs(sv_2mortal(newSVsv(porbit_objref_to_sv(view_frame))));
28 for (i=1;i<=av_len(args);i++)
29 XPUSHs(sv_2mortal(newSVsv(*av_fetch(args, i, 0))));
30 PUTBACK;
31 i = perl_call_sv(handler, G_SCALAR);
32 SPAGAIN;
33 if (i!=1)
34 croak("handler failed");
35 result = POPs;
36 bview = BONOBO_VIEW(SvGtkObjectRef(result, 0));
37 PUTBACK;
38 FREETMPS;
39 LEAVE;
40
41 return bview;
42 }
43
44 static BonoboCanvasComponent *
45 generic_item_factory (BonoboEmbeddable *embeddable, GnomeCanvas *canvas, void *closure) {
46 AV * args = (AV*)closure;
47 SV *handler = * av_fetch(args, 0, 0);
48 int i;
49 SV * result;
50 BonoboCanvasComponent * comp = NULL;
51 dSP;
52
53 ENTER;
54 SAVETMPS;
55 PUSHMARK(SP);
56 XPUSHs(sv_2mortal(newSVGtkObjectRef(GTK_OBJECT(embeddable), 0)));
57 XPUSHs(sv_2mortal(newSVGtkObjectRef(GTK_OBJECT(canvas), 0)));
58 for (i=1;i<=av_len(args);i++)
59 XPUSHs(sv_2mortal(newSVsv(*av_fetch(args, i, 0))));
60 PUTBACK;
61 i = perl_call_sv(handler, G_SCALAR);
62 SPAGAIN;
63 if (i!=1)
64 croak("handler failed");
65 result = POPs;
66 comp = BONOBO_CANVAS_COMPONENT(SvGtkObjectRef(result, 0));
67 PUTBACK;
68 FREETMPS;
69 LEAVE;
70
71 return comp;
72 }
73
74 static void
75 generic_foreach_view (BonoboView *view, void *data) {
76 AV * args = (AV*)data;
77 SV * handler = *av_fetch(args, 0, 0);
78 int i;
79 dSP;
80
81 PUSHMARK(SP);
82 XPUSHs(sv_2mortal(newSVGtkObjectRef(GTK_OBJECT(view), 0)));
83 for (i=1;i<=av_len(args);i++)
84 XPUSHs(sv_2mortal(newSVsv(*av_fetch(args, i, 0))));
85 PUTBACK;
86 perl_call_sv(handler, G_DISCARD);
87 return;
88 }
89
90 static void
91 generic_foreach_item (BonoboCanvasComponent *comp, void *data) {
92 AV * args = (AV*)data;
93 SV * handler = *av_fetch(args, 0, 0);
94 int i;
95 dSP;
96
97 PUSHMARK(SP);
98 XPUSHs(sv_2mortal(newSVGtkObjectRef(GTK_OBJECT(comp), 0)));
99 for (i=1;i<=av_len(args);i++)
100 XPUSHs(sv_2mortal(newSVsv(*av_fetch(args, i, 0))));
101 PUTBACK;
102 perl_call_sv(handler, G_DISCARD);
103 return;
104 }
105
106
107 MODULE = Gnome::BonoboEmbeddable PACKAGE = Gnome::BonoboEmbeddable PREFIX = bonobo_embeddable_
108
109 #ifdef BONOBO_EMBEDDABLE
110
111 Gnome::BonoboEmbeddable
112 bonobo_embeddable_new (Class, factory, ...)
113 SV * Class
114 SV * factory
115 CODE:
116 {
117 AV *args = newAV();
118 PackCallbackST(args, 1);
119 RETVAL = bonobo_embeddable_new(generic_view_factory, args);
120 }
121 OUTPUT:
122 RETVAL
123
124 Gnome::BonoboEmbeddable
125 bonobo_embeddable_new_canvas_item (Class, item_factory, ...)
126 SV * Class
127 SV * item_factory
128 CODE:
129 {
130 AV *args = newAV();
131 PackCallbackST(args, 1);
132 RETVAL = bonobo_embeddable_new_canvas_item(generic_item_factory, args);
133 }
134 OUTPUT:
135 RETVAL
136
137 Gnome::BonoboEmbeddable
138 bonobo_embeddable_construct (embeddable, factory, ...)
139 Gnome::BonoboEmbeddable embeddable
140 SV * factory
141 CODE:
142 {
143 AV *args = newAV();
144 PackCallbackST(args, 1);
145 RETVAL = bonobo_embeddable_construct (embeddable, generic_view_factory, args);
146 }
147 OUTPUT:
148 RETVAL
149
150 void
151 bonobo_embeddable_set_view_factory (embeddable, factory, ...)
152 Gnome::BonoboEmbeddable embeddable
153 SV * factory
154 CODE:
155 {
156 AV *args = newAV();
157 PackCallbackST(args, 1);
158 bonobo_embeddable_set_view_factory (embeddable, generic_view_factory, args);
159 }
160
161 char *
162 bonobo_embeddable_get_uri (embeddable)
163 Gnome::BonoboEmbeddable embeddable
164
165 void
166 bonobo_embeddable_set_uri (embeddable, uri)
167 Gnome::BonoboEmbeddable embeddable
168 char * uri
169
170 void
171 bonobo_embeddable_foreach_view (embeddable, handler, ...)
172 Gnome::BonoboEmbeddable embeddable
173 SV * handler
174 CODE:
175 {
176 AV *args = newAV();
177 PackCallbackST(args, 1);
178 bonobo_embeddable_foreach_view (embeddable, generic_foreach_view, args);
179 }
180
181 void
182 bonobo_embeddable_foreach_item (embeddable, handler, ...)
183 Gnome::BonoboEmbeddable embeddable
184 SV * handler
185 CODE:
186 {
187 AV *args = newAV();
188 PackCallbackST(args, 1);
189 bonobo_embeddable_foreach_item (embeddable, generic_foreach_item, args);
190 }
191
192 #endif
193