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

/* Application.vala
 *
 * Copyright (C) 2009-2025 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 <gtk/gtk.h>
#include <glib-object.h>
#include <gio/gio.h>
#include "font-manager.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <glib/gi18n-lib.h>
#include "config.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_FONT_VIEWER_TYPE_APPLICATION (font_manager_font_viewer_application_get_type ())
#define FONT_MANAGER_FONT_VIEWER_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_MANAGER_FONT_VIEWER_TYPE_APPLICATION, FontManagerFontViewerApplication))
#define FONT_MANAGER_FONT_VIEWER_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FONT_MANAGER_FONT_VIEWER_TYPE_APPLICATION, FontManagerFontViewerApplicationClass))
#define FONT_MANAGER_FONT_VIEWER_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FONT_MANAGER_FONT_VIEWER_TYPE_APPLICATION))
#define FONT_MANAGER_FONT_VIEWER_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FONT_MANAGER_FONT_VIEWER_TYPE_APPLICATION))
#define FONT_MANAGER_FONT_VIEWER_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FONT_MANAGER_FONT_VIEWER_TYPE_APPLICATION, FontManagerFontViewerApplicationClass))

typedef struct _FontManagerFontViewerApplication FontManagerFontViewerApplication;
typedef struct _FontManagerFontViewerApplicationClass FontManagerFontViewerApplicationClass;
typedef struct _FontManagerFontViewerApplicationPrivate FontManagerFontViewerApplicationPrivate;

#define FONT_MANAGER_FONT_VIEWER_TYPE_MAIN_WINDOW (font_manager_font_viewer_main_window_get_type ())
#define FONT_MANAGER_FONT_VIEWER_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_MANAGER_FONT_VIEWER_TYPE_MAIN_WINDOW, FontManagerFontViewerMainWindow))
#define FONT_MANAGER_FONT_VIEWER_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FONT_MANAGER_FONT_VIEWER_TYPE_MAIN_WINDOW, FontManagerFontViewerMainWindowClass))
#define FONT_MANAGER_FONT_VIEWER_IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FONT_MANAGER_FONT_VIEWER_TYPE_MAIN_WINDOW))
#define FONT_MANAGER_FONT_VIEWER_IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FONT_MANAGER_FONT_VIEWER_TYPE_MAIN_WINDOW))
#define FONT_MANAGER_FONT_VIEWER_MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FONT_MANAGER_FONT_VIEWER_TYPE_MAIN_WINDOW, FontManagerFontViewerMainWindowClass))

typedef struct _FontManagerFontViewerMainWindow FontManagerFontViewerMainWindow;
typedef struct _FontManagerFontViewerMainWindowClass FontManagerFontViewerMainWindowClass;
enum  {
	FONT_MANAGER_FONT_VIEWER_APPLICATION_0_PROPERTY,
	FONT_MANAGER_FONT_VIEWER_APPLICATION_MAIN_WINDOW_PROPERTY,
	FONT_MANAGER_FONT_VIEWER_APPLICATION_SETTINGS_PROPERTY,
	FONT_MANAGER_FONT_VIEWER_APPLICATION_NUM_PROPERTIES
};
static GParamSpec* font_manager_font_viewer_application_properties[FONT_MANAGER_FONT_VIEWER_APPLICATION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_variant_dict_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_dict_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _FontManagerFontViewerApplication {
	GtkApplication parent_instance;
	FontManagerFontViewerApplicationPrivate * priv;
};

struct _FontManagerFontViewerApplicationClass {
	GtkApplicationClass parent_class;
};

struct _FontManagerFontViewerApplicationPrivate {
	FontManagerFontViewerMainWindow* _main_window;
	GSettings* _settings;
	guint dbus_id;
};

static gint FontManagerFontViewerApplication_private_offset;
static gpointer font_manager_font_viewer_application_parent_class = NULL;

VALA_EXTERN GType font_manager_font_viewer_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FontManagerFontViewerApplication, g_object_unref)
VALA_EXTERN guint font_manager_font_viewer_application_register_object (void* object,
                                                            GDBusConnection* connection,
                                                            const gchar* path,
                                                            GError** error);
VALA_EXTERN GType font_manager_font_viewer_main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FontManagerFontViewerMainWindow, g_object_unref)
VALA_EXTERN FontManagerFontViewerApplication* font_manager_font_viewer_application_new (const gchar* app_id,
                                                                            GApplicationFlags app_flags);
VALA_EXTERN FontManagerFontViewerApplication* font_manager_font_viewer_application_construct (GType object_type,
                                                                                  const gchar* app_id,
                                                                                  GApplicationFlags app_flags);
VALA_EXTERN gboolean font_manager_font_viewer_application_ready (FontManagerFontViewerApplication* self,
                                                     GError** error);
VALA_EXTERN FontManagerFontViewerMainWindow* font_manager_font_viewer_application_get_main_window (FontManagerFontViewerApplication* self);
VALA_EXTERN void font_manager_font_viewer_application_show_uri (FontManagerFontViewerApplication* self,
                                                    const gchar* uri,
                                                    GError** error);
VALA_EXTERN void font_manager_font_viewer_main_window_show_uri (FontManagerFontViewerMainWindow* self,
                                                    const gchar* uri);
static void font_manager_font_viewer_application_real_open (GApplication* base,
                                                     GFile** files,
                                                     gint files_length1,
                                                     const gchar* hint);
VALA_EXTERN void font_manager_font_viewer_main_window_open (FontManagerFontViewerMainWindow* self,
                                                GFile* file);
static void font_manager_font_viewer_application_real_activate (GApplication* base);
static void font_manager_font_viewer_application_set_settings (FontManagerFontViewerApplication* self,
                                                        GSettings* value);
VALA_EXTERN GSettings* font_manager_font_viewer_application_get_settings (FontManagerFontViewerApplication* self);
VALA_EXTERN FontManagerFontViewerMainWindow* font_manager_font_viewer_main_window_new (GSettings* settings);
VALA_EXTERN FontManagerFontViewerMainWindow* font_manager_font_viewer_main_window_construct (GType object_type,
                                                                                 GSettings* settings);
static void font_manager_font_viewer_application_set_main_window (FontManagerFontViewerApplication* self,
                                                           FontManagerFontViewerMainWindow* value);
static void ___lambda8_ (FontManagerFontViewerApplication* self);
static void ____lambda8__gtk_widget_realize (GtkWidget* _sender,
                                      gpointer self);
static void ___lambda9_ (FontManagerFontViewerApplication* self);
static void ____lambda9__g_application_shutdown (GApplication* _sender,
                                          gpointer self);
VALA_EXTERN void font_manager_font_viewer_main_window_update (FontManagerFontViewerMainWindow* self);
static gint font_manager_font_viewer_application_real_command_line (GApplication* base,
                                                             GApplicationCommandLine* cl);
static gint font_manager_font_viewer_application_real_handle_local_options (GApplication* base,
                                                                     GVariantDict* options);
static gboolean font_manager_font_viewer_application_real_dbus_register (GApplication* base,
                                                                  GDBusConnection* conn,
                                                                  const gchar* path,
                                                                  GError** error);
static void font_manager_font_viewer_application_real_dbus_unregister (GApplication* base,
                                                                GDBusConnection* conn,
                                                                const gchar* path);
static gint font_manager_font_viewer_application_main (gchar** args,
                                                gint args_length1);
static void font_manager_font_viewer_application_finalize (GObject * obj);
static GType font_manager_font_viewer_application_get_type_once (void);
static void _vala_font_manager_font_viewer_application_get_property (GObject * object,
                                                              guint property_id,
                                                              GValue * value,
                                                              GParamSpec * pspec);
static void _vala_font_manager_font_viewer_application_set_property (GObject * object,
                                                              guint property_id,
                                                              const GValue * value,
                                                              GParamSpec * pspec);
static void _dbus_font_manager_font_viewer_application_ready (FontManagerFontViewerApplication* self,
                                                       GVariant* _parameters_,
                                                       GDBusMethodInvocation* invocation);
static void _dbus_font_manager_font_viewer_application_show_uri (FontManagerFontViewerApplication* self,
                                                          GVariant* _parameters_,
                                                          GDBusMethodInvocation* invocation);
static void font_manager_font_viewer_application_dbus_interface_method_call (GDBusConnection* connection,
                                                                      const gchar* sender,
                                                                      const gchar* object_path,
                                                                      const gchar* interface_name,
                                                                      const gchar* method_name,
                                                                      GVariant* parameters,
                                                                      GDBusMethodInvocation* invocation,
                                                                      gpointer user_data);
static GVariant* font_manager_font_viewer_application_dbus_interface_get_property (GDBusConnection* connection,
                                                                            const gchar* sender,
                                                                            const gchar* object_path,
                                                                            const gchar* interface_name,
                                                                            const gchar* property_name,
                                                                            GError** error,
                                                                            gpointer user_data);
static gboolean font_manager_font_viewer_application_dbus_interface_set_property (GDBusConnection* connection,
                                                                           const gchar* sender,
                                                                           const gchar* object_path,
                                                                           const gchar* interface_name,
                                                                           const gchar* property_name,
                                                                           GVariant* value,
                                                                           GError** error,
                                                                           gpointer user_data);
static void _font_manager_font_viewer_application_unregister_object (gpointer user_data);
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 const GOptionEntry FONT_MANAGER_FONT_VIEWER_APPLICATION_options[4] = {{"version", 'v', (gint) 0, G_OPTION_ARG_NONE, NULL, "Show application version", NULL}, {"debug", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, NULL, "Enable debug messages", NULL}, {"", (gchar) 0, (gint) 0, G_OPTION_ARG_FILENAME_ARRAY, NULL, NULL, NULL}, {NULL}};
static const GDBusArgInfo _font_manager_font_viewer_application_dbus_arg_info_ready_result = {-1, "result", "b", NULL};
static const GDBusArgInfo * const _font_manager_font_viewer_application_dbus_arg_info_ready_in[] = {NULL};
static const GDBusArgInfo * const _font_manager_font_viewer_application_dbus_arg_info_ready_out[] = {&_font_manager_font_viewer_application_dbus_arg_info_ready_result, NULL};
static const GDBusMethodInfo _font_manager_font_viewer_application_dbus_method_info_ready = {-1, "Ready", (GDBusArgInfo **) (&_font_manager_font_viewer_application_dbus_arg_info_ready_in), (GDBusArgInfo **) (&_font_manager_font_viewer_application_dbus_arg_info_ready_out), NULL};
static const GDBusArgInfo _font_manager_font_viewer_application_dbus_arg_info_show_uri_uri = {-1, "uri", "s", NULL};
static const GDBusArgInfo * const _font_manager_font_viewer_application_dbus_arg_info_show_uri_in[] = {&_font_manager_font_viewer_application_dbus_arg_info_show_uri_uri, NULL};
static const GDBusArgInfo * const _font_manager_font_viewer_application_dbus_arg_info_show_uri_out[] = {NULL};
static const GDBusMethodInfo _font_manager_font_viewer_application_dbus_method_info_show_uri = {-1, "ShowUri", (GDBusArgInfo **) (&_font_manager_font_viewer_application_dbus_arg_info_show_uri_in), (GDBusArgInfo **) (&_font_manager_font_viewer_application_dbus_arg_info_show_uri_out), NULL};
static const GDBusMethodInfo * const _font_manager_font_viewer_application_dbus_method_info[] = {&_font_manager_font_viewer_application_dbus_method_info_ready, &_font_manager_font_viewer_application_dbus_method_info_show_uri, NULL};
static const GDBusSignalInfo * const _font_manager_font_viewer_application_dbus_signal_info[] = {NULL};
static const GDBusPropertyInfo * const _font_manager_font_viewer_application_dbus_property_info[] = {NULL};
static const GDBusInterfaceInfo _font_manager_font_viewer_application_dbus_interface_info = {-1, "com.github.FontManager.FontViewer", (GDBusMethodInfo **) (&_font_manager_font_viewer_application_dbus_method_info), (GDBusSignalInfo **) (&_font_manager_font_viewer_application_dbus_signal_info), (GDBusPropertyInfo **) (&_font_manager_font_viewer_application_dbus_property_info), NULL};
static const GDBusInterfaceVTable _font_manager_font_viewer_application_dbus_interface_vtable = {font_manager_font_viewer_application_dbus_interface_method_call, font_manager_font_viewer_application_dbus_interface_get_property, font_manager_font_viewer_application_dbus_interface_set_property};

static inline gpointer
font_manager_font_viewer_application_get_instance_private (FontManagerFontViewerApplication* self)
{
	return G_STRUCT_MEMBER_P (self, FontManagerFontViewerApplication_private_offset);
}

FontManagerFontViewerApplication*
font_manager_font_viewer_application_construct (GType object_type,
                                                const gchar* app_id,
                                                GApplicationFlags app_flags)
{
	FontManagerFontViewerApplication * self = NULL;
	g_return_val_if_fail (app_id != NULL, NULL);
	self = (FontManagerFontViewerApplication*) g_object_new (object_type, "application-id", app_id, "flags", app_flags, NULL);
	g_application_add_main_option_entries ((GApplication*) self, FONT_MANAGER_FONT_VIEWER_APPLICATION_options);
	return self;
}

FontManagerFontViewerApplication*
font_manager_font_viewer_application_new (const gchar* app_id,
                                          GApplicationFlags app_flags)
{
	return font_manager_font_viewer_application_construct (FONT_MANAGER_FONT_VIEWER_TYPE_APPLICATION, app_id, app_flags);
}

gboolean
font_manager_font_viewer_application_ready (FontManagerFontViewerApplication* self,
                                            GError** error)
{
	gboolean _tmp0_ = FALSE;
	FontManagerFontViewerMainWindow* _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = self->priv->_main_window;
	if (_tmp1_ != NULL) {
		FontManagerFontViewerMainWindow* _tmp2_;
		_tmp2_ = self->priv->_main_window;
		_tmp0_ = gtk_widget_is_visible ((GtkWidget*) _tmp2_);
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

void
font_manager_font_viewer_application_show_uri (FontManagerFontViewerApplication* self,
                                               const gchar* uri,
                                               GError** error)
{
	gboolean _tmp0_ = FALSE;
	FontManagerFontViewerMainWindow* _tmp1_;
	FontManagerFontViewerMainWindow* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (uri != NULL);
	_tmp1_ = self->priv->_main_window;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		FontManagerFontViewerMainWindow* _tmp2_;
		_tmp2_ = self->priv->_main_window;
		_tmp0_ = !gtk_widget_is_visible ((GtkWidget*) _tmp2_);
	}
	if (_tmp0_) {
		g_application_activate ((GApplication*) self);
	}
	_tmp3_ = self->priv->_main_window;
	font_manager_font_viewer_main_window_show_uri (_tmp3_, uri);
	return;
}

static void
font_manager_font_viewer_application_real_open (GApplication* base,
                                                GFile** files,
                                                gint files_length1,
                                                const gchar* hint)
{
	FontManagerFontViewerApplication * self;
	gboolean _tmp0_ = FALSE;
	FontManagerFontViewerMainWindow* _tmp1_;
	FontManagerFontViewerMainWindow* _tmp3_;
	GFile* _tmp4_;
	self = (FontManagerFontViewerApplication*) base;
	g_return_if_fail (hint != NULL);
	_tmp1_ = self->priv->_main_window;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		FontManagerFontViewerMainWindow* _tmp2_;
		_tmp2_ = self->priv->_main_window;
		_tmp0_ = !gtk_widget_is_visible ((GtkWidget*) _tmp2_);
	}
	if (_tmp0_) {
		g_application_activate ((GApplication*) self);
	}
	_tmp3_ = self->priv->_main_window;
	_tmp4_ = files[0];
	font_manager_font_viewer_main_window_open (_tmp3_, _tmp4_);
	return;
}

static void
___lambda8_ (FontManagerFontViewerApplication* self)
{
	FontManagerFontViewerMainWindow* _tmp0_;
	_tmp0_ = self->priv->_main_window;
	font_manager_application_window_restore_state ((FontManagerApplicationWindow*) _tmp0_);
}

static void
____lambda8__gtk_widget_realize (GtkWidget* _sender,
                                 gpointer self)
{
	___lambda8_ ((FontManagerFontViewerApplication*) self);
}

static void
___lambda9_ (FontManagerFontViewerApplication* self)
{
	g_application_quit ((GApplication*) self);
}

static void
____lambda9__g_application_shutdown (GApplication* _sender,
                                     gpointer self)
{
	___lambda9_ ((FontManagerFontViewerApplication*) self);
}

static void
font_manager_font_viewer_application_real_activate (GApplication* base)
{
	FontManagerFontViewerApplication * self;
	FontManagerFontViewerMainWindow* _tmp0_;
	FontManagerFontViewerMainWindow* _tmp8_;
	FontManagerFontViewerMainWindow* _tmp9_;
	self = (FontManagerFontViewerApplication*) base;
	g_object_set ((GtkApplication*) self, "register-session", TRUE, NULL);
	_tmp0_ = self->priv->_main_window;
	if (_tmp0_ == NULL) {
		GSettings* _tmp1_;
		GSettings* _tmp2_;
		GSettings* _tmp3_;
		FontManagerFontViewerMainWindow* _tmp4_;
		FontManagerFontViewerMainWindow* _tmp5_;
		FontManagerFontViewerMainWindow* _tmp6_;
		FontManagerFontViewerMainWindow* _tmp7_;
		_tmp1_ = font_manager_get_gsettings (FONT_MANAGER_FONT_VIEWER_BUS_ID);
		_tmp2_ = _tmp1_;
		font_manager_font_viewer_application_set_settings (self, _tmp2_);
		_g_object_unref0 (_tmp2_);
		_tmp3_ = self->priv->_settings;
		_tmp4_ = font_manager_font_viewer_main_window_new (_tmp3_);
		g_object_ref_sink (_tmp4_);
		_tmp5_ = _tmp4_;
		font_manager_font_viewer_application_set_main_window (self, _tmp5_);
		_g_object_unref0 (_tmp5_);
		_tmp6_ = self->priv->_main_window;
		gtk_application_add_window ((GtkApplication*) self, (GtkWindow*) _tmp6_);
		_tmp7_ = self->priv->_main_window;
		g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_widget_get_type (), GtkWidget), "realize", (GCallback) ____lambda8__gtk_widget_realize, self, G_CONNECT_AFTER);
		g_signal_connect_object ((GApplication*) self, "shutdown", (GCallback) ____lambda9__g_application_shutdown, self, 0);
	}
	_tmp8_ = self->priv->_main_window;
	gtk_window_present ((GtkWindow*) _tmp8_);
	_tmp9_ = self->priv->_main_window;
	font_manager_font_viewer_main_window_update (_tmp9_);
	return;
}

static gpointer
_g_variant_dict_ref0 (gpointer self)
{
	return self ? g_variant_dict_ref (self) : NULL;
}

static gint
font_manager_font_viewer_application_real_command_line (GApplication* base,
                                                        GApplicationCommandLine* cl)
{
	FontManagerFontViewerApplication * self;
	GVariantDict* options = NULL;
	GVariantDict* _tmp0_;
	GVariantDict* _tmp1_;
	GVariantDict* _tmp2_;
	FontManagerStringSet* filelist = NULL;
	FontManagerStringSet* _tmp4_;
	FontManagerStringSet* _tmp5_;
	gint result;
	self = (FontManagerFontViewerApplication*) base;
	g_return_val_if_fail (cl != NULL, 0);
	g_application_hold ((GApplication*) self);
	_tmp0_ = g_application_command_line_get_options_dict (cl);
	_tmp1_ = _g_variant_dict_ref0 (_tmp0_);
	options = _tmp1_;
	_tmp2_ = options;
	if (g_variant_dict_contains (_tmp2_, "debug")) {
		FILE* _tmp3_;
		g_setenv ("G_MESSAGES_DEBUG", "[font-manager]", TRUE);
		_tmp3_ = stdout;
		fprintf (_tmp3_, "\n%s %s\n\n", _ ("Font Viewer"), PACKAGE_VERSION);
		font_manager_print_os_info ();
		font_manager_print_library_versions ();
	}
	_tmp4_ = font_manager_get_command_line_files (cl);
	filelist = _tmp4_;
	_tmp5_ = filelist;
	if (_tmp5_ != NULL) {
		GFile** files = NULL;
		FontManagerStringSet* _tmp6_;
		const gchar* _tmp7_;
		GFile* _tmp8_;
		GFile** _tmp9_;
		gint files_length1;
		gint _files_size_;
		GFile** _tmp10_;
		gint _tmp10__length1;
		_tmp6_ = filelist;
		_tmp7_ = font_manager_string_set_get (_tmp6_, (guint) 0);
		_tmp8_ = g_file_new_for_path (_tmp7_);
		_tmp9_ = g_new0 (GFile*, 1 + 1);
		_tmp9_[0] = _tmp8_;
		files = _tmp9_;
		files_length1 = 1;
		_files_size_ = files_length1;
		_tmp10_ = files;
		_tmp10__length1 = files_length1;
		g_application_open ((GApplication*) self, _tmp10_, (gint) _tmp10__length1, "null");
		files = (_vala_array_free (files, files_length1, (GDestroyNotify) g_object_unref), NULL);
	} else {
		g_application_activate ((GApplication*) self);
	}
	g_application_release ((GApplication*) self);
	result = 0;
	_g_object_unref0 (filelist);
	_g_variant_dict_unref0 (options);
	return result;
}

static gint
font_manager_font_viewer_application_real_handle_local_options (GApplication* base,
                                                                GVariantDict* options)
{
	FontManagerFontViewerApplication * self;
	gint exit_status = 0;
	gint result;
	self = (FontManagerFontViewerApplication*) base;
	g_return_val_if_fail (options != NULL, 0);
	exit_status = -1;
	if (g_variant_dict_contains (options, "version")) {
		FILE* _tmp0_;
		_tmp0_ = stdout;
		fprintf (_tmp0_, "%s %s\n", _ ("Font Viewer"), PACKAGE_VERSION);
		result = 0;
		return result;
	}
	result = exit_status;
	return result;
}

static gboolean
font_manager_font_viewer_application_real_dbus_register (GApplication* base,
                                                         GDBusConnection* conn,
                                                         const gchar* path,
                                                         GError** error)
{
	FontManagerFontViewerApplication * self;
	guint _tmp1_ = 0U;
	guint _tmp2_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	self = (FontManagerFontViewerApplication*) base;
	g_return_val_if_fail (conn != NULL, FALSE);
	g_return_val_if_fail (path != NULL, FALSE);
	G_APPLICATION_CLASS (font_manager_font_viewer_application_parent_class)->dbus_register ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_application_get_type (), GtkApplication), conn, path, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp0_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp0_;
	}
	_tmp2_ = font_manager_font_viewer_application_register_object (self, conn, FONT_MANAGER_FONT_VIEWER_BUS_PATH, &_inner_error0_);
	_tmp1_ = _tmp2_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp3_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp3_;
	}
	self->priv->dbus_id = _tmp1_;
	if (self->priv->dbus_id == ((guint) 0)) {
		g_critical ("Application.vala:119: Could not register Font Viewer service ");
	}
	result = TRUE;
	return result;
}

static void
font_manager_font_viewer_application_real_dbus_unregister (GApplication* base,
                                                           GDBusConnection* conn,
                                                           const gchar* path)
{
	FontManagerFontViewerApplication * self;
	self = (FontManagerFontViewerApplication*) base;
	g_return_if_fail (conn != NULL);
	g_return_if_fail (path != NULL);
	if (self->priv->dbus_id != ((guint) 0)) {
		g_dbus_connection_unregister_object (conn, self->priv->dbus_id);
	}
	G_APPLICATION_CLASS (font_manager_font_viewer_application_parent_class)->dbus_unregister ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_application_get_type (), GtkApplication), conn, path);
}

static gint
font_manager_font_viewer_application_main (gchar** args,
                                           gint args_length1)
{
	GApplicationFlags FLAGS = 0U;
	FontManagerFontViewerApplication* _tmp0_;
	FontManagerFontViewerApplication* _tmp1_;
	gint _tmp2_;
	gint result;
	font_manager_setup_i18n ();
	g_set_application_name (_ ("Font Viewer"));
	FLAGS = G_APPLICATION_HANDLES_COMMAND_LINE | G_APPLICATION_HANDLES_OPEN;
	_tmp0_ = font_manager_font_viewer_application_new (FONT_MANAGER_FONT_VIEWER_BUS_ID, FLAGS);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_application_run ((GApplication*) _tmp1_, (gint) args_length1, args);
	_g_object_unref0 (_tmp1_);
	result = _tmp2_;
	return result;
}

int
main (int argc,
      char ** argv)
{
	return font_manager_font_viewer_application_main (argv, argc);
}

FontManagerFontViewerMainWindow*
font_manager_font_viewer_application_get_main_window (FontManagerFontViewerApplication* self)
{
	FontManagerFontViewerMainWindow* result;
	FontManagerFontViewerMainWindow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_main_window;
	result = _tmp0_;
	return result;
}

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

static void
font_manager_font_viewer_application_set_main_window (FontManagerFontViewerApplication* self,
                                                      FontManagerFontViewerMainWindow* value)
{
	FontManagerFontViewerMainWindow* old_value;
	g_return_if_fail (self != NULL);
	old_value = font_manager_font_viewer_application_get_main_window (self);
	if (old_value != value) {
		FontManagerFontViewerMainWindow* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_main_window);
		self->priv->_main_window = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, font_manager_font_viewer_application_properties[FONT_MANAGER_FONT_VIEWER_APPLICATION_MAIN_WINDOW_PROPERTY]);
	}
}

GSettings*
font_manager_font_viewer_application_get_settings (FontManagerFontViewerApplication* self)
{
	GSettings* result;
	GSettings* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_settings;
	result = _tmp0_;
	return result;
}

static void
font_manager_font_viewer_application_set_settings (FontManagerFontViewerApplication* self,
                                                   GSettings* value)
{
	GSettings* old_value;
	g_return_if_fail (self != NULL);
	old_value = font_manager_font_viewer_application_get_settings (self);
	if (old_value != value) {
		GSettings* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_settings);
		self->priv->_settings = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, font_manager_font_viewer_application_properties[FONT_MANAGER_FONT_VIEWER_APPLICATION_SETTINGS_PROPERTY]);
	}
}

static void
font_manager_font_viewer_application_class_init (FontManagerFontViewerApplicationClass * klass,
                                                 gpointer klass_data)
{
	font_manager_font_viewer_application_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FontManagerFontViewerApplication_private_offset);
	((GApplicationClass *) klass)->open = (void (*) (GApplication*, GFile**, gint, const gchar*)) font_manager_font_viewer_application_real_open;
	((GApplicationClass *) klass)->activate = (void (*) (GApplication*)) font_manager_font_viewer_application_real_activate;
	((GApplicationClass *) klass)->command_line = (gint (*) (GApplication*, GApplicationCommandLine*)) font_manager_font_viewer_application_real_command_line;
	((GApplicationClass *) klass)->handle_local_options = (gint (*) (GApplication*, GVariantDict*)) font_manager_font_viewer_application_real_handle_local_options;
	((GApplicationClass *) klass)->dbus_register = (gboolean (*) (GApplication*, GDBusConnection*, const gchar*, GError**)) font_manager_font_viewer_application_real_dbus_register;
	((GApplicationClass *) klass)->dbus_unregister = (void (*) (GApplication*, GDBusConnection*, const gchar*)) font_manager_font_viewer_application_real_dbus_unregister;
	G_OBJECT_CLASS (klass)->get_property = _vala_font_manager_font_viewer_application_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_font_manager_font_viewer_application_set_property;
	G_OBJECT_CLASS (klass)->finalize = font_manager_font_viewer_application_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FONT_MANAGER_FONT_VIEWER_APPLICATION_MAIN_WINDOW_PROPERTY, font_manager_font_viewer_application_properties[FONT_MANAGER_FONT_VIEWER_APPLICATION_MAIN_WINDOW_PROPERTY] = g_param_spec_object ("main-window", "main-window", "main-window", FONT_MANAGER_FONT_VIEWER_TYPE_MAIN_WINDOW, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FONT_MANAGER_FONT_VIEWER_APPLICATION_SETTINGS_PROPERTY, font_manager_font_viewer_application_properties[FONT_MANAGER_FONT_VIEWER_APPLICATION_SETTINGS_PROPERTY] = g_param_spec_object ("settings", "settings", "settings", g_settings_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
font_manager_font_viewer_application_instance_init (FontManagerFontViewerApplication * self,
                                                    gpointer klass)
{
	self->priv = font_manager_font_viewer_application_get_instance_private (self);
	self->priv->_main_window = NULL;
	self->priv->_settings = NULL;
	self->priv->dbus_id = (guint) 0;
}

static void
font_manager_font_viewer_application_finalize (GObject * obj)
{
	FontManagerFontViewerApplication * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FONT_MANAGER_FONT_VIEWER_TYPE_APPLICATION, FontManagerFontViewerApplication);
	_g_object_unref0 (self->priv->_main_window);
	_g_object_unref0 (self->priv->_settings);
	G_OBJECT_CLASS (font_manager_font_viewer_application_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
font_manager_font_viewer_application_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FontManagerFontViewerApplicationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) font_manager_font_viewer_application_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FontManagerFontViewerApplication), 0, (GInstanceInitFunc) font_manager_font_viewer_application_instance_init, NULL };
	GType font_manager_font_viewer_application_type_id;
	font_manager_font_viewer_application_type_id = g_type_register_static (gtk_application_get_type (), "FontManagerFontViewerApplication", &g_define_type_info, 0);
	g_type_set_qdata (font_manager_font_viewer_application_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) font_manager_font_viewer_application_register_object);
	FontManagerFontViewerApplication_private_offset = g_type_add_instance_private (font_manager_font_viewer_application_type_id, sizeof (FontManagerFontViewerApplicationPrivate));
	return font_manager_font_viewer_application_type_id;
}

GType
font_manager_font_viewer_application_get_type (void)
{
	static volatile gsize font_manager_font_viewer_application_type_id__once = 0;
	if (g_once_init_enter (&font_manager_font_viewer_application_type_id__once)) {
		GType font_manager_font_viewer_application_type_id;
		font_manager_font_viewer_application_type_id = font_manager_font_viewer_application_get_type_once ();
		g_once_init_leave (&font_manager_font_viewer_application_type_id__once, font_manager_font_viewer_application_type_id);
	}
	return font_manager_font_viewer_application_type_id__once;
}

static void
_vala_font_manager_font_viewer_application_get_property (GObject * object,
                                                         guint property_id,
                                                         GValue * value,
                                                         GParamSpec * pspec)
{
	FontManagerFontViewerApplication * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FONT_MANAGER_FONT_VIEWER_TYPE_APPLICATION, FontManagerFontViewerApplication);
	switch (property_id) {
		case FONT_MANAGER_FONT_VIEWER_APPLICATION_MAIN_WINDOW_PROPERTY:
		g_value_set_object (value, font_manager_font_viewer_application_get_main_window (self));
		break;
		case FONT_MANAGER_FONT_VIEWER_APPLICATION_SETTINGS_PROPERTY:
		g_value_set_object (value, font_manager_font_viewer_application_get_settings (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_font_manager_font_viewer_application_set_property (GObject * object,
                                                         guint property_id,
                                                         const GValue * value,
                                                         GParamSpec * pspec)
{
	FontManagerFontViewerApplication * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FONT_MANAGER_FONT_VIEWER_TYPE_APPLICATION, FontManagerFontViewerApplication);
	switch (property_id) {
		case FONT_MANAGER_FONT_VIEWER_APPLICATION_MAIN_WINDOW_PROPERTY:
		font_manager_font_viewer_application_set_main_window (self, g_value_get_object (value));
		break;
		case FONT_MANAGER_FONT_VIEWER_APPLICATION_SETTINGS_PROPERTY:
		font_manager_font_viewer_application_set_settings (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_dbus_font_manager_font_viewer_application_ready (FontManagerFontViewerApplication* self,
                                                  GVariant* _parameters_,
                                                  GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	gboolean result;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	result = font_manager_font_viewer_application_ready (self, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		return;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	g_variant_builder_add_value (&_reply_builder, g_variant_new_boolean (result));
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
}

static void
_dbus_font_manager_font_viewer_application_show_uri (FontManagerFontViewerApplication* self,
                                                     GVariant* _parameters_,
                                                     GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	gchar* uri = NULL;
	GVariant* _tmp0_;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	_tmp0_ = g_variant_iter_next_value (&_arguments_iter);
	uri = g_variant_dup_string (_tmp0_, NULL);
	g_variant_unref (_tmp0_);
	font_manager_font_viewer_application_show_uri (self, uri, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		goto _error;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
	_error:
	_g_free0 (uri);
	;
}

static void
font_manager_font_viewer_application_dbus_interface_method_call (GDBusConnection* connection,
                                                                 const gchar* sender,
                                                                 const gchar* object_path,
                                                                 const gchar* interface_name,
                                                                 const gchar* method_name,
                                                                 GVariant* parameters,
                                                                 GDBusMethodInvocation* invocation,
                                                                 gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	if (strcmp (method_name, "Ready") == 0) {
		_dbus_font_manager_font_viewer_application_ready (object, parameters, invocation);
	} else if (strcmp (method_name, "ShowUri") == 0) {
		_dbus_font_manager_font_viewer_application_show_uri (object, parameters, invocation);
	} else {
		g_object_unref (invocation);
	}
}

static GVariant*
font_manager_font_viewer_application_dbus_interface_get_property (GDBusConnection* connection,
                                                                  const gchar* sender,
                                                                  const gchar* object_path,
                                                                  const gchar* interface_name,
                                                                  const gchar* property_name,
                                                                  GError** error,
                                                                  gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	return NULL;
}

static gboolean
font_manager_font_viewer_application_dbus_interface_set_property (GDBusConnection* connection,
                                                                  const gchar* sender,
                                                                  const gchar* object_path,
                                                                  const gchar* interface_name,
                                                                  const gchar* property_name,
                                                                  GVariant* value,
                                                                  GError** error,
                                                                  gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	return FALSE;
}

guint
font_manager_font_viewer_application_register_object (gpointer object,
                                                      GDBusConnection* connection,
                                                      const gchar* path,
                                                      GError** error)
{
	guint result;
	gpointer *data;
	data = g_new (gpointer, 3);
	data[0] = g_object_ref (object);
	data[1] = g_object_ref (connection);
	data[2] = g_strdup (path);
	result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_font_manager_font_viewer_application_dbus_interface_info), &_font_manager_font_viewer_application_dbus_interface_vtable, data, _font_manager_font_viewer_application_unregister_object, error);
	if (!result) {
		return 0;
	}
	return result;
}

static void
_font_manager_font_viewer_application_unregister_object (gpointer user_data)
{
	gpointer* data;
	data = user_data;
	g_object_unref (data[0]);
	g_object_unref (data[1]);
	g_free (data[2]);
	g_free (data);
}

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

