/*
 * This file was generated automatically by ExtUtils::ParseXS version 3.35 from the
 * contents of Gtk2.xs. Do not edit this file, edit Gtk2.xs instead.
 *
 *    ANY CHANGES MADE HERE WILL BE LOST!
 *
 */

#line 1 "xs/Gtk2.xs"
/*
 * Copyright (c) 2003-2004 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., 51 Franklin Street, Fifth Floor, 
 * Boston, MA  02110-1301  USA.
 *
 * $Id$
 */

#include "gtk2perl.h"

static gboolean
gtk2perl_init_add_callback_invoke (GPerlCallback * callback)
{
	GValue return_value = {0,};
	gboolean retval;
	g_value_init (&return_value, callback->return_type);
	gperl_callback_invoke (callback, &return_value);
	retval = g_value_get_boolean (&return_value);
	g_value_unset (&return_value);

	/* according to the gtk source, init callbacks are forgotten
	 * immediately after use; thus, we need to destroy the callback
	 * object to avoid a leak. */
	gperl_callback_destroy(callback);
	
	return retval;
}

static guint
gtk2perl_quit_add_callback_invoke (GPerlCallback * callback)
{
	GValue return_value = {0,};
	guint retval;
	g_value_init (&return_value, callback->return_type);
	gperl_callback_invoke (callback, &return_value);
	retval = g_value_get_uint (&return_value);
	g_value_unset (&return_value);
	return retval;
}

static gint
gtk2perl_key_snoop_func (GtkWidget *grab_widget,
                         GdkEventKey *event,
                         gpointer func_data)
{
	gint ret;
	GValue retval = {0,};
	g_value_init (&retval, G_TYPE_INT);
	gperl_callback_invoke ((GPerlCallback*)func_data, &retval,
	                       grab_widget, event);
	ret = g_value_get_int (&retval);
	g_value_unset (&retval);
	return ret;
}

/*
 * we must track the key snoopers ourselves so we can destroy
 * the callback objects properly.
 */
static GHashTable * key_snoopers = NULL;

static guint
install_key_snooper (SV * func, SV * data)
{
	guint id; 
	GPerlCallback * callback;
	GType param_types[2];
	param_types[0] = GTK_TYPE_WIDGET;
	param_types[1] = GDK_TYPE_EVENT;
	if (!key_snoopers)
		key_snoopers =
			g_hash_table_new_full (g_direct_hash,
			                       g_direct_equal,
			                       NULL,
			                       (GDestroyNotify)
			                           gperl_callback_destroy);
	callback = gperl_callback_new (func, data, 2, param_types, G_TYPE_INT);
	id = gtk_key_snooper_install (gtk2perl_key_snoop_func, callback);
	g_hash_table_insert (key_snoopers, GUINT_TO_POINTER (id), callback);
	return id;
}

static void
remove_key_snooper (guint id)
{
	g_return_if_fail (key_snoopers != NULL);
	gtk_key_snooper_remove (id);
	g_hash_table_remove (key_snoopers, GUINT_TO_POINTER (id));
}

#line 114 "xs/Gtk2.c"
#ifndef PERL_UNUSED_VAR
#  define PERL_UNUSED_VAR(var) if (0) var = var
#endif

#ifndef dVAR
#  define dVAR		dNOOP
#endif


/* This stuff is not part of the API! You have been warned. */
#ifndef PERL_VERSION_DECIMAL
#  define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
#endif
#ifndef PERL_DECIMAL_VERSION
#  define PERL_DECIMAL_VERSION \
	  PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
#endif
#ifndef PERL_VERSION_GE
#  define PERL_VERSION_GE(r,v,s) \
	  (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
#endif
#ifndef PERL_VERSION_LE
#  define PERL_VERSION_LE(r,v,s) \
	  (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
#endif

/* XS_INTERNAL is the explicit static-linkage variant of the default
 * XS macro.
 *
 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
 * "STATIC", ie. it exports XSUB symbols. You probably don't want that
 * for anything but the BOOT XSUB.
 *
 * See XSUB.h in core!
 */


/* TODO: This might be compatible further back than 5.10.0. */
#if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
#  undef XS_EXTERNAL
#  undef XS_INTERNAL
#  if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
#    define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
#    define XS_INTERNAL(name) STATIC XSPROTO(name)
#  endif
#  if defined(__SYMBIAN32__)
#    define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
#    define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
#  endif
#  ifndef XS_EXTERNAL
#    if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
#      define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
#      define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
#    else
#      ifdef __cplusplus
#        define XS_EXTERNAL(name) extern "C" XSPROTO(name)
#        define XS_INTERNAL(name) static XSPROTO(name)
#      else
#        define XS_EXTERNAL(name) XSPROTO(name)
#        define XS_INTERNAL(name) STATIC XSPROTO(name)
#      endif
#    endif
#  endif
#endif

/* perl >= 5.10.0 && perl <= 5.15.1 */


/* The XS_EXTERNAL macro is used for functions that must not be static
 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
 * macro defined, the best we can do is assume XS is the same.
 * Dito for XS_INTERNAL.
 */
#ifndef XS_EXTERNAL
#  define XS_EXTERNAL(name) XS(name)
#endif
#ifndef XS_INTERNAL
#  define XS_INTERNAL(name) XS(name)
#endif

/* Now, finally, after all this mess, we want an ExtUtils::ParseXS
 * internal macro that we're free to redefine for varying linkage due
 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
 */

#undef XS_EUPXS
#if defined(PERL_EUPXS_ALWAYS_EXPORT)
#  define XS_EUPXS(name) XS_EXTERNAL(name)
#else
   /* default to internal */
#  define XS_EUPXS(name) XS_INTERNAL(name)
#endif

#ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
#define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)

/* prototype to pass -Wmissing-prototypes */
STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params);

STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params)
{
    const GV *const gv = CvGV(cv);

    PERL_ARGS_ASSERT_CROAK_XS_USAGE;

    if (gv) {
        const char *const gvname = GvNAME(gv);
        const HV *const stash = GvSTASH(gv);
        const char *const hvname = stash ? HvNAME(stash) : NULL;

        if (hvname)
	    Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
        else
	    Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
    } else {
        /* Pants. I don't think that it should be possible to get here. */
	Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
    }
}
#undef  PERL_ARGS_ASSERT_CROAK_XS_USAGE

#define croak_xs_usage        S_croak_xs_usage

#endif

/* NOTE: the prototype of newXSproto() is different in versions of perls,
 * so we define a portable version of newXSproto()
 */
#ifdef newXS_flags
#define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
#else
#define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
#endif /* !defined(newXS_flags) */

#if PERL_VERSION_LE(5, 21, 5)
#  define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
#else
#  define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
#endif

#line 258 "xs/Gtk2.c"

XS_EUPXS(XS_Gtk2_get_version_info); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_get_version_info)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "class");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
#line 194 "xs/Gtk2.xs"
	EXTEND(SP,3);
	PUSHs(sv_2mortal(newSViv(gtk_major_version)));
	PUSHs(sv_2mortal(newSViv(gtk_minor_version)));
	PUSHs(sv_2mortal(newSViv(gtk_micro_version)));
	PERL_UNUSED_VAR (ax);
#line 275 "xs/Gtk2.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Gtk2_check_version); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_check_version)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "class, required_major, required_minor, required_micro");
    {
	guint	required_major = (guint)SvUV(ST(1))
;
	guint	required_minor = (guint)SvUV(ST(2))
;
	guint	required_micro = (guint)SvUV(ST(3))
;
	gchar *	RETVAL;
#line 215 "xs/Gtk2.xs"
	RETVAL = (gchar *) gtk_check_version (required_major, required_minor, required_micro);
#line 298 "xs/Gtk2.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    /* same as newSVGChar(), but not in a function */
	    sv_setpv ((SV*)RETVALSV, RETVAL);
	    SvUTF8_on (RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_MAJOR_VERSION); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_MAJOR_VERSION)
{
    dVAR; dXSARGS;
    dXSI32;
    if (items != 0)
       croak_xs_usage(cv,  "");
    {
	guint	RETVAL;
	dXSTARG;
#line 258 "xs/Gtk2.xs"
	switch (ix)
	{
	case 0: RETVAL = GTK_MAJOR_VERSION; break;
	case 1: RETVAL = GTK_MINOR_VERSION; break;
	case 2: RETVAL = GTK_MICRO_VERSION; break;
	case 3: RETVAL = gtk_major_version; break;
	case 4: RETVAL = gtk_minor_version; break;
	case 5: RETVAL = gtk_micro_version; break;
	default:
		RETVAL = -1;
		g_assert_not_reached ();
	}
#line 335 "xs/Gtk2.c"
	XSprePUSH; PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_GET_VERSION_INFO); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_GET_VERSION_INFO)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "class");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
#line 281 "xs/Gtk2.xs"
	EXTEND (SP, 3);
	PUSHs (sv_2mortal (newSViv (GTK_MAJOR_VERSION)));
	PUSHs (sv_2mortal (newSViv (GTK_MINOR_VERSION)));
	PUSHs (sv_2mortal (newSViv (GTK_MICRO_VERSION)));
	PERL_UNUSED_VAR (ax);
#line 357 "xs/Gtk2.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Gtk2_CHECK_VERSION); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_CHECK_VERSION)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "class, required_major, required_minor, required_micro");
    {
	gboolean	RETVAL;
	guint	required_major = (guint)SvUV(ST(1))
;
	guint	required_minor = (guint)SvUV(ST(2))
;
	guint	required_micro = (guint)SvUV(ST(3))
;
#line 296 "xs/Gtk2.xs"
	RETVAL = GTK_CHECK_VERSION (required_major, required_minor,
				    required_micro);
#line 381 "xs/Gtk2.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_init); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_init)
{
    dVAR; dXSARGS;
    dXSI32;
    if (items < 0 || items > 1)
       croak_xs_usage(cv,  "class=NULL");
    {
#line 330 "xs/Gtk2.xs"
	GPerlArgv *pargv;
#line 398 "xs/Gtk2.c"
	gboolean	RETVAL;
#line 332 "xs/Gtk2.xs"
	pargv = gperl_argv_new ();

	if (ix == 2) {
		RETVAL = gtk_init_check (&pargv->argc, &pargv->argv);
	} else if (PL_minus_c) {
		/* When in syntax check mode, we need to avoid calling gtk_init
		 * even if asked to because it might abort the program (e.g. if
		 * DISPLAY is not set). */
		RETVAL = gtk_init_check (&pargv->argc, &pargv->argv);
        } else {
		gtk_init (&pargv->argc, &pargv->argv);
		/* gtk_init() either succeeds or does not return. */
		RETVAL = TRUE;
	}

	gperl_argv_update (pargv);
	gperl_argv_free (pargv);
#line 418 "xs/Gtk2.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}

#if GTK_CHECK_VERSION(2, 4, 5)
#define XSubPPtmpAAAA 1


XS_EUPXS(XS_Gtk2_parse_args); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_parse_args)
{
    dVAR; dXSARGS;
    if (items < 0 || items > 1)
       croak_xs_usage(cv,  "class=NULL");
    {
#line 358 "xs/Gtk2.xs"
	GPerlArgv *pargv;
#line 437 "xs/Gtk2.c"
	gboolean	RETVAL;
#line 360 "xs/Gtk2.xs"
	pargv = gperl_argv_new ();

	RETVAL = gtk_parse_args (&pargv->argc, &pargv->argv);

	gperl_argv_update (pargv);
	gperl_argv_free (pargv);
#line 446 "xs/Gtk2.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}

#endif
#if GTK_CHECK_VERSION(2, 6, 0)
#define XSubPPtmpAAAB 1


XS_EUPXS(XS_Gtk2_get_option_group); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_get_option_group)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "class, open_default_display");
    {
	gboolean	open_default_display = (bool)SvTRUE(ST(1))
;
	GOptionGroup_own *	RETVAL;

	RETVAL = gtk_get_option_group(open_default_display);
	{
	    SV * RETVALSV;
	    RETVALSV = newSVGOptionGroup_own (RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif

XS_EUPXS(XS_Gtk2_disable_setlocale); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_disable_setlocale)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "class");
    {

	gtk_disable_setlocale(/*void*/);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2_set_locale); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_set_locale)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "class");
    {
	const gchar *	RETVAL;

	RETVAL = gtk_set_locale(/*void*/);
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    /* same as newSVGChar(), but not in a function */
	    sv_setpv ((SV*)RETVALSV, RETVAL);
	    SvUTF8_on (RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_get_default_language); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_get_default_language)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "class");
    {
	PangoLanguage *	RETVAL;

	RETVAL = gtk_get_default_language(/*void*/);
	{
	    SV * RETVALSV;
	    RETVALSV = newSVPangoLanguage (RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_events_pending); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_events_pending)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "class");
    {
	gint	RETVAL;
	dXSTARG;

	RETVAL = gtk_events_pending(/*void*/);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_main_do_event); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_main_do_event)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "class, event");
    {
	GdkEvent *	event = SvGdkEvent (ST(1))
;

	gtk_main_do_event(event);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2_main); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_main)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "class");
    {

	gtk_main(/*void*/);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2_main_level); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_main_level)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "class");
    {
	guint	RETVAL;
	dXSTARG;

	RETVAL = gtk_main_level(/*void*/);
	XSprePUSH; PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_main_quit); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_main_quit)
{
    dVAR; dXSARGS;
    if (items < 0 || items > 1)
       croak_xs_usage(cv,  "class=NULL");
    {

	gtk_main_quit(/*void*/);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2_main_iteration); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_main_iteration)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "class");
    {
	gboolean	RETVAL;

	RETVAL = gtk_main_iteration(/*void*/);
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_main_iteration_do); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_main_iteration_do)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "class, blocking");
    {
	gboolean	blocking = (bool)SvTRUE(ST(1))
;
	gboolean	RETVAL;

	RETVAL = gtk_main_iteration_do(blocking);
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_grab_add); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_grab_add)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "class, widget");
    {
	GtkWidget *	widget = SvGtkWidget (ST(1))
;

	gtk_grab_add(widget);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2_grab_get_current); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_grab_get_current)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "class");
    {
	GtkWidget_ornull *	RETVAL;

	RETVAL = gtk_grab_get_current(/*void*/);
	{
	    SV * RETVALSV;
	    RETVALSV = newSVGtkWidget_ornull (RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_grab_remove); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_grab_remove)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "class, widget");
    {
	GtkWidget *	widget = SvGtkWidget (ST(1))
;

	gtk_grab_remove(widget);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2_init_add); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_init_add)
{
    dVAR; dXSARGS;
    if (items < 2 || items > 3)
       croak_xs_usage(cv,  "class, function, data=NULL");
    {
	SV *	function = ST(1)
;
	SV *	data;
#line 472 "xs/Gtk2.xs"
	GPerlCallback * real_callback;
#line 716 "xs/Gtk2.c"

	if (items < 3)
	    data = NULL;
	else {
	    data = ST(2)
;
	}
#line 474 "xs/Gtk2.xs"
	real_callback = gperl_callback_new(function, data, 
				0, NULL, G_TYPE_BOOLEAN);
	gtk_init_add((GtkFunction)gtk2perl_init_add_callback_invoke,
		     real_callback);
#line 729 "xs/Gtk2.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2_quit_add); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_quit_add)
{
    dVAR; dXSARGS;
    if (items < 3 || items > 4)
       croak_xs_usage(cv,  "class, main_level, function, data=NULL");
    {
	guint	main_level = (guint)SvUV(ST(1))
;
	SV *	function = ST(2)
;
	SV *	data;
#line 487 "xs/Gtk2.xs"
    	GPerlCallback * real_callback;
#line 749 "xs/Gtk2.c"
	guint	RETVAL;
	dXSTARG;

	if (items < 4)
	    data = NULL;
	else {
	    data = ST(3)
;
	}
#line 489 "xs/Gtk2.xs"
	real_callback = gperl_callback_new(function, data, 
				0, NULL, G_TYPE_UINT);
	RETVAL = gtk_quit_add_full(main_level, 
			  (GtkFunction)gtk2perl_quit_add_callback_invoke, 
			  NULL, real_callback, 
			  (GtkDestroyNotify)gperl_callback_destroy);
#line 766 "xs/Gtk2.c"
	XSprePUSH; PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_quit_remove); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_quit_remove)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "class, quit_handler_id");
    {
	guint	quit_handler_id = (guint)SvUV(ST(1))
;

	gtk_quit_remove(quit_handler_id);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2_quit_add_destroy); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_quit_add_destroy)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "class, main_level, object");
    {
	guint	main_level = (guint)SvUV(ST(1))
;
	GtkObject *	object = SvGtkObject (ST(2))
;

	gtk_quit_add_destroy(main_level, object);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2_key_snooper_install); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_key_snooper_install)
{
    dVAR; dXSARGS;
    if (items < 2 || items > 3)
       croak_xs_usage(cv,  "class, snooper, func_data=NULL");
    {
	guint	RETVAL;
	dXSTARG;
	SV *	snooper = ST(1)
;
	SV *	func_data;

	if (items < 3)
	    func_data = NULL;
	else {
	    func_data = ST(2)
;
	}
#line 562 "xs/Gtk2.xs"
	RETVAL = install_key_snooper (snooper, func_data);
#line 828 "xs/Gtk2.c"
	XSprePUSH; PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_key_snooper_remove); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_key_snooper_remove)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "class, snooper_handler_id");
    {
	guint	snooper_handler_id = (guint)SvUV(ST(1))
;
#line 569 "xs/Gtk2.xs"
	remove_key_snooper (snooper_handler_id);
#line 846 "xs/Gtk2.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2_get_current_event); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_get_current_event)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "class");
    {
	GdkEvent_own_ornull *	RETVAL;

	RETVAL = gtk_get_current_event(/*void*/);
	{
	    SV * RETVALSV;
	    RETVALSV = newSVGdkEvent_own_ornull (RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_get_current_event_time); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_get_current_event_time)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "class");
    {
	guint32	RETVAL;
	dXSTARG;

	RETVAL = gtk_get_current_event_time(/*void*/);
	XSprePUSH; PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_get_current_event_state); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_get_current_event_state)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "class");
    {
	GdkModifierType	RETVAL;
#line 585 "xs/Gtk2.xs"
	if (!gtk_get_current_event_state (&RETVAL))
		XSRETURN_UNDEF;
#line 901 "xs/Gtk2.c"
	{
	    SV * RETVALSV;
	    RETVALSV = newSVGdkModifierType (RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2_get_event_widget); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2_get_event_widget)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "class, event");
    {
	GtkWidget_ornull *	RETVAL;
	GdkEvent_ornull *	event = SvGdkEvent_ornull (ST(1))
;

	RETVAL = gtk_get_event_widget(event);
	{
	    SV * RETVALSV;
	    RETVALSV = newSVGtkWidget_ornull (RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2__Widget_propagate_event); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__Widget_propagate_event)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "widget, event");
    {
	GtkWidget *	widget = SvGtkWidget (ST(0))
;
	GdkEvent *	event = SvGdkEvent (ST(1))
;

	gtk_propagate_event(widget, event);
    }
    XSRETURN_EMPTY;
}

#ifdef __cplusplus
extern "C"
#endif
XS_EXTERNAL(boot_Gtk2); /* prototype to pass -Wmissing-prototypes */
XS_EXTERNAL(boot_Gtk2)
{
#if PERL_VERSION_LE(5, 21, 5)
    dVAR; dXSARGS;
#else
    dVAR; dXSBOOTARGSXSAPIVERCHK;
#endif
#if (PERL_REVISION == 5 && PERL_VERSION < 9)
    char* file = __FILE__;
#else
    const char* file = __FILE__;
#endif

    PERL_UNUSED_VAR(file);

    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(items); /* -W */
#if PERL_VERSION_LE(5, 21, 5)
    XS_VERSION_BOOTCHECK;
#  ifdef XS_APIVERSION_BOOTCHECK
    XS_APIVERSION_BOOTCHECK;
#  endif
#endif

        newXS_deffile("Gtk2::get_version_info", XS_Gtk2_get_version_info);
        newXS_deffile("Gtk2::check_version", XS_Gtk2_check_version);
        cv = newXS_deffile("Gtk2::MAJOR_VERSION", XS_Gtk2_MAJOR_VERSION);
        XSANY.any_i32 = 0;
        cv = newXS_deffile("Gtk2::MICRO_VERSION", XS_Gtk2_MAJOR_VERSION);
        XSANY.any_i32 = 2;
        cv = newXS_deffile("Gtk2::MINOR_VERSION", XS_Gtk2_MAJOR_VERSION);
        XSANY.any_i32 = 1;
        cv = newXS_deffile("Gtk2::major_version", XS_Gtk2_MAJOR_VERSION);
        XSANY.any_i32 = 3;
        cv = newXS_deffile("Gtk2::micro_version", XS_Gtk2_MAJOR_VERSION);
        XSANY.any_i32 = 5;
        cv = newXS_deffile("Gtk2::minor_version", XS_Gtk2_MAJOR_VERSION);
        XSANY.any_i32 = 4;
        newXS_deffile("Gtk2::GET_VERSION_INFO", XS_Gtk2_GET_VERSION_INFO);
        newXS_deffile("Gtk2::CHECK_VERSION", XS_Gtk2_CHECK_VERSION);
        cv = newXS_deffile("Gtk2::init", XS_Gtk2_init);
        XSANY.any_i32 = 0;
        cv = newXS_deffile("Gtk2::init_check", XS_Gtk2_init);
        XSANY.any_i32 = 2;
#if XSubPPtmpAAAA
        newXS_deffile("Gtk2::parse_args", XS_Gtk2_parse_args);
#endif
#if XSubPPtmpAAAB
        newXS_deffile("Gtk2::get_option_group", XS_Gtk2_get_option_group);
#endif
        newXS_deffile("Gtk2::disable_setlocale", XS_Gtk2_disable_setlocale);
        newXS_deffile("Gtk2::set_locale", XS_Gtk2_set_locale);
        newXS_deffile("Gtk2::get_default_language", XS_Gtk2_get_default_language);
        newXS_deffile("Gtk2::events_pending", XS_Gtk2_events_pending);
        newXS_deffile("Gtk2::main_do_event", XS_Gtk2_main_do_event);
        newXS_deffile("Gtk2::main", XS_Gtk2_main);
        newXS_deffile("Gtk2::main_level", XS_Gtk2_main_level);
        newXS_deffile("Gtk2::main_quit", XS_Gtk2_main_quit);
        newXS_deffile("Gtk2::main_iteration", XS_Gtk2_main_iteration);
        newXS_deffile("Gtk2::main_iteration_do", XS_Gtk2_main_iteration_do);
        newXS_deffile("Gtk2::grab_add", XS_Gtk2_grab_add);
        newXS_deffile("Gtk2::grab_get_current", XS_Gtk2_grab_get_current);
        newXS_deffile("Gtk2::grab_remove", XS_Gtk2_grab_remove);
        newXS_deffile("Gtk2::init_add", XS_Gtk2_init_add);
        newXS_deffile("Gtk2::quit_add", XS_Gtk2_quit_add);
        newXS_deffile("Gtk2::quit_remove", XS_Gtk2_quit_remove);
        newXS_deffile("Gtk2::quit_add_destroy", XS_Gtk2_quit_add_destroy);
        newXS_deffile("Gtk2::key_snooper_install", XS_Gtk2_key_snooper_install);
        newXS_deffile("Gtk2::key_snooper_remove", XS_Gtk2_key_snooper_remove);
        newXS_deffile("Gtk2::get_current_event", XS_Gtk2_get_current_event);
        newXS_deffile("Gtk2::get_current_event_time", XS_Gtk2_get_current_event_time);
        newXS_deffile("Gtk2::get_current_event_state", XS_Gtk2_get_current_event_state);
        newXS_deffile("Gtk2::get_event_widget", XS_Gtk2_get_event_widget);
        newXS_deffile("Gtk2::Widget::propagate_event", XS_Gtk2__Widget_propagate_event);

    /* Initialisation Section */

#line 112 "xs/Gtk2.xs"
	{
	/* include some files autogenerated by Makefile.PL. */
	/* register Gtk/Gdk/Atk/Pango classes as perl packages.
	 * be sure to include this autogenerated set first, so that the
	 * hand-written boot code functions called by the next include
	 * can override the registrations if necessary. */
#include "register.xsh"
	/* call the boot code for all the various other modules */
#include "boot.xsh"
	/* route Gtk+ log messages through perl's warn() and croak() */
	gperl_handle_logs_for ("Gtk");
	gperl_handle_logs_for ("Gdk");
	gperl_handle_logs_for ("GdkPixbuf");

	/* make sure that we're running/linked against a version at least as 
	 * new as we built against, otherwise bad things can happen. */
	if ((((int)gtk_major_version) < GTK_MAJOR_VERSION)
	    ||
	    (gtk_major_version == GTK_MAJOR_VERSION && 
	     ((int)gtk_minor_version) < GTK_MINOR_VERSION)
	    ||
	    (gtk_major_version == GTK_MAJOR_VERSION && 
	     gtk_minor_version == GTK_MINOR_VERSION &&
	     ((int)gtk_micro_version) < GTK_MICRO_VERSION))
		warn ("*** This build of Gtk2 was compiled with gtk+ %d.%d.%d,"
		      " but is currently running with %d.%d.%d, which is too"
		      " old.  We'll continue, but expect problems!\n",
		      GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION,
		      gtk_major_version, gtk_minor_version, gtk_micro_version);
	}

#if XSubPPtmpAAAA
#endif
#if XSubPPtmpAAAB
#endif
#line 1070 "xs/Gtk2.c"

    /* End of Initialisation Section */

#if PERL_VERSION_LE(5, 21, 5)
#  if PERL_VERSION_GE(5, 9, 0)
    if (PL_unitcheckav)
        call_list(PL_scopestack_ix, PL_unitcheckav);
#  endif
    XSRETURN_YES;
#else
    Perl_xs_boot_epilog(aTHX_ ax);
#endif
}

