/* StockDialogs.c generated by valac 0.56.19, the Vala compiler
 * generated from StockDialogs.vala, do not modify */

/* Copyright (c) 2018-19 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, Inc.,; 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.
 */
/* Common dialog buttons */

#include "pantheon-files-core.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <granite.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

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block37Data Block37Data;

struct _Block37Data {
	int _ref_count_;
	GraniteMessageDialog* dialog;
};

VALA_EXTERN GraniteMessageDialog* pf_dialogs_display_dialog (GraniteMessageDialog* dialog,
                                                 GtkWindow* parent);
static Block37Data* block37_data_ref (Block37Data* _data37_);
static void block37_data_unref (void * _userdata_);
static void __lambda19_ (Block37Data* _data37_);
static void ___lambda19__gtk_dialog_response (GtkDialog* _sender,
                                       gint response_id,
                                       gpointer self);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

GraniteMessageDialog*
pf_dialogs_show_error_dialog (const gchar* primary_text,
                              const gchar* secondary_text,
                              GtkWindow* parent)
{
	GraniteMessageDialog* dialog = NULL;
	GraniteMessageDialog* _tmp0_;
	GraniteMessageDialog* _tmp1_;
	GraniteMessageDialog* result;
	g_return_val_if_fail (primary_text != NULL, NULL);
	g_return_val_if_fail (secondary_text != NULL, NULL);
	_tmp0_ = granite_message_dialog_new_with_image_from_icon_name (primary_text, secondary_text, "dialog-error", GTK_BUTTONS_CLOSE);
	g_object_ref_sink (_tmp0_);
	dialog = _tmp0_;
	_tmp1_ = pf_dialogs_display_dialog (dialog, parent);
	result = _tmp1_;
	_g_object_unref0 (dialog);
	return result;
}

GraniteMessageDialog*
pf_dialogs_show_warning_dialog (const gchar* primary_text,
                                const gchar* secondary_text,
                                GtkWindow* parent)
{
	GraniteMessageDialog* dialog = NULL;
	GraniteMessageDialog* _tmp0_;
	GraniteMessageDialog* _tmp1_;
	GraniteMessageDialog* result;
	g_return_val_if_fail (primary_text != NULL, NULL);
	g_return_val_if_fail (secondary_text != NULL, NULL);
	_tmp0_ = granite_message_dialog_new_with_image_from_icon_name (primary_text, secondary_text, "dialog-warning", GTK_BUTTONS_CLOSE);
	g_object_ref_sink (_tmp0_);
	dialog = _tmp0_;
	_tmp1_ = pf_dialogs_display_dialog (dialog, parent);
	result = _tmp1_;
	_g_object_unref0 (dialog);
	return result;
}

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

static Block37Data*
block37_data_ref (Block37Data* _data37_)
{
	g_atomic_int_inc (&_data37_->_ref_count_);
	return _data37_;
}

static void
block37_data_unref (void * _userdata_)
{
	Block37Data* _data37_;
	_data37_ = (Block37Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data37_->_ref_count_)) {
		_g_object_unref0 (_data37_->dialog);
		g_slice_free (Block37Data, _data37_);
	}
}

static void
__lambda19_ (Block37Data* _data37_)
{
	gtk_widget_destroy ((GtkWidget*) _data37_->dialog);
}

static void
___lambda19__gtk_dialog_response (GtkDialog* _sender,
                                  gint response_id,
                                  gpointer self)
{
	__lambda19_ (self);
}

GraniteMessageDialog*
pf_dialogs_display_dialog (GraniteMessageDialog* dialog,
                           GtkWindow* parent)
{
	Block37Data* _data37_;
	GraniteMessageDialog* _tmp0_;
	gboolean _tmp1_ = FALSE;
	GraniteMessageDialog* _tmp2_;
	GraniteMessageDialog* result;
	g_return_val_if_fail (dialog != NULL, NULL);
	_data37_ = g_slice_new0 (Block37Data);
	_data37_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (dialog);
	_g_object_unref0 (_data37_->dialog);
	_data37_->dialog = _tmp0_;
	if (parent != NULL) {
		_tmp1_ = G_TYPE_CHECK_INSTANCE_TYPE (parent, gtk_window_get_type ());
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gtk_window_set_transient_for ((GtkWindow*) _data37_->dialog, parent);
	}
	g_signal_connect_data ((GtkDialog*) _data37_->dialog, "response", (GCallback) ___lambda19__gtk_dialog_response, block37_data_ref (_data37_), (GClosureNotify) block37_data_unref, G_CONNECT_AFTER);
	gtk_widget_show ((GtkWidget*) _data37_->dialog);
	_tmp2_ = _g_object_ref0 (_data37_->dialog);
	result = _tmp2_;
	block37_data_unref (_data37_);
	_data37_ = NULL;
	return result;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

