/* browser-infobar.c generated by valac 0.56.3, the Vala compiler
 * generated from browser-infobar.vala, do not modify */

/*
  This file is part of Dconf Editor

  Dconf Editor 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.

  Dconf Editor 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 Dconf Editor.  If not, see <https://www.gnu.org/licenses/>.
*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <float.h>
#include <math.h>

#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_BROWSER_INFO_BAR (browser_info_bar_get_type ())
#define BROWSER_INFO_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BROWSER_INFO_BAR, BrowserInfoBar))
#define BROWSER_INFO_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BROWSER_INFO_BAR, BrowserInfoBarClass))
#define IS_BROWSER_INFO_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BROWSER_INFO_BAR))
#define IS_BROWSER_INFO_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BROWSER_INFO_BAR))
#define BROWSER_INFO_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BROWSER_INFO_BAR, BrowserInfoBarClass))

typedef struct _BrowserInfoBar BrowserInfoBar;
typedef struct _BrowserInfoBarClass BrowserInfoBarClass;
typedef struct _BrowserInfoBarPrivate BrowserInfoBarPrivate;
enum  {
	BROWSER_INFO_BAR_0_PROPERTY,
	BROWSER_INFO_BAR_NUM_PROPERTIES
};
static GParamSpec* browser_info_bar_properties[BROWSER_INFO_BAR_NUM_PROPERTIES];

#define TYPE_REGISTRY_WARNING (registry_warning_get_type ())
#define REGISTRY_WARNING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_REGISTRY_WARNING, RegistryWarning))
#define REGISTRY_WARNING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_REGISTRY_WARNING, RegistryWarningClass))
#define IS_REGISTRY_WARNING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_REGISTRY_WARNING))
#define IS_REGISTRY_WARNING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_REGISTRY_WARNING))
#define REGISTRY_WARNING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_REGISTRY_WARNING, RegistryWarningClass))

typedef struct _RegistryWarning RegistryWarning;
typedef struct _RegistryWarningClass RegistryWarningClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _BrowserInfoBar {
	GtkRevealer parent_instance;
	BrowserInfoBarPrivate * priv;
};

struct _BrowserInfoBarClass {
	GtkRevealerClass parent_class;
};

struct _BrowserInfoBarPrivate {
	GtkStack* content;
};

static gint BrowserInfoBar_private_offset;
static gpointer browser_info_bar_parent_class = NULL;

VALA_EXTERN GType browser_info_bar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BrowserInfoBar, g_object_unref)
VALA_EXTERN void browser_info_bar_add_label (BrowserInfoBar* self,
                                 const gchar* name,
                                 const gchar* text_label,
                                 const gchar* button_label,
                                 const gchar* button_action);
VALA_EXTERN GType registry_warning_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RegistryWarning, g_object_unref)
VALA_EXTERN RegistryWarning* registry_warning_new (void);
VALA_EXTERN RegistryWarning* registry_warning_construct (GType object_type);
VALA_EXTERN void browser_info_bar_hide_warning (BrowserInfoBar* self);
VALA_EXTERN gboolean browser_info_bar_is_shown (BrowserInfoBar* self,
                                    const gchar* name);
VALA_EXTERN void browser_info_bar_show_warning (BrowserInfoBar* self,
                                    const gchar* name);
VALA_EXTERN BrowserInfoBar* browser_info_bar_new (void);
VALA_EXTERN BrowserInfoBar* browser_info_bar_construct (GType object_type);
static void browser_info_bar_finalize (GObject * obj);
static GType browser_info_bar_get_type_once (void);

static inline gpointer
browser_info_bar_get_instance_private (BrowserInfoBar* self)
{
	return G_STRUCT_MEMBER_P (self, BrowserInfoBar_private_offset);
}

void
browser_info_bar_add_label (BrowserInfoBar* self,
                            const gchar* name,
                            const gchar* text_label,
                            const gchar* button_label,
                            const gchar* button_action)
{
	RegistryWarning* grid = NULL;
	RegistryWarning* _tmp0_;
	GtkLabel* label = NULL;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	RegistryWarning* _tmp16_;
	GtkStack* _tmp17_;
	RegistryWarning* _tmp18_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (text_label != NULL);
	g_return_if_fail (button_action != NULL);
	_tmp0_ = registry_warning_new ();
	g_object_ref_sink (_tmp0_);
	grid = _tmp0_;
	_tmp1_ = (GtkLabel*) gtk_label_new (text_label);
	g_object_ref_sink (_tmp1_);
	label = _tmp1_;
	_tmp2_ = label;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp2_, TRUE);
	_tmp3_ = label;
	gtk_label_set_max_width_chars (_tmp3_, 40);
	_tmp4_ = label;
	g_object_set (_tmp4_, "wrap", TRUE, NULL);
	if (button_label != NULL) {
		GtkButton* button = NULL;
		GtkButton* _tmp5_;
		GtkButton* _tmp6_;
		GtkButton* _tmp7_;
		GtkLabel* _tmp8_;
		RegistryWarning* _tmp9_;
		GtkLabel* _tmp10_;
		RegistryWarning* _tmp11_;
		GtkButton* _tmp12_;
		if (g_strcmp0 (button_action, "") == 0) {
			g_assert_not_reached ();
		}
		_tmp5_ = (GtkButton*) gtk_button_new ();
		g_object_ref_sink (_tmp5_);
		button = _tmp5_;
		_tmp6_ = button;
		gtk_button_set_label (_tmp6_, (const gchar*) button_label);
		_tmp7_ = button;
		gtk_actionable_set_detailed_action_name ((GtkActionable*) _tmp7_, button_action);
		_tmp8_ = label;
		gtk_label_set_xalign (_tmp8_, (gfloat) 0.0);
		_tmp9_ = grid;
		_tmp10_ = label;
		gtk_container_add ((GtkContainer*) _tmp9_, (GtkWidget*) _tmp10_);
		_tmp11_ = grid;
		_tmp12_ = button;
		gtk_container_add ((GtkContainer*) _tmp11_, (GtkWidget*) _tmp12_);
		_g_object_unref0 (button);
	} else {
		GtkLabel* _tmp13_;
		RegistryWarning* _tmp14_;
		GtkLabel* _tmp15_;
		_tmp13_ = label;
		gtk_label_set_xalign (_tmp13_, (gfloat) 0.5);
		_tmp14_ = grid;
		_tmp15_ = label;
		gtk_container_add ((GtkContainer*) _tmp14_, (GtkWidget*) _tmp15_);
	}
	_tmp16_ = grid;
	gtk_widget_show_all ((GtkWidget*) _tmp16_);
	_tmp17_ = self->priv->content;
	_tmp18_ = grid;
	gtk_stack_add_named (_tmp17_, (GtkWidget*) _tmp18_, name);
	_g_object_unref0 (label);
	_g_object_unref0 (grid);
}

void
browser_info_bar_hide_warning (BrowserInfoBar* self)
{
	g_return_if_fail (self != NULL);
	gtk_revealer_set_reveal_child ((GtkRevealer*) self, FALSE);
}

gboolean
browser_info_bar_is_shown (BrowserInfoBar* self,
                           const gchar* name)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (name != NULL, FALSE);
	if (gtk_revealer_get_child_revealed ((GtkRevealer*) self)) {
		GtkStack* _tmp1_;
		const gchar* _tmp2_;
		_tmp1_ = self->priv->content;
		_tmp2_ = gtk_stack_get_visible_child_name (_tmp1_);
		_tmp0_ = _tmp2_ == name;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

void
browser_info_bar_show_warning (BrowserInfoBar* self,
                               const gchar* name)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	if (!gtk_revealer_get_child_revealed ((GtkRevealer*) self)) {
		GtkStack* _tmp0_;
		GtkStack* _tmp1_;
		_tmp0_ = self->priv->content;
		gtk_stack_set_transition_type (_tmp0_, GTK_STACK_TRANSITION_TYPE_NONE);
		_tmp1_ = self->priv->content;
		gtk_stack_set_visible_child_name (_tmp1_, name);
		gtk_revealer_set_reveal_child ((GtkRevealer*) self, TRUE);
	} else {
		GtkStack* _tmp2_;
		const gchar* _tmp3_;
		_tmp2_ = self->priv->content;
		_tmp3_ = gtk_stack_get_visible_child_name (_tmp2_);
		if (_tmp3_ != name) {
			GtkStack* _tmp4_;
			GtkStack* _tmp5_;
			_tmp4_ = self->priv->content;
			gtk_stack_set_transition_type (_tmp4_, GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN);
			_tmp5_ = self->priv->content;
			gtk_stack_set_visible_child_name (_tmp5_, name);
		}
	}
}

BrowserInfoBar*
browser_info_bar_construct (GType object_type)
{
	BrowserInfoBar * self = NULL;
	self = (BrowserInfoBar*) g_object_new (object_type, NULL);
	return self;
}

BrowserInfoBar*
browser_info_bar_new (void)
{
	return browser_info_bar_construct (TYPE_BROWSER_INFO_BAR);
}

static void
browser_info_bar_class_init (BrowserInfoBarClass * klass,
                             gpointer klass_data)
{
	browser_info_bar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BrowserInfoBar_private_offset);
	G_OBJECT_CLASS (klass)->finalize = browser_info_bar_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/ca/desrt/dconf-editor/ui/browser-infobar.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "content", FALSE, BrowserInfoBar_private_offset + G_STRUCT_OFFSET (BrowserInfoBarPrivate, content));
}

static void
browser_info_bar_instance_init (BrowserInfoBar * self,
                                gpointer klass)
{
	self->priv = browser_info_bar_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
browser_info_bar_finalize (GObject * obj)
{
	BrowserInfoBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_BROWSER_INFO_BAR, BrowserInfoBar);
	G_OBJECT_CLASS (browser_info_bar_parent_class)->finalize (obj);
}

static GType
browser_info_bar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BrowserInfoBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) browser_info_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BrowserInfoBar), 0, (GInstanceInitFunc) browser_info_bar_instance_init, NULL };
	GType browser_info_bar_type_id;
	browser_info_bar_type_id = g_type_register_static (gtk_revealer_get_type (), "BrowserInfoBar", &g_define_type_info, 0);
	BrowserInfoBar_private_offset = g_type_add_instance_private (browser_info_bar_type_id, sizeof (BrowserInfoBarPrivate));
	return browser_info_bar_type_id;
}

GType
browser_info_bar_get_type (void)
{
	static volatile gsize browser_info_bar_type_id__once = 0;
	if (g_once_init_enter (&browser_info_bar_type_id__once)) {
		GType browser_info_bar_type_id;
		browser_info_bar_type_id = browser_info_bar_get_type_once ();
		g_once_init_leave (&browser_info_bar_type_id__once, browser_info_bar_type_id);
	}
	return browser_info_bar_type_id__once;
}

