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

/*-
 * Copyright 2017-2021 elementary, Inc.
 *           2017 David Hewitt <davidmhewitt@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 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, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Authored by: David Hewitt <davidmhewitt@gmail.com>
 */

#include <granite.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <gdk/gdk.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 AG_WIDGETS_TYPE_GEOCLUE2_DIALOG (ag_widgets_geoclue2_dialog_get_type ())
#define AG_WIDGETS_GEOCLUE2_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AG_WIDGETS_TYPE_GEOCLUE2_DIALOG, AgWidgetsGeoclue2Dialog))
#define AG_WIDGETS_GEOCLUE2_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AG_WIDGETS_TYPE_GEOCLUE2_DIALOG, AgWidgetsGeoclue2DialogClass))
#define AG_WIDGETS_IS_GEOCLUE2_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AG_WIDGETS_TYPE_GEOCLUE2_DIALOG))
#define AG_WIDGETS_IS_GEOCLUE2_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AG_WIDGETS_TYPE_GEOCLUE2_DIALOG))
#define AG_WIDGETS_GEOCLUE2_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AG_WIDGETS_TYPE_GEOCLUE2_DIALOG, AgWidgetsGeoclue2DialogClass))

typedef struct _AgWidgetsGeoclue2Dialog AgWidgetsGeoclue2Dialog;
typedef struct _AgWidgetsGeoclue2DialogClass AgWidgetsGeoclue2DialogClass;
typedef struct _AgWidgetsGeoclue2DialogPrivate AgWidgetsGeoclue2DialogPrivate;
enum  {
	AG_WIDGETS_GEOCLUE2_DIALOG_0_PROPERTY,
	AG_WIDGETS_GEOCLUE2_DIALOG_NUM_PROPERTIES
};
static GParamSpec* ag_widgets_geoclue2_dialog_properties[AG_WIDGETS_GEOCLUE2_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 _AgWidgetsGeoclue2Dialog {
	GraniteMessageDialog parent_instance;
	AgWidgetsGeoclue2DialogPrivate * priv;
};

struct _AgWidgetsGeoclue2DialogClass {
	GraniteMessageDialogClass parent_class;
};

static gpointer ag_widgets_geoclue2_dialog_parent_class = NULL;

VALA_EXTERN GType ag_widgets_geoclue2_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AgWidgetsGeoclue2Dialog, g_object_unref)
VALA_EXTERN AgWidgetsGeoclue2Dialog* ag_widgets_geoclue2_dialog_new (const gchar* message,
                                                         const gchar* app_name,
                                                         GIcon* icon);
VALA_EXTERN AgWidgetsGeoclue2Dialog* ag_widgets_geoclue2_dialog_construct (GType object_type,
                                                               const gchar* message,
                                                               const gchar* app_name,
                                                               GIcon* icon);
static void ag_widgets_geoclue2_dialog_real_show_all (GtkWidget* base);
static GObject * ag_widgets_geoclue2_dialog_constructor (GType type,
                                                  guint n_construct_properties,
                                                  GObjectConstructParam * construct_properties);
static GType ag_widgets_geoclue2_dialog_get_type_once (void);

AgWidgetsGeoclue2Dialog*
ag_widgets_geoclue2_dialog_construct (GType object_type,
                                      const gchar* message,
                                      const gchar* app_name,
                                      GIcon* icon)
{
	AgWidgetsGeoclue2Dialog * self = NULL;
	GThemedIcon* _tmp0_;
	GThemedIcon* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	g_return_val_if_fail (message != NULL, NULL);
	g_return_val_if_fail (app_name != NULL, NULL);
	_tmp0_ = (GThemedIcon*) g_themed_icon_new ("find-location");
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup_printf (_ ("Allow %s to Access This Device's Location?"), app_name);
	_tmp3_ = _tmp2_;
	self = (AgWidgetsGeoclue2Dialog*) g_object_new (object_type, "image-icon", _tmp1_, "primary-text", _tmp3_, "secondary-text", message, "resizable", FALSE, "skip-taskbar-hint", TRUE, "title", _ ("Location Dialog"), NULL);
	_g_free0 (_tmp3_);
	_g_object_unref0 (_tmp1_);
	if (icon != NULL) {
		granite_message_dialog_set_badge_icon ((GraniteMessageDialog*) self, icon);
	}
	return self;
}

AgWidgetsGeoclue2Dialog*
ag_widgets_geoclue2_dialog_new (const gchar* message,
                                const gchar* app_name,
                                GIcon* icon)
{
	return ag_widgets_geoclue2_dialog_construct (AG_WIDGETS_TYPE_GEOCLUE2_DIALOG, message, app_name, icon);
}

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

static void
ag_widgets_geoclue2_dialog_real_show_all (GtkWidget* base)
{
	AgWidgetsGeoclue2Dialog * self;
	GdkWindow* window = NULL;
	GdkWindow* _tmp0_;
	GdkWindow* _tmp1_;
	GdkWindow* _tmp2_;
	GdkWindow* _tmp3_;
	self = (AgWidgetsGeoclue2Dialog*) base;
	GTK_WIDGET_CLASS (ag_widgets_geoclue2_dialog_parent_class)->show_all ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, GRANITE_TYPE_MESSAGE_DIALOG, GraniteMessageDialog));
	_tmp0_ = gtk_widget_get_window ((GtkWidget*) self);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	window = _tmp1_;
	_tmp2_ = window;
	if (_tmp2_ == NULL) {
		_g_object_unref0 (window);
		return;
	}
	_tmp3_ = window;
	gdk_window_focus (_tmp3_, (guint32) GDK_CURRENT_TIME);
	_g_object_unref0 (window);
}

static GObject *
ag_widgets_geoclue2_dialog_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	AgWidgetsGeoclue2Dialog * self;
	GtkButton* deny_button = NULL;
	GtkWidget* _tmp0_;
	GtkButton* _tmp1_;
	GtkButton* allow_button = NULL;
	GtkWidget* _tmp2_;
	GtkButton* _tmp3_;
	GtkButton* _tmp4_;
	GtkStyleContext* _tmp5_;
	GtkButton* _tmp6_;
	parent_class = G_OBJECT_CLASS (ag_widgets_geoclue2_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, AG_WIDGETS_TYPE_GEOCLUE2_DIALOG, AgWidgetsGeoclue2Dialog);
	_tmp0_ = gtk_dialog_add_button ((GtkDialog*) self, _ ("Deny"), (gint) GTK_RESPONSE_NO);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_button_get_type (), GtkButton));
	deny_button = _tmp1_;
	_tmp2_ = gtk_dialog_add_button ((GtkDialog*) self, _ ("Allow"), (gint) GTK_RESPONSE_YES);
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_button_get_type (), GtkButton));
	allow_button = _tmp3_;
	_tmp4_ = allow_button;
	_tmp5_ = gtk_widget_get_style_context ((GtkWidget*) _tmp4_);
	gtk_style_context_add_class (_tmp5_, GTK_STYLE_CLASS_SUGGESTED_ACTION);
	_tmp6_ = deny_button;
	gtk_window_set_default ((GtkWindow*) self, (GtkWidget*) _tmp6_);
	gtk_window_set_keep_above ((GtkWindow*) self, TRUE);
	_g_object_unref0 (allow_button);
	_g_object_unref0 (deny_button);
	return obj;
}

static void
ag_widgets_geoclue2_dialog_class_init (AgWidgetsGeoclue2DialogClass * klass,
                                       gpointer klass_data)
{
	ag_widgets_geoclue2_dialog_parent_class = g_type_class_peek_parent (klass);
	((GtkWidgetClass *) klass)->show_all = (void (*) (GtkWidget*)) ag_widgets_geoclue2_dialog_real_show_all;
	G_OBJECT_CLASS (klass)->constructor = ag_widgets_geoclue2_dialog_constructor;
}

static void
ag_widgets_geoclue2_dialog_instance_init (AgWidgetsGeoclue2Dialog * self,
                                          gpointer klass)
{
}

static GType
ag_widgets_geoclue2_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (AgWidgetsGeoclue2DialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ag_widgets_geoclue2_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AgWidgetsGeoclue2Dialog), 0, (GInstanceInitFunc) ag_widgets_geoclue2_dialog_instance_init, NULL };
	GType ag_widgets_geoclue2_dialog_type_id;
	ag_widgets_geoclue2_dialog_type_id = g_type_register_static (GRANITE_TYPE_MESSAGE_DIALOG, "AgWidgetsGeoclue2Dialog", &g_define_type_info, 0);
	return ag_widgets_geoclue2_dialog_type_id;
}

GType
ag_widgets_geoclue2_dialog_get_type (void)
{
	static volatile gsize ag_widgets_geoclue2_dialog_type_id__once = 0;
	if (g_once_init_enter (&ag_widgets_geoclue2_dialog_type_id__once)) {
		GType ag_widgets_geoclue2_dialog_type_id;
		ag_widgets_geoclue2_dialog_type_id = ag_widgets_geoclue2_dialog_get_type_once ();
		g_once_init_leave (&ag_widgets_geoclue2_dialog_type_id__once, ag_widgets_geoclue2_dialog_type_id);
	}
	return ag_widgets_geoclue2_dialog_type_id__once;
}

