/* games-mass-edit-button.c generated by valac 0.56.19, the Vala compiler
 * generated from games-mass-edit-button.vala, do not modify */

#include "protonplus_core.h"
#include <adwaita.h>
#include <glib.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.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

enum  {
	PROTON_PLUS_WIDGETS_GAMES_MASS_EDIT_BUTTON_0_PROPERTY,
	PROTON_PLUS_WIDGETS_GAMES_MASS_EDIT_BUTTON_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_games_mass_edit_button_properties[PROTON_PLUS_WIDGETS_GAMES_MASS_EDIT_BUTTON_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	PROTON_PLUS_WIDGETS_GAMES_MASS_EDIT_BUTTON_MASS_EDIT_REQUESTED_SIGNAL,
	PROTON_PLUS_WIDGETS_GAMES_MASS_EDIT_BUTTON_NUM_SIGNALS
};
static guint proton_plus_widgets_games_mass_edit_button_signals[PROTON_PLUS_WIDGETS_GAMES_MASS_EDIT_BUTTON_NUM_SIGNALS] = {0};

struct _ProtonPlusWidgetsGamesMassEditButtonPrivate {
	AdwButtonContent* mass_edit_button_content;
	ProtonPlusWidgetsGamesFocusLastVisibleGameRequest focus_last_game;
	gpointer focus_last_game_target;
};

static gint ProtonPlusWidgetsGamesMassEditButton_private_offset;
static gpointer proton_plus_widgets_games_mass_edit_button_parent_class = NULL;
static ProtonPlusUtilsControllerDirectionalFocusIface * proton_plus_widgets_games_mass_edit_button_proton_plus_utils_controller_directional_focus_parent_iface = NULL;

static void __lambda106_ (ProtonPlusWidgetsGamesMassEditButton* self);
static void ___lambda106__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static gboolean proton_plus_widgets_games_mass_edit_button_real_controller_focus_direction (ProtonPlusUtilsControllerDirectionalFocus* base,
                                                                                     GObject* focused_object,
                                                                                     ProtonPlusUtilsControllerNavigationDirection direction);
static void proton_plus_widgets_games_mass_edit_button_finalize (GObject * obj);
static GType proton_plus_widgets_games_mass_edit_button_get_type_once (void);

static inline gpointer
proton_plus_widgets_games_mass_edit_button_get_instance_private (ProtonPlusWidgetsGamesMassEditButton* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusWidgetsGamesMassEditButton_private_offset);
}

static void
__lambda106_ (ProtonPlusWidgetsGamesMassEditButton* self)
{
	g_signal_emit (self, proton_plus_widgets_games_mass_edit_button_signals[PROTON_PLUS_WIDGETS_GAMES_MASS_EDIT_BUTTON_MASS_EDIT_REQUESTED_SIGNAL], 0);
}

static void
___lambda106__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda106_ ((ProtonPlusWidgetsGamesMassEditButton*) self);
}

ProtonPlusWidgetsGamesMassEditButton*
proton_plus_widgets_games_mass_edit_button_construct (GType object_type,
                                                      ProtonPlusWidgetsGamesFocusLastVisibleGameRequest focus_last_game,
                                                      gpointer focus_last_game_target)
{
	ProtonPlusWidgetsGamesMassEditButton * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	AdwButtonContent* _tmp2_ = NULL;
	AdwButtonContent* _tmp3_;
	self = (ProtonPlusWidgetsGamesMassEditButton*) g_object_new (object_type, NULL);
	self->priv->focus_last_game = focus_last_game;
	self->priv->focus_last_game_target = focus_last_game_target;
	_tmp0_ = g_strdup (_ ("Modify the selected games"));
	_tmp1_ = g_strdup ("screwdriver-wrench-symbolic");
	_tmp2_ = (AdwButtonContent*) adw_button_content_new ();
	adw_button_content_set_label (_tmp2_, _tmp0_);
	_g_free0 (_tmp0_);
	adw_button_content_set_icon_name (_tmp2_, _tmp1_);
	_g_free0 (_tmp1_);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->mass_edit_button_content);
	self->priv->mass_edit_button_content = _tmp2_;
	gtk_widget_set_tooltip_text ((GtkWidget*) self, _ ("Modify the selected games all at once"));
	gtk_widget_set_halign ((GtkWidget*) self, GTK_ALIGN_CENTER);
	gtk_widget_add_css_class ((GtkWidget*) self, "pill");
	gtk_widget_add_css_class ((GtkWidget*) self, "suggested-action");
	_tmp3_ = self->priv->mass_edit_button_content;
	gtk_button_set_child ((GtkButton*) self, (GtkWidget*) _tmp3_);
	g_signal_connect_object ((GtkButton*) self, "clicked", (GCallback) ___lambda106__gtk_button_clicked, self, 0);
	return self;
}

ProtonPlusWidgetsGamesMassEditButton*
proton_plus_widgets_games_mass_edit_button_new (ProtonPlusWidgetsGamesFocusLastVisibleGameRequest focus_last_game,
                                                gpointer focus_last_game_target)
{
	return proton_plus_widgets_games_mass_edit_button_construct (PROTON_PLUS_WIDGETS_GAMES_TYPE_MASS_EDIT_BUTTON, focus_last_game, focus_last_game_target);
}

void
proton_plus_widgets_games_mass_edit_button_set_selected_count (ProtonPlusWidgetsGamesMassEditButton* self,
                                                               gint count)
{
	AdwButtonContent* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->mass_edit_button_content;
	_tmp1_ = g_strdup_printf (ngettext ("Modify %d selected game", "Modify %d selected games", (gulong) count), count);
	_tmp2_ = _tmp1_;
	adw_button_content_set_label (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
	_tmp3_ = g_strdup_printf (ngettext ("Modify %d selected game all at once", "Modify %d selected games all at once", (gulong) count), count);
	_tmp4_ = _tmp3_;
	gtk_widget_set_tooltip_text ((GtkWidget*) self, _tmp4_);
	_g_free0 (_tmp4_);
}

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

static gboolean
proton_plus_widgets_games_mass_edit_button_real_controller_focus_direction (ProtonPlusUtilsControllerDirectionalFocus* base,
                                                                            GObject* focused_object,
                                                                            ProtonPlusUtilsControllerNavigationDirection direction)
{
	ProtonPlusWidgetsGamesMassEditButton * self;
	GtkWidget* focused = NULL;
	GtkWidget* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	GtkWidget* _tmp3_;
	ProtonPlusWidgetsGamesFocusLastVisibleGameRequest _tmp7_;
	gpointer _tmp7__target;
	gboolean result;
	self = (ProtonPlusWidgetsGamesMassEditButton*) base;
	g_return_val_if_fail (focused_object != NULL, FALSE);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (focused_object, gtk_widget_get_type ()) ? ((GtkWidget*) focused_object) : NULL);
	focused = _tmp0_;
	_tmp3_ = focused;
	if (_tmp3_ == NULL) {
		_tmp2_ = TRUE;
	} else {
		gboolean _tmp4_ = FALSE;
		GtkWidget* _tmp5_;
		_tmp5_ = focused;
		if (_tmp5_ != G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget)) {
			GtkWidget* _tmp6_;
			_tmp6_ = focused;
			_tmp4_ = !gtk_widget_is_ancestor (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_widget_get_type (), GtkWidget), (GtkWidget*) self);
		} else {
			_tmp4_ = FALSE;
		}
		_tmp2_ = _tmp4_;
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = direction != PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_UP;
	}
	if (_tmp1_) {
		result = FALSE;
		_g_object_unref0 (focused);
		return result;
	}
	_tmp7_ = self->priv->focus_last_game;
	_tmp7__target = self->priv->focus_last_game_target;
	result = _tmp7_ (_tmp7__target);
	_g_object_unref0 (focused);
	return result;
}

static void
proton_plus_widgets_games_mass_edit_button_class_init (ProtonPlusWidgetsGamesMassEditButtonClass * klass,
                                                       gpointer klass_data)
{
	proton_plus_widgets_games_mass_edit_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusWidgetsGamesMassEditButton_private_offset);
	G_OBJECT_CLASS (klass)->finalize = proton_plus_widgets_games_mass_edit_button_finalize;
	proton_plus_widgets_games_mass_edit_button_signals[PROTON_PLUS_WIDGETS_GAMES_MASS_EDIT_BUTTON_MASS_EDIT_REQUESTED_SIGNAL] = g_signal_new ("mass-edit-requested", PROTON_PLUS_WIDGETS_GAMES_TYPE_MASS_EDIT_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
proton_plus_widgets_games_mass_edit_button_proton_plus_utils_controller_directional_focus_interface_init (ProtonPlusUtilsControllerDirectionalFocusIface * iface,
                                                                                                          gpointer iface_data)
{
	proton_plus_widgets_games_mass_edit_button_proton_plus_utils_controller_directional_focus_parent_iface = g_type_interface_peek_parent (iface);
	iface->controller_focus_direction = (gboolean (*) (ProtonPlusUtilsControllerDirectionalFocus*, GObject*, ProtonPlusUtilsControllerNavigationDirection)) proton_plus_widgets_games_mass_edit_button_real_controller_focus_direction;
}

static void
proton_plus_widgets_games_mass_edit_button_instance_init (ProtonPlusWidgetsGamesMassEditButton * self,
                                                          gpointer klass)
{
	self->priv = proton_plus_widgets_games_mass_edit_button_get_instance_private (self);
}

static void
proton_plus_widgets_games_mass_edit_button_finalize (GObject * obj)
{
	ProtonPlusWidgetsGamesMassEditButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_GAMES_TYPE_MASS_EDIT_BUTTON, ProtonPlusWidgetsGamesMassEditButton);
	_g_object_unref0 (self->priv->mass_edit_button_content);
	G_OBJECT_CLASS (proton_plus_widgets_games_mass_edit_button_parent_class)->finalize (obj);
}

static GType
proton_plus_widgets_games_mass_edit_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsGamesMassEditButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_games_mass_edit_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsGamesMassEditButton), 0, (GInstanceInitFunc) proton_plus_widgets_games_mass_edit_button_instance_init, NULL };
	static const GInterfaceInfo proton_plus_utils_controller_directional_focus_info = { (GInterfaceInitFunc) proton_plus_widgets_games_mass_edit_button_proton_plus_utils_controller_directional_focus_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType proton_plus_widgets_games_mass_edit_button_type_id;
	proton_plus_widgets_games_mass_edit_button_type_id = g_type_register_static (gtk_button_get_type (), "ProtonPlusWidgetsGamesMassEditButton", &g_define_type_info, 0);
	g_type_add_interface_static (proton_plus_widgets_games_mass_edit_button_type_id, PROTON_PLUS_UTILS_TYPE_CONTROLLER_DIRECTIONAL_FOCUS, &proton_plus_utils_controller_directional_focus_info);
	ProtonPlusWidgetsGamesMassEditButton_private_offset = g_type_add_instance_private (proton_plus_widgets_games_mass_edit_button_type_id, sizeof (ProtonPlusWidgetsGamesMassEditButtonPrivate));
	return proton_plus_widgets_games_mass_edit_button_type_id;
}

GType
proton_plus_widgets_games_mass_edit_button_get_type (void)
{
	static volatile gsize proton_plus_widgets_games_mass_edit_button_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_games_mass_edit_button_type_id__once)) {
		GType proton_plus_widgets_games_mass_edit_button_type_id;
		proton_plus_widgets_games_mass_edit_button_type_id = proton_plus_widgets_games_mass_edit_button_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_games_mass_edit_button_type_id__once, proton_plus_widgets_games_mass_edit_button_type_id);
	}
	return proton_plus_widgets_games_mass_edit_button_type_id__once;
}

