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

/*
 *  Notes - panel plugin for Xfce Desktop Environment
 *  Copyright (c) 2006-2013  Mike Massonnet <mmassonnet@xfce.org>
 *  Copyright (c) 2023       Arthur Demchenkov <spinal.by@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 2 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 St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include "libnotes.h"
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
#include <float.h>
#include <math.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  {
	XNP_THEME_0_PROPERTY,
	XNP_THEME_NUM_PROPERTIES
};
static GParamSpec* xnp_theme_properties[XNP_THEME_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _XnpThemePrivate {
	XnpThemeGtkcss* theme_gtk_css;
};

static gint XnpTheme_private_offset;
static gpointer xnp_theme_parent_class = NULL;

static void xnp_theme_finalize (GObject * obj);
static GType xnp_theme_get_type_once (void);

static inline gpointer
xnp_theme_get_instance_private (XnpTheme* self)
{
	return G_STRUCT_MEMBER_P (self, XnpTheme_private_offset);
}

XnpTheme*
xnp_theme_construct (GType object_type)
{
	XnpTheme * self = NULL;
	XnpThemeGtkcss* _tmp0_;
	self = (XnpTheme*) g_object_new (object_type, NULL);
	_tmp0_ = xnp_theme_gtkcss_new ();
	_g_object_unref0 (self->priv->theme_gtk_css);
	self->priv->theme_gtk_css = _tmp0_;
	return self;
}

XnpTheme*
xnp_theme_new (void)
{
	return xnp_theme_construct (XNP_TYPE_THEME);
}

void
xnp_theme_use_gtk_style (XnpTheme* self)
{
	XnpThemeGtkcss* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->theme_gtk_css;
	xnp_theme_gtkcss_set_use_gtk_style (_tmp0_, TRUE);
}

void
xnp_theme_use_color (XnpTheme* self,
                     const gchar* color)
{
	GdkRGBA rgba = {0};
	GdkRGBA _tmp0_ = {0};
	XnpThemeGtkcss* _tmp1_;
	GdkRGBA _tmp2_;
	XnpThemeGtkcss* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (color != NULL);
	_tmp0_.red = (gdouble) 0;
	rgba = _tmp0_;
	if (!gdk_rgba_parse (&rgba, color)) {
		g_warning ("theme.vala:38: Cannot parse background color %s", color);
		xnp_theme_use_gtk_style (self);
		return;
	}
	_tmp1_ = self->priv->theme_gtk_css;
	_tmp2_ = rgba;
	xnp_theme_gtkcss_update_color_css (_tmp1_, &_tmp2_);
	_tmp3_ = self->priv->theme_gtk_css;
	xnp_theme_gtkcss_set_use_gtk_style (_tmp3_, FALSE);
}

static void
xnp_theme_class_init (XnpThemeClass * klass,
                      gpointer klass_data)
{
	xnp_theme_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &XnpTheme_private_offset);
	G_OBJECT_CLASS (klass)->finalize = xnp_theme_finalize;
}

static void
xnp_theme_instance_init (XnpTheme * self,
                         gpointer klass)
{
	self->priv = xnp_theme_get_instance_private (self);
}

static void
xnp_theme_finalize (GObject * obj)
{
	XnpTheme * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XNP_TYPE_THEME, XnpTheme);
	_g_object_unref0 (self->priv->theme_gtk_css);
	G_OBJECT_CLASS (xnp_theme_parent_class)->finalize (obj);
}

static GType
xnp_theme_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XnpThemeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xnp_theme_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XnpTheme), 0, (GInstanceInitFunc) xnp_theme_instance_init, NULL };
	GType xnp_theme_type_id;
	xnp_theme_type_id = g_type_register_static (G_TYPE_OBJECT, "XnpTheme", &g_define_type_info, 0);
	XnpTheme_private_offset = g_type_add_instance_private (xnp_theme_type_id, sizeof (XnpThemePrivate));
	return xnp_theme_type_id;
}

GType
xnp_theme_get_type (void)
{
	static volatile gsize xnp_theme_type_id__once = 0;
	if (g_once_init_enter (&xnp_theme_type_id__once)) {
		GType xnp_theme_type_id;
		xnp_theme_type_id = xnp_theme_get_type_once ();
		g_once_init_leave (&xnp_theme_type_id__once, xnp_theme_type_id);
	}
	return xnp_theme_type_id__once;
}

