1 /**
2 * This file is a part of the Cairo-Dock project
3 *
4 * Copyright : (C) see the 'copyright' file.
5 * E-mail    : see the 'copyright' file.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include <stdlib.h>
21 
22 #include <cairo.h>
23 #include <gtk/gtk.h>
24 #include <GL/gl.h>
25 
26 #include "cairo-dock-config.h"
27 #include "cairo-dock-log.h"
28 #include "cairo-dock-draw-opengl.h"
29 #include "cairo-dock-surface-factory.h"  // cairo_dock_create_blank_surface
30 #include "cairo-dock-keyfile-utilities.h"  // cairo_dock_open_key_file
31 #define _MANAGER_DEF_
32 #include "cairo-dock-style-manager.h"
33 
34 // public (manager, config, data)
35 GldiStyleParam myStyleParam;
36 GldiManager myStyleMgr;
37 
38 // dependancies
39 extern gchar *g_cCurrentThemePath;
40 extern gboolean g_bUseOpenGL;
41 
42 // private
43 static GtkStyleContext *s_pStyle = NULL;
44 static GdkRGBA s_menu_bg_color;
45 static cairo_pattern_t *s_menu_bg_pattern = NULL;
46 static GLuint s_menu_bg_texture = 0;
47 static GdkRGBA s_menuitem_bg_color;
48 static cairo_pattern_t *s_menuitem_bg_pattern = NULL;
49 static GdkRGBA s_text_color;
50 static int s_iStyleStamp = 1;
51 static gboolean s_bIgnoreStyleChange = FALSE;
52 
53 
_on_style_changed(G_GNUC_UNUSED GtkStyleContext * _style,gpointer data)54 static void _on_style_changed (G_GNUC_UNUSED GtkStyleContext *_style, gpointer data)
55 {
56 	if (! s_bIgnoreStyleChange)
57 	{
58 		cd_message ("style changed (%d)", GPOINTER_TO_INT (data));
59 		if (s_menu_bg_pattern != NULL)
60 		{
61 			cairo_pattern_destroy (s_menu_bg_pattern);
62 			s_menu_bg_pattern = NULL;
63 		}
64 		if (s_menu_bg_texture != 0)
65 		{
66 			_cairo_dock_delete_texture (s_menu_bg_texture);
67 			s_menu_bg_texture = 0;
68 		}
69 		if (s_menuitem_bg_pattern != NULL)
70 		{
71 			cairo_pattern_destroy (s_menuitem_bg_pattern);
72 			s_menuitem_bg_pattern = NULL;
73 		}
74 
75 		s_iStyleStamp ++;  // invalidate previous style
76 
77 		if (myStyleParam.bUseSystemColors)
78 		{
79 			GtkStyleContext *style = gtk_style_context_new();
80 			gtk_style_context_set_screen (style, gdk_screen_get_default());
81 			GtkWidgetPath *path;
82 			int pos;
83 
84 			// get text color
85 			path = gtk_widget_path_new();
86 			pos = gtk_widget_path_append_type (path, GTK_TYPE_MENU);
87 			gtk_widget_path_iter_add_class (path, pos, GTK_STYLE_CLASS_MENU);
88 			pos = gtk_widget_path_append_type (path, GTK_TYPE_MENU_ITEM);
89 			gtk_widget_path_iter_add_class (path, pos, GTK_STYLE_CLASS_MENUITEM);
90 			gtk_style_context_set_path (style, path);
91 			gtk_widget_path_free (path);
92 			gtk_style_context_add_class (style, GTK_STYLE_CLASS_MENU);
93 			gtk_style_context_add_class (style, GTK_STYLE_CLASS_MENUITEM);
94 
95 			gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &s_text_color);
96 			cd_debug ("text color: %.2f;%.2f;%.2f;%.2f", s_text_color.red, s_text_color.green, s_text_color.blue, s_text_color.alpha);
97 
98 			// get selected bg color
99 			gtk_style_context_get_background_color (style, GTK_STATE_PRELIGHT, (GdkRGBA*)&s_menuitem_bg_color);
100 			if (s_menuitem_bg_color.alpha == 0)
101 			{
102 				gtk_style_context_get (style, GTK_STATE_FLAG_PRELIGHT,
103 					GTK_STYLE_PROPERTY_BACKGROUND_IMAGE, &s_menuitem_bg_pattern,
104 					NULL);
105 				if (s_menuitem_bg_pattern == NULL)
106 				{
107 					s_menuitem_bg_color.red = s_menuitem_bg_color.green = s_menuitem_bg_color.blue = s_menuitem_bg_color.alpha = 1.;
108 				}
109 			}
110 			cd_debug ("menuitem color: %.2f;%.2f;%.2f;%.2f; %p", s_menuitem_bg_color.red, s_menuitem_bg_color.green, s_menuitem_bg_color.blue, s_menuitem_bg_color.alpha, s_menuitem_bg_pattern);
111 
112 			gtk_style_context_remove_class (style, GTK_STYLE_CLASS_MENUITEM);
113 			gtk_style_context_remove_class (style, GTK_STYLE_CLASS_MENU);
114 
115 			// get bg color
116 			path = gtk_widget_path_new();
117 			pos = gtk_widget_path_append_type (path, GTK_TYPE_WINDOW);
118 			gtk_widget_path_iter_add_class (path, pos, GTK_STYLE_CLASS_BACKGROUND);
119 			pos = gtk_widget_path_append_type (path, GTK_TYPE_MENU);
120 			gtk_widget_path_iter_add_class (path, pos, GTK_STYLE_CLASS_MENU);
121 			gtk_style_context_set_path (style, path);
122 			gtk_widget_path_free (path);
123 			gtk_style_context_add_class (style, GTK_STYLE_CLASS_BACKGROUND);
124 			gtk_style_context_add_class (style, GTK_STYLE_CLASS_MENU);
125 			#if ! GTK_CHECK_VERSION (3,12,0) // Style contexts are now invalidated automatically.
126 			gtk_style_context_invalidate (style);  // force the context to be reconstructed
127 			#endif
128 
129 			gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, (GdkRGBA*)&s_menu_bg_color);
130 			if (s_menu_bg_color.alpha == 0)
131 			{
132 				gtk_style_context_get (style, GTK_STATE_NORMAL,
133 					GTK_STYLE_PROPERTY_BACKGROUND_IMAGE, &s_menu_bg_pattern,
134 					NULL);
135 				if (s_menu_bg_pattern == NULL)
136 				{
137 					s_menu_bg_color.red = s_menu_bg_color.green = s_menu_bg_color.blue = s_menu_bg_color.alpha = 1.;  // shouldn't happen
138 				}
139 				else if (g_bUseOpenGL)
140 				{
141 					cairo_surface_t *pSurface = cairo_dock_create_blank_surface (20, 20);
142 					cairo_t *pCairoContext = cairo_create (pSurface);
143 					cairo_set_source (pCairoContext, s_menu_bg_pattern);
144 					cairo_paint (pCairoContext);
145 					cairo_destroy (pCairoContext);
146 
147 					s_menu_bg_texture = cairo_dock_create_texture_from_surface (pSurface);
148 					cairo_surface_destroy (pSurface);
149 				}
150 			}
151 			cd_debug ("menu color: %.2f;%.2f;%.2f;%.2f; %p", s_menu_bg_color.red, s_menu_bg_color.green, s_menu_bg_color.blue, s_menu_bg_color.alpha, s_menu_bg_pattern);
152 
153 			gtk_style_context_remove_class (style, GTK_STYLE_CLASS_MENU);
154 			gtk_style_context_remove_class (style, GTK_STYLE_CLASS_BACKGROUND);
155 
156 			g_object_unref (style);
157 
158 			gboolean bNotify = GPOINTER_TO_INT(data);
159 			if (bNotify && ! cairo_dock_is_loading())
160 				gldi_object_notify (&myStyleMgr, NOTIFICATION_STYLE_CHANGED);
161 		}
162 	}
163 	else cd_debug (" style changed ignored");
164 }
165 
gldi_style_colors_freeze(void)166 void gldi_style_colors_freeze (void)
167 {
168 	s_bIgnoreStyleChange = ! s_bIgnoreStyleChange;
169 }
170 
gldi_style_colors_get_stamp(void)171 int gldi_style_colors_get_stamp (void)
172 {
173 	return s_iStyleStamp;
174 }
175 
_get_bg_color(GldiColor * pColor)176 static void _get_bg_color (GldiColor *pColor)
177 {
178 	if (myStyleParam.bUseSystemColors)
179 	{
180 		if (s_menu_bg_pattern)
181 			_get_color_from_pattern (s_menu_bg_pattern, pColor);
182 		else
183 			memcpy (&pColor->rgba, &s_menu_bg_color, sizeof(GdkRGBA));
184 	}
185 	else
186 	{
187 		memcpy (pColor, &myStyleParam.fBgColor, sizeof(GldiColor));
188 	}
189 }
190 
gldi_style_color_get(GldiStyleColors iColorType,GldiColor * pColor)191 void gldi_style_color_get (GldiStyleColors iColorType, GldiColor *pColor)
192 {
193 	switch (iColorType)
194 	{
195 		case GLDI_COLOR_BG:
196 			_get_bg_color (pColor);
197 		break;
198 		case GLDI_COLOR_SELECTED:
199 			if (myStyleParam.bUseSystemColors)
200 			{
201 				if (s_menuitem_bg_pattern)
202 					_get_color_from_pattern (s_menuitem_bg_pattern, pColor);
203 				else
204 					pColor->rgba = s_menuitem_bg_color;
205 			}
206 			else
207 			{
208 				gldi_style_color_shade (&myStyleParam.fBgColor, GLDI_COLOR_SHADE_MEDIUM, pColor);
209 			}
210 		break;
211 		case GLDI_COLOR_LINE:
212 			if (myStyleParam.bUseSystemColors)
213 			{
214 				if (s_menu_bg_pattern)
215 					_get_color_from_pattern (s_menu_bg_pattern, pColor);
216 				else
217 				{
218 					pColor->rgba = s_menu_bg_color;  /// shade a little, maybe in negative ?...
219 				}
220 				pColor->rgba.alpha = 1.;
221 			}
222 			else
223 			{
224 				memcpy (pColor, &myStyleParam.fLineColor, sizeof(GldiColor));
225 			}
226 		break;
227 		case GLDI_COLOR_TEXT:
228 			if (myStyleParam.bUseSystemColors)
229 			{
230 				pColor->rgba = s_text_color;
231 			}
232 			else
233 			{
234 				memcpy (pColor, &myStyleParam.textDescription.fColorStart, sizeof(GldiColor));
235 				pColor->rgba.alpha = 1.;
236 			}
237 		break;
238 		case GLDI_COLOR_SEPARATOR:
239 			_get_bg_color (pColor);
240 			gldi_style_color_shade (pColor, GLDI_COLOR_SHADE_MEDIUM, pColor);
241 			pColor->rgba.alpha = 1.;
242 		break;
243 		case GLDI_COLOR_CHILD:
244 			_get_bg_color (pColor);
245 			gldi_style_color_shade (pColor, GLDI_COLOR_SHADE_STRONG, pColor);
246 		break;
247 		default:
248 		break;
249 	}
250 }
251 
gldi_style_colors_set_bg_color_full(cairo_t * pCairoContext,gboolean bUseAlpha)252 void gldi_style_colors_set_bg_color_full (cairo_t *pCairoContext, gboolean bUseAlpha)
253 {
254 	if (myStyleParam.bUseSystemColors)
255 	{
256 		if (pCairoContext)
257 		{
258 			if (s_menu_bg_pattern)
259 				cairo_set_source (pCairoContext, s_menu_bg_pattern);
260 			else
261 				cairo_set_source_rgba (pCairoContext, s_menu_bg_color.red, s_menu_bg_color.green, s_menu_bg_color.blue, bUseAlpha ? s_menu_bg_color.alpha : 1.);
262 		}
263 		else
264 		{
265 			if (s_menu_bg_texture != 0)
266 			{
267 				_cairo_dock_enable_texture ();
268 				glColor4f (1., 1., 1., 1.);
269 				glBindTexture (GL_TEXTURE_2D, s_menu_bg_texture);
270 			}
271 			else
272 				glColor4f (s_menu_bg_color.red, s_menu_bg_color.green, s_menu_bg_color.blue, bUseAlpha ? s_menu_bg_color.alpha : 1.);
273 		}
274 	}
275 	else
276 	{
277 		if (pCairoContext)
278 		{
279 			cairo_set_source_rgba (pCairoContext, myStyleParam.fBgColor.rgba.red, myStyleParam.fBgColor.rgba.green, myStyleParam.fBgColor.rgba.blue, bUseAlpha ? myStyleParam.fBgColor.rgba.alpha : 1.);
280 		}
281 		else
282 			glColor4f (myStyleParam.fBgColor.rgba.red, myStyleParam.fBgColor.rgba.green, myStyleParam.fBgColor.rgba.blue, bUseAlpha ? myStyleParam.fBgColor.rgba.alpha : 1.);
283 	}
284 }
285 
gldi_style_colors_set_selected_bg_color(cairo_t * pCairoContext)286 void gldi_style_colors_set_selected_bg_color (cairo_t *pCairoContext)
287 {
288 	if (myStyleParam.bUseSystemColors)
289 	{
290 		if (pCairoContext)
291 		{
292 			if (s_menuitem_bg_pattern)
293 				cairo_set_source (pCairoContext, s_menuitem_bg_pattern);
294 			else
295 				cairo_set_source_rgba (pCairoContext, s_menuitem_bg_color.red, s_menuitem_bg_color.green, s_menuitem_bg_color.blue, 1.);
296 		}
297 		else
298 		{
299 			glColor4f (s_menuitem_bg_color.red, s_menuitem_bg_color.green, s_menuitem_bg_color.blue, s_menuitem_bg_color.alpha);
300 		}
301 	}
302 	else
303 	{
304 		GldiColor color;
305 		gldi_style_color_shade (&myStyleParam.fBgColor, GLDI_COLOR_SHADE_MEDIUM, &color);
306 		if (pCairoContext)
307 			gldi_color_set_cairo (pCairoContext, &color);
308 		else
309 			gldi_color_set_opengl (&color);
310 	}
311 }
312 
gldi_style_colors_set_line_color(cairo_t * pCairoContext)313 void gldi_style_colors_set_line_color (cairo_t *pCairoContext)
314 {
315 	if (myStyleParam.bUseSystemColors)
316 	{
317 		if (pCairoContext)
318 		{
319 			if (s_menu_bg_pattern)
320 				cairo_set_source (pCairoContext, s_menu_bg_pattern);
321 			else
322 				cairo_set_source_rgb (pCairoContext, s_menu_bg_color.red, s_menu_bg_color.green, s_menu_bg_color.blue);  /// shade a little ?...
323 		}
324 		else
325 		{
326 			glColor3f (s_menu_bg_color.red, s_menu_bg_color.green, s_menu_bg_color.blue);  /// shade a little ?...
327 		}
328 	}
329 	else
330 	{
331 		if (pCairoContext)
332 			gldi_color_set_cairo (pCairoContext, &myStyleParam.fLineColor);
333 		else
334 			gldi_color_set_opengl (&myStyleParam.fLineColor);
335 	}
336 }
337 
gldi_style_colors_set_text_color(cairo_t * pCairoContext)338 void gldi_style_colors_set_text_color (cairo_t *pCairoContext)
339 {
340 	if (myStyleParam.bUseSystemColors)
341 	{
342 		if (pCairoContext)
343 			cairo_set_source_rgb (pCairoContext, s_text_color.red, s_text_color.green, s_text_color.blue);
344 		else
345 			glColor3f (s_text_color.red, s_text_color.green, s_text_color.blue);
346 	}
347 	else
348 	{
349 		if (pCairoContext)
350 			gldi_color_set_cairo_rgb (pCairoContext, &myStyleParam.textDescription.fColorStart);
351 		else
352 			gldi_color_set_opengl_rgb (&myStyleParam.textDescription.fColorStart);
353 	}
354 }
355 
gldi_style_colors_set_separator_color(cairo_t * pCairoContext)356 void gldi_style_colors_set_separator_color (cairo_t *pCairoContext)
357 {
358 	GldiColor color;
359 	_get_bg_color (&color);
360 	gldi_style_color_shade (&color, GLDI_COLOR_SHADE_MEDIUM, &color);
361 	if (pCairoContext)
362 		gldi_color_set_cairo_rgb (pCairoContext, &color);  // alpha set to 1
363 	else
364 		gldi_color_set_opengl_rgb (&color);
365 }
366 
gldi_style_colors_set_child_color(cairo_t * pCairoContext)367 void gldi_style_colors_set_child_color (cairo_t *pCairoContext)
368 {
369 	GldiColor color;
370 	_get_bg_color (&color);
371 	gldi_style_color_shade (&color, GLDI_COLOR_SHADE_STRONG, &color);
372 	if (pCairoContext)
373 		gldi_color_set_cairo (pCairoContext, &color);
374 	else
375 		gldi_color_set_opengl (&color);
376 }
377 
gldi_style_colors_paint_bg_color_with_alpha(cairo_t * pCairoContext,int iWidth,double fAlpha)378 void gldi_style_colors_paint_bg_color_with_alpha (cairo_t *pCairoContext, int iWidth, double fAlpha)
379 {
380 	if (fAlpha < 0)  // alpha is not defined => take it from the global style
381 	{
382 		if (! (myStyleParam.bUseSystemColors && s_menu_bg_pattern))
383 		{
384 			fAlpha = (myStyleParam.bUseSystemColors ? s_menu_bg_color.alpha : myStyleParam.fBgColor.rgba.alpha);
385 		}
386 	}
387 	if (fAlpha >= 0)  // alpha is now defined => use it
388 	{
389 		cairo_pattern_t *pGradationPattern;
390 		pGradationPattern = cairo_pattern_create_linear (
391 			0, 0,
392 			iWidth, 0);
393 		cairo_pattern_set_extend (pGradationPattern, CAIRO_EXTEND_NONE);
394 		cairo_pattern_add_color_stop_rgba (pGradationPattern,
395 			0.,
396 			1., 1., 1., 1.);
397 		cairo_pattern_add_color_stop_rgba (pGradationPattern,
398 			1.,
399 			1., 1., 1., fAlpha);  // bg color with horizontal alpha gradation
400 		cairo_mask (pCairoContext, pGradationPattern);
401 
402 		cairo_pattern_destroy (pGradationPattern);
403 	}
404 	else
405 	{
406 		cairo_paint (pCairoContext);
407 	}
408 }
409 
410 
411   ////////////
412  /// INIT ///
413 ////////////
414 
init(void)415 static void init (void)
416 {
417 	if (s_pStyle != NULL)
418 		return;
419 
420 	// init a style context
421 	s_pStyle = gtk_style_context_new();
422 	gtk_style_context_set_screen (s_pStyle, gdk_screen_get_default());
423 	g_signal_connect (s_pStyle, "changed", G_CALLBACK(_on_style_changed), GINT_TO_POINTER (TRUE));  // TRUE => throw a notification
424 }
425 
426   //////////////////
427  /// GET CONFIG ///
428 //////////////////
429 
get_config(GKeyFile * pKeyFile,GldiStyleParam * pStyleParam)430 static gboolean get_config (GKeyFile *pKeyFile, GldiStyleParam *pStyleParam)
431 {
432 	gboolean bFlushConfFileNeeded = FALSE;
433 
434 	pStyleParam->bUseSystemColors = (cairo_dock_get_integer_key_value (pKeyFile, "Style", "colors", &bFlushConfFileNeeded, 1, NULL, NULL) == 0);
435 
436 	if (! g_key_file_has_key (pKeyFile, "Style", "line color", NULL))  // old params (< 3.4)
437 	{
438 		// get the old params from the Dialog module's config
439 		gchar *cRenderingConfFile = g_strdup_printf ("%s/plug-ins/dialog-rendering/dialog-rendering.conf", g_cCurrentThemePath);
440 		GKeyFile *keyfile = cairo_dock_open_key_file (cRenderingConfFile);
441 		g_free (cRenderingConfFile);
442 
443 		gchar *cRenderer = cairo_dock_get_string_key_value (pKeyFile, "Dialogs", "decorator", &bFlushConfFileNeeded, "comics", NULL, NULL);
444 		if (cRenderer)
445 		{
446 			cRenderer[0] = g_ascii_toupper (cRenderer[0]);
447 
448 			cairo_dock_get_color_key_value (keyfile, cRenderer, "line color", &bFlushConfFileNeeded, &pStyleParam->fLineColor, NULL, NULL, NULL);
449 			g_key_file_set_double_list (pKeyFile, "Style", "line color", (double*)&pStyleParam->fLineColor.rgba, 4);
450 
451 			pStyleParam->iLineWidth = g_key_file_get_integer (keyfile, cRenderer, "border", NULL);
452 			g_key_file_set_integer (pKeyFile, "Style", "linewidth", pStyleParam->iLineWidth);
453 
454 			pStyleParam->iCornerRadius = g_key_file_get_integer (keyfile, cRenderer, "corner", NULL);
455 			g_key_file_set_integer (pKeyFile, "Style", "corner", pStyleParam->iCornerRadius);
456 
457 			g_free (cRenderer);
458 		}
459 		g_key_file_free (keyfile);
460 
461 		bFlushConfFileNeeded = TRUE;
462 	}
463 	else
464 	{
465 		pStyleParam->iCornerRadius = g_key_file_get_integer (pKeyFile, "Style", "corner", NULL);
466 		pStyleParam->iLineWidth = g_key_file_get_integer (pKeyFile, "Style", "linewidth", NULL);
467 		cairo_dock_get_color_key_value (pKeyFile, "Style", "line color", &bFlushConfFileNeeded, &pStyleParam->fLineColor, NULL, NULL, NULL);
468 	}
469 
470 	GldiColor bg_color = {{1.0, 1.0, 1.0, 0.7}};
471 	cairo_dock_get_color_key_value (pKeyFile, "Style", "bg color", &bFlushConfFileNeeded, &pStyleParam->fBgColor, &bg_color, "Dialogs", "background color");
472 
473 	gboolean bCustomFont = cairo_dock_get_boolean_key_value (pKeyFile, "Style", "custom font", &bFlushConfFileNeeded, FALSE, "Dialogs", "custom");
474 	gchar *cFont = (bCustomFont ? cairo_dock_get_string_key_value (pKeyFile, "Style", "font", &bFlushConfFileNeeded, NULL, "Dialogs", "message police") : _get_default_system_font ());
475 	gldi_text_description_set_font (&pStyleParam->textDescription, cFont);
476 
477 	GldiColor text_color = {{0., 0., 0., 1.}};
478 	cairo_dock_get_color_key_value (pKeyFile, "Style", "text color", &bFlushConfFileNeeded, &pStyleParam->textDescription.fColorStart, &text_color, "Dialogs", "text color");
479 
480 	return bFlushConfFileNeeded;
481 }
482 
reset_config(GldiStyleParam * pStyleParam)483 static void reset_config (GldiStyleParam *pStyleParam)
484 {
485 	gldi_text_description_reset (&pStyleParam->textDescription);
486 }
487 
488   ////////////
489  /// LOAD ///
490 ////////////
491 
load(void)492 static void load (void)
493 {
494 	if (myStyleParam.bUseSystemColors)
495 		_on_style_changed (s_pStyle, NULL);  // NULL => don't notify
496 }
497 
498   //////////////
499  /// RELOAD ///
500 //////////////
501 
reload(GldiStyleParam * pPrevStyleParam,GldiStyleParam * pStyleParam)502 static void reload (GldiStyleParam *pPrevStyleParam, GldiStyleParam *pStyleParam)
503 {
504 	cd_message ("reload style mgr...");
505 	if (pPrevStyleParam->bUseSystemColors != pStyleParam->bUseSystemColors)
506 		_on_style_changed (s_pStyle, NULL);  // load or invalidate the previous style, NULL => don't notify (it's done just after)
507 	else
508 		s_iStyleStamp ++;  // just invalidate
509 	gldi_object_notify (&myStyleMgr, NOTIFICATION_STYLE_CHANGED);
510 }
511 
512   //////////////
513  /// UNLOAD ///
514 //////////////
515 
unload(void)516 static void unload (void)
517 {
518 	if (s_menu_bg_texture != 0)
519 	{
520 		_cairo_dock_delete_texture (s_menu_bg_texture);
521 		s_menu_bg_texture = 0;
522 	}
523 }
524 
525   ///////////////
526  /// MANAGER ///
527 ///////////////
528 
gldi_register_style_manager(void)529 void gldi_register_style_manager (void)
530 {
531 	// Manager
532 	memset (&myStyleMgr, 0, sizeof (GldiManager));
533 	gldi_object_init (GLDI_OBJECT(&myStyleMgr), &myManagerObjectMgr, NULL);
534 	myStyleMgr.cModuleName  = "Style";
535 	// interface
536 	myStyleMgr.init         = init;
537 	myStyleMgr.load         = load;
538 	myStyleMgr.unload       = unload;
539 	myStyleMgr.reload       = (GldiManagerReloadFunc)reload;
540 	myStyleMgr.get_config   = (GldiManagerGetConfigFunc)get_config;
541 	myStyleMgr.reset_config = (GldiManagerResetConfigFunc)reset_config;
542 	// Config
543 	myStyleMgr.pConfig = (GldiManagerConfigPtr)&myStyleParam;
544 	myStyleMgr.iSizeOfConfig = sizeof (GldiStyleParam);
545 	// data
546 	myStyleMgr.pData = (GldiManagerDataPtr)NULL;
547 	myStyleMgr.iSizeOfData = 0;
548 
549 	// signals
550 	gldi_object_install_notifications (&myStyleMgr, NB_NOTIFICATIONS_STYLE);
551 }
552