/* accelerator-chooser-window.c generated by valac 0.56.19, the Vala compiler
 * generated from accelerator-chooser-window.vala, do not modify */

/*
 * Copyright (c) 2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "ft_ui.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include "ft_core.h"
#include <gdk/gdk.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

typedef enum  {
	FT_ACCELERATOR_CHOOSER_WINDOW_MODE_CAPTURE,
	FT_ACCELERATOR_CHOOSER_WINDOW_MODE_REVIEW
} FtAcceleratorChooserWindowMode;

#define FT_ACCELERATOR_CHOOSER_WINDOW_TYPE_MODE (ft_accelerator_chooser_window_mode_get_type ())
enum  {
	FT_ACCELERATOR_CHOOSER_WINDOW_0_PROPERTY,
	FT_ACCELERATOR_CHOOSER_WINDOW_DESCRIPTION_PROPERTY,
	FT_ACCELERATOR_CHOOSER_WINDOW_ACCELERATOR_PROPERTY,
	FT_ACCELERATOR_CHOOSER_WINDOW_NUM_PROPERTIES
};
static GParamSpec* ft_accelerator_chooser_window_properties[FT_ACCELERATOR_CHOOSER_WINDOW_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _gdk_event_unref0(var) ((var == NULL) ? NULL : (var = (gdk_event_unref (var), NULL)))
enum  {
	FT_ACCELERATOR_CHOOSER_WINDOW_RESPONSE_SIGNAL,
	FT_ACCELERATOR_CHOOSER_WINDOW_NUM_SIGNALS
};
static guint ft_accelerator_chooser_window_signals[FT_ACCELERATOR_CHOOSER_WINDOW_NUM_SIGNALS] = {0};

struct _FtAcceleratorChooserWindowPrivate {
	gchar* _accelerator;
	GtkButton* cancel_button;
	GtkButton* set_button;
	GtkLabel* description_label;
	GtkShortcutLabel* accelerator_label;
	GtkPicture* capture_image;
	GtkLabel* capture_hint;
	FtAcceleratorChooserWindowMode mode;
	gboolean system_shortcuts_inhibited;
	FtKeyboardManager* keyboard_manager;
};

static gint FtAcceleratorChooserWindow_private_offset;
static gpointer ft_accelerator_chooser_window_parent_class = NULL;

static GType ft_accelerator_chooser_window_mode_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static void ft_accelerator_chooser_window_inhibit_system_shortcuts (FtAcceleratorChooserWindow* self);
static void ft_accelerator_chooser_window_uninhibit_system_shortcuts (FtAcceleratorChooserWindow* self);
static void ft_accelerator_chooser_window_set_mode (FtAcceleratorChooserWindow* self,
                                             FtAcceleratorChooserWindowMode mode);
static void ft_accelerator_chooser_window_on_cancel_button_clicked (FtAcceleratorChooserWindow* self);
static void _ft_accelerator_chooser_window_on_cancel_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                                 gpointer self);
static void ft_accelerator_chooser_window_on_set_button_clicked (FtAcceleratorChooserWindow* self);
static void _ft_accelerator_chooser_window_on_set_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                              gpointer self);
static gboolean ft_accelerator_chooser_window_on_key_pressed (FtAcceleratorChooserWindow* self,
                                                       GtkEventControllerKey* event_controller,
                                                       guint keyval,
                                                       guint keycode,
                                                       GdkModifierType state);
static gboolean _ft_accelerator_chooser_window_on_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                                             guint keyval,
                                                                                             guint keycode,
                                                                                             GdkModifierType state,
                                                                                             gpointer self);
static void ft_accelerator_chooser_window_real_map (GtkWidget* base);
static void ft_accelerator_chooser_window_real_unmap (GtkWidget* base);
static void ft_accelerator_chooser_window_real_dispose (GObject* base);
static void ft_accelerator_chooser_window_real_response (FtAcceleratorChooserWindow* self,
                                                  gint response_id);
static GObject * ft_accelerator_chooser_window_constructor (GType type,
                                                     guint n_construct_properties,
                                                     GObjectConstructParam * construct_properties);
static void ft_accelerator_chooser_window_finalize (GObject * obj);
static GType ft_accelerator_chooser_window_get_type_once (void);
static void _vala_ft_accelerator_chooser_window_get_property (GObject * object,
                                                       guint property_id,
                                                       GValue * value,
                                                       GParamSpec * pspec);
static void _vala_ft_accelerator_chooser_window_set_property (GObject * object,
                                                       guint property_id,
                                                       const GValue * value,
                                                       GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
ft_accelerator_chooser_window_get_instance_private (FtAcceleratorChooserWindow* self)
{
	return G_STRUCT_MEMBER_P (self, FtAcceleratorChooserWindow_private_offset);
}

static GType
ft_accelerator_chooser_window_mode_get_type_once (void)
{
	static const GEnumValue values[] = {{FT_ACCELERATOR_CHOOSER_WINDOW_MODE_CAPTURE, "FT_ACCELERATOR_CHOOSER_WINDOW_MODE_CAPTURE", "capture"}, {FT_ACCELERATOR_CHOOSER_WINDOW_MODE_REVIEW, "FT_ACCELERATOR_CHOOSER_WINDOW_MODE_REVIEW", "review"}, {0, NULL, NULL}};
	GType ft_accelerator_chooser_window_mode_type_id;
	ft_accelerator_chooser_window_mode_type_id = g_enum_register_static ("FtAcceleratorChooserWindowMode", values);
	return ft_accelerator_chooser_window_mode_type_id;
}

static GType
ft_accelerator_chooser_window_mode_get_type (void)
{
	static volatile gsize ft_accelerator_chooser_window_mode_type_id__once = 0;
	if (g_once_init_enter (&ft_accelerator_chooser_window_mode_type_id__once)) {
		GType ft_accelerator_chooser_window_mode_type_id;
		ft_accelerator_chooser_window_mode_type_id = ft_accelerator_chooser_window_mode_get_type_once ();
		g_once_init_leave (&ft_accelerator_chooser_window_mode_type_id__once, ft_accelerator_chooser_window_mode_type_id);
	}
	return ft_accelerator_chooser_window_mode_type_id__once;
}

FtAcceleratorChooserWindow*
ft_accelerator_chooser_window_construct (GType object_type,
                                         const gchar* description,
                                         const gchar* accelerator)
{
	FtAcceleratorChooserWindow * self = NULL;
	g_return_val_if_fail (description != NULL, NULL);
	g_return_val_if_fail (accelerator != NULL, NULL);
	self = (FtAcceleratorChooserWindow*) g_object_new (object_type, NULL);
	ft_accelerator_chooser_window_set_description (self, description);
	ft_accelerator_chooser_window_set_accelerator (self, accelerator);
	return self;
}

FtAcceleratorChooserWindow*
ft_accelerator_chooser_window_new (const gchar* description,
                                   const gchar* accelerator)
{
	return ft_accelerator_chooser_window_construct (FT_TYPE_ACCELERATOR_CHOOSER_WINDOW, description, accelerator);
}

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

static void
ft_accelerator_chooser_window_inhibit_system_shortcuts (FtAcceleratorChooserWindow* self)
{
	FtKeyboardManager* _tmp0_ = NULL;
	FtKeyboardManager* _tmp1_;
	GdkToplevel* toplevel = NULL;
	GtkNative* _tmp2_;
	GdkSurface* _tmp3_;
	GdkToplevel* _tmp4_;
	GdkToplevel* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->keyboard_manager;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		ft_keyboard_manager_inhibit (_tmp0_);
	}
	if (self->priv->system_shortcuts_inhibited) {
		return;
	}
	_tmp2_ = gtk_widget_get_native ((GtkWidget*) self);
	_tmp3_ = gtk_native_get_surface (_tmp2_);
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, gdk_toplevel_get_type ()) ? ((GdkToplevel*) _tmp3_) : NULL);
	toplevel = _tmp4_;
	_tmp5_ = toplevel;
	if (_tmp5_ != NULL) {
		GdkToplevel* _tmp6_;
		_tmp6_ = toplevel;
		gdk_toplevel_inhibit_system_shortcuts (_tmp6_, NULL);
		self->priv->system_shortcuts_inhibited = TRUE;
	}
	_g_object_unref0 (toplevel);
}

static void
ft_accelerator_chooser_window_uninhibit_system_shortcuts (FtAcceleratorChooserWindow* self)
{
	FtKeyboardManager* _tmp0_ = NULL;
	FtKeyboardManager* _tmp1_;
	GdkToplevel* toplevel = NULL;
	GtkNative* _tmp2_;
	GdkSurface* _tmp3_;
	GdkToplevel* _tmp4_;
	GdkToplevel* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->keyboard_manager;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		ft_keyboard_manager_uninhibit (_tmp0_);
	}
	if (!self->priv->system_shortcuts_inhibited) {
		return;
	}
	_tmp2_ = gtk_widget_get_native ((GtkWidget*) self);
	_tmp3_ = gtk_native_get_surface (_tmp2_);
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, gdk_toplevel_get_type ()) ? ((GdkToplevel*) _tmp3_) : NULL);
	toplevel = _tmp4_;
	_tmp5_ = toplevel;
	if (_tmp5_ != NULL) {
		GdkToplevel* _tmp6_;
		_tmp6_ = toplevel;
		gdk_toplevel_restore_system_shortcuts (_tmp6_);
		self->priv->system_shortcuts_inhibited = FALSE;
	}
	_g_object_unref0 (toplevel);
}

static void
ft_accelerator_chooser_window_set_mode (FtAcceleratorChooserWindow* self,
                                        FtAcceleratorChooserWindowMode mode)
{
	g_return_if_fail (self != NULL);
	self->priv->mode = mode;
	switch (mode) {
		case FT_ACCELERATOR_CHOOSER_WINDOW_MODE_CAPTURE:
		{
			GtkButton* _tmp0_;
			GtkButton* _tmp1_;
			GtkShortcutLabel* _tmp2_;
			GtkPicture* _tmp3_;
			GtkLabel* _tmp4_;
			_tmp0_ = self->priv->cancel_button;
			gtk_widget_set_visible ((GtkWidget*) _tmp0_, FALSE);
			_tmp1_ = self->priv->set_button;
			gtk_widget_set_visible ((GtkWidget*) _tmp1_, FALSE);
			_tmp2_ = self->priv->accelerator_label;
			gtk_widget_set_visible ((GtkWidget*) _tmp2_, FALSE);
			_tmp3_ = self->priv->capture_image;
			gtk_widget_set_visible ((GtkWidget*) _tmp3_, TRUE);
			_tmp4_ = self->priv->capture_hint;
			gtk_widget_set_visible ((GtkWidget*) _tmp4_, TRUE);
			ft_accelerator_chooser_window_inhibit_system_shortcuts (self);
			break;
		}
		case FT_ACCELERATOR_CHOOSER_WINDOW_MODE_REVIEW:
		{
			GtkButton* _tmp5_;
			GtkButton* _tmp6_;
			GtkShortcutLabel* _tmp7_;
			GtkPicture* _tmp8_;
			GtkLabel* _tmp9_;
			_tmp5_ = self->priv->cancel_button;
			gtk_widget_set_visible ((GtkWidget*) _tmp5_, TRUE);
			_tmp6_ = self->priv->set_button;
			gtk_widget_set_visible ((GtkWidget*) _tmp6_, TRUE);
			_tmp7_ = self->priv->accelerator_label;
			gtk_widget_set_visible ((GtkWidget*) _tmp7_, TRUE);
			_tmp8_ = self->priv->capture_image;
			gtk_widget_set_visible ((GtkWidget*) _tmp8_, FALSE);
			_tmp9_ = self->priv->capture_hint;
			gtk_widget_set_visible ((GtkWidget*) _tmp9_, FALSE);
			break;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
	if (mode != FT_ACCELERATOR_CHOOSER_WINDOW_MODE_CAPTURE) {
		ft_accelerator_chooser_window_uninhibit_system_shortcuts (self);
	}
}

static void
ft_accelerator_chooser_window_on_cancel_button_clicked (FtAcceleratorChooserWindow* self)
{
	g_return_if_fail (self != NULL);
	g_signal_emit (self, ft_accelerator_chooser_window_signals[FT_ACCELERATOR_CHOOSER_WINDOW_RESPONSE_SIGNAL], 0, (gint) GTK_RESPONSE_CANCEL);
}

static void
_ft_accelerator_chooser_window_on_cancel_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                            gpointer self)
{
	ft_accelerator_chooser_window_on_cancel_button_clicked ((FtAcceleratorChooserWindow*) self);
}

static void
ft_accelerator_chooser_window_on_set_button_clicked (FtAcceleratorChooserWindow* self)
{
	g_return_if_fail (self != NULL);
	g_signal_emit (self, ft_accelerator_chooser_window_signals[FT_ACCELERATOR_CHOOSER_WINDOW_RESPONSE_SIGNAL], 0, (gint) GTK_RESPONSE_APPLY);
}

static void
_ft_accelerator_chooser_window_on_set_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                         gpointer self)
{
	ft_accelerator_chooser_window_on_set_button_clicked ((FtAcceleratorChooserWindow*) self);
}

static gpointer
_gdk_event_ref0 (gpointer self)
{
	return self ? gdk_event_ref (self) : NULL;
}

static gboolean
ft_accelerator_chooser_window_on_key_pressed (FtAcceleratorChooserWindow* self,
                                              GtkEventControllerKey* event_controller,
                                              guint keyval,
                                              guint keycode,
                                              GdkModifierType state)
{
	GdkKeyEvent* event = NULL;
	GdkEvent* _tmp0_;
	GdkKeyEvent* _tmp1_;
	gboolean _tmp2_ = FALSE;
	GdkKeyEvent* _tmp3_;
	FtAccelerator accelerator = {0};
	FtAccelerator _tmp5_ = {0};
	FtAccelerator _tmp6_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event_controller != NULL, FALSE);
	_tmp0_ = gtk_event_controller_get_current_event ((GtkEventController*) event_controller);
	_tmp1_ = _gdk_event_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, gdk_key_event_get_type ()) ? ((GdkKeyEvent*) _tmp0_) : NULL);
	event = _tmp1_;
	if (self->priv->mode != FT_ACCELERATOR_CHOOSER_WINDOW_MODE_CAPTURE) {
		if (keyval == GDK_KEY_Return) {
			g_signal_emit (self, ft_accelerator_chooser_window_signals[FT_ACCELERATOR_CHOOSER_WINDOW_RESPONSE_SIGNAL], 0, (gint) GTK_RESPONSE_APPLY);
			result = GDK_EVENT_STOP;
			_gdk_event_unref0 (event);
			return result;
		}
		result = GDK_EVENT_PROPAGATE;
		_gdk_event_unref0 (event);
		return result;
	}
	_tmp3_ = event;
	if (_tmp3_ == NULL) {
		_tmp2_ = TRUE;
	} else {
		GdkKeyEvent* _tmp4_;
		_tmp4_ = event;
		_tmp2_ = gdk_key_event_is_modifier (_tmp4_);
	}
	if (_tmp2_) {
		result = GDK_EVENT_STOP;
		_gdk_event_unref0 (event);
		return result;
	}
	ft_accelerator_from_keycode (keycode, state, gtk_event_controller_key_get_group (event_controller), &_tmp5_);
	accelerator = _tmp5_;
	_tmp6_ = accelerator;
	if (_tmp6_.modifiers == GDK_NO_MODIFIER_MASK) {
		switch (keyval) {
			case GDK_KEY_Escape:
			{
				g_signal_emit (self, ft_accelerator_chooser_window_signals[FT_ACCELERATOR_CHOOSER_WINDOW_RESPONSE_SIGNAL], 0, (gint) GTK_RESPONSE_CANCEL);
				result = GDK_EVENT_STOP;
				_gdk_event_unref0 (event);
				return result;
			}
			case GDK_KEY_BackSpace:
			{
				ft_accelerator_chooser_window_set_accelerator (self, "");
				g_signal_emit (self, ft_accelerator_chooser_window_signals[FT_ACCELERATOR_CHOOSER_WINDOW_RESPONSE_SIGNAL], 0, (gint) GTK_RESPONSE_APPLY);
				result = GDK_EVENT_STOP;
				_gdk_event_unref0 (event);
				return result;
			}
			default:
			{
				break;
			}
		}
	}
	if (ft_accelerator_is_valid (&accelerator)) {
		gchar* _tmp7_;
		gchar* _tmp8_;
		_tmp7_ = ft_accelerator_to_string (&accelerator);
		_tmp8_ = _tmp7_;
		ft_accelerator_chooser_window_set_accelerator (self, _tmp8_);
		_g_free0 (_tmp8_);
		ft_accelerator_chooser_window_set_mode (self, FT_ACCELERATOR_CHOOSER_WINDOW_MODE_REVIEW);
	}
	result = GDK_EVENT_STOP;
	_gdk_event_unref0 (event);
	return result;
}

static gboolean
_ft_accelerator_chooser_window_on_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                                    guint keyval,
                                                                                    guint keycode,
                                                                                    GdkModifierType state,
                                                                                    gpointer self)
{
	gboolean result;
	result = ft_accelerator_chooser_window_on_key_pressed ((FtAcceleratorChooserWindow*) self, _sender, keyval, keycode, state);
	return result;
}

static void
ft_accelerator_chooser_window_real_map (GtkWidget* base)
{
	FtAcceleratorChooserWindow * self;
	self = (FtAcceleratorChooserWindow*) base;
	GTK_WIDGET_CLASS (ft_accelerator_chooser_window_parent_class)->map ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_window_get_type (), AdwWindow));
	if (self->priv->mode == FT_ACCELERATOR_CHOOSER_WINDOW_MODE_CAPTURE) {
		ft_accelerator_chooser_window_inhibit_system_shortcuts (self);
	}
}

static void
ft_accelerator_chooser_window_real_unmap (GtkWidget* base)
{
	FtAcceleratorChooserWindow * self;
	self = (FtAcceleratorChooserWindow*) base;
	ft_accelerator_chooser_window_uninhibit_system_shortcuts (self);
	GTK_WIDGET_CLASS (ft_accelerator_chooser_window_parent_class)->unmap ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_window_get_type (), AdwWindow));
}

static void
ft_accelerator_chooser_window_real_dispose (GObject* base)
{
	FtAcceleratorChooserWindow * self;
	self = (FtAcceleratorChooserWindow*) base;
	_g_object_unref0 (self->priv->keyboard_manager);
	self->priv->keyboard_manager = NULL;
	G_OBJECT_CLASS (ft_accelerator_chooser_window_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_window_get_type (), AdwWindow));
}

const gchar*
ft_accelerator_chooser_window_get_description (FtAcceleratorChooserWindow* self)
{
	const gchar* result;
	GtkLabel* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->description_label;
	_tmp1_ = gtk_label_get_label (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
ft_accelerator_chooser_window_set_description (FtAcceleratorChooserWindow* self,
                                               const gchar* value)
{
	GtkLabel* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->description_label;
	gtk_label_set_label (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, ft_accelerator_chooser_window_properties[FT_ACCELERATOR_CHOOSER_WINDOW_DESCRIPTION_PROPERTY]);
}

const gchar*
ft_accelerator_chooser_window_get_accelerator (FtAcceleratorChooserWindow* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_accelerator;
	result = _tmp0_;
	return result;
}

void
ft_accelerator_chooser_window_set_accelerator (FtAcceleratorChooserWindow* self,
                                               const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = ft_accelerator_chooser_window_get_accelerator (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_accelerator);
		self->priv->_accelerator = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, ft_accelerator_chooser_window_properties[FT_ACCELERATOR_CHOOSER_WINDOW_ACCELERATOR_PROPERTY]);
	}
}

static void
ft_accelerator_chooser_window_real_response (FtAcceleratorChooserWindow* self,
                                             gint response_id)
{
	gtk_window_close ((GtkWindow*) self);
}

static GObject *
ft_accelerator_chooser_window_constructor (GType type,
                                           guint n_construct_properties,
                                           GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FtAcceleratorChooserWindow * self;
	FtKeyboardManager* _tmp0_;
	parent_class = G_OBJECT_CLASS (ft_accelerator_chooser_window_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_ACCELERATOR_CHOOSER_WINDOW, FtAcceleratorChooserWindow);
	_tmp0_ = ft_keyboard_manager_new ();
	_g_object_unref0 (self->priv->keyboard_manager);
	self->priv->keyboard_manager = _tmp0_;
	ft_accelerator_chooser_window_set_mode (self, FT_ACCELERATOR_CHOOSER_WINDOW_MODE_CAPTURE);
	return obj;
}

static void
ft_accelerator_chooser_window_class_init (FtAcceleratorChooserWindowClass * klass,
                                          gpointer klass_data)
{
	ft_accelerator_chooser_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtAcceleratorChooserWindow_private_offset);
	((GtkWidgetClass *) klass)->map = (void (*) (GtkWidget*)) ft_accelerator_chooser_window_real_map;
	((GtkWidgetClass *) klass)->unmap = (void (*) (GtkWidget*)) ft_accelerator_chooser_window_real_unmap;
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_accelerator_chooser_window_real_dispose;
	((FtAcceleratorChooserWindowClass *) klass)->response = ft_accelerator_chooser_window_real_response;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_accelerator_chooser_window_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_accelerator_chooser_window_set_property;
	G_OBJECT_CLASS (klass)->constructor = ft_accelerator_chooser_window_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_accelerator_chooser_window_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_ACCELERATOR_CHOOSER_WINDOW_DESCRIPTION_PROPERTY, ft_accelerator_chooser_window_properties[FT_ACCELERATOR_CHOOSER_WINDOW_DESCRIPTION_PROPERTY] = g_param_spec_string ("description", "description", "description", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_ACCELERATOR_CHOOSER_WINDOW_ACCELERATOR_PROPERTY, ft_accelerator_chooser_window_properties[FT_ACCELERATOR_CHOOSER_WINDOW_ACCELERATOR_PROPERTY] = g_param_spec_string ("accelerator", "accelerator", "accelerator", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/io/github/focustimerhq/FocusTimer/ui/preferences/keyboard-shortcuts/accelerator-chooser-window.ui");
	ft_accelerator_chooser_window_signals[FT_ACCELERATOR_CHOOSER_WINDOW_RESPONSE_SIGNAL] = g_signal_new ("response", FT_TYPE_ACCELERATOR_CHOOSER_WINDOW, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (FtAcceleratorChooserWindowClass, response), NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "cancel_button", FALSE, FtAcceleratorChooserWindow_private_offset + G_STRUCT_OFFSET (FtAcceleratorChooserWindowPrivate, cancel_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "set_button", FALSE, FtAcceleratorChooserWindow_private_offset + G_STRUCT_OFFSET (FtAcceleratorChooserWindowPrivate, set_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "description_label", FALSE, FtAcceleratorChooserWindow_private_offset + G_STRUCT_OFFSET (FtAcceleratorChooserWindowPrivate, description_label));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "accelerator_label", FALSE, FtAcceleratorChooserWindow_private_offset + G_STRUCT_OFFSET (FtAcceleratorChooserWindowPrivate, accelerator_label));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "capture_image", FALSE, FtAcceleratorChooserWindow_private_offset + G_STRUCT_OFFSET (FtAcceleratorChooserWindowPrivate, capture_image));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "capture_hint", FALSE, FtAcceleratorChooserWindow_private_offset + G_STRUCT_OFFSET (FtAcceleratorChooserWindowPrivate, capture_hint));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_cancel_button_clicked", G_CALLBACK(_ft_accelerator_chooser_window_on_cancel_button_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_set_button_clicked", G_CALLBACK(_ft_accelerator_chooser_window_on_set_button_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_key_pressed", G_CALLBACK(_ft_accelerator_chooser_window_on_key_pressed_gtk_event_controller_key_key_pressed));
}

static void
ft_accelerator_chooser_window_instance_init (FtAcceleratorChooserWindow * self,
                                             gpointer klass)
{
	self->priv = ft_accelerator_chooser_window_get_instance_private (self);
	self->priv->system_shortcuts_inhibited = FALSE;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
ft_accelerator_chooser_window_finalize (GObject * obj)
{
	FtAcceleratorChooserWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_ACCELERATOR_CHOOSER_WINDOW, FtAcceleratorChooserWindow);
	_g_free0 (self->priv->_accelerator);
	_g_object_unref0 (self->priv->keyboard_manager);
	G_OBJECT_CLASS (ft_accelerator_chooser_window_parent_class)->finalize (obj);
}

static GType
ft_accelerator_chooser_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtAcceleratorChooserWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_accelerator_chooser_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtAcceleratorChooserWindow), 0, (GInstanceInitFunc) ft_accelerator_chooser_window_instance_init, NULL };
	GType ft_accelerator_chooser_window_type_id;
	ft_accelerator_chooser_window_type_id = g_type_register_static (adw_window_get_type (), "FtAcceleratorChooserWindow", &g_define_type_info, 0);
	FtAcceleratorChooserWindow_private_offset = g_type_add_instance_private (ft_accelerator_chooser_window_type_id, sizeof (FtAcceleratorChooserWindowPrivate));
	return ft_accelerator_chooser_window_type_id;
}

GType
ft_accelerator_chooser_window_get_type (void)
{
	static volatile gsize ft_accelerator_chooser_window_type_id__once = 0;
	if (g_once_init_enter (&ft_accelerator_chooser_window_type_id__once)) {
		GType ft_accelerator_chooser_window_type_id;
		ft_accelerator_chooser_window_type_id = ft_accelerator_chooser_window_get_type_once ();
		g_once_init_leave (&ft_accelerator_chooser_window_type_id__once, ft_accelerator_chooser_window_type_id);
	}
	return ft_accelerator_chooser_window_type_id__once;
}

static void
_vala_ft_accelerator_chooser_window_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec)
{
	FtAcceleratorChooserWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_ACCELERATOR_CHOOSER_WINDOW, FtAcceleratorChooserWindow);
	switch (property_id) {
		case FT_ACCELERATOR_CHOOSER_WINDOW_DESCRIPTION_PROPERTY:
		g_value_set_string (value, ft_accelerator_chooser_window_get_description (self));
		break;
		case FT_ACCELERATOR_CHOOSER_WINDOW_ACCELERATOR_PROPERTY:
		g_value_set_string (value, ft_accelerator_chooser_window_get_accelerator (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_accelerator_chooser_window_set_property (GObject * object,
                                                  guint property_id,
                                                  const GValue * value,
                                                  GParamSpec * pspec)
{
	FtAcceleratorChooserWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_ACCELERATOR_CHOOSER_WINDOW, FtAcceleratorChooserWindow);
	switch (property_id) {
		case FT_ACCELERATOR_CHOOSER_WINDOW_DESCRIPTION_PROPERTY:
		ft_accelerator_chooser_window_set_description (self, g_value_get_string (value));
		break;
		case FT_ACCELERATOR_CHOOSER_WINDOW_ACCELERATOR_PROPERTY:
		ft_accelerator_chooser_window_set_accelerator (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

