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

/* Display.vala
 *
 * Copyright (C) 2009-2024 Jerry Casiano
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.
 *
 * If not, see <http://www.gnu.org/licenses/gpl-3.0.txt>.
*/

#include <glib-object.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include "font-manager.h"
#include <string.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>

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

#define FONT_MANAGER_TYPE_PREVIOUS_DISPLAY_SETTINGS (font_manager_previous_display_settings_get_type ())
typedef struct _FontManagerPreviousDisplaySettings FontManagerPreviousDisplaySettings;

#define FONT_MANAGER_TYPE_PREFERENCE_LIST (font_manager_preference_list_get_type ())
#define FONT_MANAGER_PREFERENCE_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_MANAGER_TYPE_PREFERENCE_LIST, FontManagerPreferenceList))
#define FONT_MANAGER_PREFERENCE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FONT_MANAGER_TYPE_PREFERENCE_LIST, FontManagerPreferenceListClass))
#define FONT_MANAGER_IS_PREFERENCE_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FONT_MANAGER_TYPE_PREFERENCE_LIST))
#define FONT_MANAGER_IS_PREFERENCE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FONT_MANAGER_TYPE_PREFERENCE_LIST))
#define FONT_MANAGER_PREFERENCE_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FONT_MANAGER_TYPE_PREFERENCE_LIST, FontManagerPreferenceListClass))

typedef struct _FontManagerPreferenceList FontManagerPreferenceList;
typedef struct _FontManagerPreferenceListClass FontManagerPreferenceListClass;
typedef struct _FontManagerPreferenceListPrivate FontManagerPreferenceListPrivate;

#define FONT_MANAGER_TYPE_BASE_CONTROLS (font_manager_base_controls_get_type ())
#define FONT_MANAGER_BASE_CONTROLS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_MANAGER_TYPE_BASE_CONTROLS, FontManagerBaseControls))
#define FONT_MANAGER_BASE_CONTROLS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FONT_MANAGER_TYPE_BASE_CONTROLS, FontManagerBaseControlsClass))
#define FONT_MANAGER_IS_BASE_CONTROLS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FONT_MANAGER_TYPE_BASE_CONTROLS))
#define FONT_MANAGER_IS_BASE_CONTROLS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FONT_MANAGER_TYPE_BASE_CONTROLS))
#define FONT_MANAGER_BASE_CONTROLS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FONT_MANAGER_TYPE_BASE_CONTROLS, FontManagerBaseControlsClass))

typedef struct _FontManagerBaseControls FontManagerBaseControls;
typedef struct _FontManagerBaseControlsClass FontManagerBaseControlsClass;

#define FONT_MANAGER_TYPE_DISPLAY_PREFERENCES (font_manager_display_preferences_get_type ())
#define FONT_MANAGER_DISPLAY_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_MANAGER_TYPE_DISPLAY_PREFERENCES, FontManagerDisplayPreferences))
#define FONT_MANAGER_DISPLAY_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FONT_MANAGER_TYPE_DISPLAY_PREFERENCES, FontManagerDisplayPreferencesClass))
#define FONT_MANAGER_IS_DISPLAY_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FONT_MANAGER_TYPE_DISPLAY_PREFERENCES))
#define FONT_MANAGER_IS_DISPLAY_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FONT_MANAGER_TYPE_DISPLAY_PREFERENCES))
#define FONT_MANAGER_DISPLAY_PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FONT_MANAGER_TYPE_DISPLAY_PREFERENCES, FontManagerDisplayPreferencesClass))

typedef struct _FontManagerDisplayPreferences FontManagerDisplayPreferences;
typedef struct _FontManagerDisplayPreferencesClass FontManagerDisplayPreferencesClass;
typedef struct _FontManagerDisplayPreferencesPrivate FontManagerDisplayPreferencesPrivate;

#define FONT_MANAGER_TYPE_SUBPIXEL_GEOMETRY (font_manager_subpixel_geometry_get_type ())
#define FONT_MANAGER_SUBPIXEL_GEOMETRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_MANAGER_TYPE_SUBPIXEL_GEOMETRY, FontManagerSubpixelGeometry))
#define FONT_MANAGER_SUBPIXEL_GEOMETRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FONT_MANAGER_TYPE_SUBPIXEL_GEOMETRY, FontManagerSubpixelGeometryClass))
#define FONT_MANAGER_IS_SUBPIXEL_GEOMETRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FONT_MANAGER_TYPE_SUBPIXEL_GEOMETRY))
#define FONT_MANAGER_IS_SUBPIXEL_GEOMETRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FONT_MANAGER_TYPE_SUBPIXEL_GEOMETRY))
#define FONT_MANAGER_SUBPIXEL_GEOMETRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FONT_MANAGER_TYPE_SUBPIXEL_GEOMETRY, FontManagerSubpixelGeometryClass))

typedef struct _FontManagerSubpixelGeometry FontManagerSubpixelGeometry;
typedef struct _FontManagerSubpixelGeometryClass FontManagerSubpixelGeometryClass;
enum  {
	FONT_MANAGER_DISPLAY_PREFERENCES_0_PROPERTY,
	FONT_MANAGER_DISPLAY_PREFERENCES_PROPERTIES_PROPERTY,
	FONT_MANAGER_DISPLAY_PREFERENCES_NUM_PROPERTIES
};
static GParamSpec* font_manager_display_preferences_properties[FONT_MANAGER_DISPLAY_PREFERENCES_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 FONT_MANAGER_TYPE_FONTCONFIG_FOOTER (font_manager_fontconfig_footer_get_type ())
#define FONT_MANAGER_FONTCONFIG_FOOTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_MANAGER_TYPE_FONTCONFIG_FOOTER, FontManagerFontconfigFooter))
#define FONT_MANAGER_FONTCONFIG_FOOTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FONT_MANAGER_TYPE_FONTCONFIG_FOOTER, FontManagerFontconfigFooterClass))
#define FONT_MANAGER_IS_FONTCONFIG_FOOTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FONT_MANAGER_TYPE_FONTCONFIG_FOOTER))
#define FONT_MANAGER_IS_FONTCONFIG_FOOTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FONT_MANAGER_TYPE_FONTCONFIG_FOOTER))
#define FONT_MANAGER_FONTCONFIG_FOOTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FONT_MANAGER_TYPE_FONTCONFIG_FOOTER, FontManagerFontconfigFooterClass))

typedef struct _FontManagerFontconfigFooter FontManagerFontconfigFooter;
typedef struct _FontManagerFontconfigFooterClass FontManagerFontconfigFooterClass;
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))

struct _FontManagerPreviousDisplaySettings {
	gint filter;
	gint rgba;
	gdouble dpi;
	gdouble scale;
};

struct _FontManagerPreferenceList {
	GtkBox parent_instance;
	FontManagerPreferenceListPrivate * priv;
	GtkListBox* list;
	FontManagerBaseControls* controls;
	GtkSeparator* separator;
};

struct _FontManagerPreferenceListClass {
	GtkBoxClass parent_class;
	void (*on_add_selected) (FontManagerPreferenceList* self);
	void (*on_list_row_selected) (FontManagerPreferenceList* self, GtkListBox* box, GtkListBoxRow* row);
	void (*on_map) (FontManagerPreferenceList* self);
	void (*on_remove_selected) (FontManagerPreferenceList* self);
	void (*on_unmap) (FontManagerPreferenceList* self);
};

struct _FontManagerDisplayPreferences {
	FontManagerPreferenceList parent_instance;
	FontManagerDisplayPreferencesPrivate * priv;
};

struct _FontManagerDisplayPreferencesClass {
	FontManagerPreferenceListClass parent_class;
};

struct _FontManagerDisplayPreferencesPrivate {
	FontManagerFontProperties* _properties;
	gboolean initialized;
	GtkSpinButton* dpi;
	GtkSpinButton* scale;
	GtkDropDown* lcdfilter;
	FontManagerSubpixelGeometry* spg;
	FontManagerPreviousDisplaySettings settings;
};

static gint FontManagerDisplayPreferences_private_offset;
static gpointer font_manager_display_preferences_parent_class = NULL;

VALA_EXTERN GType font_manager_previous_display_settings_get_type (void) G_GNUC_CONST ;
VALA_EXTERN FontManagerPreviousDisplaySettings* font_manager_previous_display_settings_dup (const FontManagerPreviousDisplaySettings* self);
VALA_EXTERN void font_manager_previous_display_settings_free (FontManagerPreviousDisplaySettings* self);
VALA_EXTERN void font_manager_previous_display_settings_init (FontManagerPreviousDisplaySettings *self,
                                                  FontManagerFontProperties* properties);
VALA_EXTERN gboolean font_manager_previous_display_settings_changed (FontManagerPreviousDisplaySettings *self,
                                                         FontManagerFontProperties* properties);
VALA_EXTERN void font_manager_previous_display_settings_load (FontManagerPreviousDisplaySettings *self,
                                                  FontManagerFontProperties* properties);
VALA_EXTERN GType font_manager_preference_list_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FontManagerPreferenceList, g_object_unref)
VALA_EXTERN GType font_manager_base_controls_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FontManagerBaseControls, g_object_unref)
VALA_EXTERN GType font_manager_display_preferences_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FontManagerDisplayPreferences, g_object_unref)
VALA_EXTERN GType font_manager_subpixel_geometry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FontManagerSubpixelGeometry, g_object_unref)
VALA_EXTERN void font_manager_preference_list_on_map (FontManagerPreferenceList* self);
VALA_EXTERN void font_manager_preference_list_on_unmap (FontManagerPreferenceList* self);
VALA_EXTERN FontManagerDisplayPreferences* font_manager_display_preferences_new (void);
VALA_EXTERN FontManagerDisplayPreferences* font_manager_display_preferences_construct (GType object_type);
VALA_EXTERN FontManagerPreferenceList* font_manager_preference_list_new (void);
VALA_EXTERN FontManagerPreferenceList* font_manager_preference_list_construct (GType object_type);
static void font_manager_display_preferences_set_properties (FontManagerDisplayPreferences* self,
                                                      FontManagerFontProperties* value);
static void font_manager_display_preferences_generate_options_list (FontManagerDisplayPreferences* self);
VALA_EXTERN void font_manager_preference_list_append_row (FontManagerPreferenceList* self,
                                              GtkWidget* widget);
static void _g_free0_ (gpointer var);
static void _vala_gchar_free_function_content_of (gpointer data);
VALA_EXTERN FontManagerSubpixelGeometry* font_manager_subpixel_geometry_new (void);
VALA_EXTERN FontManagerSubpixelGeometry* font_manager_subpixel_geometry_construct (GType object_type);
VALA_EXTERN GPtrArray* font_manager_subpixel_geometry_get_options (FontManagerSubpixelGeometry* self);
static void font_manager_display_preferences_bind_properties (FontManagerDisplayPreferences* self);
VALA_EXTERN FontManagerFontProperties* font_manager_display_preferences_get_properties (FontManagerDisplayPreferences* self);
VALA_EXTERN GType font_manager_fontconfig_footer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FontManagerFontconfigFooter, g_object_unref)
VALA_EXTERN FontManagerFontconfigFooter* font_manager_fontconfig_footer_new (void);
VALA_EXTERN FontManagerFontconfigFooter* font_manager_fontconfig_footer_construct (GType object_type);
static void font_manager_display_preferences_on_reset (FontManagerDisplayPreferences* self);
static void _font_manager_display_preferences_on_reset_font_manager_fontconfig_footer_reset_requested (FontManagerFontconfigFooter* _sender,
                                                                                                gpointer self);
static void font_manager_display_preferences_real_on_map (FontManagerPreferenceList* base);
static void font_manager_display_preferences_real_on_unmap (FontManagerPreferenceList* base);
static void font_manager_display_preferences_finalize (GObject * obj);
static GType font_manager_display_preferences_get_type_once (void);
static void _vala_font_manager_display_preferences_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec);
static void _vala_font_manager_display_preferences_set_property (GObject * object,
                                                          guint property_id,
                                                          const GValue * value,
                                                          GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

void
font_manager_previous_display_settings_init (FontManagerPreviousDisplaySettings *self,
                                             FontManagerFontProperties* properties)
{
	gdouble _tmp0_;
	gdouble _tmp1_;
	gdouble _tmp2_;
	gdouble _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	g_return_if_fail (properties != NULL);
	memset (self, 0, sizeof (FontManagerPreviousDisplaySettings));
	g_object_get (properties, "dpi", &_tmp0_, NULL);
	_tmp1_ = _tmp0_;
	(*self).dpi = _tmp1_;
	g_object_get (properties, "scale", &_tmp2_, NULL);
	_tmp3_ = _tmp2_;
	(*self).scale = _tmp3_;
	g_object_get (properties, "lcdfilter", &_tmp4_, NULL);
	_tmp5_ = _tmp4_;
	(*self).filter = _tmp5_;
	g_object_get (properties, "rgba", &_tmp6_, NULL);
	_tmp7_ = _tmp6_;
	(*self).rgba = _tmp7_;
}

gboolean
font_manager_previous_display_settings_changed (FontManagerPreviousDisplaySettings *self,
                                                FontManagerFontProperties* properties)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gint _tmp3_;
	gint _tmp4_;
	gboolean result;
	g_return_val_if_fail (properties != NULL, FALSE);
	g_object_get (properties, "lcdfilter", &_tmp3_, NULL);
	_tmp4_ = _tmp3_;
	if (_tmp4_ != (*self).filter) {
		_tmp2_ = TRUE;
	} else {
		gint _tmp5_;
		gint _tmp6_;
		g_object_get (properties, "rgba", &_tmp5_, NULL);
		_tmp6_ = _tmp5_;
		_tmp2_ = _tmp6_ != (*self).rgba;
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		gdouble _tmp7_;
		gdouble _tmp8_;
		g_object_get (properties, "dpi", &_tmp7_, NULL);
		_tmp8_ = _tmp7_;
		_tmp1_ = _tmp8_ != (*self).dpi;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		gdouble _tmp9_;
		gdouble _tmp10_;
		g_object_get (properties, "scale", &_tmp9_, NULL);
		_tmp10_ = _tmp9_;
		_tmp0_ = _tmp10_ != (*self).scale;
	}
	result = _tmp0_;
	return result;
}

void
font_manager_previous_display_settings_load (FontManagerPreviousDisplaySettings *self,
                                             FontManagerFontProperties* properties)
{
	g_return_if_fail (properties != NULL);
	g_object_set ((GObject*) properties, "lcdfilter", (*self).filter, "rgba", (*self).rgba, "dpi", (*self).dpi, "scale", (*self).scale, NULL);
	return;
}

FontManagerPreviousDisplaySettings*
font_manager_previous_display_settings_dup (const FontManagerPreviousDisplaySettings* self)
{
	FontManagerPreviousDisplaySettings* dup;
	dup = g_new0 (FontManagerPreviousDisplaySettings, 1);
	memcpy (dup, self, sizeof (FontManagerPreviousDisplaySettings));
	return dup;
}

void
font_manager_previous_display_settings_free (FontManagerPreviousDisplaySettings* self)
{
	g_free (self);
}

 G_GNUC_NO_INLINE static GType
font_manager_previous_display_settings_get_type_once (void)
{
	GType font_manager_previous_display_settings_type_id;
	font_manager_previous_display_settings_type_id = g_boxed_type_register_static ("FontManagerPreviousDisplaySettings", (GBoxedCopyFunc) font_manager_previous_display_settings_dup, (GBoxedFreeFunc) font_manager_previous_display_settings_free);
	return font_manager_previous_display_settings_type_id;
}

GType
font_manager_previous_display_settings_get_type (void)
{
	static volatile gsize font_manager_previous_display_settings_type_id__once = 0;
	if (g_once_init_enter (&font_manager_previous_display_settings_type_id__once)) {
		GType font_manager_previous_display_settings_type_id;
		font_manager_previous_display_settings_type_id = font_manager_previous_display_settings_get_type_once ();
		g_once_init_leave (&font_manager_previous_display_settings_type_id__once, font_manager_previous_display_settings_type_id);
	}
	return font_manager_previous_display_settings_type_id__once;
}

static inline gpointer
font_manager_display_preferences_get_instance_private (FontManagerDisplayPreferences* self)
{
	return G_STRUCT_MEMBER_P (self, FontManagerDisplayPreferences_private_offset);
}

FontManagerDisplayPreferences*
font_manager_display_preferences_construct (GType object_type)
{
	FontManagerDisplayPreferences * self = NULL;
	GtkListBox* _tmp0_;
	gchar* _tmp1_;
	FontManagerFontProperties* _tmp2_ = NULL;
	FontManagerFontProperties* _tmp3_;
	self = (FontManagerDisplayPreferences*) font_manager_preference_list_construct (object_type);
	font_manager_widget_set_name ((GtkWidget*) self, "FontManagerDisplayPreferences");
	_tmp0_ = ((FontManagerPreferenceList*) self)->list;
	gtk_list_box_set_selection_mode (_tmp0_, GTK_SELECTION_NONE);
	_tmp1_ = g_strdup ("19-DisplayProperties.conf");
	_tmp2_ = font_manager_font_properties_new ();
	g_object_set (_tmp2_, "type", (gint) FONT_MANAGER_FONT_PROPERTIES_TYPE_DISPLAY, NULL);
	g_object_set (_tmp2_, "target-file", _tmp1_, NULL);
	_g_free0 (_tmp1_);
	_tmp3_ = _tmp2_;
	font_manager_display_preferences_set_properties (self, _tmp3_);
	_g_object_unref0 (_tmp3_);
	return self;
}

FontManagerDisplayPreferences*
font_manager_display_preferences_new (void)
{
	return font_manager_display_preferences_construct (FONT_MANAGER_TYPE_DISPLAY_PREFERENCES);
}

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

static void
_vala_gchar_free_function_content_of (gpointer data)
{
	gchar* self;
	self = *((gchar**) data);
	_g_free0_ (self);
}

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

static void
_font_manager_display_preferences_on_reset_font_manager_fontconfig_footer_reset_requested (FontManagerFontconfigFooter* _sender,
                                                                                           gpointer self)
{
	font_manager_display_preferences_on_reset ((FontManagerDisplayPreferences*) self);
}

static void
font_manager_display_preferences_generate_options_list (FontManagerDisplayPreferences* self)
{
	GtkSpinButton* _tmp0_;
	GtkSpinButton* _tmp1_;
	FontManagerPreferenceRow* _tmp2_;
	FontManagerPreferenceRow* _tmp3_;
	GtkSpinButton* _tmp4_;
	GtkSpinButton* _tmp5_;
	FontManagerPreferenceRow* _tmp6_;
	FontManagerPreferenceRow* _tmp7_;
	GArray* filters = NULL;
	GArray* _tmp8_;
	GtkStringList* filter_list = NULL;
	GArray* _tmp14_;
	gpointer* _tmp15_;
	gint _tmp15__length1;
	GtkStringList* _tmp16_;
	GtkStringList* _tmp17_;
	GListModel* _tmp18_;
	GtkDropDown* _tmp19_;
	GtkDropDown* _tmp20_;
	FontManagerPreferenceRow* _tmp21_;
	FontManagerPreferenceRow* _tmp22_;
	FontManagerSubpixelGeometry* _tmp23_;
	FontManagerSubpixelGeometry* _tmp24_;
	GPtrArray* _tmp25_;
	GPtrArray* _tmp26_;
	gconstpointer _tmp27_;
	FontManagerSubpixelGeometry* _tmp28_;
	GPtrArray* _tmp29_;
	GPtrArray* _tmp30_;
	gconstpointer _tmp31_;
	FontManagerSubpixelGeometry* _tmp32_;
	FontManagerSubpixelGeometry* _tmp33_;
	FontManagerSubpixelGeometry* _tmp34_;
	FontManagerSubpixelGeometry* _tmp35_;
	GtkWidget* _tmp36_;
	FontManagerSubpixelGeometry* _tmp37_;
	FontManagerPreferenceRow* _tmp38_;
	FontManagerPreferenceRow* _tmp39_;
	FontManagerFontProperties* _tmp40_;
	FontManagerFontconfigFooter* footer = NULL;
	FontManagerFontconfigFooter* _tmp41_;
	FontManagerFontconfigFooter* _tmp42_;
	FontManagerFontconfigFooter* _tmp43_;
	g_return_if_fail (self != NULL);
	if (self->priv->initialized) {
		return;
	}
	_tmp0_ = (GtkSpinButton*) gtk_spin_button_new_with_range (0.0, 1000.0, 1.0);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->dpi);
	self->priv->dpi = _tmp0_;
	_tmp1_ = self->priv->dpi;
	_tmp2_ = (FontManagerPreferenceRow*) font_manager_preference_row_new (_ ("Target DPI"), NULL, NULL, (GtkWidget*) _tmp1_);
	g_object_ref_sink (_tmp2_);
	_tmp3_ = _tmp2_;
	font_manager_preference_list_append_row ((FontManagerPreferenceList*) self, (GtkWidget*) _tmp3_);
	_g_object_unref0 (_tmp3_);
	_tmp4_ = (GtkSpinButton*) gtk_spin_button_new_with_range (0.0, 1000.0, 0.1);
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->scale);
	self->priv->scale = _tmp4_;
	_tmp5_ = self->priv->scale;
	_tmp6_ = (FontManagerPreferenceRow*) font_manager_preference_row_new (_ ("Scale Factor"), NULL, NULL, (GtkWidget*) _tmp5_);
	g_object_ref_sink (_tmp6_);
	_tmp7_ = _tmp6_;
	font_manager_preference_list_append_row ((FontManagerPreferenceList*) self, (GtkWidget*) _tmp7_);
	_g_object_unref0 (_tmp7_);
	_tmp8_ = g_array_new (TRUE, TRUE, sizeof (gchar*));
	g_array_set_clear_func (_tmp8_, (GDestroyNotify) _vala_gchar_free_function_content_of);
	filters = _tmp8_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp9_ = FALSE;
			_tmp9_ = TRUE;
			while (TRUE) {
				GArray* _tmp11_;
				const gchar* _tmp12_;
				gchar* _tmp13_;
				if (!_tmp9_) {
					gint _tmp10_;
					_tmp10_ = i;
					i = _tmp10_ + 1;
				}
				_tmp9_ = FALSE;
				if (!(i <= ((gint) FONT_MANAGER_LCD_FILTER_LEGACY))) {
					break;
				}
				_tmp11_ = filters;
				_tmp12_ = font_manager_lcd_filter_to_string ((FontManagerLCDFilter) i);
				_tmp13_ = g_strdup (_tmp12_);
				g_array_append_val (_tmp11_, _tmp13_);
			}
		}
	}
	_tmp14_ = filters;
	_tmp15_ = _tmp14_->data;
	_tmp15__length1 = _tmp14_->len;
	_tmp16_ = gtk_string_list_new (_tmp15_);
	filter_list = _tmp16_;
	_tmp17_ = filter_list;
	_tmp18_ = _g_object_ref0 ((GListModel*) _tmp17_);
	_tmp19_ = (GtkDropDown*) gtk_drop_down_new (_tmp18_, NULL);
	g_object_ref_sink (_tmp19_);
	_g_object_unref0 (self->priv->lcdfilter);
	self->priv->lcdfilter = _tmp19_;
	_tmp20_ = self->priv->lcdfilter;
	_tmp21_ = (FontManagerPreferenceRow*) font_manager_preference_row_new (_ ("LCD Filter"), NULL, NULL, (GtkWidget*) _tmp20_);
	g_object_ref_sink (_tmp21_);
	_tmp22_ = _tmp21_;
	font_manager_preference_list_append_row ((FontManagerPreferenceList*) self, (GtkWidget*) _tmp22_);
	_g_object_unref0 (_tmp22_);
	_tmp23_ = font_manager_subpixel_geometry_new ();
	g_object_ref_sink (_tmp23_);
	_g_object_unref0 (self->priv->spg);
	self->priv->spg = _tmp23_;
	_tmp24_ = self->priv->spg;
	_tmp25_ = font_manager_subpixel_geometry_get_options (_tmp24_);
	_tmp26_ = _tmp25_;
	_tmp27_ = g_ptr_array_index (_tmp26_, (guint) FONT_MANAGER_SUBPIXEL_ORDER_UNKNOWN);
	gtk_widget_set_visible ((GtkWidget*) ((GtkCheckButton*) _tmp27_), FALSE);
	_tmp28_ = self->priv->spg;
	_tmp29_ = font_manager_subpixel_geometry_get_options (_tmp28_);
	_tmp30_ = _tmp29_;
	_tmp31_ = g_ptr_array_index (_tmp30_, (guint) FONT_MANAGER_SUBPIXEL_ORDER_NONE);
	gtk_widget_set_visible ((GtkWidget*) ((GtkCheckButton*) _tmp31_), FALSE);
	_tmp32_ = self->priv->spg;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp32_, 0);
	_tmp33_ = self->priv->spg;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp33_, FALSE);
	_tmp34_ = self->priv->spg;
	gtk_widget_set_halign ((GtkWidget*) _tmp34_, GTK_ALIGN_END);
	_tmp35_ = self->priv->spg;
	_tmp36_ = gtk_widget_get_last_child ((GtkWidget*) _tmp35_);
	gtk_widget_set_margin_end (_tmp36_, 0);
	_tmp37_ = self->priv->spg;
	_tmp38_ = (FontManagerPreferenceRow*) font_manager_preference_row_new (_ ("Subpixel Geometry"), NULL, NULL, (GtkWidget*) _tmp37_);
	g_object_ref_sink (_tmp38_);
	_tmp39_ = _tmp38_;
	font_manager_preference_list_append_row ((FontManagerPreferenceList*) self, (GtkWidget*) _tmp39_);
	_g_object_unref0 (_tmp39_);
	font_manager_display_preferences_bind_properties (self);
	_tmp40_ = self->priv->_properties;
	font_manager_previous_display_settings_init (&self->priv->settings, _tmp40_);
	_tmp41_ = font_manager_fontconfig_footer_new ();
	g_object_ref_sink (_tmp41_);
	footer = _tmp41_;
	_tmp42_ = footer;
	g_signal_connect_object (_tmp42_, "reset-requested", (GCallback) _font_manager_display_preferences_on_reset_font_manager_fontconfig_footer_reset_requested, self, 0);
	_tmp43_ = footer;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp43_);
	self->priv->initialized = TRUE;
	_g_object_unref0 (footer);
	_g_object_unref0 (filter_list);
	_g_array_unref0 (filters);
	return;
}

static void
font_manager_display_preferences_bind_properties (FontManagerDisplayPreferences* self)
{
	GBindingFlags flags = 0U;
	FontManagerFontProperties* _tmp0_;
	GtkSpinButton* _tmp1_;
	FontManagerFontProperties* _tmp2_;
	GtkSpinButton* _tmp3_;
	FontManagerFontProperties* _tmp4_;
	FontManagerSubpixelGeometry* _tmp5_;
	FontManagerFontProperties* _tmp6_;
	GtkDropDown* _tmp7_;
	g_return_if_fail (self != NULL);
	flags = G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE;
	_tmp0_ = self->priv->_properties;
	_tmp1_ = self->priv->dpi;
	g_object_bind_property_with_closures ((GObject*) _tmp0_, "dpi", (GObject*) _tmp1_, "value", flags, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp2_ = self->priv->_properties;
	_tmp3_ = self->priv->scale;
	g_object_bind_property_with_closures ((GObject*) _tmp2_, "scale", (GObject*) _tmp3_, "value", flags, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp4_ = self->priv->_properties;
	_tmp5_ = self->priv->spg;
	g_object_bind_property_with_closures ((GObject*) _tmp4_, "rgba", (GObject*) _tmp5_, "selected", flags, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp6_ = self->priv->_properties;
	_tmp7_ = self->priv->lcdfilter;
	g_object_bind_property_with_closures ((GObject*) _tmp6_, "lcdfilter", (GObject*) _tmp7_, "selected", flags, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	return;
}

static void
font_manager_display_preferences_on_reset (FontManagerDisplayPreferences* self)
{
	FontManagerFontProperties* _tmp0_;
	FontManagerFontProperties* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_properties;
	font_manager_font_properties_discard (_tmp0_);
	_tmp1_ = self->priv->_properties;
	font_manager_previous_display_settings_load (&self->priv->settings, _tmp1_);
	return;
}

static void
font_manager_display_preferences_real_on_map (FontManagerPreferenceList* base)
{
	FontManagerDisplayPreferences * self;
	FontManagerFontProperties* _tmp0_;
	self = (FontManagerDisplayPreferences*) base;
	font_manager_display_preferences_generate_options_list (self);
	_tmp0_ = self->priv->_properties;
	font_manager_font_properties_load (_tmp0_);
	return;
}

static void
font_manager_display_preferences_real_on_unmap (FontManagerPreferenceList* base)
{
	FontManagerDisplayPreferences * self;
	FontManagerFontProperties* _tmp0_;
	self = (FontManagerDisplayPreferences*) base;
	_tmp0_ = self->priv->_properties;
	if (font_manager_previous_display_settings_changed (&self->priv->settings, _tmp0_)) {
		FontManagerFontProperties* _tmp1_;
		_tmp1_ = self->priv->_properties;
		font_manager_font_properties_save (_tmp1_);
	}
	return;
}

FontManagerFontProperties*
font_manager_display_preferences_get_properties (FontManagerDisplayPreferences* self)
{
	FontManagerFontProperties* result;
	FontManagerFontProperties* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_properties;
	result = _tmp0_;
	return result;
}

static void
font_manager_display_preferences_set_properties (FontManagerDisplayPreferences* self,
                                                 FontManagerFontProperties* value)
{
	FontManagerFontProperties* old_value;
	g_return_if_fail (self != NULL);
	old_value = font_manager_display_preferences_get_properties (self);
	if (old_value != value) {
		FontManagerFontProperties* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_properties);
		self->priv->_properties = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, font_manager_display_preferences_properties[FONT_MANAGER_DISPLAY_PREFERENCES_PROPERTIES_PROPERTY]);
	}
}

static void
font_manager_display_preferences_class_init (FontManagerDisplayPreferencesClass * klass,
                                             gpointer klass_data)
{
	font_manager_display_preferences_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FontManagerDisplayPreferences_private_offset);
	((FontManagerPreferenceListClass *) klass)->on_map = (void (*) (FontManagerPreferenceList*)) font_manager_display_preferences_real_on_map;
	((FontManagerPreferenceListClass *) klass)->on_unmap = (void (*) (FontManagerPreferenceList*)) font_manager_display_preferences_real_on_unmap;
	G_OBJECT_CLASS (klass)->get_property = _vala_font_manager_display_preferences_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_font_manager_display_preferences_set_property;
	G_OBJECT_CLASS (klass)->finalize = font_manager_display_preferences_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FONT_MANAGER_DISPLAY_PREFERENCES_PROPERTIES_PROPERTY, font_manager_display_preferences_properties[FONT_MANAGER_DISPLAY_PREFERENCES_PROPERTIES_PROPERTY] = g_param_spec_object ("properties", "properties", "properties", font_manager_font_properties_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
font_manager_display_preferences_instance_init (FontManagerDisplayPreferences * self,
                                                gpointer klass)
{
	self->priv = font_manager_display_preferences_get_instance_private (self);
	self->priv->initialized = FALSE;
}

static void
font_manager_display_preferences_finalize (GObject * obj)
{
	FontManagerDisplayPreferences * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FONT_MANAGER_TYPE_DISPLAY_PREFERENCES, FontManagerDisplayPreferences);
	_g_object_unref0 (self->priv->_properties);
	_g_object_unref0 (self->priv->dpi);
	_g_object_unref0 (self->priv->scale);
	_g_object_unref0 (self->priv->lcdfilter);
	_g_object_unref0 (self->priv->spg);
	G_OBJECT_CLASS (font_manager_display_preferences_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
font_manager_display_preferences_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FontManagerDisplayPreferencesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) font_manager_display_preferences_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FontManagerDisplayPreferences), 0, (GInstanceInitFunc) font_manager_display_preferences_instance_init, NULL };
	GType font_manager_display_preferences_type_id;
	font_manager_display_preferences_type_id = g_type_register_static (FONT_MANAGER_TYPE_PREFERENCE_LIST, "FontManagerDisplayPreferences", &g_define_type_info, 0);
	FontManagerDisplayPreferences_private_offset = g_type_add_instance_private (font_manager_display_preferences_type_id, sizeof (FontManagerDisplayPreferencesPrivate));
	return font_manager_display_preferences_type_id;
}

GType
font_manager_display_preferences_get_type (void)
{
	static volatile gsize font_manager_display_preferences_type_id__once = 0;
	if (g_once_init_enter (&font_manager_display_preferences_type_id__once)) {
		GType font_manager_display_preferences_type_id;
		font_manager_display_preferences_type_id = font_manager_display_preferences_get_type_once ();
		g_once_init_leave (&font_manager_display_preferences_type_id__once, font_manager_display_preferences_type_id);
	}
	return font_manager_display_preferences_type_id__once;
}

static void
_vala_font_manager_display_preferences_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec)
{
	FontManagerDisplayPreferences * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FONT_MANAGER_TYPE_DISPLAY_PREFERENCES, FontManagerDisplayPreferences);
	switch (property_id) {
		case FONT_MANAGER_DISPLAY_PREFERENCES_PROPERTIES_PROPERTY:
		g_value_set_object (value, font_manager_display_preferences_get_properties (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_font_manager_display_preferences_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec)
{
	FontManagerDisplayPreferences * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FONT_MANAGER_TYPE_DISPLAY_PREFERENCES, FontManagerDisplayPreferences);
	switch (property_id) {
		case FONT_MANAGER_DISPLAY_PREFERENCES_PROPERTIES_PROPERTY:
		font_manager_display_preferences_set_properties (self, g_value_get_object (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;
}

