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

/*
 * Copyright 2019 elementary, Inc. (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/>.
 */

#include <granite-7.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.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 AUDIENCE_TYPE_UNSUPPORTED_FILE_DIALOG (audience_unsupported_file_dialog_get_type ())
#define AUDIENCE_UNSUPPORTED_FILE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AUDIENCE_TYPE_UNSUPPORTED_FILE_DIALOG, AudienceUnsupportedFileDialog))
#define AUDIENCE_UNSUPPORTED_FILE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AUDIENCE_TYPE_UNSUPPORTED_FILE_DIALOG, AudienceUnsupportedFileDialogClass))
#define AUDIENCE_IS_UNSUPPORTED_FILE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AUDIENCE_TYPE_UNSUPPORTED_FILE_DIALOG))
#define AUDIENCE_IS_UNSUPPORTED_FILE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AUDIENCE_TYPE_UNSUPPORTED_FILE_DIALOG))
#define AUDIENCE_UNSUPPORTED_FILE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AUDIENCE_TYPE_UNSUPPORTED_FILE_DIALOG, AudienceUnsupportedFileDialogClass))

typedef struct _AudienceUnsupportedFileDialog AudienceUnsupportedFileDialog;
typedef struct _AudienceUnsupportedFileDialogClass AudienceUnsupportedFileDialogClass;
typedef struct _AudienceUnsupportedFileDialogPrivate AudienceUnsupportedFileDialogPrivate;
enum  {
	AUDIENCE_UNSUPPORTED_FILE_DIALOG_0_PROPERTY,
	AUDIENCE_UNSUPPORTED_FILE_DIALOG_CONTENT_TYPE_PROPERTY,
	AUDIENCE_UNSUPPORTED_FILE_DIALOG_URI_PROPERTY,
	AUDIENCE_UNSUPPORTED_FILE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* audience_unsupported_file_dialog_properties[AUDIENCE_UNSUPPORTED_FILE_DIALOG_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _AudienceUnsupportedFileDialog {
	GraniteMessageDialog parent_instance;
	AudienceUnsupportedFileDialogPrivate * priv;
};

struct _AudienceUnsupportedFileDialogClass {
	GraniteMessageDialogClass parent_class;
};

struct _AudienceUnsupportedFileDialogPrivate {
	gchar* _content_type;
	gchar* _uri;
};

static gint AudienceUnsupportedFileDialog_private_offset;
static gpointer audience_unsupported_file_dialog_parent_class = NULL;

VALA_EXTERN GType audience_unsupported_file_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AudienceUnsupportedFileDialog, g_object_unref)
VALA_EXTERN AudienceUnsupportedFileDialog* audience_unsupported_file_dialog_new (const gchar* uri,
                                                                     const gchar* filename,
                                                                     const gchar* content_type);
VALA_EXTERN AudienceUnsupportedFileDialog* audience_unsupported_file_dialog_construct (GType object_type,
                                                                           const gchar* uri,
                                                                           const gchar* filename,
                                                                           const gchar* content_type);
VALA_EXTERN const gchar* audience_unsupported_file_dialog_get_content_type (AudienceUnsupportedFileDialog* self);
static void audience_unsupported_file_dialog_set_content_type (AudienceUnsupportedFileDialog* self,
                                                        const gchar* value);
VALA_EXTERN const gchar* audience_unsupported_file_dialog_get_uri (AudienceUnsupportedFileDialog* self);
static void audience_unsupported_file_dialog_set_uri (AudienceUnsupportedFileDialog* self,
                                               const gchar* value);
static GObject * audience_unsupported_file_dialog_constructor (GType type,
                                                        guint n_construct_properties,
                                                        GObjectConstructParam * construct_properties);
static void audience_unsupported_file_dialog_finalize (GObject * obj);
static GType audience_unsupported_file_dialog_get_type_once (void);
static void _vala_audience_unsupported_file_dialog_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec);
static void _vala_audience_unsupported_file_dialog_set_property (GObject * object,
                                                          guint property_id,
                                                          const GValue * value,
                                                          GParamSpec * pspec);

static inline gpointer
audience_unsupported_file_dialog_get_instance_private (AudienceUnsupportedFileDialog* self)
{
	return G_STRUCT_MEMBER_P (self, AudienceUnsupportedFileDialog_private_offset);
}

AudienceUnsupportedFileDialog*
audience_unsupported_file_dialog_construct (GType object_type,
                                            const gchar* uri,
                                            const gchar* filename,
                                            const gchar* content_type)
{
	AudienceUnsupportedFileDialog * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GThemedIcon* _tmp2_;
	GThemedIcon* _tmp3_;
	GApplication* _tmp4_;
	GtkWindow* _tmp5_;
	GtkWindow* _tmp6_;
	g_return_val_if_fail (uri != NULL, NULL);
	g_return_val_if_fail (filename != NULL, NULL);
	g_return_val_if_fail (content_type != NULL, NULL);
	_tmp0_ = g_strdup_printf ("Videos might not be able to play the file '%s'.", filename);
	_tmp1_ = _tmp0_;
	_tmp2_ = (GThemedIcon*) g_themed_icon_new ("dialog-error");
	_tmp3_ = _tmp2_;
	_tmp4_ = g_application_get_default ();
	_tmp5_ = gtk_application_get_active_window (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_application_get_type (), GtkApplication));
	_tmp6_ = _tmp5_;
	self = (AudienceUnsupportedFileDialog*) g_object_new (object_type, "title", "", "primary-text", _ ("Unrecognized file format"), "secondary-text", _ (_tmp1_), "buttons", GTK_BUTTONS_CANCEL, "image-icon", _tmp3_, "transient-for", _tmp6_, "content-type", content_type, "uri", uri, NULL);
	_g_object_unref0 (_tmp3_);
	_g_free0 (_tmp1_);
	return self;
}

AudienceUnsupportedFileDialog*
audience_unsupported_file_dialog_new (const gchar* uri,
                                      const gchar* filename,
                                      const gchar* content_type)
{
	return audience_unsupported_file_dialog_construct (AUDIENCE_TYPE_UNSUPPORTED_FILE_DIALOG, uri, filename, content_type);
}

const gchar*
audience_unsupported_file_dialog_get_content_type (AudienceUnsupportedFileDialog* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_content_type;
	result = _tmp0_;
	return result;
}

static void
audience_unsupported_file_dialog_set_content_type (AudienceUnsupportedFileDialog* self,
                                                   const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = audience_unsupported_file_dialog_get_content_type (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_content_type);
		self->priv->_content_type = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, audience_unsupported_file_dialog_properties[AUDIENCE_UNSUPPORTED_FILE_DIALOG_CONTENT_TYPE_PROPERTY]);
	}
}

const gchar*
audience_unsupported_file_dialog_get_uri (AudienceUnsupportedFileDialog* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_uri;
	result = _tmp0_;
	return result;
}

static void
audience_unsupported_file_dialog_set_uri (AudienceUnsupportedFileDialog* self,
                                          const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = audience_unsupported_file_dialog_get_uri (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_uri);
		self->priv->_uri = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, audience_unsupported_file_dialog_properties[AUDIENCE_UNSUPPORTED_FILE_DIALOG_URI_PROPERTY]);
	}
}

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

static GObject *
audience_unsupported_file_dialog_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	AudienceUnsupportedFileDialog * self;
	GtkWidget* play_anyway_button = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	gchar* error_text = NULL;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	parent_class = G_OBJECT_CLASS (audience_unsupported_file_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, AUDIENCE_TYPE_UNSUPPORTED_FILE_DIALOG, AudienceUnsupportedFileDialog);
	_tmp0_ = granite_dialog_add_button ((GraniteDialog*) self, _ ("Play Anyway"), (gint) GTK_RESPONSE_ACCEPT);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	play_anyway_button = _tmp1_;
	_tmp2_ = play_anyway_button;
	gtk_widget_add_css_class (_tmp2_, GRANITE_STYLE_CLASS_DESTRUCTIVE_ACTION);
	_tmp3_ = self->priv->_uri;
	_tmp4_ = self->priv->_content_type;
	_tmp5_ = g_content_type_get_description (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_strdup_printf (_ ("Unable to play file at: %s\nThe file is not a video (\"%s\")."), _tmp3_, _tmp6_);
	_tmp8_ = _tmp7_;
	_g_free0 (_tmp6_);
	error_text = _tmp8_;
	_tmp9_ = error_text;
	granite_message_dialog_show_error_details ((GraniteMessageDialog*) self, _tmp9_);
	_g_free0 (error_text);
	_g_object_unref0 (play_anyway_button);
	return obj;
}

static void
audience_unsupported_file_dialog_class_init (AudienceUnsupportedFileDialogClass * klass,
                                             gpointer klass_data)
{
	audience_unsupported_file_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &AudienceUnsupportedFileDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_audience_unsupported_file_dialog_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_audience_unsupported_file_dialog_set_property;
	G_OBJECT_CLASS (klass)->constructor = audience_unsupported_file_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = audience_unsupported_file_dialog_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), AUDIENCE_UNSUPPORTED_FILE_DIALOG_CONTENT_TYPE_PROPERTY, audience_unsupported_file_dialog_properties[AUDIENCE_UNSUPPORTED_FILE_DIALOG_CONTENT_TYPE_PROPERTY] = g_param_spec_string ("content-type", "content-type", "content-type", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), AUDIENCE_UNSUPPORTED_FILE_DIALOG_URI_PROPERTY, audience_unsupported_file_dialog_properties[AUDIENCE_UNSUPPORTED_FILE_DIALOG_URI_PROPERTY] = g_param_spec_string ("uri", "uri", "uri", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
audience_unsupported_file_dialog_instance_init (AudienceUnsupportedFileDialog * self,
                                                gpointer klass)
{
	self->priv = audience_unsupported_file_dialog_get_instance_private (self);
}

static void
audience_unsupported_file_dialog_finalize (GObject * obj)
{
	AudienceUnsupportedFileDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, AUDIENCE_TYPE_UNSUPPORTED_FILE_DIALOG, AudienceUnsupportedFileDialog);
	_g_free0 (self->priv->_content_type);
	_g_free0 (self->priv->_uri);
	G_OBJECT_CLASS (audience_unsupported_file_dialog_parent_class)->finalize (obj);
}

static GType
audience_unsupported_file_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (AudienceUnsupportedFileDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) audience_unsupported_file_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AudienceUnsupportedFileDialog), 0, (GInstanceInitFunc) audience_unsupported_file_dialog_instance_init, NULL };
	GType audience_unsupported_file_dialog_type_id;
	audience_unsupported_file_dialog_type_id = g_type_register_static (GRANITE_TYPE_MESSAGE_DIALOG, "AudienceUnsupportedFileDialog", &g_define_type_info, 0);
	AudienceUnsupportedFileDialog_private_offset = g_type_add_instance_private (audience_unsupported_file_dialog_type_id, sizeof (AudienceUnsupportedFileDialogPrivate));
	return audience_unsupported_file_dialog_type_id;
}

GType
audience_unsupported_file_dialog_get_type (void)
{
	static volatile gsize audience_unsupported_file_dialog_type_id__once = 0;
	if (g_once_init_enter (&audience_unsupported_file_dialog_type_id__once)) {
		GType audience_unsupported_file_dialog_type_id;
		audience_unsupported_file_dialog_type_id = audience_unsupported_file_dialog_get_type_once ();
		g_once_init_leave (&audience_unsupported_file_dialog_type_id__once, audience_unsupported_file_dialog_type_id);
	}
	return audience_unsupported_file_dialog_type_id__once;
}

static void
_vala_audience_unsupported_file_dialog_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec)
{
	AudienceUnsupportedFileDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, AUDIENCE_TYPE_UNSUPPORTED_FILE_DIALOG, AudienceUnsupportedFileDialog);
	switch (property_id) {
		case AUDIENCE_UNSUPPORTED_FILE_DIALOG_CONTENT_TYPE_PROPERTY:
		g_value_set_string (value, audience_unsupported_file_dialog_get_content_type (self));
		break;
		case AUDIENCE_UNSUPPORTED_FILE_DIALOG_URI_PROPERTY:
		g_value_set_string (value, audience_unsupported_file_dialog_get_uri (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_audience_unsupported_file_dialog_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec)
{
	AudienceUnsupportedFileDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, AUDIENCE_TYPE_UNSUPPORTED_FILE_DIALOG, AudienceUnsupportedFileDialog);
	switch (property_id) {
		case AUDIENCE_UNSUPPORTED_FILE_DIALOG_CONTENT_TYPE_PROPERTY:
		audience_unsupported_file_dialog_set_content_type (self, g_value_get_string (value));
		break;
		case AUDIENCE_UNSUPPORTED_FILE_DIALOG_URI_PROPERTY:
		audience_unsupported_file_dialog_set_uri (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

