File: GtkMenu.xs

package info (click to toggle)
libgtk-perl 0.1.17-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 1,352 kB
  • ctags: 1,100
  • sloc: ansic: 4,393; perl: 3,463; makefile: 36
file content (135 lines) | stat: -rw-r--r-- 2,221 bytes parent folder | download
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include <gtk/gtk.h>

#include "GtkTypes.h"
#include "GdkTypes.h"
#include "MiscTypes.h"

#include "GtkDefs.h"

#ifndef boolSV
# define boolSV(b) ((b) ? &sv_yes : &sv_no)
#endif

void menu_pos_func (GtkMenu *menu, int *x, int *y, gpointer user_data)
{
	AV * args = (AV*)user_data;
	SV * handler = *av_fetch(args, 0, 0);
	int i;
	dSP;
	
	ENTER;
	SAVETMPS;

	PUSHMARK(sp);
	XPUSHs(sv_2mortal(newSVGtkObjectRef(GTK_OBJECT(menu), 0)));
	for (i=1;i<=av_len(args);i++)
		XPUSHs(sv_2mortal(newSVsv(*av_fetch(args, i, 0))));
	XPUSHs(sv_2mortal(newSViv(*x)));
	XPUSHs(sv_2mortal(newSViv(*y)));
	PUTBACK;

	i = perl_call_sv(handler, G_ARRAY);
	SPAGAIN;
	
	if (i>2)
		croak("MenuPosFunc must return two or less values");
	if (i==1)
		POPs;
	else {
		*x = SvIV(POPs);
		*y = SvIV(POPs);
	}
	
	PUTBACK;
	FREETMPS;
	LEAVE;
}


MODULE = Gtk::Menu		PACKAGE = Gtk::Menu		PREFIX = gtk_menu_

#ifdef GTK_MENU

Gtk::Menu_Sink
new(Class)
	SV *	Class
	CODE:
	RETVAL = GTK_MENU(gtk_menu_new());
	OUTPUT:
	RETVAL

void
gtk_menu_append(self, child)
	Gtk::Menu	self
	Gtk::Widget	child

void
gtk_menu_prepend(self, child)
	Gtk::Menu	self
	Gtk::Widget	child

void
gtk_menu_insert(self, child, position)
	Gtk::Menu	self
	Gtk::Widget	child
	int	position

void
gtk_menu_popup(menu, parent_menu_shell, parent_menu_item, button, activate_time, func, ...)
	Gtk::Menu	menu
	Gtk::Widget	parent_menu_shell
	Gtk::Widget	parent_menu_item
	int	button
	int	activate_time
	SV *	func
	CODE:
	{
		AV * args = newAV();
		int i;
		for(i=5;i<items;i++)
			av_push(args,newSVsv(ST(i)));
		gtk_menu_popup(menu, parent_menu_shell, parent_menu_item, menu_pos_func,
			 (void*)args, button, activate_time);
	}

void
gtk_menu_popdown(self)
	Gtk::Menu	self

Gtk::Widget
gtk_menu_get_active(self)
	Gtk::Menu	self

void
gtk_menu_set_active(self, index)
	Gtk::Menu	self
	int	index

void
gtk_menu_set_accelerator_table(self, table)
	Gtk::Menu	self
	Gtk::AcceleratorTable	table

#if 0

void
gtk_menu_attach_to_widget (self, attach_widget, detacher)
	Gtk::Menu   self
	Gtk::Widget attach_widget

Gtk::Widget
gtk_menu_get_attach_widget (self)
	Gtk::Menu   self

void
gtk_menu_detach (self)
	Gtk::Menu   self

#endif

#endif