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

/*
* Copyright 2021 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 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 "granite-7.h"
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <stdlib.h>
#include <string.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

enum  {
	GRANITE_DIALOG_0_PROPERTY,
	GRANITE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* granite_dialog_properties[GRANITE_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer granite_dialog_parent_class = NULL;

static void granite_dialog_real_constructed (GObject* base);
static GObject * granite_dialog_constructor (GType type,
                                      guint n_construct_properties,
                                      GObjectConstructParam * construct_properties);
static GType granite_dialog_get_type_once (void);

/**
     * Constructs a new {@link Granite.Dialog}.
     */
GraniteDialog*
granite_dialog_construct (GType object_type)
{
	GraniteDialog * self = NULL;
	self = (GraniteDialog*) g_object_new (object_type, NULL);
	return self;
}

GraniteDialog*
granite_dialog_new (void)
{
	return granite_dialog_construct (GRANITE_TYPE_DIALOG);
}

static void
granite_dialog_real_constructed (GObject* base)
{
	GraniteDialog * self;
	GtkLabel* titlebar = NULL;
	GtkLabel* _tmp0_ = NULL;
	self = (GraniteDialog*) base;
	G_OBJECT_CLASS (granite_dialog_parent_class)->constructed ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_dialog_get_type (), GtkDialog));
	_tmp0_ = (GtkLabel*) gtk_label_new ("");
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, FALSE);
	g_object_ref_sink (_tmp0_);
	titlebar = _tmp0_;
	gtk_window_set_titlebar ((GtkWindow*) self, (GtkWidget*) titlebar);
	_g_object_unref0 (titlebar);
}

/**
     * Behaves as described in {@link Gtk.Dialog.add_button}. The last button to be added
     * will have keyboard focus by default.
     */
GtkWidget*
granite_dialog_add_button (GraniteDialog* self,
                           const gchar* button_text,
                           gint response_id)
{
	GtkWidget* button = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (button_text != NULL, NULL);
	_tmp0_ = gtk_dialog_add_button (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_dialog_get_type (), GtkDialog), button_text, response_id);
	button = _tmp0_;
	gtk_widget_grab_focus (button);
	result = button;
	return result;
}

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

static GObject *
granite_dialog_constructor (GType type,
                            guint n_construct_properties,
                            GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GraniteDialog * self;
	GtkWidget* box = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWindowHandle* window_handle = NULL;
	GtkWindowHandle* _tmp2_;
	GtkWindowHandle* _tmp3_;
	GtkWindowHandle* _tmp4_;
	GtkWidget* _tmp5_;
	GtkBox* content_area = NULL;
	GtkBox* _tmp6_;
	GtkBox* _tmp7_;
	GtkBox* _tmp8_;
	GtkBox* _tmp9_;
	parent_class = G_OBJECT_CLASS (granite_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRANITE_TYPE_DIALOG, GraniteDialog);
	gtk_window_set_deletable ((GtkWindow*) self, FALSE);
	g_object_set ((GtkDialog*) self, "use-header-bar", (gint) FALSE, NULL);
	_tmp0_ = gtk_window_get_child ((GtkWindow*) self);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	box = _tmp1_;
	_tmp2_ = (GtkWindowHandle*) gtk_window_handle_new ();
	g_object_ref_sink (_tmp2_);
	window_handle = _tmp2_;
	_tmp3_ = window_handle;
	gtk_window_set_child ((GtkWindow*) self, (GtkWidget*) _tmp3_);
	_tmp4_ = window_handle;
	_tmp5_ = box;
	gtk_window_handle_set_child (_tmp4_, _tmp5_);
	_tmp6_ = gtk_dialog_get_content_area ((GtkDialog*) self);
	_tmp7_ = _g_object_ref0 (_tmp6_);
	content_area = _tmp7_;
	_tmp8_ = content_area;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp8_, TRUE);
	_tmp9_ = content_area;
	gtk_widget_add_css_class ((GtkWidget*) _tmp9_, GRANITE_STYLE_CLASS_DIALOG_CONTENT_AREA);
	_g_object_unref0 (content_area);
	_g_object_unref0 (window_handle);
	_g_object_unref0 (box);
	return obj;
}

static void
granite_dialog_class_init (GraniteDialogClass * klass,
                           gpointer klass_data)
{
	granite_dialog_parent_class = g_type_class_peek_parent (klass);
	((GObjectClass *) klass)->constructed = (void (*) (GObject*)) granite_dialog_real_constructed;
	G_OBJECT_CLASS (klass)->constructor = granite_dialog_constructor;
}

static void
granite_dialog_instance_init (GraniteDialog * self,
                              gpointer klass)
{
}

/**
* Granite.Dialog is a styled {@link Gtk.Dialog} that uses an empty title area and
* action widgets in the bottom/end position.
*
* ''Example''<<BR>>
* {{{
*   var header = new Granite.HeaderLabel ("Header");
*   var entry = new Gtk.Entry ();
*   var gtk_switch = new Gtk.Switch () {
*       halign = Gtk.Align.START
*   };
*
*   var layout = new Gtk.Grid () {
*       row_spacing = 12
*   };
*   layout.attach (header, 0, 1);
*   layout.attach (entry, 0, 2);
*   layout.attach (gtk_switch, 0, 3);
*
*   var dialog = new Granite.Dialog () {
*       transient_for = window
*   };
*   dialog.content_area.add (layout);
*   dialog.add_button ("Cancel", Gtk.ResponseType.CANCEL);
*
*   var suggested_button = dialog.add_button ("Suggested Action", Gtk.ResponseType.ACCEPT);
*   suggested_button.add_css_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
*
*   dialog.show_all ();
*   dialog.response.connect ((response_id) => {
*       if (response_id == Gtk.ResponseType.ACCEPT) {
*           // Do Something
*       }
*
*       dialog.destroy ();
*   });
* }}}
*/
static GType
granite_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraniteDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) granite_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraniteDialog), 0, (GInstanceInitFunc) granite_dialog_instance_init, NULL };
	GType granite_dialog_type_id;
	granite_dialog_type_id = g_type_register_static (gtk_dialog_get_type (), "GraniteDialog", &g_define_type_info, 0);
	return granite_dialog_type_id;
}

GType
granite_dialog_get_type (void)
{
	static volatile gsize granite_dialog_type_id__once = 0;
	if (g_once_init_enter (&granite_dialog_type_id__once)) {
		GType granite_dialog_type_id;
		granite_dialog_type_id = granite_dialog_get_type_once ();
		g_once_init_leave (&granite_dialog_type_id__once, granite_dialog_type_id);
	}
	return granite_dialog_type_id__once;
}

