/* AppChooser.c generated by valac 0.56.19, the Vala compiler
 * generated from AppChooser.vala, do not modify */

/* SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
 */

#include "keyboard.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <gio/gdesktopappinfo.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
#include <glib-object.h>
#include <granite-7.h>
#include <glib/gi18n-lib.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  {
	KEYBOARD_SHORTCUTS_APP_CHOOSER_0_PROPERTY,
	KEYBOARD_SHORTCUTS_APP_CHOOSER_NUM_PROPERTIES
};
static GParamSpec* keyboard_shortcuts_app_chooser_properties[KEYBOARD_SHORTCUTS_APP_CHOOSER_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))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
enum  {
	KEYBOARD_SHORTCUTS_APP_CHOOSER_APP_CHOSEN_SIGNAL,
	KEYBOARD_SHORTCUTS_APP_CHOOSER_CUSTOM_COMMAND_CHOSEN_SIGNAL,
	KEYBOARD_SHORTCUTS_APP_CHOOSER_NUM_SIGNALS
};
static guint keyboard_shortcuts_app_chooser_signals[KEYBOARD_SHORTCUTS_APP_CHOOSER_NUM_SIGNALS] = {0};

struct _KeyboardShortcutsAppChooserPrivate {
	GtkListBox* list;
	GtkSearchEntry* search_entry;
	GtkEntry* custom_entry;
};

static gint KeyboardShortcutsAppChooser_private_offset;
static gpointer keyboard_shortcuts_app_chooser_parent_class = NULL;

static gchar** _vala_array_dup6 (gchar** self,
                          gssize length);
static gint keyboard_shortcuts_app_chooser_sort_function (KeyboardShortcutsAppChooser* self,
                                                   GtkListBoxRow* row1,
                                                   GtkListBoxRow* row2);
static gboolean keyboard_shortcuts_app_chooser_filter_function (KeyboardShortcutsAppChooser* self,
                                                         GtkListBoxRow* list_box_row);
static void keyboard_shortcuts_app_chooser_on_app_selected (KeyboardShortcutsAppChooser* self,
                                                     GtkListBoxRow* list_box_row);
static void _g_free0_ (gpointer var);
static void _g_variant_unref0_ (gpointer var);
static GVariant* _variant_new1 (const gchar* value);
static void keyboard_shortcuts_app_chooser_on_custom_command_entered (KeyboardShortcutsAppChooser* self);
static void g_cclosure_user_marshal_VOID__STRING_BOXED (GClosure * closure,
                                                 GValue * return_value,
                                                 guint n_param_values,
                                                 const GValue * param_values,
                                                 gpointer invocation_hint,
                                                 gpointer marshal_data);
static GObject * keyboard_shortcuts_app_chooser_constructor (GType type,
                                                      guint n_construct_properties,
                                                      GObjectConstructParam * construct_properties);
static gint _keyboard_shortcuts_app_chooser_sort_function_gtk_list_box_sort_func (GtkListBoxRow* row1,
                                                                           GtkListBoxRow* row2,
                                                                           gpointer self);
static gboolean _keyboard_shortcuts_app_chooser_filter_function_gtk_list_box_filter_func (GtkListBoxRow* row,
                                                                                   gpointer self);
static void _keyboard_shortcuts_app_chooser___lambda66_ (KeyboardShortcutsAppChooser* self);
static void __keyboard_shortcuts_app_chooser___lambda66__gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                                                   gpointer self);
static void _gtk_widget_hide_gtk_dialog_response (GtkDialog* _sender,
                                           gint response_id,
                                           gpointer self);
static void _keyboard_shortcuts_app_chooser_on_app_selected_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                                 GtkListBoxRow* row,
                                                                                 gpointer self);
static void _keyboard_shortcuts_app_chooser_on_custom_command_entered_gtk_entry_activate (GtkEntry* _sender,
                                                                                   gpointer self);
static void keyboard_shortcuts_app_chooser_finalize (GObject * obj);
static GType keyboard_shortcuts_app_chooser_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

static inline gpointer
keyboard_shortcuts_app_chooser_get_instance_private (KeyboardShortcutsAppChooser* self)
{
	return G_STRUCT_MEMBER_P (self, KeyboardShortcutsAppChooser_private_offset);
}

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

static gchar**
_vala_array_dup6 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

void
keyboard_shortcuts_app_chooser_init_list (KeyboardShortcutsAppChooser* self,
                                          GList* app_infos)
{
	g_return_if_fail (self != NULL);
	{
		GList* app_info_collection = NULL;
		GList* app_info_it = NULL;
		app_info_collection = app_infos;
		for (app_info_it = app_info_collection; app_info_it != NULL; app_info_it = app_info_it->next) {
			GDesktopAppInfo* _tmp0_;
			GDesktopAppInfo* app_info = NULL;
			_tmp0_ = _g_object_ref0 ((GDesktopAppInfo*) app_info_it->data);
			app_info = _tmp0_;
			{
				GIcon* _tmp1_ = NULL;
				GDesktopAppInfo* _tmp2_;
				GIcon* _tmp3_;
				GIcon* _tmp4_;
				GIcon* icon = NULL;
				GIcon* _tmp6_;
				gchar* name = NULL;
				GDesktopAppInfo* _tmp7_;
				const gchar* _tmp8_;
				gchar* _tmp9_;
				gchar* description = NULL;
				GDesktopAppInfo* _tmp10_;
				const gchar* _tmp11_;
				gchar* _tmp12_;
				gchar* filename = NULL;
				GDesktopAppInfo* _tmp13_;
				const gchar* _tmp14_;
				GFile* _tmp15_;
				GFile* _tmp16_;
				gchar* _tmp17_;
				gchar* _tmp18_;
				GtkListBox* _tmp19_;
				GIcon* _tmp20_;
				const gchar* _tmp21_;
				const gchar* _tmp22_;
				const gchar* _tmp23_;
				KeyboardShortcutsAppChooserRowInfo _tmp24_ = {0};
				KeyboardShortcutsAppChooserRow* _tmp25_;
				KeyboardShortcutsAppChooserRow* _tmp26_;
				GtkIconTheme* icon_theme = NULL;
				GdkDisplay* _tmp27_;
				GtkIconTheme* _tmp28_;
				gchar** actions = NULL;
				GDesktopAppInfo* _tmp29_;
				gchar** _tmp30_;
				gchar** _tmp31_;
				gchar** _tmp32_;
				gint _tmp32__length1;
				gint actions_length1;
				gint _actions_size_;
				_tmp2_ = app_info;
				_tmp3_ = g_app_info_get_icon ((GAppInfo*) _tmp2_);
				_tmp4_ = _g_object_ref0 (_tmp3_);
				_tmp1_ = _tmp4_;
				if (_tmp1_ == NULL) {
					GThemedIcon* _tmp5_;
					_tmp5_ = (GThemedIcon*) g_themed_icon_new ("application-default-icon");
					_g_object_unref0 (_tmp1_);
					_tmp1_ = (GIcon*) _tmp5_;
				}
				_tmp6_ = _tmp1_;
				_tmp1_ = NULL;
				icon = _tmp6_;
				_tmp7_ = app_info;
				_tmp8_ = g_app_info_get_name ((GAppInfo*) _tmp7_);
				_tmp9_ = g_strdup (_tmp8_);
				name = _tmp9_;
				_tmp10_ = app_info;
				_tmp11_ = g_app_info_get_description ((GAppInfo*) _tmp10_);
				_tmp12_ = g_strdup (_tmp11_);
				description = _tmp12_;
				_tmp13_ = app_info;
				_tmp14_ = g_desktop_app_info_get_filename (_tmp13_);
				_tmp15_ = g_file_new_for_path (_tmp14_);
				_tmp16_ = _tmp15_;
				_tmp17_ = g_file_get_basename (_tmp16_);
				_tmp18_ = _tmp17_;
				_g_object_unref0 (_tmp16_);
				filename = _tmp18_;
				_tmp19_ = self->priv->list;
				_tmp20_ = icon;
				_tmp21_ = name;
				_tmp22_ = description;
				_tmp23_ = filename;
				_g_object_unref0 (_tmp24_.icon);
				_tmp24_.icon = _tmp20_;
				_g_object_unref0 (_tmp24_.overlay_icon);
				_tmp24_.overlay_icon = NULL;
				_g_free0 (_tmp24_.name);
				_tmp24_.name = _tmp21_;
				_g_free0 (_tmp24_.description);
				_tmp24_.description = _tmp22_;
				_g_free0 (_tmp24_.action);
				_tmp24_.action = NULL;
				_g_free0 (_tmp24_.filename);
				_tmp24_.filename = _tmp23_;
				_tmp25_ = keyboard_shortcuts_app_chooser_row_new (&_tmp24_);
				g_object_ref_sink (_tmp25_);
				_tmp26_ = _tmp25_;
				gtk_list_box_prepend (_tmp19_, (GtkWidget*) _tmp26_);
				_g_object_unref0 (_tmp26_);
				_tmp27_ = gdk_display_get_default ();
				_tmp28_ = gtk_icon_theme_get_for_display (_tmp27_);
				icon_theme = _tmp28_;
				_tmp29_ = app_info;
				_tmp31_ = _tmp30_ = g_desktop_app_info_list_actions (_tmp29_);
				_tmp32_ = (_tmp31_ != NULL) ? _vala_array_dup6 (_tmp31_, _vala_array_length (_tmp30_)) : _tmp31_;
				_tmp32__length1 = _vala_array_length (_tmp30_);
				actions = _tmp32_;
				actions_length1 = _tmp32__length1;
				_actions_size_ = actions_length1;
				{
					gint i = 0;
					i = 0;
					{
						gboolean _tmp33_ = FALSE;
						_tmp33_ = TRUE;
						while (TRUE) {
							gchar** _tmp35_;
							gint _tmp35__length1;
							gchar* action = NULL;
							gchar** _tmp36_;
							gint _tmp36__length1;
							const gchar* _tmp37_;
							gchar* _tmp38_;
							GIcon* action_icon = NULL;
							GDesktopAppInfo* _tmp39_;
							const gchar* _tmp40_;
							GIcon* _tmp41_;
							gchar* action_name = NULL;
							const gchar* _tmp42_;
							GDesktopAppInfo* _tmp43_;
							const gchar* _tmp44_;
							gchar* _tmp45_;
							gchar* _tmp46_;
							gchar* _tmp47_;
							gchar* _tmp48_;
							GtkListBox* _tmp49_;
							GIcon* _tmp50_;
							GIcon* _tmp51_;
							const gchar* _tmp52_;
							const gchar* _tmp53_;
							const gchar* _tmp54_;
							const gchar* _tmp55_;
							KeyboardShortcutsAppChooserRowInfo _tmp56_ = {0};
							KeyboardShortcutsAppChooserRow* _tmp57_;
							KeyboardShortcutsAppChooserRow* _tmp58_;
							if (!_tmp33_) {
								gint _tmp34_;
								_tmp34_ = i;
								i = _tmp34_ + 1;
							}
							_tmp33_ = FALSE;
							_tmp35_ = actions;
							_tmp35__length1 = actions_length1;
							if (!(i < _tmp35__length1)) {
								break;
							}
							_tmp36_ = actions;
							_tmp36__length1 = actions_length1;
							_tmp37_ = _tmp36_[i];
							_tmp38_ = g_strdup (_tmp37_);
							action = _tmp38_;
							_tmp39_ = app_info;
							_tmp40_ = action;
							_tmp41_ = keyboard_shortcuts_utils_get_action_icon (_tmp39_, _tmp40_);
							action_icon = _tmp41_;
							_tmp42_ = name;
							_tmp43_ = app_info;
							_tmp44_ = action;
							_tmp45_ = g_desktop_app_info_get_action_name (_tmp43_, _tmp44_);
							_tmp46_ = _tmp45_;
							_tmp47_ = g_strdup_printf ("%s → %s", _tmp42_, _tmp46_);
							_tmp48_ = _tmp47_;
							_g_free0 (_tmp46_);
							action_name = _tmp48_;
							_tmp49_ = self->priv->list;
							_tmp50_ = icon;
							_tmp51_ = action_icon;
							_tmp52_ = action_name;
							_tmp53_ = description;
							_tmp54_ = action;
							_tmp55_ = filename;
							_g_object_unref0 (_tmp56_.icon);
							_tmp56_.icon = _tmp50_;
							_g_object_unref0 (_tmp56_.overlay_icon);
							_tmp56_.overlay_icon = _tmp51_;
							_g_free0 (_tmp56_.name);
							_tmp56_.name = _tmp52_;
							_g_free0 (_tmp56_.description);
							_tmp56_.description = _tmp53_;
							_g_free0 (_tmp56_.action);
							_tmp56_.action = _tmp54_;
							_g_free0 (_tmp56_.filename);
							_tmp56_.filename = _tmp55_;
							_tmp57_ = keyboard_shortcuts_app_chooser_row_new (&_tmp56_);
							g_object_ref_sink (_tmp57_);
							_tmp58_ = _tmp57_;
							gtk_list_box_prepend (_tmp49_, (GtkWidget*) _tmp58_);
							_g_object_unref0 (_tmp58_);
							_g_free0 (action_name);
							_g_object_unref0 (action_icon);
							_g_free0 (action);
						}
					}
				}
				actions = (_vala_array_free (actions, actions_length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (filename);
				_g_free0 (description);
				_g_free0 (name);
				_g_object_unref0 (icon);
				_g_object_unref0 (_tmp1_);
				_g_object_unref0 (app_info);
			}
		}
	}
}

static gint
keyboard_shortcuts_app_chooser_sort_function (KeyboardShortcutsAppChooser* self,
                                              GtkListBoxRow* row1,
                                              GtkListBoxRow* row2)
{
	KeyboardShortcutsAppChooserRow* row_1 = NULL;
	GtkWidget* _tmp0_;
	KeyboardShortcutsAppChooserRow* row_2 = NULL;
	GtkWidget* _tmp1_;
	gchar* name_1 = NULL;
	KeyboardShortcutsAppChooserRowInfo _tmp2_ = {0};
	KeyboardShortcutsAppChooserRowInfo _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* name_2 = NULL;
	KeyboardShortcutsAppChooserRowInfo _tmp6_ = {0};
	KeyboardShortcutsAppChooserRowInfo _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (row1 != NULL, -1);
	g_return_val_if_fail (row2 != NULL, -1);
	_tmp0_ = gtk_list_box_row_get_child (row1);
	row_1 = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, KEYBOARD_SHORTCUTS_TYPE_APP_CHOOSER_ROW, KeyboardShortcutsAppChooserRow);
	_tmp1_ = gtk_list_box_row_get_child (row2);
	row_2 = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, KEYBOARD_SHORTCUTS_TYPE_APP_CHOOSER_ROW, KeyboardShortcutsAppChooserRow);
	keyboard_shortcuts_app_chooser_row_get_info (row_1, &_tmp2_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_.name;
	_tmp5_ = g_strdup (_tmp4_);
	name_1 = _tmp5_;
	keyboard_shortcuts_app_chooser_row_get_info (row_2, &_tmp6_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_.name;
	_tmp9_ = g_strdup (_tmp8_);
	name_2 = _tmp9_;
	result = g_utf8_collate (name_1, name_2);
	_g_free0 (name_2);
	_g_free0 (name_1);
	return result;
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static gboolean
keyboard_shortcuts_app_chooser_filter_function (KeyboardShortcutsAppChooser* self,
                                                GtkListBoxRow* list_box_row)
{
	KeyboardShortcutsAppChooserRow* app_row = NULL;
	GtkWidget* _tmp0_;
	KeyboardShortcutsAppChooserRow* _tmp1_;
	gboolean _tmp2_ = FALSE;
	KeyboardShortcutsAppChooserRow* _tmp3_;
	KeyboardShortcutsAppChooserRowInfo _tmp4_ = {0};
	KeyboardShortcutsAppChooserRowInfo _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	GtkSearchEntry* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gboolean _tmp14_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (list_box_row != NULL, FALSE);
	_tmp0_ = gtk_list_box_row_get_child (list_box_row);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, KEYBOARD_SHORTCUTS_TYPE_APP_CHOOSER_ROW, KeyboardShortcutsAppChooserRow));
	app_row = _tmp1_;
	_tmp3_ = app_row;
	keyboard_shortcuts_app_chooser_row_get_info (_tmp3_, &_tmp4_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_.name;
	_tmp7_ = g_utf8_strdown (_tmp6_, (gssize) -1);
	_tmp8_ = _tmp7_;
	_tmp9_ = self->priv->search_entry;
	_tmp10_ = gtk_editable_get_text ((GtkEditable*) _tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = g_utf8_strdown (_tmp11_, (gssize) -1);
	_tmp13_ = _tmp12_;
	_tmp14_ = string_contains (_tmp8_, _tmp13_);
	_g_free0 (_tmp13_);
	_g_free0 (_tmp8_);
	if (_tmp14_) {
		_tmp2_ = TRUE;
	} else {
		KeyboardShortcutsAppChooserRow* _tmp15_;
		KeyboardShortcutsAppChooserRowInfo _tmp16_ = {0};
		KeyboardShortcutsAppChooserRowInfo _tmp17_;
		const gchar* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		GtkSearchEntry* _tmp21_;
		const gchar* _tmp22_;
		const gchar* _tmp23_;
		gchar* _tmp24_;
		gchar* _tmp25_;
		_tmp15_ = app_row;
		keyboard_shortcuts_app_chooser_row_get_info (_tmp15_, &_tmp16_);
		_tmp17_ = _tmp16_;
		_tmp18_ = _tmp17_.name;
		_tmp19_ = g_utf8_strdown (_tmp18_, (gssize) -1);
		_tmp20_ = _tmp19_;
		_tmp21_ = self->priv->search_entry;
		_tmp22_ = gtk_editable_get_text ((GtkEditable*) _tmp21_);
		_tmp23_ = _tmp22_;
		_tmp24_ = g_utf8_strdown (_tmp23_, (gssize) -1);
		_tmp25_ = _tmp24_;
		_tmp2_ = string_contains (_tmp20_, _tmp25_);
		_g_free0 (_tmp25_);
		_g_free0 (_tmp20_);
	}
	result = _tmp2_;
	_g_object_unref0 (app_row);
	return result;
}

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

static void
_g_variant_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_variant_unref (var), NULL));
}

static GVariant*
_variant_new1 (const gchar* value)
{
	return g_variant_ref_sink (g_variant_new_string (value));
}

static void
keyboard_shortcuts_app_chooser_on_app_selected (KeyboardShortcutsAppChooser* self,
                                                GtkListBoxRow* list_box_row)
{
	KeyboardShortcutsAppChooserRow* app_row = NULL;
	GtkWidget* _tmp0_;
	KeyboardShortcutsAppChooserRow* _tmp1_;
	GHashTable* parameters = NULL;
	GHashTable* _tmp2_;
	KeyboardShortcutsAppChooserRow* _tmp3_;
	KeyboardShortcutsAppChooserRowInfo _tmp4_ = {0};
	KeyboardShortcutsAppChooserRowInfo _tmp5_;
	const gchar* _tmp6_;
	KeyboardShortcutsAppChooserRow* _tmp14_;
	KeyboardShortcutsAppChooserRowInfo _tmp15_ = {0};
	KeyboardShortcutsAppChooserRowInfo _tmp16_;
	const gchar* _tmp17_;
	GHashTable* _tmp18_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (list_box_row != NULL);
	_tmp0_ = gtk_list_box_row_get_child (list_box_row);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, KEYBOARD_SHORTCUTS_TYPE_APP_CHOOSER_ROW, KeyboardShortcutsAppChooserRow));
	app_row = _tmp1_;
	_tmp2_ = g_hash_table_new_full (NULL, NULL, _g_free0_, _g_variant_unref0_);
	parameters = _tmp2_;
	_tmp3_ = app_row;
	keyboard_shortcuts_app_chooser_row_get_info (_tmp3_, &_tmp4_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_.action;
	if (_tmp6_ != NULL) {
		GHashTable* _tmp7_;
		gchar* _tmp8_;
		KeyboardShortcutsAppChooserRow* _tmp9_;
		KeyboardShortcutsAppChooserRowInfo _tmp10_ = {0};
		KeyboardShortcutsAppChooserRowInfo _tmp11_;
		const gchar* _tmp12_;
		GVariant* _tmp13_;
		_tmp7_ = parameters;
		_tmp8_ = g_strdup ("action");
		_tmp9_ = app_row;
		keyboard_shortcuts_app_chooser_row_get_info (_tmp9_, &_tmp10_);
		_tmp11_ = _tmp10_;
		_tmp12_ = _tmp11_.action;
		_tmp13_ = _variant_new1 (_tmp12_);
		g_hash_table_insert (_tmp7_, _tmp8_, _tmp13_);
	}
	_tmp14_ = app_row;
	keyboard_shortcuts_app_chooser_row_get_info (_tmp14_, &_tmp15_);
	_tmp16_ = _tmp15_;
	_tmp17_ = _tmp16_.filename;
	_tmp18_ = parameters;
	g_signal_emit (self, keyboard_shortcuts_app_chooser_signals[KEYBOARD_SHORTCUTS_APP_CHOOSER_APP_CHOSEN_SIGNAL], 0, _tmp17_, _tmp18_);
	gtk_widget_hide ((GtkWidget*) self);
	_g_hash_table_unref0 (parameters);
	_g_object_unref0 (app_row);
}

static void
keyboard_shortcuts_app_chooser_on_custom_command_entered (KeyboardShortcutsAppChooser* self)
{
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GHashTable* _tmp3_;
	GHashTable* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->custom_entry;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_hash_table_new_full (NULL, NULL, _g_free0_, _g_variant_unref0_);
	_tmp4_ = _tmp3_;
	g_signal_emit (self, keyboard_shortcuts_app_chooser_signals[KEYBOARD_SHORTCUTS_APP_CHOOSER_CUSTOM_COMMAND_CHOSEN_SIGNAL], 0, _tmp2_, _tmp4_);
	_g_hash_table_unref0 (_tmp4_);
	gtk_widget_hide ((GtkWidget*) self);
}

KeyboardShortcutsAppChooser*
keyboard_shortcuts_app_chooser_construct (GType object_type)
{
	KeyboardShortcutsAppChooser * self = NULL;
	self = (KeyboardShortcutsAppChooser*) granite_dialog_construct (object_type);
	return self;
}

KeyboardShortcutsAppChooser*
keyboard_shortcuts_app_chooser_new (void)
{
	return keyboard_shortcuts_app_chooser_construct (KEYBOARD_SHORTCUTS_TYPE_APP_CHOOSER);
}

static void
g_cclosure_user_marshal_VOID__STRING_BOXED (GClosure * closure,
                                            GValue * return_value,
                                            guint n_param_values,
                                            const GValue * param_values,
                                            gpointer invocation_hint,
                                            gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__STRING_BOXED) (gpointer data1, const char* arg_1, gpointer arg_2, gpointer data2);
	register GMarshalFunc_VOID__STRING_BOXED callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__STRING_BOXED) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_string (param_values + 1), g_value_get_boxed (param_values + 2), data2);
}

static gint
_keyboard_shortcuts_app_chooser_sort_function_gtk_list_box_sort_func (GtkListBoxRow* row1,
                                                                      GtkListBoxRow* row2,
                                                                      gpointer self)
{
	gint result;
	result = keyboard_shortcuts_app_chooser_sort_function ((KeyboardShortcutsAppChooser*) self, row1, row2);
	return result;
}

static gboolean
_keyboard_shortcuts_app_chooser_filter_function_gtk_list_box_filter_func (GtkListBoxRow* row,
                                                                          gpointer self)
{
	gboolean result;
	result = keyboard_shortcuts_app_chooser_filter_function ((KeyboardShortcutsAppChooser*) self, row);
	return result;
}

static void
_keyboard_shortcuts_app_chooser___lambda66_ (KeyboardShortcutsAppChooser* self)
{
	GtkListBox* _tmp0_;
	_tmp0_ = self->priv->list;
	gtk_list_box_invalidate_filter (_tmp0_);
}

static void
__keyboard_shortcuts_app_chooser___lambda66__gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                                              gpointer self)
{
	_keyboard_shortcuts_app_chooser___lambda66_ ((KeyboardShortcutsAppChooser*) self);
}

static void
_gtk_widget_hide_gtk_dialog_response (GtkDialog* _sender,
                                      gint response_id,
                                      gpointer self)
{
	gtk_widget_hide ((GtkWidget*) self);
}

static void
_keyboard_shortcuts_app_chooser_on_app_selected_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                            GtkListBoxRow* row,
                                                                            gpointer self)
{
	keyboard_shortcuts_app_chooser_on_app_selected ((KeyboardShortcutsAppChooser*) self, row);
}

static void
_keyboard_shortcuts_app_chooser_on_custom_command_entered_gtk_entry_activate (GtkEntry* _sender,
                                                                              gpointer self)
{
	keyboard_shortcuts_app_chooser_on_custom_command_entered ((KeyboardShortcutsAppChooser*) self);
}

static GObject *
keyboard_shortcuts_app_chooser_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	KeyboardShortcutsAppChooser * self;
	gchar* _tmp0_;
	GtkSearchEntry* _tmp1_ = NULL;
	GtkSearchEntry* _tmp2_;
	GtkListBox* _tmp3_ = NULL;
	GtkListBox* _tmp4_;
	GtkListBox* _tmp5_;
	GtkListBox* _tmp6_;
	GtkScrolledWindow* scrolled = NULL;
	GtkListBox* _tmp7_;
	GtkWidget* _tmp8_;
	GtkScrolledWindow* _tmp9_ = NULL;
	gchar* _tmp10_;
	gchar* _tmp11_;
	GtkEntry* _tmp12_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp13_;
	GtkBox* _tmp14_;
	GtkSearchEntry* _tmp15_;
	GtkBox* _tmp16_;
	GtkScrolledWindow* _tmp17_;
	GtkBox* _tmp18_;
	GtkEntry* _tmp19_;
	GtkBox* _tmp20_;
	GtkBox* _tmp21_;
	GtkSearchEntry* _tmp22_;
	GtkSearchEntry* _tmp23_;
	GtkListBox* _tmp24_;
	GtkEntry* _tmp25_;
	parent_class = G_OBJECT_CLASS (keyboard_shortcuts_app_chooser_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KEYBOARD_SHORTCUTS_TYPE_APP_CHOOSER, KeyboardShortcutsAppChooser);
	_tmp0_ = g_strdup (_ ("Search Applications"));
	_tmp1_ = (GtkSearchEntry*) gtk_search_entry_new ();
	g_object_set (_tmp1_, "placeholder-text", _tmp0_, NULL);
	_g_free0 (_tmp0_);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->search_entry);
	self->priv->search_entry = _tmp1_;
	_tmp2_ = self->priv->search_entry;
	gtk_search_entry_set_key_capture_widget (_tmp2_, (GtkWidget*) self);
	_tmp3_ = (GtkListBox*) gtk_list_box_new ();
	gtk_widget_set_hexpand ((GtkWidget*) _tmp3_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp3_, TRUE);
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->list);
	self->priv->list = _tmp3_;
	_tmp4_ = self->priv->list;
	gtk_widget_add_css_class ((GtkWidget*) _tmp4_, GRANITE_STYLE_CLASS_RICH_LIST);
	_tmp5_ = self->priv->list;
	gtk_list_box_set_sort_func (_tmp5_, _keyboard_shortcuts_app_chooser_sort_function_gtk_list_box_sort_func, g_object_ref (self), g_object_unref);
	_tmp6_ = self->priv->list;
	gtk_list_box_set_filter_func (_tmp6_, _keyboard_shortcuts_app_chooser_filter_function_gtk_list_box_filter_func, g_object_ref (self), g_object_unref);
	_tmp7_ = self->priv->list;
	_tmp8_ = _g_object_ref0 ((GtkWidget*) _tmp7_);
	_tmp9_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	gtk_scrolled_window_set_child (_tmp9_, _tmp8_);
	_g_object_unref0 (_tmp8_);
	gtk_scrolled_window_set_has_frame (_tmp9_, TRUE);
	g_object_ref_sink (_tmp9_);
	scrolled = _tmp9_;
	_tmp10_ = g_strdup (_ ("Type in a custom command"));
	_tmp11_ = g_strdup ("utilities-terminal-symbolic");
	_tmp12_ = (GtkEntry*) gtk_entry_new ();
	gtk_entry_set_placeholder_text (_tmp12_, _tmp10_);
	_g_free0 (_tmp10_);
	g_object_set (_tmp12_, "primary-icon-activatable", FALSE, NULL);
	g_object_set (_tmp12_, "primary-icon-name", _tmp11_, NULL);
	_g_free0 (_tmp11_);
	g_object_ref_sink (_tmp12_);
	_g_object_unref0 (self->priv->custom_entry);
	self->priv->custom_entry = _tmp12_;
	_tmp13_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	g_object_ref_sink (_tmp13_);
	box = _tmp13_;
	_tmp14_ = box;
	_tmp15_ = self->priv->search_entry;
	gtk_box_append (_tmp14_, (GtkWidget*) _tmp15_);
	_tmp16_ = box;
	_tmp17_ = scrolled;
	gtk_box_append (_tmp16_, (GtkWidget*) _tmp17_);
	_tmp18_ = box;
	_tmp19_ = self->priv->custom_entry;
	gtk_box_append (_tmp18_, (GtkWidget*) _tmp19_);
	gtk_window_set_modal ((GtkWindow*) self, TRUE);
	g_object_set ((GtkWindow*) self, "default-height", 500, NULL);
	g_object_set ((GtkWindow*) self, "default-width", 400, NULL);
	_tmp20_ = gtk_dialog_get_content_area ((GtkDialog*) self);
	_tmp21_ = box;
	gtk_box_append (_tmp20_, (GtkWidget*) _tmp21_);
	granite_dialog_add_button ((GraniteDialog*) self, _ ("Cancel"), (gint) GTK_RESPONSE_CANCEL);
	gtk_accessible_update_property ((GtkAccessible*) self, GTK_ACCESSIBLE_PROPERTY_LABEL, _ ("Select an app"), -1, -1);
	_tmp22_ = self->priv->search_entry;
	gtk_widget_grab_focus ((GtkWidget*) _tmp22_);
	_tmp23_ = self->priv->search_entry;
	g_signal_connect_object (_tmp23_, "search-changed", (GCallback) __keyboard_shortcuts_app_chooser___lambda66__gtk_search_entry_search_changed, self, 0);
	g_signal_connect_object ((GtkDialog*) self, "response", (GCallback) _gtk_widget_hide_gtk_dialog_response, (GtkWidget*) self, 0);
	_tmp24_ = self->priv->list;
	g_signal_connect_object (_tmp24_, "row-activated", (GCallback) _keyboard_shortcuts_app_chooser_on_app_selected_gtk_list_box_row_activated, self, 0);
	_tmp25_ = self->priv->custom_entry;
	g_signal_connect_object (_tmp25_, "activate", (GCallback) _keyboard_shortcuts_app_chooser_on_custom_command_entered_gtk_entry_activate, self, 0);
	_g_object_unref0 (box);
	_g_object_unref0 (scrolled);
	return obj;
}

static void
keyboard_shortcuts_app_chooser_class_init (KeyboardShortcutsAppChooserClass * klass,
                                           gpointer klass_data)
{
	keyboard_shortcuts_app_chooser_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KeyboardShortcutsAppChooser_private_offset);
	G_OBJECT_CLASS (klass)->constructor = keyboard_shortcuts_app_chooser_constructor;
	G_OBJECT_CLASS (klass)->finalize = keyboard_shortcuts_app_chooser_finalize;
	keyboard_shortcuts_app_chooser_signals[KEYBOARD_SHORTCUTS_APP_CHOOSER_APP_CHOSEN_SIGNAL] = g_signal_new ("app-chosen", KEYBOARD_SHORTCUTS_TYPE_APP_CHOOSER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__STRING_BOXED, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_HASH_TABLE);
	keyboard_shortcuts_app_chooser_signals[KEYBOARD_SHORTCUTS_APP_CHOOSER_CUSTOM_COMMAND_CHOSEN_SIGNAL] = g_signal_new ("custom-command-chosen", KEYBOARD_SHORTCUTS_TYPE_APP_CHOOSER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__STRING_BOXED, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_HASH_TABLE);
}

static void
keyboard_shortcuts_app_chooser_instance_init (KeyboardShortcutsAppChooser * self,
                                              gpointer klass)
{
	self->priv = keyboard_shortcuts_app_chooser_get_instance_private (self);
}

static void
keyboard_shortcuts_app_chooser_finalize (GObject * obj)
{
	KeyboardShortcutsAppChooser * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KEYBOARD_SHORTCUTS_TYPE_APP_CHOOSER, KeyboardShortcutsAppChooser);
	_g_object_unref0 (self->priv->list);
	_g_object_unref0 (self->priv->search_entry);
	_g_object_unref0 (self->priv->custom_entry);
	G_OBJECT_CLASS (keyboard_shortcuts_app_chooser_parent_class)->finalize (obj);
}

static GType
keyboard_shortcuts_app_chooser_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KeyboardShortcutsAppChooserClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) keyboard_shortcuts_app_chooser_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KeyboardShortcutsAppChooser), 0, (GInstanceInitFunc) keyboard_shortcuts_app_chooser_instance_init, NULL };
	GType keyboard_shortcuts_app_chooser_type_id;
	keyboard_shortcuts_app_chooser_type_id = g_type_register_static (GRANITE_TYPE_DIALOG, "KeyboardShortcutsAppChooser", &g_define_type_info, 0);
	KeyboardShortcutsAppChooser_private_offset = g_type_add_instance_private (keyboard_shortcuts_app_chooser_type_id, sizeof (KeyboardShortcutsAppChooserPrivate));
	return keyboard_shortcuts_app_chooser_type_id;
}

GType
keyboard_shortcuts_app_chooser_get_type (void)
{
	static volatile gsize keyboard_shortcuts_app_chooser_type_id__once = 0;
	if (g_once_init_enter (&keyboard_shortcuts_app_chooser_type_id__once)) {
		GType keyboard_shortcuts_app_chooser_type_id;
		keyboard_shortcuts_app_chooser_type_id = keyboard_shortcuts_app_chooser_get_type_once ();
		g_once_init_leave (&keyboard_shortcuts_app_chooser_type_id__once, keyboard_shortcuts_app_chooser_type_id);
	}
	return keyboard_shortcuts_app_chooser_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

