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

#line 1 "xs/GtkActionGroup.xs"
/*
 * Copyright (c) 2003-2005, 2010 by the gtk2-perl team (see the file AUTHORS)
 *
 * Licensed under the LGPL, see LICENSE file for more information.
 *
 * $Id$
 */

#include "gtk2perl.h"
#include "gtk2perl-private.h" /* For the translate callback. */

/* helper for using gperl_signal_connect when you don't have the SV of
 * the instance... */
#define WRAPINSTANCE(object)	(sv_2mortal (newSVGObject (G_OBJECT (object))))


/* these macros expect there to exist an SV** named svp */

#define HFETCHPV(hv, key)	\
	(((svp = hv_fetch ((hv), (key), strlen ((key)), FALSE))	\
	  && gperl_sv_is_defined (*svp))					\
	  ? SvPV_nolen (*svp)					\
	  : NULL)

#define HFETCHCV(hv, key)	\
	(((svp = hv_fetch ((hv), (key), strlen ((key)), FALSE))	\
	  && gperl_sv_is_defined (*svp))					\
	  ? (gpointer)(*svp)					\
	  : NULL)

#define HFETCHIV(hv, key)	\
	(((svp = hv_fetch ((hv), (key), strlen ((key)), FALSE))	\
	  && gperl_sv_is_defined (*svp))					\
	  ? SvIV (*svp)						\
	  : 0)

#define AFETCHPV(av, index)	\
	(((svp = av_fetch ((av), (index), FALSE)) && gperl_sv_is_defined (*svp))	\
	 ? SvPV_nolen (*svp)						\
	 : NULL)

#define AFETCHCV(av, index)	\
	(((svp = av_fetch ((av), (index), FALSE)) && gperl_sv_is_defined (*svp))	\
	 ? (gpointer)(*svp)						\
	 : NULL)

#define AFETCHIV(av, index)	\
	(((svp = av_fetch ((av), (index), FALSE)) && gperl_sv_is_defined (*svp))	\
	 ? SvIV (*svp)							\
	 : 0)


/*
struct _GtkActionEntry
{
  gchar     *name;
  gchar     *stock_id;
  gchar     *label;
  gchar     *accelerator;
  gchar     *tooltip;
  GCallback  callback;
};
*/

static void
read_action_entry_from_sv (SV * sv,
                           GtkActionEntry * action)
{
	SV ** svp;
	if (!gperl_sv_is_defined (sv) || !SvROK (sv))
		croak ("invalid action entry");

	switch (SvTYPE (SvRV (sv))) {
	    case SVt_PVHV:
		{
		HV * hv = (HV*) SvRV (sv);
		action->name        = HFETCHPV (hv, "name");
		action->stock_id    = HFETCHPV (hv, "stock_id");
		action->label       = HFETCHPV (hv, "label");
		action->accelerator = HFETCHPV (hv, "accelerator");
		action->tooltip     = HFETCHPV (hv, "tooltip");
		action->callback    = HFETCHCV (hv, "callback");
		}
		break;
	    case SVt_PVAV:
		{
		AV * av = (AV*) SvRV (sv);
		action->name        = AFETCHPV (av, 0);
		action->stock_id    = AFETCHPV (av, 1);
		action->label       = AFETCHPV (av, 2);
		action->accelerator = AFETCHPV (av, 3);
		action->tooltip     = AFETCHPV (av, 4);
		action->callback    = AFETCHCV (av, 5);
		}
		break;
	    default:
		croak ("action entry must be a hash or an array");
	}
}


/*
struct _GtkToggleActionEntry
{
  gchar     *name;
  gchar     *stock_id;
  gchar     *label;
  gchar     *accelerator;
  gchar     *tooltip;
  GCallback  callback;
  gboolean   is_active;
};
*/

static void
read_toggle_action_entry_from_sv (SV * sv,
                                  GtkToggleActionEntry * action)
{
	SV ** svp;
	if (!gperl_sv_is_defined (sv) || !SvROK (sv))
		croak ("invalid toggle action entry");

	switch (SvTYPE (SvRV (sv))) {
	    case SVt_PVHV:
		{
		HV * hv = (HV*) SvRV (sv);
		action->name        = HFETCHPV (hv, "name");
		action->stock_id    = HFETCHPV (hv, "stock_id");
		action->label       = HFETCHPV (hv, "label");
		action->accelerator = HFETCHPV (hv, "accelerator");
		action->tooltip     = HFETCHPV (hv, "tooltip");
		action->callback    = HFETCHCV (hv, "callback");
		action->is_active   = HFETCHIV (hv, "is_active");
		}
		break;
	    case SVt_PVAV:
		{
		AV * av = (AV*) SvRV (sv);
		if (av_len (av) < 5)
			croak ("not enough items in array form of toggle action entry; expecting:\n"
			       "     [ name, stock_id, label, accelerator, tooltip, value]\n"
			       "  ");
		action->name        = AFETCHPV (av, 0);
		action->stock_id    = AFETCHPV (av, 1);
		action->label       = AFETCHPV (av, 2);
		action->accelerator = AFETCHPV (av, 3);
		action->tooltip     = AFETCHPV (av, 4);
		action->callback    = AFETCHCV (av, 5);
		action->is_active   = AFETCHIV (av, 6);
		}
		break;
	    default:
		croak ("action entry must be a hash or an array");
	}
}


/*
struct _GtkRadioActionEntry
{
  gchar *name;
  gchar *stock_id;
  gchar *label;
  gchar *accelerator;
  gchar *tooltip;
  gint   value;
};
*/

static void
read_radio_action_entry_from_sv (SV * sv,
                                 GtkRadioActionEntry * action)
{
	SV ** svp;
	if (!gperl_sv_is_defined (sv) || !SvROK (sv))
		croak ("invalid radio action entry");

	switch (SvTYPE (SvRV (sv))) {
	    case SVt_PVHV:
		{
		HV * hv = (HV*) SvRV (sv);
		action->name        = HFETCHPV (hv, "name");
		action->stock_id    = HFETCHPV (hv, "stock_id");
		action->label       = HFETCHPV (hv, "label");
		action->accelerator = HFETCHPV (hv, "accelerator");
		action->tooltip     = HFETCHPV (hv, "tooltip");
		action->value       = HFETCHIV (hv, "value");
		}
		break;
	    case SVt_PVAV:
		{
		AV * av = (AV*) SvRV (sv);
		if (av_len (av) < 5)
			croak ("not enough items in array form of radio action entry; expecting:\n"
			       "     [ name, stock_id, label, accelerator, tooltip, value]\n"
			       "  ");
		action->name        = AFETCHPV (av, 0);
		action->stock_id    = AFETCHPV (av, 1);
		action->label       = AFETCHPV (av, 2);
		action->accelerator = AFETCHPV (av, 3);
		action->tooltip     = AFETCHPV (av, 4);
		action->value       = AFETCHIV (av, 5);
		}
		break;
	    default:
		croak ("action entry must be a hash or an array");
	}
}

#line 220 "xs/GtkActionGroup.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(pTHX_ const CV *const cv, const char *const params);

STATIC void
S_croak_xs_usage(pTHX_ 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(aTHX_ "Usage: %s::%s(%s)", hvname, gvname, params);
        else
            Perl_croak(aTHX_ "Usage: %s(%s)", gvname, params);
    } else {
        /* Pants. I don't think that it should be possible to get here. */
        Perl_croak(aTHX_ "Usage: CODE(0x%"UVxf")(%s)", PTR2UV(cv), params);
    }
}
#undef  PERL_ARGS_ASSERT_CROAK_XS_USAGE

#ifdef PERL_IMPLICIT_CONTEXT
#define croak_xs_usage(a,b)    S_croak_xs_usage(aTHX_ a,b)
#else
#define croak_xs_usage        S_croak_xs_usage
#endif

#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) */

#line 362 "xs/GtkActionGroup.c"

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

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

	RETVAL = gtk_action_group_new(name);
	ST(0) = newSVGtkActionGroup_noinc (RETVAL);
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2__ActionGroup_get_name); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_get_name)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "action_group");
    {
	const gchar *	RETVAL;
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;

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


XS_EUPXS(XS_Gtk2__ActionGroup_set_sensitive); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_set_sensitive)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "action_group, sensitive");
    {
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;
	gboolean	sensitive = (bool)SvTRUE(ST(1))
;

	gtk_action_group_set_sensitive(action_group, sensitive);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ActionGroup_get_sensitive); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_get_sensitive)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "action_group");
    {
	gboolean	RETVAL;
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;

	RETVAL = gtk_action_group_get_sensitive(action_group);
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2__ActionGroup_set_visible); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_set_visible)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "action_group, sensitive");
    {
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;
	gboolean	sensitive = (bool)SvTRUE(ST(1))
;

	gtk_action_group_set_visible(action_group, sensitive);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ActionGroup_get_visible); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_get_visible)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "action_group");
    {
	gboolean	RETVAL;
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;

	RETVAL = gtk_action_group_get_visible(action_group);
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2__ActionGroup_get_action); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_get_action)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "action_group, action_name");
    {
	GtkAction *	RETVAL;
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;
	const gchar *	action_name;

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

	RETVAL = gtk_action_group_get_action(action_group, action_name);
	ST(0) = newSVGtkAction (RETVAL);
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Gtk2__ActionGroup_list_actions); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_list_actions)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "action_group");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
#line 245 "xs/GtkActionGroup.xs"
	GList * actions, * i;
#line 516 "xs/GtkActionGroup.c"
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;
#line 247 "xs/GtkActionGroup.xs"
	actions = gtk_action_group_list_actions (action_group);
	for (i = actions ; i != NULL ; i = i->next)
		XPUSHs (sv_2mortal (newSVGtkAction (i->data)));
	g_list_free (actions);
#line 524 "xs/GtkActionGroup.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Gtk2__ActionGroup_add_action); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_add_action)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "action_group, action");
    {
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;
	GtkAction *	action = SvGtkAction (ST(1))
;

	gtk_action_group_add_action(action_group, action);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ActionGroup_add_action_with_accel); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_add_action_with_accel)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "action_group, action, accelerator");
    {
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;
	GtkAction *	action = SvGtkAction (ST(1))
;
	const gchar_ornull *	accelerator;

	/* same as SvGChar(), but allows undef as NULL */
	if (gperl_sv_is_defined (ST(2))) {
		sv_utf8_upgrade (ST(2));
		accelerator = (const gchar_ornull *)SvPV_nolen (ST(2));
	} else {
		accelerator = NULL;
	}
;

	gtk_action_group_add_action_with_accel(action_group, action, accelerator);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ActionGroup_remove_action); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_remove_action)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "action_group, action");
    {
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;
	GtkAction *	action = SvGtkAction (ST(1))
;

	gtk_action_group_remove_action(action_group, action);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ActionGroup_add_actions); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_add_actions)
{
    dVAR; dXSARGS;
    if (items < 2 || items > 3)
       croak_xs_usage(cv,  "action_group, action_entries, user_data=NULL");
    {
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;
	SV *	action_entries = ST(1)
;
	SV *	user_data;
#line 266 "xs/GtkActionGroup.xs"
	AV * av;
	GtkActionEntry * entries;
	gint n_actions, i;
#line 611 "xs/GtkActionGroup.c"

	if (items < 3)
	    user_data = NULL;
	else {
	    user_data = ST(2)
;
	}
#line 270 "xs/GtkActionGroup.xs"
	if (!gperl_sv_is_array_ref (action_entries))
		croak ("actions must be a reference to an array of action entries");
	av = (AV*) SvRV (action_entries);
	n_actions = av_len (av) + 1;
	if (n_actions < 1)
		croak ("action array is empty");
	entries = gperl_alloc_temp (sizeof (GtkActionEntry) * n_actions);
	for (i = 0 ; i < n_actions ; i++) {
		SV ** svp = av_fetch (av, i, 0);
		read_action_entry_from_sv (*svp, entries+i);
	}

	for (i = 0 ; i < n_actions ; i++) {
		GtkAction * action;
		gchar * accel_path;
		const gchar * label;
		const gchar * tooltip;
#if GTK_CHECK_VERSION (2, 6, 0)
		label = gtk_action_group_translate_string (action_group,
							   entries[i].label);
		tooltip =
			gtk_action_group_translate_string (action_group,
							   entries[i].tooltip);
#else
		label = entries[i].label;
		tooltip = entries[i].tooltip;
#endif

		action = gtk_action_new (entries[i].name,
		                         label,
		                         tooltip,
		                         entries[i].stock_id);
		if (entries[i].callback)
			gperl_signal_connect (WRAPINSTANCE (action),
			                      "activate",
					      (SV*)(entries[i].callback),
					      user_data, 0);

		/* set the accel path for the menu item */
		accel_path = g_strconcat
				("<Actions>/",
				 gtk_action_group_get_name (action_group),
				 "/", entries[i].name, NULL);

		if (entries[i].accelerator) {
			guint accel_key = 0;
			GdkModifierType accel_mods;

			gtk_accelerator_parse (entries[i].accelerator,
			                       &accel_key, &accel_mods);
			if (accel_key)
				gtk_accel_map_add_entry (accel_path,
				                         accel_key,
				                         accel_mods);
		}

		gtk_action_set_accel_path (action, accel_path);
		g_free (accel_path);

		gtk_action_group_add_action (action_group, action);
		g_object_unref (action);
	}
#line 682 "xs/GtkActionGroup.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ActionGroup_add_toggle_actions); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_add_toggle_actions)
{
    dVAR; dXSARGS;
    if (items < 2 || items > 3)
       croak_xs_usage(cv,  "action_group, toggle_action_entries, user_data=NULL");
    {
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;
	SV *	toggle_action_entries = ST(1)
;
	SV *	user_data;
#line 341 "xs/GtkActionGroup.xs"
	AV * av;
	GtkToggleActionEntry * entries;
	gint n_actions, i;
#line 704 "xs/GtkActionGroup.c"

	if (items < 3)
	    user_data = NULL;
	else {
	    user_data = ST(2)
;
	}
#line 345 "xs/GtkActionGroup.xs"
	if (!gperl_sv_is_array_ref (toggle_action_entries))
		croak ("entries must be a reference to an array of toggle action entries");
	av = (AV*) SvRV (toggle_action_entries);
	n_actions = av_len (av) + 1;
	if (n_actions < 1)
		croak ("toggle action array is empty");
	entries = gperl_alloc_temp (sizeof (GtkToggleActionEntry) * n_actions);
	for (i = 0 ; i < n_actions ; i++) {
		SV ** svp = av_fetch (av, i, 0);
		read_toggle_action_entry_from_sv (*svp, entries+i);
	}

	for (i = 0 ; i < n_actions ; i++) {
		GtkAction * action;
		gchar * accel_path;
		const gchar * label;
		const gchar * tooltip;
#if GTK_CHECK_VERSION (2, 6, 0)
		label = gtk_action_group_translate_string (action_group,
							   entries[i].label);
		tooltip =
			gtk_action_group_translate_string (action_group,
							   entries[i].tooltip);
#else
		label = entries[i].label;
		tooltip = entries[i].tooltip;
#endif

		action = g_object_new (GTK_TYPE_TOGGLE_ACTION,
		                       "name", entries[i].name,
		                       "label", label,
		                       "tooltip", tooltip,
		                       "stock_id", entries[i].stock_id,
		                       NULL);
		gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
		                              entries[i].is_active);
		if (entries[i].callback)
			gperl_signal_connect (WRAPINSTANCE (action),
			                      "activate",
					      (SV*)(entries[i].callback),
					      user_data, 0);

		/* set the accel path for the menu item */
		accel_path = g_strconcat
				("<Actions>/",
				 gtk_action_group_get_name (action_group),
				 "/", entries[i].name, NULL);

		if (entries[i].accelerator) {
			guint accel_key = 0;
			GdkModifierType accel_mods;

			gtk_accelerator_parse (entries[i].accelerator,
			                       &accel_key, &accel_mods);
			if (accel_key)
				gtk_accel_map_add_entry (accel_path,
				                         accel_key,
				                         accel_mods);
		}

		gtk_action_set_accel_path (action, accel_path);
		g_free (accel_path);

		gtk_action_group_add_action (action_group, action);
		g_object_unref (action);
	}
#line 779 "xs/GtkActionGroup.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ActionGroup_add_radio_actions); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_add_radio_actions)
{
    dVAR; dXSARGS;
    if (items < 4 || items > 5)
       croak_xs_usage(cv,  "action_group, radio_action_entries, value, on_change, user_data=NULL");
    {
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;
	SV *	radio_action_entries = ST(1)
;
	gint	value = (gint)SvIV(ST(2))
;
	SV *	on_change = ST(3)
;
	SV *	user_data;
#line 463 "xs/GtkActionGroup.xs"
	AV * av;
	GtkRadioActionEntry * entries;
	GtkAction * first_action = NULL;
	GSList * group = NULL;
	gint n_actions, i;
#line 807 "xs/GtkActionGroup.c"

	if (items < 5)
	    user_data = NULL;
	else {
	    user_data = ST(4)
;
	}
#line 469 "xs/GtkActionGroup.xs"
	if (!gperl_sv_is_array_ref (radio_action_entries))
		croak ("radio_action_entries must be a reference to an array of action entries");
	av = (AV*) SvRV (radio_action_entries);
	n_actions = av_len (av) + 1;
	if (n_actions < 1)
		croak ("radio action array is empty");
	entries = gperl_alloc_temp (sizeof (GtkRadioActionEntry) * n_actions);
	for (i = 0 ; i < n_actions ; i++) {
		SV ** svp = av_fetch (av, i, 0);
		read_radio_action_entry_from_sv (*svp, entries+i);
	}

	for (i = 0 ; i < n_actions ; i++) {
		GtkAction * action;
		gchar * accel_path;
		const gchar * label;
		const gchar * tooltip;
#if GTK_CHECK_VERSION (2, 6, 0)
		label = gtk_action_group_translate_string (action_group,
							   entries[i].label);
		tooltip =
			gtk_action_group_translate_string (action_group,
							   entries[i].tooltip);
#else
		label = entries[i].label;
		tooltip = entries[i].tooltip;
#endif

		action = g_object_new (GTK_TYPE_RADIO_ACTION,
		                       "name", entries[i].name,
		                       "label", label,
		                       "tooltip", tooltip,
		                       "stock_id", entries[i].stock_id,
		                       "value", entries[i].value,
		                       NULL);

		if (i == 0)
			first_action = action;
		gtk_radio_action_set_group (GTK_RADIO_ACTION (action), group);
		group = gtk_radio_action_get_group (GTK_RADIO_ACTION (action));
		if (value == entries[i].value)
			gtk_toggle_action_set_active
					(GTK_TOGGLE_ACTION (action), TRUE);

		/* set the accel path for the menu item */
		accel_path = g_strconcat
				("<Actions>/",
				 gtk_action_group_get_name (action_group),
				 "/", entries[i].name, NULL);

		if (entries[i].accelerator) {
			guint accel_key = 0;
			GdkModifierType accel_mods;

			gtk_accelerator_parse (entries[i].accelerator,
			                       &accel_key, &accel_mods);
			if (accel_key)
				gtk_accel_map_add_entry (accel_path,
				                         accel_key,
				                         accel_mods);
		}

		gtk_action_set_accel_path (action, accel_path);
		g_free (accel_path);

		gtk_action_group_add_action (action_group, action);
		g_object_unref (action);
	}

	if (gperl_sv_is_defined (on_change))
		gperl_signal_connect (WRAPINSTANCE (first_action),
		                      "changed", on_change, user_data, 0);
#line 888 "xs/GtkActionGroup.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ActionGroup_set_translation_domain); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_set_translation_domain)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "action_group, domain");
    {
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;
	const gchar *	domain;

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

	gtk_action_group_set_translation_domain(action_group, domain);
    }
    XSRETURN_EMPTY;
}

#if GTK_CHECK_VERSION (2, 6, 0)
#define XSubPPtmpAAAA 1


XS_EUPXS(XS_Gtk2__ActionGroup_set_translate_func); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_set_translate_func)
{
    dVAR; dXSARGS;
    if (items < 2 || items > 3)
       croak_xs_usage(cv,  "action_group, func, data=NULL");
    {
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;
	SV *	func = ST(1)
;
	SV *	data;
#line 563 "xs/GtkActionGroup.xs"
	GPerlCallback *callback;
#line 933 "xs/GtkActionGroup.c"

	if (items < 3)
	    data = NULL;
	else {
	    data = ST(2)
;
	}
#line 565 "xs/GtkActionGroup.xs"
	callback = gtk2perl_translate_func_create (func, data);
	gtk_action_group_set_translate_func (action_group,
	                                     gtk2perl_translate_func,
	                                     callback,
	                                     (GtkDestroyNotify)
	                                       gperl_callback_destroy);
#line 948 "xs/GtkActionGroup.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Gtk2__ActionGroup_translate_string); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Gtk2__ActionGroup_translate_string)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "action_group, string");
    {
	const gchar *	RETVAL;
	GtkActionGroup *	action_group = SvGtkActionGroup (ST(0))
;
	const gchar *	string;

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

	RETVAL = gtk_action_group_translate_string(action_group, string);
	ST(0) = sv_newmortal();
	/* same as newSVGChar(), but not in a function */
	sv_setpv ((SV*)ST(0), RETVAL);
	SvUTF8_on (ST(0));
    }
    XSRETURN(1);
}

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

    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(items); /* -W */
#ifdef XS_APIVERSION_BOOTCHECK
    XS_APIVERSION_BOOTCHECK;
#endif
    XS_VERSION_BOOTCHECK;

        newXS("Gtk2::ActionGroup::new", XS_Gtk2__ActionGroup_new, file);
        newXS("Gtk2::ActionGroup::get_name", XS_Gtk2__ActionGroup_get_name, file);
        newXS("Gtk2::ActionGroup::set_sensitive", XS_Gtk2__ActionGroup_set_sensitive, file);
        newXS("Gtk2::ActionGroup::get_sensitive", XS_Gtk2__ActionGroup_get_sensitive, file);
        newXS("Gtk2::ActionGroup::set_visible", XS_Gtk2__ActionGroup_set_visible, file);
        newXS("Gtk2::ActionGroup::get_visible", XS_Gtk2__ActionGroup_get_visible, file);
        newXS("Gtk2::ActionGroup::get_action", XS_Gtk2__ActionGroup_get_action, file);
        newXS("Gtk2::ActionGroup::list_actions", XS_Gtk2__ActionGroup_list_actions, file);
        newXS("Gtk2::ActionGroup::add_action", XS_Gtk2__ActionGroup_add_action, file);
        newXS("Gtk2::ActionGroup::add_action_with_accel", XS_Gtk2__ActionGroup_add_action_with_accel, file);
        newXS("Gtk2::ActionGroup::remove_action", XS_Gtk2__ActionGroup_remove_action, file);
        newXS("Gtk2::ActionGroup::add_actions", XS_Gtk2__ActionGroup_add_actions, file);
        newXS("Gtk2::ActionGroup::add_toggle_actions", XS_Gtk2__ActionGroup_add_toggle_actions, file);
        newXS("Gtk2::ActionGroup::add_radio_actions", XS_Gtk2__ActionGroup_add_radio_actions, file);
        newXS("Gtk2::ActionGroup::set_translation_domain", XS_Gtk2__ActionGroup_set_translation_domain, file);
#if XSubPPtmpAAAA
        newXS("Gtk2::ActionGroup::set_translate_func", XS_Gtk2__ActionGroup_set_translate_func, file);
        newXS("Gtk2::ActionGroup::translate_string", XS_Gtk2__ActionGroup_translate_string, file);
#endif

    /* Initialisation Section */

#if XSubPPtmpAAAA
#endif
#line 1025 "xs/GtkActionGroup.c"

    /* End of Initialisation Section */

#if (PERL_REVISION == 5 && PERL_VERSION >= 9)
  if (PL_unitcheckav)
       call_list(PL_scopestack_ix, PL_unitcheckav);
#endif
    XSRETURN_YES;
}

