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

/*
 * CustomMessageDialog.vala
 *
 * Copyright 2012-2018 Tony George <teejeetech@gmail.com>
 *
 * 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 2 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *
 *
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <pango/pango.h>
#include <glib/gi18n-lib.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#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 TYPE_CUSTOM_MESSAGE_DIALOG (custom_message_dialog_get_type ())
#define CUSTOM_MESSAGE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CUSTOM_MESSAGE_DIALOG, CustomMessageDialog))
#define CUSTOM_MESSAGE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CUSTOM_MESSAGE_DIALOG, CustomMessageDialogClass))
#define IS_CUSTOM_MESSAGE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CUSTOM_MESSAGE_DIALOG))
#define IS_CUSTOM_MESSAGE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CUSTOM_MESSAGE_DIALOG))
#define CUSTOM_MESSAGE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CUSTOM_MESSAGE_DIALOG, CustomMessageDialogClass))

typedef struct _CustomMessageDialog CustomMessageDialog;
typedef struct _CustomMessageDialogClass CustomMessageDialogClass;
typedef struct _CustomMessageDialogPrivate CustomMessageDialogPrivate;
enum  {
	CUSTOM_MESSAGE_DIALOG_0_PROPERTY,
	CUSTOM_MESSAGE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* custom_message_dialog_properties[CUSTOM_MESSAGE_DIALOG_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))

struct _CustomMessageDialog {
	GtkDialog parent_instance;
	CustomMessageDialogPrivate * priv;
};

struct _CustomMessageDialogClass {
	GtkDialogClass parent_class;
};

struct _CustomMessageDialogPrivate {
	GtkBox* vbox_main;
	GtkLabel* lbl_msg;
	GtkScrolledWindow* sw_msg;
	GtkButton* btn_ok;
	GtkButton* btn_cancel;
	GtkButton* btn_yes;
	GtkButton* btn_no;
	gchar* msg_title;
	gchar* msg_body;
	GtkMessageType msg_type;
	GtkButtonsType buttons_type;
};

static gint CustomMessageDialog_private_offset;
static gpointer custom_message_dialog_parent_class = NULL;

VALA_EXTERN GType custom_message_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CustomMessageDialog, g_object_unref)
VALA_EXTERN CustomMessageDialog* custom_message_dialog_new (const gchar* _msg_title,
                                                const gchar* _msg_body,
                                                GtkMessageType _msg_type,
                                                GtkWindow* parent,
                                                GtkButtonsType _buttons_type);
VALA_EXTERN CustomMessageDialog* custom_message_dialog_construct (GType object_type,
                                                      const gchar* _msg_title,
                                                      const gchar* _msg_body,
                                                      GtkMessageType _msg_type,
                                                      GtkWindow* parent,
                                                      GtkButtonsType _buttons_type);
VALA_EXTERN void custom_message_dialog_init_window (CustomMessageDialog* self);
VALA_EXTERN GdkPixbuf* icon_manager_lookup (const gchar* icon_name,
                                gint icon_size,
                                gboolean symbolic,
                                gboolean use_hardcoded,
                                gint scale);
VALA_EXTERN gchar* tee_jee_misc_escape_html (const gchar* html);
static void custom_message_dialog_finalize (GObject * obj);
static GType custom_message_dialog_get_type_once (void);

static inline gpointer
custom_message_dialog_get_instance_private (CustomMessageDialog* self)
{
	return G_STRUCT_MEMBER_P (self, CustomMessageDialog_private_offset);
}

CustomMessageDialog*
custom_message_dialog_construct (GType object_type,
                                 const gchar* _msg_title,
                                 const gchar* _msg_body,
                                 GtkMessageType _msg_type,
                                 GtkWindow* parent,
                                 GtkButtonsType _buttons_type)
{
	CustomMessageDialog * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GtkLabel* _tmp2_;
	GtkScrolledWindow* _tmp3_;
	GtkScrolledWindow* _tmp4_;
	GtkScrolledWindow* _tmp5_;
	GtkLabel* _tmp6_;
	g_return_val_if_fail (_msg_title != NULL, NULL);
	g_return_val_if_fail (_msg_body != NULL, NULL);
	self = (CustomMessageDialog*) g_object_new (object_type, NULL);
	gtk_window_set_transient_for ((GtkWindow*) self, parent);
	gtk_window_set_modal ((GtkWindow*) self, TRUE);
	_tmp0_ = g_strdup (_msg_title);
	_g_free0 (self->priv->msg_title);
	self->priv->msg_title = _tmp0_;
	_tmp1_ = g_strdup (_msg_body);
	_g_free0 (self->priv->msg_body);
	self->priv->msg_body = _tmp1_;
	self->priv->msg_type = _msg_type;
	self->priv->buttons_type = _buttons_type;
	custom_message_dialog_init_window (self);
	_tmp2_ = self->priv->lbl_msg;
	g_object_set ((GtkWidget*) _tmp2_, "expand", TRUE, NULL);
	_tmp3_ = self->priv->sw_msg;
	g_object_set ((GtkWidget*) _tmp3_, "expand", TRUE, NULL);
	_tmp4_ = self->priv->sw_msg;
	g_object_set (_tmp4_, "vscrollbar-policy", GTK_POLICY_NEVER, NULL);
	_tmp5_ = self->priv->sw_msg;
	gtk_widget_set_size_request ((GtkWidget*) _tmp5_, 500, 150);
	gtk_widget_show_all ((GtkWidget*) self);
	_tmp6_ = self->priv->lbl_msg;
	if (gtk_widget_get_allocated_height ((GtkWidget*) _tmp6_) > 400) {
		GtkScrolledWindow* _tmp7_;
		GtkScrolledWindow* _tmp8_;
		_tmp7_ = self->priv->sw_msg;
		g_object_set (_tmp7_, "vscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL);
		_tmp8_ = self->priv->sw_msg;
		gtk_widget_set_size_request ((GtkWidget*) _tmp8_, 500, 400);
	}
	return self;
}

CustomMessageDialog*
custom_message_dialog_new (const gchar* _msg_title,
                           const gchar* _msg_body,
                           GtkMessageType _msg_type,
                           GtkWindow* parent,
                           GtkButtonsType _buttons_type)
{
	return custom_message_dialog_construct (TYPE_CUSTOM_MESSAGE_DIALOG, _msg_title, _msg_body, _msg_type, parent, _buttons_type);
}

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

void
custom_message_dialog_init_window (CustomMessageDialog* self)
{
	GdkPixbuf* _tmp0_;
	GdkPixbuf* _tmp1_;
	GtkBox* _tmp2_;
	GtkBox* _tmp3_;
	GtkBox* _tmp4_;
	GtkBox* hbox_contents = NULL;
	GtkBox* _tmp5_;
	GtkBox* _tmp6_;
	GtkBox* _tmp7_;
	GtkBox* _tmp8_;
	gchar* icon_name = NULL;
	gchar* _tmp9_;
	GtkImage* img = NULL;
	const gchar* _tmp15_;
	GtkImage* _tmp16_;
	GtkBox* _tmp17_;
	GtkImage* _tmp18_;
	gchar* text = NULL;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	const gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	const gchar* _tmp25_;
	GtkLabel* _tmp26_;
	GtkLabel* _tmp27_;
	GtkLabel* _tmp28_;
	GtkLabel* _tmp29_;
	GtkLabel* _tmp30_;
	GtkLabel* _tmp31_;
	GtkLabel* _tmp32_;
	GtkScrolledWindow* _tmp33_;
	GtkScrolledWindow* _tmp34_;
	GtkLabel* _tmp35_;
	GtkScrolledWindow* _tmp36_;
	GtkScrolledWindow* _tmp37_;
	GtkBox* _tmp38_;
	GtkScrolledWindow* _tmp39_;
	g_return_if_fail (self != NULL);
	gtk_window_set_title ((GtkWindow*) self, "");
	g_object_set ((GtkWindow*) self, "window-position", GTK_WIN_POS_CENTER_ON_PARENT, NULL);
	_tmp0_ = icon_manager_lookup ("timeshift", 16, FALSE, FALSE, 1);
	_tmp1_ = _tmp0_;
	gtk_window_set_icon ((GtkWindow*) self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	gtk_window_set_resizable ((GtkWindow*) self, FALSE);
	gtk_window_set_deletable ((GtkWindow*) self, FALSE);
	gtk_window_set_skip_taskbar_hint ((GtkWindow*) self, TRUE);
	gtk_window_set_skip_pager_hint ((GtkWindow*) self, TRUE);
	_tmp2_ = gtk_dialog_get_content_area ((GtkDialog*) self);
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, gtk_box_get_type ()) ? ((GtkBox*) _tmp2_) : NULL);
	_g_object_unref0 (self->priv->vbox_main);
	self->priv->vbox_main = _tmp3_;
	_tmp4_ = self->priv->vbox_main;
	g_object_set ((GtkWidget*) _tmp4_, "margin", 6, NULL);
	_tmp5_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp5_);
	hbox_contents = _tmp5_;
	_tmp6_ = hbox_contents;
	g_object_set ((GtkWidget*) _tmp6_, "margin", 6, NULL);
	_tmp7_ = self->priv->vbox_main;
	_tmp8_ = hbox_contents;
	gtk_container_add ((GtkContainer*) _tmp7_, (GtkWidget*) _tmp8_);
	_tmp9_ = g_strdup ("dialog-info");
	icon_name = _tmp9_;
	switch (self->priv->msg_type) {
		case GTK_MESSAGE_INFO:
		{
			gchar* _tmp10_;
			_tmp10_ = g_strdup ("dialog-info");
			_g_free0 (icon_name);
			icon_name = _tmp10_;
			break;
		}
		case GTK_MESSAGE_WARNING:
		{
			gchar* _tmp11_;
			_tmp11_ = g_strdup ("dialog-warning");
			_g_free0 (icon_name);
			icon_name = _tmp11_;
			break;
		}
		case GTK_MESSAGE_QUESTION:
		{
			gchar* _tmp12_;
			_tmp12_ = g_strdup ("dialog-question");
			_g_free0 (icon_name);
			icon_name = _tmp12_;
			break;
		}
		case GTK_MESSAGE_ERROR:
		{
			gchar* _tmp13_;
			_tmp13_ = g_strdup ("dialog-error");
			_g_free0 (icon_name);
			icon_name = _tmp13_;
			break;
		}
		case GTK_MESSAGE_OTHER:
		{
			gchar* _tmp14_;
			_tmp14_ = g_strdup ("dialog-info");
			_g_free0 (icon_name);
			icon_name = _tmp14_;
			break;
		}
		default:
		break;
	}
	_tmp15_ = icon_name;
	_tmp16_ = (GtkImage*) gtk_image_new_from_icon_name (_tmp15_, (GtkIconSize) GTK_ICON_SIZE_DIALOG);
	g_object_ref_sink (_tmp16_);
	img = _tmp16_;
	_tmp17_ = hbox_contents;
	_tmp18_ = img;
	gtk_container_add ((GtkContainer*) _tmp17_, (GtkWidget*) _tmp18_);
	_tmp19_ = self->priv->msg_title;
	_tmp20_ = tee_jee_misc_escape_html (_tmp19_);
	_tmp21_ = _tmp20_;
	_tmp22_ = self->priv->msg_body;
	_tmp23_ = g_strdup_printf ("<span weight=\"bold\" size=\"x-large\">%s</span>\n\n%s", _tmp21_, _tmp22_);
	_tmp24_ = _tmp23_;
	_g_free0 (_tmp21_);
	text = _tmp24_;
	_tmp25_ = text;
	_tmp26_ = (GtkLabel*) gtk_label_new (_tmp25_);
	g_object_ref_sink (_tmp26_);
	_g_object_unref0 (self->priv->lbl_msg);
	self->priv->lbl_msg = _tmp26_;
	_tmp27_ = self->priv->lbl_msg;
	gtk_label_set_xalign (_tmp27_, 0.0f);
	_tmp28_ = self->priv->lbl_msg;
	gtk_label_set_yalign (_tmp28_, 0.0f);
	_tmp29_ = self->priv->lbl_msg;
	gtk_label_set_max_width_chars (_tmp29_, 70);
	_tmp30_ = self->priv->lbl_msg;
	g_object_set (_tmp30_, "wrap", TRUE, NULL);
	_tmp31_ = self->priv->lbl_msg;
	g_object_set (_tmp31_, "wrap-mode", PANGO_WRAP_WORD_CHAR, NULL);
	_tmp32_ = self->priv->lbl_msg;
	gtk_label_set_use_markup (_tmp32_, TRUE);
	_tmp33_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	g_object_ref_sink (_tmp33_);
	_g_object_unref0 (self->priv->sw_msg);
	self->priv->sw_msg = _tmp33_;
	_tmp34_ = self->priv->sw_msg;
	_tmp35_ = self->priv->lbl_msg;
	gtk_container_add ((GtkContainer*) _tmp34_, (GtkWidget*) _tmp35_);
	_tmp36_ = self->priv->sw_msg;
	g_object_set (_tmp36_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	_tmp37_ = self->priv->sw_msg;
	g_object_set (_tmp37_, "vscrollbar-policy", GTK_POLICY_NEVER, NULL);
	_tmp38_ = hbox_contents;
	_tmp39_ = self->priv->sw_msg;
	gtk_container_add ((GtkContainer*) _tmp38_, (GtkWidget*) _tmp39_);
	switch (self->priv->buttons_type) {
		case GTK_BUTTONS_NONE:
		{
			break;
		}
		case GTK_BUTTONS_OK:
		{
			GtkWidget* _tmp40_;
			GtkButton* _tmp41_;
			GtkButton* _tmp42_;
			_tmp40_ = gtk_dialog_add_button ((GtkDialog*) self, _ ("OK"), (gint) GTK_RESPONSE_OK);
			_tmp41_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp40_, gtk_button_get_type (), GtkButton));
			_g_object_unref0 (self->priv->btn_ok);
			self->priv->btn_ok = _tmp41_;
			_tmp42_ = self->priv->btn_ok;
			gtk_widget_grab_focus ((GtkWidget*) _tmp42_);
			break;
		}
		case GTK_BUTTONS_CLOSE:
		{
			GtkWidget* _tmp43_;
			GtkButton* _tmp44_;
			GtkButton* _tmp45_;
			_tmp43_ = gtk_dialog_add_button ((GtkDialog*) self, _ ("Close"), (gint) GTK_RESPONSE_CLOSE);
			_tmp44_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp43_, gtk_button_get_type (), GtkButton));
			_g_object_unref0 (self->priv->btn_cancel);
			self->priv->btn_cancel = _tmp44_;
			_tmp45_ = self->priv->btn_cancel;
			gtk_widget_grab_focus ((GtkWidget*) _tmp45_);
			break;
		}
		case GTK_BUTTONS_CANCEL:
		{
			GtkWidget* _tmp46_;
			GtkButton* _tmp47_;
			GtkButton* _tmp48_;
			_tmp46_ = gtk_dialog_add_button ((GtkDialog*) self, _ ("Cancel"), (gint) GTK_RESPONSE_CANCEL);
			_tmp47_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp46_, gtk_button_get_type (), GtkButton));
			_g_object_unref0 (self->priv->btn_cancel);
			self->priv->btn_cancel = _tmp47_;
			_tmp48_ = self->priv->btn_cancel;
			gtk_widget_grab_focus ((GtkWidget*) _tmp48_);
			break;
		}
		case GTK_BUTTONS_OK_CANCEL:
		{
			GtkWidget* _tmp49_;
			GtkButton* _tmp50_;
			GtkWidget* _tmp51_;
			GtkButton* _tmp52_;
			GtkButton* _tmp53_;
			_tmp49_ = gtk_dialog_add_button ((GtkDialog*) self, _ ("OK"), (gint) GTK_RESPONSE_OK);
			_tmp50_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp49_, gtk_button_get_type (), GtkButton));
			_g_object_unref0 (self->priv->btn_ok);
			self->priv->btn_ok = _tmp50_;
			_tmp51_ = gtk_dialog_add_button ((GtkDialog*) self, _ ("Cancel"), (gint) GTK_RESPONSE_CANCEL);
			_tmp52_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp51_, gtk_button_get_type (), GtkButton));
			_g_object_unref0 (self->priv->btn_cancel);
			self->priv->btn_cancel = _tmp52_;
			_tmp53_ = self->priv->btn_ok;
			gtk_widget_grab_focus ((GtkWidget*) _tmp53_);
			break;
		}
		case GTK_BUTTONS_YES_NO:
		{
			GtkWidget* _tmp54_;
			GtkButton* _tmp55_;
			GtkWidget* _tmp56_;
			GtkButton* _tmp57_;
			GtkButton* _tmp58_;
			_tmp54_ = gtk_dialog_add_button ((GtkDialog*) self, _ ("Yes"), (gint) GTK_RESPONSE_YES);
			_tmp55_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp54_, gtk_button_get_type (), GtkButton));
			_g_object_unref0 (self->priv->btn_yes);
			self->priv->btn_yes = _tmp55_;
			_tmp56_ = gtk_dialog_add_button ((GtkDialog*) self, _ ("No"), (gint) GTK_RESPONSE_NO);
			_tmp57_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp56_, gtk_button_get_type (), GtkButton));
			_g_object_unref0 (self->priv->btn_no);
			self->priv->btn_no = _tmp57_;
			_tmp58_ = self->priv->btn_yes;
			gtk_widget_grab_focus ((GtkWidget*) _tmp58_);
			break;
		}
		default:
		break;
	}
	_g_free0 (text);
	_g_object_unref0 (img);
	_g_free0 (icon_name);
	_g_object_unref0 (hbox_contents);
}

static void
custom_message_dialog_class_init (CustomMessageDialogClass * klass,
                                  gpointer klass_data)
{
	custom_message_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &CustomMessageDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = custom_message_dialog_finalize;
}

static void
custom_message_dialog_instance_init (CustomMessageDialog * self,
                                     gpointer klass)
{
	self->priv = custom_message_dialog_get_instance_private (self);
}

static void
custom_message_dialog_finalize (GObject * obj)
{
	CustomMessageDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_CUSTOM_MESSAGE_DIALOG, CustomMessageDialog);
	_g_object_unref0 (self->priv->vbox_main);
	_g_object_unref0 (self->priv->lbl_msg);
	_g_object_unref0 (self->priv->sw_msg);
	_g_object_unref0 (self->priv->btn_ok);
	_g_object_unref0 (self->priv->btn_cancel);
	_g_object_unref0 (self->priv->btn_yes);
	_g_object_unref0 (self->priv->btn_no);
	_g_free0 (self->priv->msg_title);
	_g_free0 (self->priv->msg_body);
	G_OBJECT_CLASS (custom_message_dialog_parent_class)->finalize (obj);
}

static GType
custom_message_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (CustomMessageDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) custom_message_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CustomMessageDialog), 0, (GInstanceInitFunc) custom_message_dialog_instance_init, NULL };
	GType custom_message_dialog_type_id;
	custom_message_dialog_type_id = g_type_register_static (gtk_dialog_get_type (), "CustomMessageDialog", &g_define_type_info, 0);
	CustomMessageDialog_private_offset = g_type_add_instance_private (custom_message_dialog_type_id, sizeof (CustomMessageDialogPrivate));
	return custom_message_dialog_type_id;
}

GType
custom_message_dialog_get_type (void)
{
	static volatile gsize custom_message_dialog_type_id__once = 0;
	if (g_once_init_enter (&custom_message_dialog_type_id__once)) {
		GType custom_message_dialog_type_id;
		custom_message_dialog_type_id = custom_message_dialog_get_type_once ();
		g_once_init_leave (&custom_message_dialog_type_id__once, custom_message_dialog_type_id);
	}
	return custom_message_dialog_type_id__once;
}

