File: GtkNotebook.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 (475 lines) | stat: -rw-r--r-- 14,810 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
/*
 * Copyright (c) 2003-2006 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"

static GtkWidget *
ensure_label_widget (SV * sv)
{
	if (!gperl_sv_is_defined (sv))
		return NULL;
	if (sv_derived_from (sv, "Gtk2::Widget"))
		return SvGtkWidget (sv);
	/* assume it's a string, and automagickally wrap a label around it */
	return gtk_label_new (SvPV_nolen (sv));
}

#if !GTK_CHECK_VERSION(2,4,0)
static int
notebook_return_value_spoof_helper (GtkNotebook * notebook,
				    int position)
{
	/* Adapted from gtk+ 2.6.2's gtk_notebook_insert_page_menu().
	 * They calculate the new position before doing the actual
	 * insertion, so call this *before* calling the function whose
	 * return value it spoofs.  Dirty, dirty, dirty. */
	int nchildren = g_list_length (notebook->children);
	if ((position < 0) || (position > nchildren))
		position = nchildren;
	return position;
}
#endif

#if GTK_CHECK_VERSION (2, 10, 0)

static GPerlCallback *
gtk2perl_notebook_window_creation_func_create (SV * func,
                                               SV * data)
{
        GType param_types[4];
        param_types[0] = GTK_TYPE_NOTEBOOK;
        param_types[1] = GTK_TYPE_WIDGET;
        param_types[2] = G_TYPE_INT;
        param_types[3] = G_TYPE_INT;
        return gperl_callback_new (func, data, G_N_ELEMENTS (param_types),
                                   param_types, GTK_TYPE_NOTEBOOK);
}

static GtkNotebook *
gtk2perl_notebook_window_creation_func (GtkNotebook *source,
                                        GtkWidget   *page,
                                        gint         x,
                                        gint         y,
                                        gpointer     data)
{
        GtkNotebook * retval;
        GValue value = {0, };
        g_value_init (&value, GTK_TYPE_NOTEBOOK);
        gperl_callback_invoke ((GPerlCallback*) data, &value, source, page, x, y);
        retval = g_value_get_object (&value);
        g_value_unset (&value);
        return retval;
}

#endif /* 2.10 */

MODULE = Gtk2::Notebook	PACKAGE = Gtk2::Notebook	PREFIX = gtk_notebook_

## GtkWidget * gtk_notebook_new (void)
GtkWidget *
gtk_notebook_new (class)
    C_ARGS:
	/*void*/


 ##
 ## In gtk+ 2.4.0, several of these functions were changed to return the
 ## index of the inserted item, where they had void return before.  If you
 ## just do a big #if around them, the docgen picks up two copies of each
 ## xsub, so we have to move the #if into the xsub and have only one of
 ## each.  Since we're doing that, and it's not too hard, we'll spoof the
 ## return value for older versions of gtk+ to avoid exposing the version
 ## difference to perl.  What's that, you say?  Why, yes, it does suck. :-/
 ## I apologize for all the #ifs.
 ##

## gint gtk_notebook_append_page (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label)
=for apidoc
(integer return since Gtk2-Perl 1.080)
=cut
gint
gtk_notebook_append_page (notebook, child, tab_label=NULL)
	GtkNotebook * notebook
	GtkWidget   * child
	SV          * tab_label
    CODE:
	RETVAL =
#if !GTK_CHECK_VERSION(2,4,0)
		notebook_return_value_spoof_helper (notebook, -1);
#endif
		gtk_notebook_append_page (notebook, child,
					  ensure_label_widget (tab_label));
    OUTPUT:
	RETVAL

## gint gtk_notebook_append_page_menu (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label, GtkWidget *menu_label)
=for apidoc
(integer return since Gtk2-Perl 1.080)
=cut
gint
gtk_notebook_append_page_menu (notebook, child, tab_label, menu_label)
	GtkNotebook      * notebook
	GtkWidget        * child
	GtkWidget_ornull * tab_label
	GtkWidget_ornull * menu_label
    CODE:
	RETVAL =
#if !GTK_CHECK_VERSION(2,4,0)
		notebook_return_value_spoof_helper (notebook, -1);
#endif
		gtk_notebook_append_page_menu (notebook, child,
					       tab_label, menu_label);
    OUTPUT:
	RETVAL

## gint gtk_notebook_prepend_page (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label)
=for apidoc
(integer return since Gtk2-Perl 1.080)
=cut
gint
gtk_notebook_prepend_page (notebook, child, tab_label=NULL)
	GtkNotebook * notebook
	GtkWidget   * child
	SV          * tab_label
    CODE:
	RETVAL =
#if !GTK_CHECK_VERSION(2,4,0)
		notebook_return_value_spoof_helper (notebook, 0);
#endif
		gtk_notebook_prepend_page (notebook, child,
					   ensure_label_widget (tab_label));
    OUTPUT:
	RETVAL

## gint gtk_notebook_prepend_page_menu (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label, GtkWidget *menu_label)
=for apidoc
(integer return since Gtk2-Perl 1.080)
=cut
gint
gtk_notebook_prepend_page_menu (notebook, child, tab_label, menu_label)
	GtkNotebook      * notebook
	GtkWidget        * child
	GtkWidget_ornull * tab_label
	GtkWidget_ornull * menu_label
    CODE:
	RETVAL =
#if !GTK_CHECK_VERSION(2,4,0)
		notebook_return_value_spoof_helper (notebook, 0);
#endif
		gtk_notebook_prepend_page_menu (notebook, child,
						tab_label, menu_label);
    OUTPUT:
	RETVAL

## gint gtk_notebook_insert_page (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label, gint position)
=for apidoc
(integer return since Gtk2-Perl 1.080)
=cut
gint
gtk_notebook_insert_page (notebook, child, tab_label, position)
	GtkNotebook * notebook
	GtkWidget   * child
	SV          * tab_label
	gint          position
    CODE:
	RETVAL =
#if !GTK_CHECK_VERSION(2,4,0)
		notebook_return_value_spoof_helper (notebook, position);
#endif
		gtk_notebook_insert_page (notebook, child,
					  ensure_label_widget (tab_label),
					  position);
    OUTPUT:
	RETVAL

## gint gtk_notebook_insert_page_menu (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label, GtkWidget *menu_label, gint position)
=for apidoc
(integer return since Gtk2-Perl 1.080)
=cut
gint
gtk_notebook_insert_page_menu (notebook, child, tab_label, menu_label, position)
	GtkNotebook      * notebook
	GtkWidget        * child
	GtkWidget_ornull * tab_label
	GtkWidget_ornull * menu_label
	gint               position
    CODE:
	RETVAL =
#if !GTK_CHECK_VERSION(2,4,0)
		notebook_return_value_spoof_helper (notebook, position);
#endif
		gtk_notebook_insert_page_menu (notebook, child, tab_label,
					       menu_label, position);
    OUTPUT:
	RETVAL


## void gtk_notebook_remove_page (GtkNotebook *notebook, gint page_num)
void
gtk_notebook_remove_page (notebook, page_num)
	GtkNotebook * notebook
	gint          page_num

## GtkWidget* gtk_notebook_get_nth_page (GtkNotebook *notebook, gint page_num)
GtkWidget_ornull *
gtk_notebook_get_nth_page (notebook, page_num)
	GtkNotebook * notebook
	gint          page_num

## gint gtk_notebook_page_num (GtkNotebook *notebook, GtkWidget *child)
gint
gtk_notebook_page_num (notebook, child)
	GtkNotebook * notebook
	GtkWidget   * child

## void gtk_notebook_set_current_page (GtkNotebook *notebook, gint page_num)
void
gtk_notebook_set_current_page (notebook, page_num)
	GtkNotebook * notebook
	gint          page_num

## void gtk_notebook_next_page (GtkNotebook *notebook)
void
gtk_notebook_next_page (notebook)
	GtkNotebook * notebook

## void gtk_notebook_prev_page (GtkNotebook *notebook)
void
gtk_notebook_prev_page (notebook)
	GtkNotebook * notebook

## gboolean gtk_notebook_get_show_border (GtkNotebook *notebook)
gboolean
gtk_notebook_get_show_border (notebook)
	GtkNotebook * notebook

## void gtk_notebook_set_show_tabs (GtkNotebook *notebook, gboolean show_tabs)
void
gtk_notebook_set_show_tabs (notebook, show_tabs)
	GtkNotebook * notebook
	gboolean      show_tabs

## gboolean gtk_notebook_get_show_tabs (GtkNotebook *notebook)
gboolean
gtk_notebook_get_show_tabs (notebook)
	GtkNotebook * notebook

## void gtk_notebook_set_tab_pos (GtkNotebook *notebook, GtkPositionType pos)
void
gtk_notebook_set_tab_pos (notebook, pos)
	GtkNotebook     * notebook
	GtkPositionType   pos

## GtkPositionType gtk_notebook_get_tab_pos (GtkNotebook *notebook)
GtkPositionType
gtk_notebook_get_tab_pos (notebook)
	GtkNotebook * notebook

## void gtk_notebook_set_tab_border (GtkNotebook *notebook, guint border_width)
void
gtk_notebook_set_tab_border (notebook, border_width)
	GtkNotebook * notebook
	guint         border_width

## void gtk_notebook_set_tab_hborder (GtkNotebook *notebook, guint tab_hborder)
void
gtk_notebook_set_tab_hborder (notebook, tab_hborder)
	GtkNotebook * notebook
	guint         tab_hborder

## void gtk_notebook_set_tab_vborder (GtkNotebook *notebook, guint tab_vborder)
void
gtk_notebook_set_tab_vborder (notebook, tab_vborder)
	GtkNotebook * notebook
	guint         tab_vborder

## void gtk_notebook_set_scrollable (GtkNotebook *notebook, gboolean scrollable)
void
gtk_notebook_set_scrollable (notebook, scrollable)
	GtkNotebook * notebook
	gboolean      scrollable

## gboolean gtk_notebook_get_scrollable (GtkNotebook *notebook)
gboolean
gtk_notebook_get_scrollable (notebook)
	GtkNotebook * notebook

## void gtk_notebook_popup_disable (GtkNotebook *notebook)
void
gtk_notebook_popup_disable (notebook)
	GtkNotebook * notebook

## void gtk_notebook_set_tab_label (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label)
void
gtk_notebook_set_tab_label (notebook, child, tab_label=NULL)
	GtkNotebook      * notebook
	GtkWidget        * child
	GtkWidget_ornull * tab_label

## void gtk_notebook_set_tab_label_text (GtkNotebook *notebook, GtkWidget *child, const gchar *tab_text)
void
gtk_notebook_set_tab_label_text (notebook, child, tab_text)
	GtkNotebook * notebook
	GtkWidget   * child
	const gchar * tab_text

## GtkWidget * gtk_notebook_get_menu_label (GtkNotebook *notebook, GtkWidget *child)
GtkWidget_ornull *
gtk_notebook_get_menu_label (notebook, child)
	GtkNotebook * notebook
	GtkWidget   * child

## void gtk_notebook_set_menu_label (GtkNotebook *notebook, GtkWidget *child, GtkWidget *menu_label)
void
gtk_notebook_set_menu_label (notebook, child, menu_label=NULL)
	GtkNotebook      * notebook
	GtkWidget        * child
	GtkWidget_ornull * menu_label

## void gtk_notebook_set_menu_label_text (GtkNotebook *notebook, GtkWidget *child, const gchar *menu_text)
void
gtk_notebook_set_menu_label_text (notebook, child, menu_text)
	GtkNotebook * notebook
	GtkWidget   * child
	const gchar * menu_text

## void gtk_notebook_query_tab_label_packing (GtkNotebook *notebook, GtkWidget *child, gboolean *expand, gboolean *fill, GtkPackType *pack_type)
void
gtk_notebook_query_tab_label_packing (GtkNotebook * notebook, GtkWidget * child)
    PREINIT:
	gboolean expand;
	gboolean fill;
	GtkPackType pack_type;
    PPCODE:
	gtk_notebook_query_tab_label_packing (notebook, child, &expand, &fill, &pack_type);
	EXTEND (SP, 3);
	PUSHs (sv_2mortal (boolSV (expand)));
	PUSHs (sv_2mortal (boolSV (fill)));
	PUSHs (sv_2mortal (newSVGtkPackType (pack_type)));

## void gtk_notebook_set_tab_label_packing (GtkNotebook *notebook, GtkWidget *child, gboolean expand, gboolean fill, GtkPackType pack_type)
void
gtk_notebook_set_tab_label_packing (notebook, child, expand, fill, pack_type)
	GtkNotebook * notebook
	GtkWidget   * child
	gboolean      expand
	gboolean      fill
	GtkPackType   pack_type

## void gtk_notebook_reorder_child (GtkNotebook *notebook, GtkWidget *child, gint position)
void
gtk_notebook_reorder_child (notebook, child, position)
	GtkNotebook * notebook
	GtkWidget   * child
	gint          position

##GtkType gtk_notebook_get_type (void) G_GNUC_CONST

##gint gtk_notebook_get_current_page (GtkNotebook *notebook)
gint
gtk_notebook_get_current_page (notebook)
	GtkNotebook * notebook

##void gtk_notebook_set_show_border (GtkNotebook *notebook, gboolean show_border)
void
gtk_notebook_set_show_border (notebook, show_border)
	GtkNotebook * notebook
	gboolean      show_border

##void gtk_notebook_popup_enable (GtkNotebook *notebook)
void
gtk_notebook_popup_enable (notebook)
	GtkNotebook * notebook

##GtkWidget * gtk_notebook_get_tab_label (GtkNotebook *notebook, GtkWidget *child)
GtkWidget *
gtk_notebook_get_tab_label (notebook, child)
	GtkNotebook * notebook
	GtkWidget   * child

##gint gtk_notebook_get_n_pages (GtkNotebook *notebook)
gint
gtk_notebook_get_n_pages (notebook)
	GtkNotebook * notebook
    CODE:
#if GTK_CHECK_VERSION(2,2,0)
	RETVAL = gtk_notebook_get_n_pages (notebook);
#else
	/* this wasn't defined before 2.2.0...  but it's really handy and
	 * easy to implement, like so: */
	RETVAL = g_list_length (notebook->children);
#endif
    OUTPUT:
	RETVAL

## const gchar * gtk_notebook_get_menu_label_text (GtkNotebook *notebook, GtkWidget *child)
const gchar *
gtk_notebook_get_menu_label_text (notebook, child)
	GtkNotebook * notebook
	GtkWidget   * child

## const gchar * gtk_notebook_get_tab_label_text (GtkNotebook *notebook, GtkWidget *child)
const gchar *
gtk_notebook_get_tab_label_text (notebook, child)
	GtkNotebook * notebook
	GtkWidget   * child

#if GTK_CHECK_VERSION (2, 10, 0)

void gtk_notebook_set_window_creation_hook (class, SV * func, SV * data=NULL);
    PREINIT:
	GPerlCallback * callback;
    CODE:
	callback = gtk2perl_notebook_window_creation_func_create (func, data);
	gtk_notebook_set_window_creation_hook
		(gtk2perl_notebook_window_creation_func, callback,
		 (GDestroyNotify) gperl_callback_destroy);

void gtk_notebook_set_group_id (GtkNotebook *notebook, gint group_id);

gint gtk_notebook_get_group_id (GtkNotebook *notebook);

void gtk_notebook_set_tab_reorderable (GtkNotebook *notebook, GtkWidget *child, gboolean reorderable);

gboolean gtk_notebook_get_tab_reorderable (GtkNotebook *notebook, GtkWidget *child);

void gtk_notebook_set_tab_detachable (GtkNotebook *notebook, GtkWidget *child, gboolean detachable);

gboolean gtk_notebook_get_tab_detachable (GtkNotebook *notebook, GtkWidget *child);

#endif /* 2.10 */

#if GTK_CHECK_VERSION (2, 20, 0)

void gtk_notebook_set_action_widget (GtkNotebook *notebook, GtkWidget *widget, GtkPackType pack_type);

GtkWidget_ornull* gtk_notebook_get_action_widget (GtkNotebook *notebook, GtkPackType pack_type);

#endif /* 2.20 */

#if GTK_CHECK_VERSION (2, 22, 0)

guint16 gtk_notebook_get_tab_hborder (GtkNotebook *notebook);

guint16 gtk_notebook_get_tab_vborder (GtkNotebook *notebook);

#endif /* 2.22 */