/* preferences-panel-automation.c generated by valac 0.56.19, the Vala compiler
 * generated from preferences-panel-automation.vala, do not modify */

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

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

enum  {
	FT_PREFERENCES_PANEL_AUTOMATION_0_PROPERTY,
	FT_PREFERENCES_PANEL_AUTOMATION_NUM_PROPERTIES
};
static GParamSpec* ft_preferences_panel_automation_properties[FT_PREFERENCES_PANEL_AUTOMATION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
typedef struct _Block28Data Block28Data;
typedef struct _Block19Data Block19Data;
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _FtPreferencesPanelAutomationPrivate {
	AdwPreferencesPage* page;
	AdwPreferencesRow* add_row;
	FtActionManager* action_manager;
	GHashTable* rows;
	GtkListBox* listbox;
	guint update_idle_id;
};

struct _Block28Data {
	int _ref_count_;
	FtPreferencesPanelAutomation* self;
	GHashTable* to_remove;
};

struct _Block19Data {
	int _ref_count_;
	GHashTable* self;
	GFunc func;
	gpointer func_target;
};

static gint FtPreferencesPanelAutomation_private_offset;
static gpointer ft_preferences_panel_automation_parent_class = NULL;

static gint ft_preferences_panel_automation_sort_func (GtkListBoxRow* row_1,
                                                GtkListBoxRow* row_2);
static void ft_preferences_panel_automation_update (FtPreferencesPanelAutomation* self);
static Block28Data* block28_data_ref (Block28Data* _data28_);
static void block28_data_unref (void * _userdata_);
static void __lambda79_ (Block28Data* _data28_,
                  const gchar* uuid,
                  FtActionListBoxRow* row);
static void ___lambda79__gh_func (gconstpointer key,
                           gconstpointer value,
                           gpointer self);
static void ft_preferences_panel_automation_on_move_row (FtPreferencesPanelAutomation* self,
                                                  FtActionListBoxRow* row,
                                                  FtActionListBoxRow* destination_row);
static void _ft_preferences_panel_automation_on_move_row_ft_action_list_box_row_move_row (FtActionListBoxRow* _sender,
                                                                                   FtActionListBoxRow* destination_row,
                                                                                   gpointer self);
static Block19Data* block19_data_ref (Block19Data* _data19_);
static void block19_data_unref (void * _userdata_);
static void ___lambda2__gh_func (gconstpointer key,
                          gconstpointer value,
                          gpointer self);
static void __lambda80_ (FtPreferencesPanelAutomation* self,
                  FtActionListBoxRow* row);
static void ___lambda80__gfunc (gconstpointer data,
                         gpointer self);
static void ft_preferences_panel_automation_open_action_edit_window (FtPreferencesPanelAutomation* self,
                                                              FtAction* action);
static void ft_preferences_panel_automation_on_items_changed (FtPreferencesPanelAutomation* self,
                                                       guint position,
                                                       guint removed,
                                                       guint added);
static gboolean ___lambda81_ (FtPreferencesPanelAutomation* self);
static gboolean ____lambda81__gtk_tick_callback (GtkWidget* widget,
                                          GdkFrameClock* frame_clock,
                                          gpointer self);
static void ft_preferences_panel_automation_on_listbox_row_activated (FtPreferencesPanelAutomation* self,
                                                               GtkListBoxRow* row);
static AdwPreferencesPage* ft_preferences_panel_automation_real_get_preferences_page (FtPreferencesPanel* base);
static void ft_preferences_panel_automation_real_dispose (GObject* base);
static void _ft_preferences_panel_automation_on_items_changed_g_list_model_items_changed (GListModel* _sender,
                                                                                   guint position,
                                                                                   guint removed,
                                                                                   guint added,
                                                                                   gpointer self);
static void _ft_preferences_panel_automation_on_listbox_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                                           GtkListBoxRow* row,
                                                                                           gpointer self);
static GObject * ft_preferences_panel_automation_constructor (GType type,
                                                       guint n_construct_properties,
                                                       GObjectConstructParam * construct_properties);
static void _g_free0_ (gpointer var);
static gint _ft_preferences_panel_automation_sort_func_gtk_list_box_sort_func (GtkListBoxRow* row1,
                                                                        GtkListBoxRow* row2,
                                                                        gpointer self);
static void ft_preferences_panel_automation_finalize (GObject * obj);
static GType ft_preferences_panel_automation_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
ft_preferences_panel_automation_get_instance_private (FtPreferencesPanelAutomation* self)
{
	return G_STRUCT_MEMBER_P (self, FtPreferencesPanelAutomation_private_offset);
}

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

static gint
ft_preferences_panel_automation_sort_func (GtkListBoxRow* row_1,
                                           GtkListBoxRow* row_2)
{
	FtActionListBoxRow* action_row_1 = NULL;
	FtActionListBoxRow* _tmp0_;
	FtActionListBoxRow* action_row_2 = NULL;
	FtActionListBoxRow* _tmp1_;
	FtActionListBoxRow* _tmp2_;
	FtActionListBoxRow* _tmp3_;
	FtActionListBoxRow* _tmp4_;
	guint _tmp5_;
	guint _tmp6_;
	FtActionListBoxRow* _tmp7_;
	guint _tmp8_;
	guint _tmp9_;
	gint result;
	g_return_val_if_fail (row_1 != NULL, -1);
	g_return_val_if_fail (row_2 != NULL, -1);
	_tmp0_ = _g_object_ref0 (FT_IS_ACTION_LIST_BOX_ROW (row_1) ? ((FtActionListBoxRow*) row_1) : NULL);
	action_row_1 = _tmp0_;
	_tmp1_ = _g_object_ref0 (FT_IS_ACTION_LIST_BOX_ROW (row_2) ? ((FtActionListBoxRow*) row_2) : NULL);
	action_row_2 = _tmp1_;
	_tmp2_ = action_row_1;
	if (_tmp2_ == NULL) {
		result = 1;
		_g_object_unref0 (action_row_2);
		_g_object_unref0 (action_row_1);
		return result;
	}
	_tmp3_ = action_row_2;
	if (_tmp3_ == NULL) {
		result = -1;
		_g_object_unref0 (action_row_2);
		_g_object_unref0 (action_row_1);
		return result;
	}
	_tmp4_ = action_row_1;
	_tmp5_ = ft_action_list_box_row_get_sort_order (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = action_row_2;
	_tmp8_ = ft_action_list_box_row_get_sort_order (_tmp7_);
	_tmp9_ = _tmp8_;
	result = ((gint) _tmp6_) - ((gint) _tmp9_);
	_g_object_unref0 (action_row_2);
	_g_object_unref0 (action_row_1);
	return result;
}

static Block28Data*
block28_data_ref (Block28Data* _data28_)
{
	g_atomic_int_inc (&_data28_->_ref_count_);
	return _data28_;
}

static void
block28_data_unref (void * _userdata_)
{
	Block28Data* _data28_;
	_data28_ = (Block28Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data28_->_ref_count_)) {
		FtPreferencesPanelAutomation* self;
		self = _data28_->self;
		_g_hash_table_unref0 (_data28_->to_remove);
		_g_object_unref0 (self);
		g_slice_free (Block28Data, _data28_);
	}
}

static void
__lambda79_ (Block28Data* _data28_,
             const gchar* uuid,
             FtActionListBoxRow* row)
{
	FtPreferencesPanelAutomation* self;
	GHashTable* _tmp0_;
	self = _data28_->self;
	g_return_if_fail (uuid != NULL);
	g_return_if_fail (row != NULL);
	_tmp0_ = _data28_->to_remove;
	g_hash_table_add (_tmp0_, row);
}

static void
___lambda79__gh_func (gconstpointer key,
                      gconstpointer value,
                      gpointer self)
{
	__lambda79_ (self, (const gchar*) key, (FtActionListBoxRow*) value);
}

static void
_ft_preferences_panel_automation_on_move_row_ft_action_list_box_row_move_row (FtActionListBoxRow* _sender,
                                                                              FtActionListBoxRow* destination_row,
                                                                              gpointer self)
{
	ft_preferences_panel_automation_on_move_row ((FtPreferencesPanelAutomation*) self, _sender, destination_row);
}

static Block19Data*
block19_data_ref (Block19Data* _data19_)
{
	g_atomic_int_inc (&_data19_->_ref_count_);
	return _data19_;
}

static void
block19_data_unref (void * _userdata_)
{
	Block19Data* _data19_;
	_data19_ = (Block19Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data19_->_ref_count_)) {
		GHashTable* self;
		self = _data19_->self;
		_g_hash_table_unref0 (self);
		g_slice_free (Block19Data, _data19_);
	}
}

static void
__lambda2_ (Block19Data* _data19_,
            gconstpointer k,
            gconstpointer v)
{
	GHashTable* self;
	self = _data19_->self;
	_data19_->func (v, _data19_->func_target);
}

static void
___lambda2__gh_func (gconstpointer key,
                     gconstpointer value,
                     gpointer self)
{
	__lambda2_ (self, key, value);
}

static void
_vala_g_hash_set_foreach (GHashTable* self,
                          GFunc func,
                          gpointer func_target)
{
	Block19Data* _data19_;
	g_return_if_fail (self != NULL);
	_data19_ = g_slice_new0 (Block19Data);
	_data19_->_ref_count_ = 1;
	_data19_->self = g_hash_table_ref (self);
	_data19_->func = func;
	_data19_->func_target = func_target;
	g_hash_table_foreach ((GHashTable*) self, ___lambda2__gh_func, _data19_);
	block19_data_unref (_data19_);
	_data19_ = NULL;
}

static void
__lambda80_ (FtPreferencesPanelAutomation* self,
             FtActionListBoxRow* row)
{
	guint _tmp0_;
	GHashTable* _tmp1_;
	FtAction* _tmp2_;
	FtAction* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	GtkListBox* _tmp6_;
	g_return_if_fail (row != NULL);
	g_signal_parse_name ("move-row", FT_TYPE_ACTION_LIST_BOX_ROW, &_tmp0_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (row, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _ft_preferences_panel_automation_on_move_row_ft_action_list_box_row_move_row, self);
	_tmp1_ = self->priv->rows;
	_tmp2_ = ft_action_list_box_row_get_action (row);
	_tmp3_ = _tmp2_;
	_tmp4_ = ft_action_get_uuid (_tmp3_);
	_tmp5_ = _tmp4_;
	g_hash_table_remove (_tmp1_, _tmp5_);
	_tmp6_ = self->priv->listbox;
	gtk_list_box_remove (_tmp6_, (GtkWidget*) row);
}

static void
___lambda80__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda80_ ((FtPreferencesPanelAutomation*) self, (FtActionListBoxRow*) data);
}

static void
ft_preferences_panel_automation_update (FtPreferencesPanelAutomation* self)
{
	Block28Data* _data28_;
	FtActionListModel* model = NULL;
	FtActionManager* _tmp0_;
	FtActionListModel* _tmp1_;
	FtActionListModel* _tmp2_;
	FtActionListModel* _tmp3_;
	guint n_items = 0U;
	FtActionListModel* _tmp4_;
	guint _tmp5_;
	guint _tmp6_;
	GHashFunc _tmp7_;
	GEqualFunc _tmp8_;
	GHashTable* _tmp9_;
	GHashTable* _tmp10_;
	GHashTable* _tmp39_;
	GtkListBox* _tmp40_;
	g_return_if_fail (self != NULL);
	_data28_ = g_slice_new0 (Block28Data);
	_data28_->_ref_count_ = 1;
	_data28_->self = g_object_ref (self);
	_tmp0_ = self->priv->action_manager;
	_tmp1_ = ft_action_manager_get_model (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	model = _tmp3_;
	_tmp4_ = model;
	_tmp5_ = ft_action_list_model_get_n_items (_tmp4_);
	_tmp6_ = _tmp5_;
	n_items = _tmp6_;
	_tmp7_ = g_direct_hash;
	_tmp8_ = g_direct_equal;
	_tmp9_ = g_hash_table_new_full (_tmp7_, _tmp8_, NULL, NULL);
	_data28_->to_remove = _tmp9_;
	if (self->priv->update_idle_id != ((guint) 0)) {
		gtk_widget_remove_tick_callback ((GtkWidget*) self, self->priv->update_idle_id);
		self->priv->update_idle_id = (guint) 0;
	}
	_tmp10_ = self->priv->rows;
	g_hash_table_foreach (_tmp10_, ___lambda79__gh_func, _data28_);
	{
		guint position = 0U;
		position = 0U;
		{
			gboolean _tmp11_ = FALSE;
			_tmp11_ = TRUE;
			while (TRUE) {
				FtAction* action = NULL;
				FtActionListModel* _tmp13_;
				GObject* _tmp14_;
				FtAction* _tmp15_;
				FtActionListBoxRow* row = NULL;
				GHashTable* _tmp16_;
				FtAction* _tmp17_;
				const gchar* _tmp18_;
				const gchar* _tmp19_;
				gconstpointer _tmp20_;
				FtActionListBoxRow* _tmp21_;
				FtActionListBoxRow* _tmp22_;
				FtActionListBoxRow* _tmp36_;
				GHashTable* _tmp37_;
				FtActionListBoxRow* _tmp38_;
				if (!_tmp11_) {
					guint _tmp12_;
					_tmp12_ = position;
					position = _tmp12_ + 1;
				}
				_tmp11_ = FALSE;
				if (!(position < n_items)) {
					break;
				}
				_tmp13_ = model;
				_tmp14_ = g_list_model_get_item ((GListModel*) _tmp13_, position);
				action = G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, FT_TYPE_ACTION, FtAction);
				_tmp15_ = action;
				_vala_assert (_tmp15_ != NULL, "action != null");
				_tmp16_ = self->priv->rows;
				_tmp17_ = action;
				_tmp18_ = ft_action_get_uuid (_tmp17_);
				_tmp19_ = _tmp18_;
				_tmp20_ = g_hash_table_lookup (_tmp16_, _tmp19_);
				_tmp21_ = _g_object_ref0 ((FtActionListBoxRow*) _tmp20_);
				row = _tmp21_;
				_tmp22_ = row;
				if (_tmp22_ != NULL) {
					FtActionListBoxRow* _tmp23_;
					FtAction* _tmp24_;
					_tmp23_ = row;
					_tmp24_ = action;
					ft_action_list_box_row_set_action (_tmp23_, _tmp24_);
				} else {
					FtAction* _tmp25_;
					FtActionListBoxRow* _tmp26_;
					FtActionListBoxRow* _tmp27_;
					GtkListBox* _tmp28_;
					FtActionListBoxRow* _tmp29_;
					GHashTable* _tmp30_;
					FtAction* _tmp31_;
					const gchar* _tmp32_;
					const gchar* _tmp33_;
					gchar* _tmp34_;
					FtActionListBoxRow* _tmp35_;
					_tmp25_ = action;
					_tmp26_ = ft_action_list_box_row_new (_tmp25_);
					g_object_ref_sink (_tmp26_);
					_g_object_unref0 (row);
					row = _tmp26_;
					_tmp27_ = row;
					g_signal_connect_object (_tmp27_, "move-row", (GCallback) _ft_preferences_panel_automation_on_move_row_ft_action_list_box_row_move_row, self, 0);
					_tmp28_ = self->priv->listbox;
					_tmp29_ = row;
					gtk_list_box_append (_tmp28_, (GtkWidget*) _tmp29_);
					_tmp30_ = self->priv->rows;
					_tmp31_ = action;
					_tmp32_ = ft_action_get_uuid (_tmp31_);
					_tmp33_ = _tmp32_;
					_tmp34_ = g_strdup (_tmp33_);
					_tmp35_ = row;
					g_hash_table_insert (_tmp30_, _tmp34_, _tmp35_);
				}
				_tmp36_ = row;
				ft_action_list_box_row_set_sort_order (_tmp36_, position);
				_tmp37_ = _data28_->to_remove;
				_tmp38_ = row;
				g_hash_table_remove (_tmp37_, _tmp38_);
				_g_object_unref0 (row);
				_g_object_unref0 (action);
			}
		}
	}
	_tmp39_ = _data28_->to_remove;
	_vala_g_hash_set_foreach (_tmp39_, ___lambda80__gfunc, self);
	_tmp40_ = self->priv->listbox;
	gtk_list_box_invalidate_sort (_tmp40_);
	_g_object_unref0 (model);
	block28_data_unref (_data28_);
	_data28_ = NULL;
}

static void
ft_preferences_panel_automation_open_action_edit_window (FtPreferencesPanelAutomation* self,
                                                         FtAction* action)
{
	FtActionEditWindow* window = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	FtActionEditWindow* _tmp2_;
	GtkRoot* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = ft_action_get_uuid (action);
	_tmp1_ = _tmp0_;
	_tmp2_ = ft_action_edit_window_new (_tmp1_);
	g_object_ref_sink (_tmp2_);
	window = _tmp2_;
	_tmp3_ = gtk_widget_get_root ((GtkWidget*) self);
	gtk_window_set_transient_for ((GtkWindow*) window, G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_window_get_type (), GtkWindow));
	gtk_window_present ((GtkWindow*) window);
	_g_object_unref0 (window);
}

static gboolean
___lambda81_ (FtPreferencesPanelAutomation* self)
{
	gboolean result;
	self->priv->update_idle_id = (guint) 0;
	ft_preferences_panel_automation_update (self);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
____lambda81__gtk_tick_callback (GtkWidget* widget,
                                 GdkFrameClock* frame_clock,
                                 gpointer self)
{
	gboolean result;
	result = ___lambda81_ ((FtPreferencesPanelAutomation*) self);
	return result;
}

static void
ft_preferences_panel_automation_on_items_changed (FtPreferencesPanelAutomation* self,
                                                  guint position,
                                                  guint removed,
                                                  guint added)
{
	g_return_if_fail (self != NULL);
	if (self->priv->update_idle_id == ((guint) 0)) {
		self->priv->update_idle_id = gtk_widget_add_tick_callback ((GtkWidget*) self, ____lambda81__gtk_tick_callback, g_object_ref (self), g_object_unref);
	}
}

static void
ft_preferences_panel_automation_on_listbox_row_activated (FtPreferencesPanelAutomation* self,
                                                          GtkListBoxRow* row)
{
	AdwPreferencesRow* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (row != NULL);
	_tmp0_ = self->priv->add_row;
	if (row == G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_list_box_row_get_type (), GtkListBoxRow)) {
		FtEventAction* _tmp1_;
		FtEventAction* _tmp2_;
		_tmp1_ = ft_event_action_new (NULL);
		_tmp2_ = _tmp1_;
		ft_preferences_panel_automation_open_action_edit_window (self, (FtAction*) _tmp2_);
		_g_object_unref0 (_tmp2_);
	} else {
		FtAction* _tmp3_;
		FtAction* _tmp4_;
		_tmp3_ = ft_action_list_box_row_get_action (G_TYPE_CHECK_INSTANCE_CAST (row, FT_TYPE_ACTION_LIST_BOX_ROW, FtActionListBoxRow));
		_tmp4_ = _tmp3_;
		ft_preferences_panel_automation_open_action_edit_window (self, _tmp4_);
	}
}

static void
ft_preferences_panel_automation_on_move_row (FtPreferencesPanelAutomation* self,
                                             FtActionListBoxRow* row,
                                             FtActionListBoxRow* destination_row)
{
	FtActionManager* _tmp0_;
	FtActionListModel* _tmp1_;
	FtActionListModel* _tmp2_;
	FtAction* _tmp3_;
	FtAction* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	guint _tmp7_;
	guint _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (row != NULL);
	g_return_if_fail (destination_row != NULL);
	_tmp0_ = self->priv->action_manager;
	_tmp1_ = ft_action_manager_get_model (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = ft_action_list_box_row_get_action (row);
	_tmp4_ = _tmp3_;
	_tmp5_ = ft_action_get_uuid (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = ft_action_list_box_row_get_sort_order (destination_row);
	_tmp8_ = _tmp7_;
	ft_action_list_model_move_action (_tmp2_, _tmp6_, _tmp8_);
	ft_preferences_panel_automation_update (self);
}

static AdwPreferencesPage*
ft_preferences_panel_automation_real_get_preferences_page (FtPreferencesPanel* base)
{
	FtPreferencesPanelAutomation * self;
	AdwPreferencesPage* _tmp0_;
	AdwPreferencesPage* result;
	self = (FtPreferencesPanelAutomation*) base;
	_tmp0_ = self->priv->page;
	result = _tmp0_;
	return result;
}

static void
_ft_preferences_panel_automation_on_items_changed_g_list_model_items_changed (GListModel* _sender,
                                                                              guint position,
                                                                              guint removed,
                                                                              guint added,
                                                                              gpointer self)
{
	ft_preferences_panel_automation_on_items_changed ((FtPreferencesPanelAutomation*) self, position, removed, added);
}

static void
_ft_preferences_panel_automation_on_listbox_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                                      GtkListBoxRow* row,
                                                                                      gpointer self)
{
	ft_preferences_panel_automation_on_listbox_row_activated ((FtPreferencesPanelAutomation*) self, row);
}

static void
ft_preferences_panel_automation_real_dispose (GObject* base)
{
	FtPreferencesPanelAutomation * self;
	FtActionManager* _tmp0_;
	GtkListBox* _tmp5_;
	GHashTable* _tmp8_;
	self = (FtPreferencesPanelAutomation*) base;
	if (self->priv->update_idle_id != ((guint) 0)) {
		gtk_widget_remove_tick_callback ((GtkWidget*) self, self->priv->update_idle_id);
		self->priv->update_idle_id = (guint) 0;
	}
	_tmp0_ = self->priv->action_manager;
	if (_tmp0_ != NULL) {
		FtActionManager* _tmp1_;
		FtActionListModel* _tmp2_;
		FtActionListModel* _tmp3_;
		guint _tmp4_;
		_tmp1_ = self->priv->action_manager;
		_tmp2_ = ft_action_manager_get_model (_tmp1_);
		_tmp3_ = _tmp2_;
		g_signal_parse_name ("items-changed", g_list_model_get_type (), &_tmp4_, NULL, FALSE);
		g_signal_handlers_disconnect_matched ((GListModel*) _tmp3_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp4_, 0, NULL, (GCallback) _ft_preferences_panel_automation_on_items_changed_g_list_model_items_changed, self);
	}
	_tmp5_ = self->priv->listbox;
	if (_tmp5_ != NULL) {
		GtkListBox* _tmp6_;
		guint _tmp7_;
		_tmp6_ = self->priv->listbox;
		g_signal_parse_name ("row-activated", gtk_list_box_get_type (), &_tmp7_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp6_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp7_, 0, NULL, (GCallback) _ft_preferences_panel_automation_on_listbox_row_activated_gtk_list_box_row_activated, self);
	}
	_tmp8_ = self->priv->rows;
	if (_tmp8_ != NULL) {
		GHashTable* _tmp9_;
		_tmp9_ = self->priv->rows;
		g_hash_table_remove_all (_tmp9_);
		_g_hash_table_unref0 (self->priv->rows);
		self->priv->rows = NULL;
	}
	_g_hash_table_unref0 (self->priv->rows);
	self->priv->rows = NULL;
	self->priv->listbox = NULL;
	_g_object_unref0 (self->priv->action_manager);
	self->priv->action_manager = NULL;
	G_OBJECT_CLASS (ft_preferences_panel_automation_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, FT_TYPE_PREFERENCES_PANEL, FtPreferencesPanel));
}

FtPreferencesPanelAutomation*
ft_preferences_panel_automation_construct (GType object_type)
{
	FtPreferencesPanelAutomation * self = NULL;
	self = (FtPreferencesPanelAutomation*) ft_preferences_panel_construct (object_type);
	return self;
}

FtPreferencesPanelAutomation*
ft_preferences_panel_automation_new (void)
{
	return ft_preferences_panel_automation_construct (FT_TYPE_PREFERENCES_PANEL_AUTOMATION);
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static gint
_ft_preferences_panel_automation_sort_func_gtk_list_box_sort_func (GtkListBoxRow* row1,
                                                                   GtkListBoxRow* row2,
                                                                   gpointer self)
{
	gint result;
	result = ft_preferences_panel_automation_sort_func (row1, row2);
	return result;
}

static GObject *
ft_preferences_panel_automation_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FtPreferencesPanelAutomation * self;
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	FtActionManager* _tmp3_;
	FtActionManager* _tmp4_;
	FtActionListModel* _tmp5_;
	FtActionListModel* _tmp6_;
	AdwPreferencesRow* _tmp7_;
	GtkWidget* _tmp8_;
	GtkWidget* _tmp9_;
	GtkListBox* _tmp10_;
	GtkListBox* _tmp11_;
	GtkListBox* _tmp12_;
	parent_class = G_OBJECT_CLASS (ft_preferences_panel_automation_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_PREFERENCES_PANEL_AUTOMATION, FtPreferencesPanelAutomation);
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, _g_free0_, NULL);
	_g_hash_table_unref0 (self->priv->rows);
	self->priv->rows = _tmp2_;
	_tmp3_ = ft_action_manager_new ();
	_g_object_unref0 (self->priv->action_manager);
	self->priv->action_manager = _tmp3_;
	_tmp4_ = self->priv->action_manager;
	_tmp5_ = ft_action_manager_get_model (_tmp4_);
	_tmp6_ = _tmp5_;
	g_signal_connect_object ((GListModel*) _tmp6_, "items-changed", (GCallback) _ft_preferences_panel_automation_on_items_changed_g_list_model_items_changed, self, 0);
	_tmp7_ = self->priv->add_row;
	_tmp8_ = gtk_widget_get_parent ((GtkWidget*) _tmp7_);
	_tmp9_ = _tmp8_;
	self->priv->listbox = G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_list_box_get_type (), GtkListBox);
	_tmp10_ = self->priv->listbox;
	gtk_list_box_set_selection_mode (_tmp10_, GTK_SELECTION_NONE);
	_tmp11_ = self->priv->listbox;
	gtk_list_box_set_sort_func (_tmp11_, _ft_preferences_panel_automation_sort_func_gtk_list_box_sort_func, NULL, NULL);
	_tmp12_ = self->priv->listbox;
	g_signal_connect_object (_tmp12_, "row-activated", (GCallback) _ft_preferences_panel_automation_on_listbox_row_activated_gtk_list_box_row_activated, self, 0);
	ft_preferences_panel_automation_update (self);
	return obj;
}

static void
ft_preferences_panel_automation_class_init (FtPreferencesPanelAutomationClass * klass,
                                            gpointer klass_data)
{
	ft_preferences_panel_automation_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtPreferencesPanelAutomation_private_offset);
	((FtPreferencesPanelClass *) klass)->get_preferences_page = (AdwPreferencesPage* (*) (FtPreferencesPanel*)) ft_preferences_panel_automation_real_get_preferences_page;
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_preferences_panel_automation_real_dispose;
	G_OBJECT_CLASS (klass)->constructor = ft_preferences_panel_automation_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_preferences_panel_automation_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/io/github/focustimerhq/FocusTimer/ui/preferences/automation/preferences-panel-automation.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "page", FALSE, FtPreferencesPanelAutomation_private_offset + G_STRUCT_OFFSET (FtPreferencesPanelAutomationPrivate, page));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "add_row", FALSE, FtPreferencesPanelAutomation_private_offset + G_STRUCT_OFFSET (FtPreferencesPanelAutomationPrivate, add_row));
}

static void
ft_preferences_panel_automation_instance_init (FtPreferencesPanelAutomation * self,
                                               gpointer klass)
{
	self->priv = ft_preferences_panel_automation_get_instance_private (self);
	self->priv->action_manager = NULL;
	self->priv->rows = NULL;
	self->priv->listbox = NULL;
	self->priv->update_idle_id = (guint) 0;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
ft_preferences_panel_automation_finalize (GObject * obj)
{
	FtPreferencesPanelAutomation * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_PREFERENCES_PANEL_AUTOMATION, FtPreferencesPanelAutomation);
	_g_object_unref0 (self->priv->action_manager);
	_g_hash_table_unref0 (self->priv->rows);
	G_OBJECT_CLASS (ft_preferences_panel_automation_parent_class)->finalize (obj);
}

static GType
ft_preferences_panel_automation_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtPreferencesPanelAutomationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_preferences_panel_automation_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtPreferencesPanelAutomation), 0, (GInstanceInitFunc) ft_preferences_panel_automation_instance_init, NULL };
	GType ft_preferences_panel_automation_type_id;
	ft_preferences_panel_automation_type_id = g_type_register_static (FT_TYPE_PREFERENCES_PANEL, "FtPreferencesPanelAutomation", &g_define_type_info, 0);
	FtPreferencesPanelAutomation_private_offset = g_type_add_instance_private (ft_preferences_panel_automation_type_id, sizeof (FtPreferencesPanelAutomationPrivate));
	return ft_preferences_panel_automation_type_id;
}

GType
ft_preferences_panel_automation_get_type (void)
{
	static volatile gsize ft_preferences_panel_automation_type_id__once = 0;
	if (g_once_init_enter (&ft_preferences_panel_automation_type_id__once)) {
		GType ft_preferences_panel_automation_type_id;
		ft_preferences_panel_automation_type_id = ft_preferences_panel_automation_get_type_once ();
		g_once_init_leave (&ft_preferences_panel_automation_type_id__once, ft_preferences_panel_automation_type_id);
	}
	return ft_preferences_panel_automation_type_id__once;
}

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;
}

