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

/*-
 * Copyright (c) 2013-2018 elementary LLC (https://elementary.io)
 *
 * 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/>.
 *
 * Authored by: Tom Beckmann <tomjonabc@gmail.com>
 *              Cody Garver <cody@elementaryos.org>
 *              Artem Anufrij <artem.anufrij@live.de>
 */

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include <granite-7.h>
#include <glib/gi18n-lib.h>
#include <locale.h>
#include <gst/gst.h>

#define AUDIENCE_SCHEMA "io.elementary.videos"
#define AUDIENCE_APP_ACTION_PREFIX "app."
#define AUDIENCE_APP_ACTION_NEXT "action-next"
#define AUDIENCE_APP_ACTION_PLAY_PAUSE "action-play-pause"
#define AUDIENCE_APP_ACTION_PREVIOUS "action-previous"
#define GETTEXT_PACKAGE "io.elementary.videos"
#define LOCALEDIR "/usr/share/locale"
#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 AUDIENCE_TYPE_APP (audience_app_get_type ())
#define AUDIENCE_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AUDIENCE_TYPE_APP, AudienceApp))
#define AUDIENCE_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AUDIENCE_TYPE_APP, AudienceAppClass))
#define AUDIENCE_IS_APP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AUDIENCE_TYPE_APP))
#define AUDIENCE_IS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AUDIENCE_TYPE_APP))
#define AUDIENCE_APP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AUDIENCE_TYPE_APP, AudienceAppClass))

typedef struct _AudienceApp AudienceApp;
typedef struct _AudienceAppClass AudienceAppClass;
typedef struct _AudienceAppPrivate AudienceAppPrivate;

#define AUDIENCE_TYPE_WINDOW (audience_window_get_type ())
#define AUDIENCE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AUDIENCE_TYPE_WINDOW, AudienceWindow))
#define AUDIENCE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AUDIENCE_TYPE_WINDOW, AudienceWindowClass))
#define AUDIENCE_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AUDIENCE_TYPE_WINDOW))
#define AUDIENCE_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AUDIENCE_TYPE_WINDOW))
#define AUDIENCE_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AUDIENCE_TYPE_WINDOW, AudienceWindowClass))

typedef struct _AudienceWindow AudienceWindow;
typedef struct _AudienceWindowClass AudienceWindowClass;
enum  {
	AUDIENCE_APP_0_PROPERTY,
	AUDIENCE_APP_NUM_PROPERTIES
};
static GParamSpec* audience_app_properties[AUDIENCE_APP_NUM_PROPERTIES];
typedef void (*GSimpleActionActivateCallback) (GSimpleAction* action, GVariant* parameter, gpointer user_data);
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block1Data Block1Data;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))

#define AUDIENCE_TYPE_PLAYBACK_MANAGER (audience_playback_manager_get_type ())
#define AUDIENCE_PLAYBACK_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AUDIENCE_TYPE_PLAYBACK_MANAGER, AudiencePlaybackManager))
#define AUDIENCE_PLAYBACK_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AUDIENCE_TYPE_PLAYBACK_MANAGER, AudiencePlaybackManagerClass))
#define AUDIENCE_IS_PLAYBACK_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AUDIENCE_TYPE_PLAYBACK_MANAGER))
#define AUDIENCE_IS_PLAYBACK_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AUDIENCE_TYPE_PLAYBACK_MANAGER))
#define AUDIENCE_PLAYBACK_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AUDIENCE_TYPE_PLAYBACK_MANAGER, AudiencePlaybackManagerClass))

typedef struct _AudiencePlaybackManager AudiencePlaybackManager;
typedef struct _AudiencePlaybackManagerClass AudiencePlaybackManagerClass;

#define VIDEOS_TYPE_MPRIS_ROOT (videos_mpris_root_get_type ())
#define VIDEOS_MPRIS_ROOT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIDEOS_TYPE_MPRIS_ROOT, VideosMprisRoot))
#define VIDEOS_MPRIS_ROOT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VIDEOS_TYPE_MPRIS_ROOT, VideosMprisRootClass))
#define VIDEOS_IS_MPRIS_ROOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIDEOS_TYPE_MPRIS_ROOT))
#define VIDEOS_IS_MPRIS_ROOT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIDEOS_TYPE_MPRIS_ROOT))
#define VIDEOS_MPRIS_ROOT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VIDEOS_TYPE_MPRIS_ROOT, VideosMprisRootClass))

typedef struct _VideosMprisRoot VideosMprisRoot;
typedef struct _VideosMprisRootClass VideosMprisRootClass;

#define VIDEOS_TYPE_MPRIS_PLAYER (videos_mpris_player_get_type ())
#define VIDEOS_MPRIS_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIDEOS_TYPE_MPRIS_PLAYER, VideosMprisPlayer))
#define VIDEOS_MPRIS_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VIDEOS_TYPE_MPRIS_PLAYER, VideosMprisPlayerClass))
#define VIDEOS_IS_MPRIS_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIDEOS_TYPE_MPRIS_PLAYER))
#define VIDEOS_IS_MPRIS_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIDEOS_TYPE_MPRIS_PLAYER))
#define VIDEOS_MPRIS_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VIDEOS_TYPE_MPRIS_PLAYER, VideosMprisPlayerClass))

typedef struct _VideosMprisPlayer VideosMprisPlayer;
typedef struct _VideosMprisPlayerClass VideosMprisPlayerClass;

struct _AudienceApp {
	GtkApplication parent_instance;
	AudienceAppPrivate * priv;
	AudienceWindow* mainwindow;
	GVolumeMonitor* monitor;
};

struct _AudienceAppClass {
	GtkApplicationClass parent_class;
};

struct _Block1Data {
	int _ref_count_;
	AudienceApp* self;
	GraniteSettings* granite_settings;
	GtkSettings* gtk_settings;
};

VALA_EXTERN GSettings* audience_settings;
GSettings* audience_settings = NULL;
static gpointer audience_app_parent_class = NULL;
static AudienceApp* audience_app_app;
static AudienceApp* audience_app_app = NULL;

VALA_EXTERN GType audience_app_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AudienceApp, g_object_unref)
VALA_EXTERN GType audience_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AudienceWindow, g_object_unref)
static void audience_app_action_play_pause (AudienceApp* self);
static void _audience_app_action_play_pause_gsimple_action_activate_callback (GSimpleAction* action,
                                                                       GVariant* parameter,
                                                                       gpointer self);
static void audience_app_action_next (AudienceApp* self);
static void _audience_app_action_next_gsimple_action_activate_callback (GSimpleAction* action,
                                                                 GVariant* parameter,
                                                                 gpointer self);
static void audience_app_action_previous (AudienceApp* self);
static void _audience_app_action_previous_gsimple_action_activate_callback (GSimpleAction* action,
                                                                     GVariant* parameter,
                                                                     gpointer self);
VALA_EXTERN AudienceApp* audience_app_new (void);
VALA_EXTERN AudienceApp* audience_app_construct (GType object_type);
VALA_EXTERN AudienceApp* audience_app_get_instance (void);
static void audience_app_real_startup (GApplication* base);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void __lambda75_ (Block1Data* _data1_);
static void ___lambda75__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void audience_app_real_activate (GApplication* base);
VALA_EXTERN gchar* audience_app_get_cache_directory (AudienceApp* self);
static void audience_app_on_bus_acquired (AudienceApp* self,
                                   GDBusConnection* connection,
                                   const gchar* name);
static void _audience_app_on_bus_acquired_gbus_acquired_callback (GDBusConnection* connection,
                                                           const gchar* name,
                                                           gpointer self);
VALA_EXTERN AudienceWindow* audience_window_new (void);
VALA_EXTERN AudienceWindow* audience_window_construct (GType object_type);
static void audience_app_real_open (GApplication* base,
                             GFile** files,
                             gint files_length1,
                             const gchar* hint);
VALA_EXTERN void audience_window_open_files (AudienceWindow* self,
                                 GFile** files,
                                 gint files_length1,
                                 gboolean clear_playlist_items,
                                 gboolean force_play);
static GVariant* _variant_new1 (gboolean value);
static GVariant* _variant_new2 (gboolean value);
VALA_EXTERN GType audience_playback_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AudiencePlaybackManager, g_object_unref)
VALA_EXTERN AudiencePlaybackManager* audience_playback_manager_get_default (void);
VALA_EXTERN gboolean audience_playback_manager_next (AudiencePlaybackManager* self);
VALA_EXTERN void audience_playback_manager_previous (AudiencePlaybackManager* self);
VALA_EXTERN VideosMprisRoot* videos_mpris_root_new (void);
VALA_EXTERN VideosMprisRoot* videos_mpris_root_construct (GType object_type);
VALA_EXTERN GType videos_mpris_root_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (VideosMprisRoot, g_object_unref)
VALA_EXTERN guint videos_mpris_root_register_object (void* object,
                                         GDBusConnection* connection,
                                         const gchar* path,
                                         GError** error);
VALA_EXTERN VideosMprisPlayer* videos_mpris_player_new (GDBusConnection* connection);
VALA_EXTERN VideosMprisPlayer* videos_mpris_player_construct (GType object_type,
                                                  GDBusConnection* connection);
VALA_EXTERN GType videos_mpris_player_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (VideosMprisPlayer, g_object_unref)
VALA_EXTERN guint videos_mpris_player_register_object (void* object,
                                           GDBusConnection* connection,
                                           const gchar* path,
                                           GError** error);
static GObject * audience_app_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties);
static void audience_app_finalize (GObject * obj);
static GType audience_app_get_type_once (void);
static void _vala_main (gchar** args,
                 gint args_length1);

static const GActionEntry AUDIENCE_APP_ACTION_ENTRIES[3] = {{AUDIENCE_APP_ACTION_PLAY_PAUSE, _audience_app_action_play_pause_gsimple_action_activate_callback, NULL, "false"}, {AUDIENCE_APP_ACTION_NEXT, _audience_app_action_next_gsimple_action_activate_callback}, {AUDIENCE_APP_ACTION_PREVIOUS, _audience_app_action_previous_gsimple_action_activate_callback}};

static void
_audience_app_action_play_pause_gsimple_action_activate_callback (GSimpleAction* action,
                                                                  GVariant* parameter,
                                                                  gpointer self)
{
	audience_app_action_play_pause ((AudienceApp*) self);
}

static void
_audience_app_action_next_gsimple_action_activate_callback (GSimpleAction* action,
                                                            GVariant* parameter,
                                                            gpointer self)
{
	audience_app_action_next ((AudienceApp*) self);
}

static void
_audience_app_action_previous_gsimple_action_activate_callback (GSimpleAction* action,
                                                                GVariant* parameter,
                                                                gpointer self)
{
	audience_app_action_previous ((AudienceApp*) self);
}

AudienceApp*
audience_app_construct (GType object_type)
{
	AudienceApp * self = NULL;
	GApplicationFlags _tmp0_;
	GApplicationFlags _tmp1_;
	GSettings* _tmp2_;
	self = (AudienceApp*) g_object_new (object_type, NULL);
	_tmp0_ = g_application_get_flags ((GApplication*) self);
	_tmp1_ = _tmp0_;
	g_application_set_flags ((GApplication*) self, _tmp1_ | G_APPLICATION_HANDLES_OPEN);
	_tmp2_ = g_settings_new (AUDIENCE_SCHEMA);
	_g_object_unref0 (audience_settings);
	audience_settings = _tmp2_;
	return self;
}

AudienceApp*
audience_app_new (void)
{
	return audience_app_construct (AUDIENCE_TYPE_APP);
}

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

AudienceApp*
audience_app_get_instance (void)
{
	AudienceApp* _tmp0_;
	AudienceApp* _tmp2_;
	AudienceApp* _tmp3_;
	AudienceApp* result;
	_tmp0_ = audience_app_app;
	if (_tmp0_ == NULL) {
		AudienceApp* _tmp1_;
		_tmp1_ = audience_app_new ();
		_g_object_unref0 (audience_app_app);
		audience_app_app = _tmp1_;
	}
	_tmp2_ = audience_app_app;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		AudienceApp* self;
		self = _data1_->self;
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static void
__lambda75_ (Block1Data* _data1_)
{
	AudienceApp* self;
	GraniteSettingsColorScheme _tmp0_;
	GraniteSettingsColorScheme _tmp1_;
	self = _data1_->self;
	_tmp0_ = granite_settings_get_prefers_color_scheme (_data1_->granite_settings);
	_tmp1_ = _tmp0_;
	g_object_set (_data1_->gtk_settings, "gtk-application-prefer-dark-theme", _tmp1_ == GRANITE_SETTINGS_COLOR_SCHEME_DARK, NULL);
}

static void
___lambda75__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda75_ (self);
}

static void
audience_app_real_startup (GApplication* base)
{
	AudienceApp * self;
	Block1Data* _data1_;
	GraniteSettings* _tmp0_;
	GtkSettings* _tmp1_;
	GraniteSettingsColorScheme _tmp2_;
	GraniteSettingsColorScheme _tmp3_;
	self = (AudienceApp*) base;
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	G_APPLICATION_CLASS (audience_app_parent_class)->startup ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_application_get_type (), GtkApplication));
	granite_init ();
	_tmp0_ = granite_settings_get_default ();
	_data1_->granite_settings = _tmp0_;
	_tmp1_ = gtk_settings_get_default ();
	_data1_->gtk_settings = _tmp1_;
	g_signal_connect_data ((GObject*) _data1_->granite_settings, "notify::prefers-color-scheme", (GCallback) ___lambda75__g_object_notify, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	_tmp2_ = granite_settings_get_prefers_color_scheme (_data1_->granite_settings);
	_tmp3_ = _tmp2_;
	g_object_set (_data1_->gtk_settings, "gtk-application-prefer-dark-theme", _tmp3_ == GRANITE_SETTINGS_COLOR_SCHEME_DARK, NULL);
	block1_data_unref (_data1_);
	_data1_ = NULL;
}

static void
_audience_app_on_bus_acquired_gbus_acquired_callback (GDBusConnection* connection,
                                                      const gchar* name,
                                                      gpointer self)
{
	audience_app_on_bus_acquired ((AudienceApp*) self, connection, name);
}

static void
audience_app_real_activate (GApplication* base)
{
	AudienceApp * self;
	AudienceWindow* _tmp0_;
	GError* _inner_error0_ = NULL;
	self = (AudienceApp*) base;
	_tmp0_ = self->mainwindow;
	if (_tmp0_ == NULL) {
		GSettings* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		gboolean _tmp4_;
		guint mpris_id = 0U;
		AudienceWindow* _tmp15_;
		AudienceWindow* _tmp16_;
		AudienceWindow* _tmp17_;
		g_action_map_add_action_entries ((GActionMap*) self, AUDIENCE_APP_ACTION_ENTRIES, (gint) G_N_ELEMENTS (AUDIENCE_APP_ACTION_ENTRIES), self);
		_tmp1_ = audience_settings;
		_tmp2_ = g_settings_get_string (_tmp1_, "last-folder");
		_tmp3_ = _tmp2_;
		_tmp4_ = g_strcmp0 (_tmp3_, "-1") == 0;
		_g_free0 (_tmp3_);
		if (_tmp4_) {
			GSettings* _tmp5_;
			const gchar* _tmp6_;
			_tmp5_ = audience_settings;
			_tmp6_ = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS);
			g_settings_set_string (_tmp5_, "last-folder", _tmp6_);
		}
		{
			GFile* cache = NULL;
			gchar* _tmp7_;
			gchar* _tmp8_;
			GFile* _tmp9_;
			GFile* _tmp10_;
			GFile* _tmp11_;
			_tmp7_ = audience_app_get_cache_directory (self);
			_tmp8_ = _tmp7_;
			_tmp9_ = g_file_new_for_path (_tmp8_);
			_tmp10_ = _tmp9_;
			_g_free0 (_tmp8_);
			cache = _tmp10_;
			_tmp11_ = cache;
			if (!g_file_query_exists (_tmp11_, NULL)) {
				GFile* _tmp12_;
				_tmp12_ = cache;
				g_file_make_directory (_tmp12_, NULL, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (cache);
					goto __catch0_g_error;
				}
			}
			_g_object_unref0 (cache);
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			GError* _tmp13_;
			const gchar* _tmp14_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp13_ = e;
			_tmp14_ = _tmp13_->message;
			g_warning ("Application.vala:92: %s", _tmp14_);
			_g_error_free0 (e);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
		mpris_id = g_bus_own_name_with_closures (G_BUS_TYPE_SESSION, "org.mpris.MediaPlayer2.io.elementary.videos", G_BUS_NAME_OWNER_FLAGS_NONE, (GClosure*) ((_audience_app_on_bus_acquired_gbus_acquired_callback == NULL) ? NULL : g_cclosure_new ((GCallback) _audience_app_on_bus_acquired_gbus_acquired_callback, g_object_ref (self), (GClosureNotify) g_object_unref)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
		if (mpris_id == ((guint) 0)) {
			g_warning ("Application.vala:105: Could not initialize MPRIS session.\n");
		}
		_tmp15_ = audience_window_new ();
		g_object_ref_sink (_tmp15_);
		_g_object_unref0 (self->mainwindow);
		self->mainwindow = _tmp15_;
		_tmp16_ = self->mainwindow;
		gtk_window_set_application ((GtkWindow*) _tmp16_, (GtkApplication*) self);
		_tmp17_ = self->mainwindow;
		gtk_window_set_title ((GtkWindow*) _tmp17_, _ ("Videos"));
	}
}

gchar*
audience_app_get_cache_directory (AudienceApp* self)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_get_user_cache_dir ();
	_tmp1_ = g_application_get_application_id ((GApplication*) self);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_build_filename (_tmp0_, _tmp2_, NULL);
	result = _tmp3_;
	return result;
}

static void
audience_app_real_open (GApplication* base,
                        GFile** files,
                        gint files_length1,
                        const gchar* hint)
{
	AudienceApp * self;
	AudienceWindow* _tmp0_;
	self = (AudienceApp*) base;
	g_return_if_fail (hint != NULL);
	g_application_activate ((GApplication*) self);
	_tmp0_ = self->mainwindow;
	audience_window_open_files (_tmp0_, files, (gint) files_length1, TRUE, TRUE);
}

static GVariant*
_variant_new1 (gboolean value)
{
	return g_variant_ref_sink (g_variant_new_boolean (value));
}

static GVariant*
_variant_new2 (gboolean value)
{
	return g_variant_ref_sink (g_variant_new_boolean (value));
}

static void
audience_app_action_play_pause (AudienceApp* self)
{
	GAction* play_pause_action = NULL;
	GAction* _tmp0_;
	GAction* _tmp1_;
	GAction* _tmp2_;
	GVariant* _tmp3_;
	GVariant* _tmp4_;
	gboolean _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_action_map_lookup_action ((GActionMap*) self, AUDIENCE_APP_ACTION_PLAY_PAUSE);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	play_pause_action = _tmp1_;
	_tmp2_ = play_pause_action;
	_tmp3_ = g_action_get_state (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_variant_get_boolean (_tmp4_);
	_g_variant_unref0 (_tmp4_);
	if (_tmp5_) {
		GAction* _tmp6_;
		GVariant* _tmp7_;
		_tmp6_ = play_pause_action;
		_tmp7_ = _variant_new1 (FALSE);
		g_simple_action_set_state (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, g_simple_action_get_type (), GSimpleAction), _tmp7_);
		_g_variant_unref0 (_tmp7_);
	} else {
		GAction* _tmp8_;
		GVariant* _tmp9_;
		_tmp8_ = play_pause_action;
		_tmp9_ = _variant_new2 (TRUE);
		g_simple_action_set_state (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, g_simple_action_get_type (), GSimpleAction), _tmp9_);
		_g_variant_unref0 (_tmp9_);
	}
	_g_object_unref0 (play_pause_action);
}

static void
audience_app_action_next (AudienceApp* self)
{
	AudiencePlaybackManager* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = audience_playback_manager_get_default ();
	audience_playback_manager_next (_tmp0_);
}

static void
audience_app_action_previous (AudienceApp* self)
{
	AudiencePlaybackManager* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = audience_playback_manager_get_default ();
	audience_playback_manager_previous (_tmp0_);
}

static void
audience_app_on_bus_acquired (AudienceApp* self,
                              GDBusConnection* connection,
                              const gchar* name)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (connection != NULL);
	g_return_if_fail (name != NULL);
	{
		VideosMprisRoot* _tmp0_;
		VideosMprisRoot* _tmp1_;
		VideosMprisPlayer* _tmp2_;
		VideosMprisPlayer* _tmp3_;
		_tmp0_ = videos_mpris_root_new ();
		_tmp1_ = _tmp0_;
		videos_mpris_root_register_object (_tmp1_, connection, "/org/mpris/MediaPlayer2", &_inner_error0_);
		_g_object_unref0 (_tmp1_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
		_tmp2_ = videos_mpris_player_new (connection);
		_tmp3_ = _tmp2_;
		videos_mpris_player_register_object (_tmp3_, connection, "/org/mpris/MediaPlayer2", &_inner_error0_);
		_g_object_unref0 (_tmp3_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	goto __finally0;
	__catch0_g_io_error:
	{
		GError* e = NULL;
		GError* _tmp4_;
		const gchar* _tmp5_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp4_ = e;
		_tmp5_ = _tmp4_->message;
		g_warning ("Application.vala:146: could not create MPRIS player: %s\n", _tmp5_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static GObject *
audience_app_constructor (GType type,
                          guint n_construct_properties,
                          GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	AudienceApp * self;
	parent_class = G_OBJECT_CLASS (audience_app_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, AUDIENCE_TYPE_APP, AudienceApp);
	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	g_application_set_application_id ((GApplication*) self, "io.elementary.videos");
	return obj;
}

static void
audience_app_class_init (AudienceAppClass * klass,
                         gpointer klass_data)
{
	audience_app_parent_class = g_type_class_peek_parent (klass);
	((GApplicationClass *) klass)->startup = (void (*) (GApplication*)) audience_app_real_startup;
	((GApplicationClass *) klass)->activate = (void (*) (GApplication*)) audience_app_real_activate;
	((GApplicationClass *) klass)->open = (void (*) (GApplication*, GFile**, gint, const gchar*)) audience_app_real_open;
	G_OBJECT_CLASS (klass)->constructor = audience_app_constructor;
	G_OBJECT_CLASS (klass)->finalize = audience_app_finalize;
}

static void
audience_app_instance_init (AudienceApp * self,
                            gpointer klass)
{
}

static void
audience_app_finalize (GObject * obj)
{
	AudienceApp * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, AUDIENCE_TYPE_APP, AudienceApp);
	_g_object_unref0 (self->mainwindow);
	_g_object_unref0 (self->monitor);
	G_OBJECT_CLASS (audience_app_parent_class)->finalize (obj);
}

static GType
audience_app_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (AudienceAppClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) audience_app_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AudienceApp), 0, (GInstanceInitFunc) audience_app_instance_init, NULL };
	GType audience_app_type_id;
	audience_app_type_id = g_type_register_static (gtk_application_get_type (), "AudienceApp", &g_define_type_info, 0);
	return audience_app_type_id;
}

GType
audience_app_get_type (void)
{
	static volatile gsize audience_app_type_id__once = 0;
	if (g_once_init_enter (&audience_app_type_id__once)) {
		GType audience_app_type_id;
		audience_app_type_id = audience_app_get_type_once ();
		g_once_init_leave (&audience_app_type_id__once, audience_app_type_id);
	}
	return audience_app_type_id__once;
}

static void
_vala_main (gchar** args,
            gint args_length1)
{
	AudienceApp* app = NULL;
	AudienceApp* _tmp0_;
	gst_init ((gint*) (&args_length1), &args);
	_tmp0_ = audience_app_get_instance ();
	app = _tmp0_;
	g_application_run ((GApplication*) app, (gint) args_length1, args);
	_g_object_unref0 (app);
}

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

