File: GtkMenuItem.xs

package info (click to toggle)
libgtk2-perl 2:1.2499-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,668 kB
  • ctags: 594
  • sloc: perl: 22,100; ansic: 122; makefile: 17
file content (191 lines) | stat: -rw-r--r-- 5,251 bytes parent folder | download | duplicates (3)
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
 * Copyright (c) 2003, 2010 by the gtk2-perl team (see the file AUTHORS)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
 * Boston, MA  02111-1307  USA.
 *
 * $Id$
 */

#include "gtk2perl.h"
#include <gperl_marshal.h>

/*

  void (* toggle_size_request)  (GtkMenuItem *menu_item,
                                 gint        *requisition);

*/

static void
gtk2perl_menu_item_toggle_size_request_marshal (GClosure * closure,
                                                GValue * return_value,
                                                guint n_param_values,
                                                const GValue * param_values,
                                                gpointer invocation_hint,
                                                gpointer marshal_data)
{
	gint * requisition;
	dGPERL_CLOSURE_MARSHAL_ARGS;

	GPERL_CLOSURE_MARSHAL_INIT (closure, marshal_data);

	PERL_UNUSED_VAR (return_value);
	PERL_UNUSED_VAR (n_param_values);
	PERL_UNUSED_VAR (invocation_hint);

	ENTER;
	SAVETMPS;

	PUSHMARK (SP);

	GPERL_CLOSURE_MARSHAL_PUSH_INSTANCE (param_values);

	requisition = g_value_get_pointer (param_values+1);

	GPERL_CLOSURE_MARSHAL_PUSH_DATA;

	PUTBACK;

	GPERL_CLOSURE_MARSHAL_CALL (G_SCALAR);

	if (count == 1) {
		*requisition = POPi;
	} else {
		/* NOTE: croaking here can cause bad things to happen to the
		 * app, because croaking in signal handlers is bad juju. */
		croak ("an toggle-size-request signal handler must return one "
		       "item (the requisition), but the callback returned %d "
		       "items", count);
	}

	PUTBACK;
	FREETMPS;
	LEAVE;
}

MODULE = Gtk2::MenuItem	PACKAGE = Gtk2::MenuItem	PREFIX = gtk_menu_item_

=for position DESCRIPTION

=head1 DESCRIPTION

If a MenuItem is created with a C<$label> string, or if the C<label>
property is set later, then it should be destroyed with
C<< $item->destroy >>.  Just dropping the last Perl ref is not enough
because (as of Gtk through to 2.18) there's a circular reference from
the child C<Gtk2::AccelLabel> back up to the item (the C<accel-widget>
property).

When a MenuItem is in a C<Gtk2::Menu> a C<destroy> happens
automatically.  Dropping the last ref to a Menu calls C<destroy> on
its children, as usual for a container.  But if you remove a MenuItem
with a label from a menu (or never add it to one) then be sure to
C<< $item->destroy >> explicitly.

=cut

BOOT:
	gperl_signal_set_marshaller_for (GTK_TYPE_MENU_ITEM, "toggle_size_request",
	                                 gtk2perl_menu_item_toggle_size_request_marshal);

=for apidoc Gtk2::MenuItem::new
If a C<$label> argument is given then this is C<new_with_mnemonic>.
=cut
GtkWidget*
gtk_menu_item_new (class, label=NULL)
	const gchar * label
    ALIAS:
	Gtk2::MenuItem::new_with_mnemonic = 1
	Gtk2::MenuItem::new_with_label = 2
    CODE:
	if (label) {
		if (ix == 2)
			RETVAL = gtk_menu_item_new_with_label (label);
		else
			RETVAL = gtk_menu_item_new_with_mnemonic (label);
	} else
		RETVAL = gtk_menu_item_new ();
    OUTPUT:
	RETVAL

void
gtk_menu_item_set_submenu (menu_item, submenu)
	GtkMenuItem *menu_item
	GtkWidget_ornull *submenu

GtkWidget_ornull*
gtk_menu_item_get_submenu (menu_item)
	GtkMenuItem *menu_item

void
gtk_menu_item_remove_submenu (menu_item)
	GtkMenuItem *menu_item

void
gtk_menu_item_select (menu_item)
	GtkMenuItem *menu_item

void
gtk_menu_item_deselect (menu_item)
	GtkMenuItem *menu_item

void
gtk_menu_item_activate (menu_item)
	GtkMenuItem *menu_item

void gtk_menu_item_toggle_size_request (GtkMenuItem *menu_item, OUTLIST gint requisition)

void
gtk_menu_item_toggle_size_allocate (menu_item, allocation)
	GtkMenuItem *menu_item
	gint allocation

void
gtk_menu_item_set_right_justified (menu_item, right_justified)
	GtkMenuItem *menu_item
	gboolean right_justified

gboolean
gtk_menu_item_get_right_justified (menu_item)
	GtkMenuItem *menu_item

void
gtk_menu_item_set_accel_path (menu_item, accel_path)
	GtkMenuItem *menu_item
	const gchar *accel_path

 ##void _gtk_menu_item_refresh_accel_path (GtkMenuItem *menu_item, const gchar *prefix, GtkAccelGroup *accel_group, gboolean group_changed)

#if GTK_CHECK_VERSION (2, 14, 0)

const gchar* gtk_menu_item_get_accel_path (GtkMenuItem *menu_item);

#endif /* 2.14 */

#if GTK_CHECK_VERSION (2, 16, 0)

gboolean
gtk_menu_item_get_use_underline (GtkMenuItem *menu_item)

void
gtk_menu_item_set_use_underline (GtkMenuItem *menu_item, gboolean use_underline)

const gchar * gtk_menu_item_get_label (GtkMenuItem *menu_item);

void gtk_menu_item_set_label (GtkMenuItem *menu_item, const gchar *label);

#endif /* 2.16 */