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

/*
 * This file is part of budgie-desktop
 *
 * Copyright © 2015-2022 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 "icontasklistapplet.h"
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>

enum  {
	BUTTON_WRAPPER_0_PROPERTY,
	BUTTON_WRAPPER_ORIENT_PROPERTY,
	BUTTON_WRAPPER_NUM_PROPERTIES
};
static GParamSpec* button_wrapper_properties[BUTTON_WRAPPER_NUM_PROPERTIES];

static gpointer button_wrapper_parent_class = NULL;
static GType button_wrapper_type_id = 0;

static void __lambda46_ (ButtonWrapper* self);
static void ___lambda46__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void button_wrapper_finalize (GObject * obj);
static void _vala_button_wrapper_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec);
static void _vala_button_wrapper_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec);

ButtonWrapper*
button_wrapper_construct (GType object_type,
                          IconButton* button)
{
	ButtonWrapper * self = NULL;
	self = (ButtonWrapper*) g_object_new (object_type, NULL);
	self->button = button;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) button);
	gtk_revealer_set_reveal_child ((GtkRevealer*) self, FALSE);
	gtk_widget_show_all ((GtkWidget*) self);
	return self;
}

ButtonWrapper*
button_wrapper_new (IconButton* button)
{
	return button_wrapper_construct (TYPE_BUTTON_WRAPPER, button);
}

static void
__lambda46_ (ButtonWrapper* self)
{
	gtk_widget_hide ((GtkWidget*) self);
	gtk_widget_destroy ((GtkWidget*) self);
}

static void
___lambda46__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda46_ ((ButtonWrapper*) self);
}

void
button_wrapper_gracefully_die (ButtonWrapper* self)
{
	GtkSettings* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	GtkOrientation _tmp3_;
	GtkOrientation _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_widget_get_settings ((GtkWidget*) self);
	g_object_get (_tmp0_, "gtk-enable-animations", &_tmp1_, NULL);
	_tmp2_ = _tmp1_;
	if (!_tmp2_) {
		gtk_widget_hide ((GtkWidget*) self);
		gtk_widget_destroy ((GtkWidget*) self);
		return;
	}
	_tmp3_ = button_wrapper_get_orient (self);
	_tmp4_ = _tmp3_;
	if (_tmp4_ == GTK_ORIENTATION_HORIZONTAL) {
		gtk_revealer_set_transition_type ((GtkRevealer*) self, GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT);
	} else {
		gtk_revealer_set_transition_type ((GtkRevealer*) self, GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
	}
	g_signal_connect_object ((GObject*) self, "notify::child-revealed", (GCallback) ___lambda46__g_object_notify, self, G_CONNECT_AFTER);
	gtk_revealer_set_reveal_child ((GtkRevealer*) self, FALSE);
}

GtkOrientation
button_wrapper_get_orient (ButtonWrapper* self)
{
	GtkOrientation result;
	g_return_val_if_fail (self != NULL, 0);
	if (gtk_revealer_get_transition_type ((GtkRevealer*) self) == GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN) {
		result = GTK_ORIENTATION_VERTICAL;
		return result;
	}
	result = GTK_ORIENTATION_HORIZONTAL;
	return result;
}

void
button_wrapper_set_orient (ButtonWrapper* self,
                           GtkOrientation value)
{
	g_return_if_fail (self != NULL);
	if (value == GTK_ORIENTATION_VERTICAL) {
		gtk_revealer_set_transition_type ((GtkRevealer*) self, GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
	} else {
		gtk_revealer_set_transition_type ((GtkRevealer*) self, GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT);
	}
	g_object_notify_by_pspec ((GObject *) self, button_wrapper_properties[BUTTON_WRAPPER_ORIENT_PROPERTY]);
}

static void
button_wrapper_class_init (ButtonWrapperClass * klass,
                           gpointer klass_data)
{
	button_wrapper_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->get_property = _vala_button_wrapper_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_button_wrapper_set_property;
	G_OBJECT_CLASS (klass)->finalize = button_wrapper_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BUTTON_WRAPPER_ORIENT_PROPERTY, button_wrapper_properties[BUTTON_WRAPPER_ORIENT_PROPERTY] = g_param_spec_enum ("orient", "orient", "orient", gtk_orientation_get_type (), 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
button_wrapper_instance_init (ButtonWrapper * self,
                              gpointer klass)
{
}

static void
button_wrapper_finalize (GObject * obj)
{
	ButtonWrapper * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_BUTTON_WRAPPER, ButtonWrapper);
	G_OBJECT_CLASS (button_wrapper_parent_class)->finalize (obj);
}

/**
 * The wrapper provides nice visual effects to house an IconButton, allowing
 * us to slide the buttons into view when ready, and dispose of them as and
 * when our slide-out animation has finished. Without the wrapper, we'd have
 * a very ugly effect of icons just "popping" off.
 */
GType
button_wrapper_get_type (void)
{
	return button_wrapper_type_id;
}

GType
button_wrapper_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (ButtonWrapperClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) button_wrapper_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ButtonWrapper), 0, (GInstanceInitFunc) button_wrapper_instance_init, NULL };
	button_wrapper_type_id = g_type_module_register_type (module, gtk_revealer_get_type (), "ButtonWrapper", &g_define_type_info, 0);
	return button_wrapper_type_id;
}

static void
_vala_button_wrapper_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec)
{
	ButtonWrapper * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_BUTTON_WRAPPER, ButtonWrapper);
	switch (property_id) {
		case BUTTON_WRAPPER_ORIENT_PROPERTY:
		g_value_set_enum (value, button_wrapper_get_orient (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_button_wrapper_set_property (GObject * object,
                                   guint property_id,
                                   const GValue * value,
                                   GParamSpec * pspec)
{
	ButtonWrapper * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_BUTTON_WRAPPER, ButtonWrapper);
	switch (property_id) {
		case BUTTON_WRAPPER_ORIENT_PROPERTY:
		button_wrapper_set_orient (self, g_value_get_enum (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

