/* SessionButton.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from SessionButton.vala, do not modify */

/*
 * SPDX-License-Identifier: GPL-2.0-or-later
 * SPDX-FileCopyrightText: 2018-2025 elementary, Inc. (https://elementary.io)
 *
 * Authors: Corentin Noël <corentin@elementary.io>
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define GREETER_TYPE_SESSION_BUTTON (greeter_session_button_get_type ())
#define GREETER_SESSION_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GREETER_TYPE_SESSION_BUTTON, GreeterSessionButton))
#define GREETER_SESSION_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GREETER_TYPE_SESSION_BUTTON, GreeterSessionButtonClass))
#define GREETER_IS_SESSION_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GREETER_TYPE_SESSION_BUTTON))
#define GREETER_IS_SESSION_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GREETER_TYPE_SESSION_BUTTON))
#define GREETER_SESSION_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GREETER_TYPE_SESSION_BUTTON, GreeterSessionButtonClass))

typedef struct _GreeterSessionButton GreeterSessionButton;
typedef struct _GreeterSessionButtonClass GreeterSessionButtonClass;
typedef struct _GreeterSessionButtonPrivate GreeterSessionButtonPrivate;
enum  {
	GREETER_SESSION_BUTTON_0_PROPERTY,
	GREETER_SESSION_BUTTON_NUM_PROPERTIES
};
static GParamSpec* greeter_session_button_properties[GREETER_SESSION_BUTTON_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_variant_iter_free0(var) ((var == NULL) ? NULL : (var = (g_variant_iter_free (var), NULL)))

struct _GreeterSessionButton {
	GtkBin parent_instance;
	GreeterSessionButtonPrivate * priv;
};

struct _GreeterSessionButtonClass {
	GtkBinClass parent_class;
};

static gpointer greeter_session_button_parent_class = NULL;

VALA_EXTERN GType greeter_session_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GreeterSessionButton, g_object_unref)
VALA_EXTERN GreeterSessionButton* greeter_session_button_new (void);
VALA_EXTERN GreeterSessionButton* greeter_session_button_construct (GType object_type);
static GObject * greeter_session_button_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
static GType greeter_session_button_get_type_once (void);

GreeterSessionButton*
greeter_session_button_construct (GType object_type)
{
	GreeterSessionButton * self = NULL;
	self = (GreeterSessionButton*) g_object_new (object_type, NULL);
	return self;
}

GreeterSessionButton*
greeter_session_button_new (void)
{
	return greeter_session_button_construct (GREETER_TYPE_SESSION_BUTTON);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static GObject *
greeter_session_button_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GreeterSessionButton * self;
	GMenu* menu = NULL;
	GMenu* _tmp0_;
	GtkApplication* application = NULL;
	GApplication* _tmp1_;
	GVariant* hint = NULL;
	GtkApplication* _tmp2_;
	GVariant* _tmp3_;
	GVariantIter* iter = NULL;
	GVariant* _tmp4_;
	GVariantIter* _tmp5_;
	GVariant* val = NULL;
	gchar* key = NULL;
	GtkMenuButton* menu_button = NULL;
	GtkImage* _tmp15_;
	GMenu* _tmp16_;
	GMenuModel* _tmp17_;
	GtkMenuButton* _tmp18_ = NULL;
	GtkMenuButton* _tmp19_;
	GtkStyleContext* _tmp20_;
	GtkMenuButton* _tmp21_;
	parent_class = G_OBJECT_CLASS (greeter_session_button_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GREETER_TYPE_SESSION_BUTTON, GreeterSessionButton);
	_tmp0_ = g_menu_new ();
	menu = _tmp0_;
	_tmp1_ = g_application_get_default ();
	application = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_application_get_type (), GtkApplication);
	_tmp2_ = application;
	_tmp3_ = g_action_group_get_action_state_hint ((GActionGroup*) _tmp2_, "select-session");
	hint = _tmp3_;
	_tmp4_ = hint;
	_tmp5_ = g_variant_iter_new (_tmp4_);
	iter = _tmp5_;
	val = NULL;
	key = NULL;
	while (TRUE) {
		GVariantIter* _tmp6_;
		gchar* _tmp7_ = NULL;
		GVariant* _tmp8_ = NULL;
		gboolean _tmp9_;
		GMenu* _tmp10_;
		const gchar* _tmp11_;
		GVariant* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		_tmp6_ = iter;
		_tmp9_ = g_variant_iter_next (_tmp6_, "{sv}", &_tmp7_, &_tmp8_, NULL);
		_g_free0 (key);
		key = _tmp7_;
		_g_variant_unref0 (val);
		val = _tmp8_;
		if (!_tmp9_) {
			break;
		}
		_tmp10_ = menu;
		_tmp11_ = key;
		_tmp12_ = val;
		_tmp13_ = g_action_print_detailed_name ("app.select-session", _tmp12_);
		_tmp14_ = _tmp13_;
		g_menu_append (_tmp10_, _tmp11_, _tmp14_);
		_g_free0 (_tmp14_);
	}
	_tmp15_ = (GtkImage*) gtk_image_new_from_icon_name ("open-menu-symbolic", (GtkIconSize) GTK_ICON_SIZE_BUTTON);
	g_object_ref_sink (_tmp15_);
	_tmp16_ = menu;
	_tmp17_ = _g_object_ref0 ((GMenuModel*) _tmp16_);
	_tmp18_ = (GtkMenuButton*) gtk_menu_button_new ();
	g_object_set ((GtkContainer*) _tmp18_, "child", (GtkWidget*) _tmp15_, NULL);
	_g_object_unref0 (_tmp15_);
	gtk_menu_button_set_direction (_tmp18_, GTK_ARROW_DOWN);
	gtk_menu_button_set_menu_model (_tmp18_, _tmp17_);
	_g_object_unref0 (_tmp17_);
	g_object_ref_sink (_tmp18_);
	menu_button = _tmp18_;
	_tmp19_ = menu_button;
	_tmp20_ = gtk_widget_get_style_context ((GtkWidget*) _tmp19_);
	gtk_style_context_add_class (_tmp20_, GTK_STYLE_CLASS_FLAT);
	_tmp21_ = menu_button;
	g_object_set ((GtkContainer*) self, "child", (GtkWidget*) _tmp21_, NULL);
	_g_object_unref0 (menu_button);
	_g_free0 (key);
	_g_variant_unref0 (val);
	_g_variant_iter_free0 (iter);
	_g_variant_unref0 (hint);
	_g_object_unref0 (menu);
	return obj;
}

static void
greeter_session_button_class_init (GreeterSessionButtonClass * klass,
                                   gpointer klass_data)
{
	greeter_session_button_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = greeter_session_button_constructor;
}

static void
greeter_session_button_instance_init (GreeterSessionButton * self,
                                      gpointer klass)
{
}

static GType
greeter_session_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GreeterSessionButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) greeter_session_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GreeterSessionButton), 0, (GInstanceInitFunc) greeter_session_button_instance_init, NULL };
	GType greeter_session_button_type_id;
	greeter_session_button_type_id = g_type_register_static (gtk_bin_get_type (), "GreeterSessionButton", &g_define_type_info, 0);
	return greeter_session_button_type_id;
}

GType
greeter_session_button_get_type (void)
{
	static volatile gsize greeter_session_button_type_id__once = 0;
	if (g_once_init_enter (&greeter_session_button_type_id__once)) {
		GType greeter_session_button_type_id;
		greeter_session_button_type_id = greeter_session_button_get_type_once ();
		g_once_init_leave (&greeter_session_button_type_id__once, greeter_session_button_type_id);
	}
	return greeter_session_button_type_id__once;
}

