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

#line 1 "xs/GtkItemFactory.xs"
/*
 * Copyright (c) 2003 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"

/* ------------------------------------------------------------------------- */

/*
 * a custom marshaler for the item factory callbacks
 */
static void
gtk2perl_item_factory_item_activate (gpointer    data,
				     guint       callback_action,
				     GtkWidget * widget)
{
	SV    * callback_sv;
	SV    * callback_data;

	dSP;

	/* the callback out of the widget */
	callback_sv = (SV *) g_object_get_data (
				G_OBJECT (widget),
				"_gtk2perl_item_factory_callback_sv");

	callback_data = (SV *) data;

	ENTER;
	SAVETMPS;

	PUSHMARK (SP);
	/* put the parameters on the stack (we're always type 1) */
	EXTEND (SP, 3);
	PUSHs (sv_2mortal (newSVsv (callback_data
	                            ? callback_data
	       	                    : &PL_sv_undef)));
	PUSHs (sv_2mortal (newSViv (callback_action)));
	PUSHs (sv_2mortal (newSVGtkWidget (widget)));
	PUTBACK;

	/* call the code in sv */
	call_sv (callback_sv, G_DISCARD);

	FREETMPS;
	LEAVE;
}

/* ------------------------------------------------------------------------- */

GPerlCallback *
gtk2perl_translate_func_create (SV * func, SV * data)
{
	GType param_types[1];
	param_types[0] = G_TYPE_STRING;
	return gperl_callback_new (func, data, G_N_ELEMENTS (param_types),
				   param_types, G_TYPE_STRING);
}

gchar *
gtk2perl_translate_func (const gchar *path,
			 gpointer data)
{
	GPerlCallback * callback = (GPerlCallback*)data;
	GValue value = {0,};
	SV * tempsv = NULL;
	gchar * retval;

	g_value_init (&value, callback->return_type);
	gperl_callback_invoke (callback, &value, path);
	retval = (gchar *) g_value_get_string (&value);
	/* g_value_unset() will free the string to which retval points.
	 * we will need to keep a copy; let's use a mortal scalar to keep
	 * it around long enough to be useful to the C callers. */
	if (retval)
		tempsv = sv_2mortal (newSVGChar (retval));
	g_value_unset (&value);

	/* using SvPV rather than SvGChar because we used newSVGChar to create
	 * it above, so we're assured that it's been upgraded to utf8 already.
	 * this avoids uncertainty about whether SvGChar may vivify the mortal
	 * value.  (i'm paranoid.) */
	return tempsv ? SvPV_nolen (tempsv) : NULL;
}

/* ------------------------------------------------------------------------- */

#define HV_FETCH_AND_CHECK(_member, _sv) \
	if (hv_exists (hv, #_member, strlen (#_member))) { \
		value = hv_fetch (hv, #_member, strlen (#_member), FALSE); \
		if (value && gperl_sv_is_defined (*value)) \
			entry->_member = _sv; \
	}

#define AV_FETCH_AND_CHECK(_index, _member, _sv) \
	value = av_fetch (av, _index, 0); \
	if (value && gperl_sv_is_defined (*value)) \
		entry->_member = _sv;

GtkItemFactoryEntry *
SvGtkItemFactoryEntry (SV *data, SV **callback)
{
	GtkItemFactoryEntry *entry = gperl_alloc_temp (sizeof (GtkItemFactoryEntry));
	memset (entry, 0, sizeof (GtkItemFactoryEntry));

	if (!gperl_sv_is_defined (data))
		return entry; /* fail silently if undef */

	if (gperl_sv_is_hash_ref (data)) {
		HV *hv = (HV *) SvRV (data);
		SV **value;

		HV_FETCH_AND_CHECK (path, SvGChar (*value));
		HV_FETCH_AND_CHECK (accelerator, SvGChar (*value));

		if (hv_exists (hv, "callback", 8)) {
			value = hv_fetch (hv, "callback", 8, FALSE);

			if (callback && value && gperl_sv_is_defined (*value)) {
				*callback = *value;
				entry->callback = gtk2perl_item_factory_item_activate;
			}
		}

		HV_FETCH_AND_CHECK (callback_action, SvIV (*value));
		HV_FETCH_AND_CHECK (item_type, SvGChar (*value));
		HV_FETCH_AND_CHECK (extra_data, SvPOK (*value) ? SvGChar (*value) : NULL);
	} else if (gperl_sv_is_array_ref (data)) {
		AV *av = (AV *) SvRV (data);
		SV **value;

		AV_FETCH_AND_CHECK (0, path, SvGChar (*value));
		AV_FETCH_AND_CHECK (1, accelerator, SvGChar (*value));

		value = av_fetch (av, 2, 0);

		if (callback && value && gperl_sv_is_defined (*value)) {
			*callback = *value;
			entry->callback = gtk2perl_item_factory_item_activate;
		}

		AV_FETCH_AND_CHECK (3, callback_action, SvIV (*value));
		AV_FETCH_AND_CHECK (4, item_type, SvGChar (*value));
		AV_FETCH_AND_CHECK (5, extra_data, SvPOK (*value) ? SvGChar (*value) : NULL);
	} else {
		croak ("badly formed GtkItemFactoryEntry; use either list or hash form:\n"
		       "    list form:\n"
		       "        [ path, accel, callback, action, type ]\n"
		       "    hash form:\n"
		       "        {\n"
		       "           path            => $path,\n"
		       "           accelerator     => $accel,   # optional\n"
		       "           callback        => $callback,\n"
		       "           callback_action => $action,\n"
		       "           item_type       => $type,    # optional\n"
		       "           extra_data      => $extra,   # optional\n"
		       "         }\n"
		       "  ");
	}

	return entry;
}

static void
gtk2perl_item_factory_create_item_helper (GtkItemFactory *ifactory,
                                          SV *entry_ref,
                                          SV *callback_data)
{
	GtkItemFactoryEntry *entry;
	gchar *clean_path;
	GtkWidget *widget = NULL;

	SV *callback_sv = NULL, *tmp_defsv;
	SV * real_data = callback_data ? gperl_sv_copy (callback_data) : NULL;

	entry = SvGtkItemFactoryEntry (entry_ref, &callback_sv);

	/* remove all those underscores that gtk+ turns into accelerators to
	 * get a clean path that can later be used for item retrieval */
	tmp_defsv = newSVsv (DEFSV);

	sv_setsv (DEFSV, sv_2mortal (newSVGChar (entry->path)));
	eval_pv ("s/_(?!_+)//g; s/_+/_/g;", 1);
	clean_path = SvGChar (sv_2mortal (newSVsv (DEFSV)));

	sv_setsv (DEFSV, tmp_defsv);

	/* create the item in the normal manner now */
	gtk_item_factory_create_item (ifactory, entry, real_data, 1);
	
	/* get the widget that was created by create_item (this is why
	 * we needed clean_path) */
	widget = gtk_item_factory_get_item (ifactory, clean_path);
	if (widget) {
		/* put the sv we need to call into the widget */
		g_object_set_data_full (G_OBJECT (widget),
		                        "_gtk2perl_item_factory_callback_sv",
		                        gperl_sv_copy (callback_sv),
		                        (GtkDestroyNotify) gperl_sv_free);
		if (real_data)
			g_object_set_data_full (G_OBJECT (widget),
			                        "_gtk2perl_item_factory_callback_data",
			                        real_data,
			                        (GtkDestroyNotify) gperl_sv_free);
	} else {
		if (real_data)
			gperl_sv_free (real_data);
		croak("ItemFactory couldn't retrieve widget it just created");
	}
}

/* ------------------------------------------------------------------------- */

#line 240 "xs/GtkItemFactory.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 384 "xs/GtkItemFactory.c"

XS_EUPXS(XS_Gtk2__ItemFactory_new); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ItemFactory_new)
{
    dVAR; dXSARGS;
    if (items < 3 || items > 4)
       croak_xs_usage(cv,  "class, container_type_package, path, accel_group=NULL");
    {
	char *	container_type_package = (char *)SvPV_nolen(ST(1))
;
	const gchar *	path;
	GtkAccelGroup_ornull *	accel_group;
#line 242 "xs/GtkItemFactory.xs"
	GType container_type;
#line 399 "xs/GtkItemFactory.c"
	GtkItemFactory *	RETVAL;

	/* same as SvGChar(), but not in a function */
	sv_utf8_upgrade (ST(2));
	path = (const gchar *)SvPV_nolen (ST(2))
;

	if (items < 4)
	    accel_group = NULL;
	else {
	    accel_group = SvGtkAccelGroup_ornull (ST(3))
;
	}
#line 244 "xs/GtkItemFactory.xs"
	container_type = gperl_type_from_package (container_type_package);
	RETVAL = gtk_item_factory_new (container_type, path, accel_group);
#line 416 "xs/GtkItemFactory.c"
	{
	    SV * RETVALSV;
	    RETVALSV = newSVGtkItemFactory (RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


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

	RETVAL = gtk_item_factory_from_widget(widget);
	{
	    SV * RETVALSV;
	    RETVALSV = newSVGtkItemFactory_ornull (RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


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

	RETVAL = gtk_item_factory_path_from_widget(widget);
	{
	    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__ItemFactory_get_item); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ItemFactory_get_item)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "ifactory, path");
    {
	GtkItemFactory *	ifactory = SvGtkItemFactory (ST(0))
;
	const gchar *	path;
	GtkWidget_ornull *	RETVAL;

	/* same as SvGChar(), but not in a function */
	sv_utf8_upgrade (ST(1));
	path = (const gchar *)SvPV_nolen (ST(1))
;

	RETVAL = gtk_item_factory_get_item(ifactory, path);
	{
	    SV * RETVALSV;
	    RETVALSV = newSVGtkWidget_ornull (RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2__ItemFactory_get_widget); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ItemFactory_get_widget)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "ifactory, path");
    {
	GtkItemFactory *	ifactory = SvGtkItemFactory (ST(0))
;
	const gchar *	path;
	GtkWidget_ornull *	RETVAL;

	/* same as SvGChar(), but not in a function */
	sv_utf8_upgrade (ST(1));
	path = (const gchar *)SvPV_nolen (ST(1))
;

	RETVAL = gtk_item_factory_get_widget(ifactory, path);
	{
	    SV * RETVALSV;
	    RETVALSV = newSVGtkWidget_ornull (RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2__ItemFactory_get_widget_by_action); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ItemFactory_get_widget_by_action)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "ifactory, action");
    {
	GtkItemFactory *	ifactory = SvGtkItemFactory (ST(0))
;
	guint	action = (guint)SvUV(ST(1))
;
	GtkWidget_ornull *	RETVAL;

	RETVAL = gtk_item_factory_get_widget_by_action(ifactory, action);
	{
	    SV * RETVALSV;
	    RETVALSV = newSVGtkWidget_ornull (RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2__ItemFactory_get_item_by_action); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ItemFactory_get_item_by_action)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "ifactory, action");
    {
	GtkItemFactory *	ifactory = SvGtkItemFactory (ST(0))
;
	guint	action = (guint)SvUV(ST(1))
;
	GtkWidget_ornull *	RETVAL;

	RETVAL = gtk_item_factory_get_item_by_action(ifactory, action);
	{
	    SV * RETVALSV;
	    RETVALSV = newSVGtkWidget_ornull (RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2__ItemFactory_create_item); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ItemFactory_create_item)
{
    dVAR; dXSARGS;
    if (items < 2 || items > 3)
       croak_xs_usage(cv,  "ifactory, entry_ref, callback_data=NULL");
    {
	GtkItemFactory *	ifactory = SvGtkItemFactory (ST(0))
;
	SV *	entry_ref = ST(1)
;
	SV *	callback_data;

	if (items < 3)
	    callback_data = NULL;
	else {
	    callback_data = ST(2)
;
	}
#line 295 "xs/GtkItemFactory.xs"
	gtk2perl_item_factory_create_item_helper (ifactory, entry_ref, callback_data);
#line 605 "xs/GtkItemFactory.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ItemFactory_create_items); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ItemFactory_create_items)
{
    dVAR; dXSARGS;
    if (items < 2)
       croak_xs_usage(cv,  "ifactory, callback_data, ...");
    {
	GtkItemFactory *	ifactory = SvGtkItemFactory (ST(0))
;
	SV *	callback_data = ST(1)
;
#line 307 "xs/GtkItemFactory.xs"
	int i;
#line 624 "xs/GtkItemFactory.c"
#line 309 "xs/GtkItemFactory.xs"
	for (i = 2; i < items; i++)
		gtk2perl_item_factory_create_item_helper (ifactory, ST (i), callback_data);
#line 628 "xs/GtkItemFactory.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ItemFactory_delete_item); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ItemFactory_delete_item)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "ifactory, path");
    {
	GtkItemFactory *	ifactory = SvGtkItemFactory (ST(0))
;
	const gchar *	path;

	/* same as SvGChar(), but not in a function */
	sv_utf8_upgrade (ST(1));
	path = (const gchar *)SvPV_nolen (ST(1))
;

	gtk_item_factory_delete_item(ifactory, path);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ItemFactory_delete_entry); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ItemFactory_delete_entry)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "ifactory, entry_ref");
    {
	GtkItemFactory *	ifactory = SvGtkItemFactory (ST(0))
;
	SV *	entry_ref = ST(1)
;
#line 327 "xs/GtkItemFactory.xs"
	GtkItemFactoryEntry *entry;
#line 669 "xs/GtkItemFactory.c"
#line 329 "xs/GtkItemFactory.xs"
	entry = SvGtkItemFactoryEntry (entry_ref, NULL);
	gtk_item_factory_delete_entry (ifactory, entry);
#line 673 "xs/GtkItemFactory.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ItemFactory_delete_entries); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ItemFactory_delete_entries)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "ifactory, ...");
    {
	GtkItemFactory *	ifactory = SvGtkItemFactory (ST(0))
;
#line 340 "xs/GtkItemFactory.xs"
	int i;
	GtkItemFactoryEntry *entry;
#line 691 "xs/GtkItemFactory.c"
#line 343 "xs/GtkItemFactory.xs"
	for (i = 1; i < items; i++) {
		entry = SvGtkItemFactoryEntry (ST (i), NULL);
		gtk_item_factory_delete_entry (ifactory, entry);
	}
#line 697 "xs/GtkItemFactory.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ItemFactory_popup); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ItemFactory_popup)
{
    dVAR; dXSARGS;
    if (items < 5 || items > 6)
       croak_xs_usage(cv,  "ifactory, x, y, mouse_button, time_, popup_data=NULL");
    {
	GtkItemFactory *	ifactory = SvGtkItemFactory (ST(0))
;
	guint	x = (guint)SvUV(ST(1))
;
	guint	y = (guint)SvUV(ST(2))
;
	guint	mouse_button = (guint)SvUV(ST(3))
;
	guint32	time_ = (guint32)SvUV(ST(4))
;
	SV *	popup_data;
#line 361 "xs/GtkItemFactory.xs"
	SV * real_popup_data = NULL;
#line 723 "xs/GtkItemFactory.c"

	if (items < 6)
	    popup_data = NULL;
	else {
	    popup_data = ST(5)
;
	}
#line 363 "xs/GtkItemFactory.xs"
	if (gperl_sv_is_defined (popup_data))
		real_popup_data = gperl_sv_copy (popup_data);
	gtk_item_factory_popup_with_data (ifactory,
	                                  real_popup_data, 
	                                  real_popup_data
	                                   ? (GDestroyNotify)gperl_sv_free
	                                   : NULL, 
	                                  x, y, mouse_button, time_);
#line 740 "xs/GtkItemFactory.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ItemFactory_popup_data); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ItemFactory_popup_data)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "ifactory");
    {
	GtkItemFactory *	ifactory = SvGtkItemFactory (ST(0))
;
	SV *	RETVAL;
#line 376 "xs/GtkItemFactory.xs"
	RETVAL = (SV *) gtk_item_factory_popup_data (ifactory);

	if (RETVAL) {
		RETVAL = gperl_sv_copy (RETVAL);
	} else {
		RETVAL = &PL_sv_undef;
	}
#line 764 "xs/GtkItemFactory.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2__ItemFactory_popup_data_from_widget); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ItemFactory_popup_data_from_widget)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "class, widget");
    {
	GtkWidget *	widget = SvGtkWidget (ST(1))
;
	SV *	RETVAL;
#line 390 "xs/GtkItemFactory.xs"
	RETVAL = (SV *) gtk_item_factory_popup_data_from_widget (widget);

	if (RETVAL) {
		RETVAL = gperl_sv_copy (RETVAL);
	} else {
		RETVAL = &PL_sv_undef;
	}
#line 790 "xs/GtkItemFactory.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2__ItemFactory_set_translate_func); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ItemFactory_set_translate_func)
{
    dVAR; dXSARGS;
    if (items < 2 || items > 3)
       croak_xs_usage(cv,  "ifactory, func, data=NULL");
    {
	GtkItemFactory *	ifactory = SvGtkItemFactory (ST(0))
;
	SV *	func = ST(1)
;
	SV *	data;
#line 406 "xs/GtkItemFactory.xs"
	GPerlCallback *callback;
#line 812 "xs/GtkItemFactory.c"

	if (items < 3)
	    data = NULL;
	else {
	    data = ST(2)
;
	}
#line 408 "xs/GtkItemFactory.xs"
	callback = gtk2perl_translate_func_create (func, data);
	gtk_item_factory_set_translate_func (ifactory,
	                                     gtk2perl_translate_func,
	                                     callback,
	                                     (GtkDestroyNotify)
	                                       gperl_callback_destroy);
#line 827 "xs/GtkItemFactory.c"
    }
    XSRETURN_EMPTY;
}

#ifdef __cplusplus
extern "C"
#endif
XS_EXTERNAL(boot_Gtk2__ItemFactory); /* prototype to pass -Wmissing-prototypes */
XS_EXTERNAL(boot_Gtk2__ItemFactory)
{
#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::ItemFactory::new", XS_Gtk2__ItemFactory_new);
        newXS_deffile("Gtk2::ItemFactory::from_widget", XS_Gtk2__ItemFactory_from_widget);
        newXS_deffile("Gtk2::ItemFactory::path_from_widget", XS_Gtk2__ItemFactory_path_from_widget);
        newXS_deffile("Gtk2::ItemFactory::get_item", XS_Gtk2__ItemFactory_get_item);
        newXS_deffile("Gtk2::ItemFactory::get_widget", XS_Gtk2__ItemFactory_get_widget);
        newXS_deffile("Gtk2::ItemFactory::get_widget_by_action", XS_Gtk2__ItemFactory_get_widget_by_action);
        newXS_deffile("Gtk2::ItemFactory::get_item_by_action", XS_Gtk2__ItemFactory_get_item_by_action);
        newXS_deffile("Gtk2::ItemFactory::create_item", XS_Gtk2__ItemFactory_create_item);
        newXS_deffile("Gtk2::ItemFactory::create_items", XS_Gtk2__ItemFactory_create_items);
        newXS_deffile("Gtk2::ItemFactory::delete_item", XS_Gtk2__ItemFactory_delete_item);
        newXS_deffile("Gtk2::ItemFactory::delete_entry", XS_Gtk2__ItemFactory_delete_entry);
        newXS_deffile("Gtk2::ItemFactory::delete_entries", XS_Gtk2__ItemFactory_delete_entries);
        newXS_deffile("Gtk2::ItemFactory::popup", XS_Gtk2__ItemFactory_popup);
        newXS_deffile("Gtk2::ItemFactory::popup_data", XS_Gtk2__ItemFactory_popup_data);
        newXS_deffile("Gtk2::ItemFactory::popup_data_from_widget", XS_Gtk2__ItemFactory_popup_data_from_widget);
        newXS_deffile("Gtk2::ItemFactory::set_translate_func", XS_Gtk2__ItemFactory_set_translate_func);
#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
}

