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

/*
* Copyright (c) 2018-2020 Daniel Pinto (https://github.com/danielpinto8zz6/budgie-network-applet)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published by
* the Free Software Foundation, either version 2.1 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 Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*
*/

#include "networkapplet.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.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  {
	NETWORK_WIDGETS_OVERLAY_ICON_0_PROPERTY,
	NETWORK_WIDGETS_OVERLAY_ICON_NUM_PROPERTIES
};
static GParamSpec* network_widgets_overlay_icon_properties[NETWORK_WIDGETS_OVERLAY_ICON_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _NetworkWidgetsOverlayIconPrivate {
	GtkImage* main_image;
	GtkImage* overlay_image;
};

static gint NetworkWidgetsOverlayIcon_private_offset;
static gpointer network_widgets_overlay_icon_parent_class = NULL;
static GType network_widgets_overlay_icon_type_id = 0;

static GObject * network_widgets_overlay_icon_constructor (GType type,
                                                    guint n_construct_properties,
                                                    GObjectConstructParam * construct_properties);
static void network_widgets_overlay_icon_finalize (GObject * obj);

static inline gpointer
network_widgets_overlay_icon_get_instance_private (NetworkWidgetsOverlayIcon* self)
{
	return G_STRUCT_MEMBER_P (self, NetworkWidgetsOverlayIcon_private_offset);
}

NetworkWidgetsOverlayIcon*
network_widgets_overlay_icon_construct (GType object_type,
                                        const gchar* icon_name)
{
	NetworkWidgetsOverlayIcon * self = NULL;
	GtkImage* _tmp0_;
	g_return_val_if_fail (icon_name != NULL, NULL);
	self = (NetworkWidgetsOverlayIcon*) g_object_new (object_type, NULL);
	_tmp0_ = self->priv->main_image;
	g_object_set (_tmp0_, "icon-name", icon_name, NULL);
	return self;
}

NetworkWidgetsOverlayIcon*
network_widgets_overlay_icon_new (const gchar* icon_name)
{
	return network_widgets_overlay_icon_construct (NETWORK_WIDGETS_TYPE_OVERLAY_ICON, icon_name);
}

void
network_widgets_overlay_icon_set_name (NetworkWidgetsOverlayIcon* self,
                                       const gchar* main_image_icon_name,
                                       const gchar* overlay_image_icon_name)
{
	GtkImage* _tmp0_;
	GtkImage* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (main_image_icon_name != NULL);
	_tmp0_ = self->priv->main_image;
	g_object_set (_tmp0_, "icon-name", main_image_icon_name, NULL);
	_tmp1_ = self->priv->overlay_image;
	g_object_set (_tmp1_, "icon-name", overlay_image_icon_name, NULL);
}

static GObject *
network_widgets_overlay_icon_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	NetworkWidgetsOverlayIcon * self;
	GtkImage* _tmp0_;
	GtkImage* _tmp1_;
	GtkImage* _tmp2_;
	GtkImage* _tmp3_;
	GtkImage* _tmp4_;
	GtkImage* _tmp5_;
	parent_class = G_OBJECT_CLASS (network_widgets_overlay_icon_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NETWORK_WIDGETS_TYPE_OVERLAY_ICON, NetworkWidgetsOverlayIcon);
	_tmp0_ = (GtkImage*) gtk_image_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->main_image);
	self->priv->main_image = _tmp0_;
	_tmp1_ = self->priv->main_image;
	g_object_set (_tmp1_, "icon-size", (gint) GTK_ICON_SIZE_MENU, NULL);
	_tmp2_ = (GtkImage*) gtk_image_new ();
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->overlay_image);
	self->priv->overlay_image = _tmp2_;
	_tmp3_ = self->priv->overlay_image;
	g_object_set (_tmp3_, "icon-size", (gint) GTK_ICON_SIZE_MENU, NULL);
	_tmp4_ = self->priv->main_image;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp4_);
	_tmp5_ = self->priv->overlay_image;
	gtk_overlay_add_overlay ((GtkOverlay*) self, (GtkWidget*) _tmp5_);
	return obj;
}

static void
network_widgets_overlay_icon_class_init (NetworkWidgetsOverlayIconClass * klass,
                                         gpointer klass_data)
{
	network_widgets_overlay_icon_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &NetworkWidgetsOverlayIcon_private_offset);
	G_OBJECT_CLASS (klass)->constructor = network_widgets_overlay_icon_constructor;
	G_OBJECT_CLASS (klass)->finalize = network_widgets_overlay_icon_finalize;
}

static void
network_widgets_overlay_icon_instance_init (NetworkWidgetsOverlayIcon * self,
                                            gpointer klass)
{
	self->priv = network_widgets_overlay_icon_get_instance_private (self);
}

static void
network_widgets_overlay_icon_finalize (GObject * obj)
{
	NetworkWidgetsOverlayIcon * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NETWORK_WIDGETS_TYPE_OVERLAY_ICON, NetworkWidgetsOverlayIcon);
	_g_object_unref0 (self->priv->main_image);
	_g_object_unref0 (self->priv->overlay_image);
	G_OBJECT_CLASS (network_widgets_overlay_icon_parent_class)->finalize (obj);
}

GType
network_widgets_overlay_icon_get_type (void)
{
	return network_widgets_overlay_icon_type_id;
}

GType
network_widgets_overlay_icon_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (NetworkWidgetsOverlayIconClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) network_widgets_overlay_icon_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NetworkWidgetsOverlayIcon), 0, (GInstanceInitFunc) network_widgets_overlay_icon_instance_init, NULL };
	network_widgets_overlay_icon_type_id = g_type_module_register_type (module, gtk_overlay_get_type (), "NetworkWidgetsOverlayIcon", &g_define_type_info, 0);
	NetworkWidgetsOverlayIcon_private_offset = sizeof (NetworkWidgetsOverlayIconPrivate);
	return network_widgets_overlay_icon_type_id;
}

