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

/*
 * This file is part of budgie-desktop
 *
 * Copyright Budgie Desktop Developers
 *
 * 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.
 */

#include "placesindicator.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.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  {
	MESSAGE_REVEALER_0_PROPERTY,
	MESSAGE_REVEALER_NUM_PROPERTIES
};
static GParamSpec* message_revealer_properties[MESSAGE_REVEALER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block1Data Block1Data;

struct _MessageRevealerPrivate {
	GtkInfoBar* info_bar;
	GtkLabel* message_label;
	guint expire_id;
};

struct _Block1Data {
	int _ref_count_;
	MessageRevealer* self;
	gulong connection;
};

static gint MessageRevealer_private_offset;
static gpointer message_revealer_parent_class = NULL;
static GType message_revealer_type_id = 0;

static void message_revealer_show_it (MessageRevealer* self);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void __lambda4_ (MessageRevealer* self);
static void ___lambda4__g_object_notify (GObject* _sender,
                                  GParamSpec* pspec,
                                  gpointer self);
static gboolean __lambda5_ (Block1Data* _data1_);
static gboolean ___lambda5__gsource_func (gpointer self);
static gboolean _message_revealer_hide_it_gsource_func (gpointer self);
static void message_revealer_finalize (GObject * obj);

static inline gpointer
message_revealer_get_instance_private (MessageRevealer* self)
{
	return G_STRUCT_MEMBER_P (self, MessageRevealer_private_offset);
}

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

MessageRevealer*
message_revealer_construct (GType object_type)
{
	MessageRevealer * self = NULL;
	GtkInfoBar* _tmp0_;
	GtkInfoBar* _tmp1_;
	GtkStyleContext* _tmp2_;
	GtkInfoBar* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkContainer* info_bar_container = NULL;
	GtkInfoBar* _tmp8_;
	GtkContainer* _tmp9_;
	GtkContainer* _tmp10_;
	GtkLabel* _tmp11_;
	self = (MessageRevealer*) g_object_new (object_type, "visible", FALSE, NULL);
	_tmp0_ = (GtkInfoBar*) gtk_info_bar_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->info_bar);
	self->priv->info_bar = _tmp0_;
	_tmp1_ = self->priv->info_bar;
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
	gtk_style_context_add_class (_tmp2_, "message-bar");
	_tmp3_ = self->priv->info_bar;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp3_);
	_tmp4_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->message_label);
	self->priv->message_label = _tmp4_;
	_tmp5_ = self->priv->message_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp5_, GTK_ALIGN_START);
	_tmp6_ = self->priv->message_label;
	gtk_label_set_line_wrap (_tmp6_, TRUE);
	_tmp7_ = self->priv->message_label;
	gtk_label_set_max_width_chars (_tmp7_, 30);
	_tmp8_ = self->priv->info_bar;
	_tmp9_ = gtk_info_bar_get_content_area (_tmp8_);
	_tmp10_ = _g_object_ref0 (_tmp9_);
	info_bar_container = _tmp10_;
	_tmp11_ = self->priv->message_label;
	gtk_container_add (info_bar_container, (GtkWidget*) _tmp11_);
	_g_object_unref0 (info_bar_container);
	return self;
}

MessageRevealer*
message_revealer_new (void)
{
	return message_revealer_construct (TYPE_MESSAGE_REVEALER);
}

static void
message_revealer_show_it (MessageRevealer* self)
{
	g_return_if_fail (self != NULL);
	gtk_widget_set_no_show_all ((GtkWidget*) self, FALSE);
	gtk_widget_show_all ((GtkWidget*) self);
	gtk_revealer_set_reveal_child ((GtkRevealer*) self, TRUE);
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		MessageRevealer* self;
		self = _data1_->self;
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static void
__lambda4_ (MessageRevealer* self)
{
	gtk_widget_set_no_show_all ((GtkWidget*) self, TRUE);
	gtk_widget_hide ((GtkWidget*) self);
}

static void
___lambda4__g_object_notify (GObject* _sender,
                             GParamSpec* pspec,
                             gpointer self)
{
	__lambda4_ ((MessageRevealer*) self);
}

static gboolean
__lambda5_ (Block1Data* _data1_)
{
	MessageRevealer* self;
	gboolean result;
	self = _data1_->self;
	g_signal_handler_disconnect ((GObject*) self, _data1_->connection);
	result = FALSE;
	return result;
}

static gboolean
___lambda5__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda5_ (self);
	return result;
}

gboolean
message_revealer_hide_it (MessageRevealer* self)
{
	Block1Data* _data1_;
	gulong _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	if (self->priv->expire_id != ((guint) 0)) {
		g_source_remove (self->priv->expire_id);
	}
	self->priv->expire_id = (guint) 0;
	_tmp0_ = g_signal_connect_object ((GObject*) self, "notify::child-revealed", (GCallback) ___lambda4__g_object_notify, self, G_CONNECT_AFTER);
	_data1_->connection = _tmp0_;
	gtk_revealer_set_reveal_child ((GtkRevealer*) self, FALSE);
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 300, ___lambda5__gsource_func, block1_data_ref (_data1_), block1_data_unref);
	result = FALSE;
	block1_data_unref (_data1_);
	_data1_ = NULL;
	return result;
}

static gboolean
_message_revealer_hide_it_gsource_func (gpointer self)
{
	gboolean result;
	result = message_revealer_hide_it ((MessageRevealer*) self);
	return result;
}

void
message_revealer_set_content (MessageRevealer* self,
                              const gchar* message)
{
	GtkLabel* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	_tmp0_ = self->priv->message_label;
	gtk_label_set_text (_tmp0_, message);
	message_revealer_show_it (self);
	if (self->priv->expire_id != ((guint) 0)) {
		g_source_remove (self->priv->expire_id);
	}
	self->priv->expire_id = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 5000, _message_revealer_hide_it_gsource_func, g_object_ref (self), g_object_unref);
}

static void
message_revealer_class_init (MessageRevealerClass * klass,
                             gpointer klass_data)
{
	message_revealer_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &MessageRevealer_private_offset);
	G_OBJECT_CLASS (klass)->finalize = message_revealer_finalize;
}

static void
message_revealer_instance_init (MessageRevealer * self,
                                gpointer klass)
{
	self->priv = message_revealer_get_instance_private (self);
	self->priv->expire_id = (guint) 0;
}

static void
message_revealer_finalize (GObject * obj)
{
	MessageRevealer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MESSAGE_REVEALER, MessageRevealer);
	_g_object_unref0 (self->priv->info_bar);
	_g_object_unref0 (self->priv->message_label);
	G_OBJECT_CLASS (message_revealer_parent_class)->finalize (obj);
}

GType
message_revealer_get_type (void)
{
	return message_revealer_type_id;
}

GType
message_revealer_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (MessageRevealerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) message_revealer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MessageRevealer), 0, (GInstanceInitFunc) message_revealer_instance_init, NULL };
	message_revealer_type_id = g_type_module_register_type (module, gtk_revealer_get_type (), "MessageRevealer", &g_define_type_info, 0);
	MessageRevealer_private_offset = sizeof (MessageRevealerPrivate);
	return message_revealer_type_id;
}

