1/*
2 * * Copyright (C) 2009-2011 Ali <aliov@xfce.org>
3 * * Copyright (C) 2012-2017 Simon Steinbeiß <ochosi@xfce.org>
4 * * Copyright (C) 2012-2020 Sean Davis <bluesabre@xfce.org>
5 *
6 * Licensed under the GNU General Public License Version 2
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 */
22
23#ifndef SRC_MISC_PAROLE_H_
24#define SRC_MISC_PAROLE_H_
25
26#define __PAROLE_H_INSIDE__
27
28#include <glib-object.h>
29
30#include <libxfce4util/libxfce4util.h>
31
32#include "src/misc/parole-debug.h"
33#include "src/misc/parole-file.h"
34#include "src/misc/parole-filters.h"
35#include "src/misc/parole-pl-parser.h"
36#include "src/misc/parole-provider-player.h"
37#include "src/misc/parole-provider-plugin.h"
38#include "src/misc/parole-stream.h"
39
40/**
41 * PAROLE_MAJOR_VERSION:
42 *
43 * Major version number.
44 *
45 * Since: 0.2
46 */
47#define PAROLE_MAJOR_VERSION		@PAROLE_VERSION_MAJOR@
48
49/**
50 * PAROLE_MINOR_VERSION:
51 *
52 * Minor version number.
53 *
54 * Since: 0.2
55 */
56#define PAROLE_MINOR_VERSION		@PAROLE_VERSION_MINOR@
57
58/**
59 * PAROLE_MICRO_VERSION:
60 *
61 * Micro version number.
62 *
63 * Since: 0.2
64 */
65#define PAROLE_MICRO_VERSION		@PAROLE_VERSION_MICRO@
66
67/**
68 * PAROLE_CHECK_VERSION:
69 * @major: major version number
70 * @minor: minor version number
71 * @micro: micro version number
72 *
73 * Checks the parole version.
74 *
75 * Since: 0.2
76 */
77#define	PAROLE_CHECK_VERSION(major,minor,micro)					\
78    (PAROLE_MAJOR_VERSION > (major) || 						\
79    (PAROLE_MAJOR_VERSION == (major) && PAROLE_MINOR_VERSION > (minor)) || 	\
80    (PAROLE_MAJOR_VERSION == (major) && PAROLE_MINOR_VERSION == (minor) && 	\
81     PAROLE_MICRO_VERSION >= (micro)))
82
83/*
84 * GType module registration macros.
85 */
86/**
87 * PAROLE_DEFINE_TYPE:
88 * @TN: The name of the new type, in Camel case
89 * @t_n: The name of the new type, in lowercase, with words separated by '_'
90 * @T_P: The #GType of the parent type
91 *
92 * Create a new type definition.
93 *
94 * Since: 0.2
95 */
96#define PAROLE_DEFINE_TYPE(TN, t_n, T_P) PAROLE_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
97
98/**
99 * PAROLE_DEFINE_TYPE_EXTENDED:
100 * @TN: The name of the new type, in Camel case
101 * @t_n: The name of the new type, in lowercase, with words separated by '_'
102 * @T_P: The #GType of the parent type
103 * @_f_: #GTypeFlags to pass to g_type_module_register_type ()
104 * @_C_: Custom code that gets inserted in *_get_type() function
105 *
106 * Create a new type definition, passing flags and custom code to be inserted in the *_get_type() function.
107 *
108 * Since: 0.2
109 */
110#define PAROLE_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_)	_PAROLE_DEFINE_TYPE_EXTENDED_BEGIN(TN, t_n, T_P, _f_) {_C_;} _PAROLE_DEFINE_TYPE_EXTENDED_END()
111
112/**
113 * PAROLE_DEFINE_TYPE_WITH_CODE:
114 * @TN: The name of the new type, in Camel case
115 * @t_n: The name of the new type, in lowercase, with words separated by '_'
116 * @T_P: The #GType of the parent type
117 * @_C_: Custom code that gets inserted in *_get_type() function
118 *
119 * Create a new type definition, passing custom code to be inserted in the *_get_type() function.
120 *
121 * Since: 0.2
122 */
123#define PAROLE_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)	_PAROLE_DEFINE_TYPE_EXTENDED_BEGIN(TN, t_n, T_P, 0) {_C_;} _PAROLE_DEFINE_TYPE_EXTENDED_END()
124
125/**
126 * PAROLE_DEFINE_ABSTRACT_TYPE:
127 * @TN: The name of the new type, in Camel case
128 * @t_n: The name of the new type, in lowercase, with words separated by '_'
129 * @T_P: The #GType of the parent type
130 *
131 * Create a new abstract type definition.
132 *
133 * Since: 0.2
134 */
135#define PAROLE_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P) PAROLE_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, {})
136
137/**
138 * PAROLE_DEFINE_ABSTRACT_TYPE_WITH_CODE:
139 * @TN: The name of the new type, in Camel case
140 * @t_n: The name of the new type, in lowercase, with words separated by '_'
141 * @T_P: The #GType of the parent type
142 * @_C_: Custom code that gets inserted in *_get_type() function
143 *
144 * Create a new abstract type definition, passing custom code to be inserted in the *_get_type() function.
145 *
146 * Since: 0.2
147 */
148#define PAROLE_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) PAROLE_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, _C_)
149
150
151#define _PAROLE_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
152										\
153static gpointer type_name##_parent_class = NULL; 				\
154static GType    type_name##_type = G_TYPE_INVALID; 				\
155										\
156static void     type_name##_init              (TypeName        *self); 		\
157static void     type_name##_class_init        (TypeName##Class *klass); 	\
158static void     type_name##_class_intern_init (TypeName##Class *klass) 		\
159{ 										\
160    type_name##_parent_class = g_type_class_peek_parent (klass); 		\
161    type_name##_class_init (klass); 						\
162} 										\
163										\
164GType 										\
165type_name##_get_type (void) 							\
166{ 										\
167  return type_name##_type; 							\
168} 										\
169										\
170void 										\
171type_name##_register_type (ParoleProviderPlugin *provider_plugin_def) 		\
172{ 										\
173    GType parole_define_type_id; 						\
174										\
175    static const GTypeInfo parole_define_type_info = 				\
176    {										\
177	sizeof (TypeName##Class), 						\
178	NULL, 									\
179	NULL, 									\
180	(GClassInitFunc) (void (*)(void)) type_name##_class_intern_init, 			\
181	NULL, 									\
182	NULL, 									\
183	sizeof (TypeName), 							\
184	0, 									\
185	(GInstanceInitFunc) (void (*)(void)) type_name##_init, 					\
186	NULL, 									\
187    }; 										\
188										\
189    parole_define_type_id = 							\
190	g_type_module_register_type ((GTypeModule*)provider_plugin_def, 	\
191				     TYPE_PARENT, 				\
192				     #TypeName, 				\
193				     &parole_define_type_info, 			\
194				     flags); 					\
195    type_name##_type = parole_define_type_id; 					\
196										\
197    { /* Code */
198#define _PAROLE_DEFINE_TYPE_EXTENDED_END()					\
199    }										\
200}
201
202/**
203 * PAROLE_IMPLEMENT_INTERFACE:
204 * @TYPE_IFACE: the #GType of the interface to add
205 * @iface_init: The interface init function
206 *
207 * Convenience function for interface implementation.
208 *
209 */
210#define PAROLE_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) 			\
211{ 										\
212    static const GInterfaceInfo parole_implement_interface_info = 		\
213    { 										\
214	(GInterfaceInitFunc) (void (*)(void)) iface_init 					\
215    }; 										\
216										\
217    g_type_module_add_interface ((GTypeModule*)provider_plugin_def, 		\
218				 parole_define_type_id, 			\
219				 TYPE_IFACE, 					\
220				 &parole_implement_interface_info); 		\
221}
222
223
224#undef __PAROLE_H_INSIDE__
225
226#endif /* SRC_MISC_PAROLE_H_ */
227