File: theme.c

package info (click to toggle)
xfce4-notes-plugin 1.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,292 kB
  • sloc: ansic: 13,235; sh: 5,064; makefile: 303; sed: 16
file content (163 lines) | stat: -rw-r--r-- 4,964 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/* theme.c generated by valac 0.56.17, 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;
}