Avoid call to g_thread_init() with GLib >= 2.32.
[lxde/lxappearance.git] / src / lxappearance.c
1 /*
2 * lxappearance.c
3 *
4 * Copyright 2010 PCMan <pcman.tw@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301, USA.
20 */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include "lxappearance.h"
27
28 #include <gtk/gtk.h>
29 #include <glib/gi18n.h>
30
31 #include <X11/X.h>
32 #include <X11/Xatom.h>
33 #include <X11/Xlib.h>
34 #include <gdk/gdkx.h>
35 #include <string.h>
36
37 #if ENABLE_DBUS
38 #include <dbus/dbus.h>
39 #endif
40
41 #include "widget-theme.h"
42 #include "color-scheme.h"
43 #include "icon-theme.h"
44 #include "cursor-theme.h"
45 #include "font.h"
46 #include "other.h"
47 #include "plugin.h"
48
49 LXAppearance app = {0};
50
51 Atom lxsession_atom = 0;
52 static const char* lxsession_name = NULL;
53
54 /* Dbus functions Copy from lxsession-logout
55 TODO Create a library fro this ?
56 */
57
58 static gboolean check_lxde_dbus()
59 {
60 #if ENABLE_DBUS
61 DBusError error;
62 dbus_error_init(&error);
63 DBusConnection * connection = dbus_bus_get(DBUS_BUS_SESSION, &error);
64 if (connection == NULL)
65 {
66 g_warning(G_STRLOC ": Failed to connect to the session message bus: %s", error.message);
67 dbus_error_free(&error);
68 return FALSE;
69 }
70
71 dbus_bool_t ret = dbus_bus_name_has_owner(connection,"org.lxde.SessionManager",NULL);
72
73 if (ret == TRUE)
74 {
75 return TRUE;
76 }
77 else
78 {
79 return FALSE;
80 }
81 #else
82 return FALSE;
83 #endif
84 }
85
86 static void check_lxsession()
87 {
88 lxsession_atom = XInternAtom( GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "_LXSESSION", True );
89 if( lxsession_atom != None )
90 {
91 XGrabServer( GDK_DISPLAY_XDISPLAY(gdk_display_get_default()) );
92 if( XGetSelectionOwner( GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), lxsession_atom ) )
93 {
94 app.use_lxsession = TRUE;
95 lxsession_name = g_getenv("DESKTOP_SESSION");
96 }
97 XUngrabServer( GDK_DISPLAY_XDISPLAY(gdk_display_get_default()) );
98 }
99
100 /* Check Lxsession also with dbus */
101 if (check_lxde_dbus())
102 {
103 app.use_lxsession = TRUE;
104 lxsession_name = g_getenv("DESKTOP_SESSION");
105 }
106
107 }
108
109 static GOptionEntry option_entries[] =
110 {
111 { NULL }
112 };
113
114 static void save_cursor_theme_name()
115 {
116 char* dir_path;
117 if(!app.cursor_theme || !g_strcmp0(app.cursor_theme, "default"))
118 return;
119
120 dir_path = g_build_filename(g_get_home_dir(), ".icons/default", NULL);
121 if(0 == g_mkdir_with_parents(dir_path, 0700))
122 {
123 char* index_theme = g_build_filename(dir_path, "index.theme", NULL);
124 char* content = g_strdup_printf(
125 "# This file is written by LXAppearance. Do not edit.\n"
126 "[Icon Theme]\n"
127 "Name=Default\n"
128 "Comment=Default Cursor Theme\n"
129 "Inherits=%s\n", app.cursor_theme ? app.cursor_theme : "");
130 g_file_set_contents(index_theme, content, -1, NULL);
131 g_free(content);
132 g_free(index_theme);
133 }
134 g_free(dir_path);
135
136 /*
137 dir_path = g_build_filename(g_get_home_dir(), ".Xdefaults", NULL);
138 Xcursor.theme: name
139 Xcursor.size: [size]
140 g_file_set_contents(dir_path, "", -1, NULL);
141 g_free(dir_path);
142 */
143 }
144
145 static void reload_all_programs()
146 {
147 #if GTK_CHECK_VERSION(3, 0, 0)
148
149 /* TODO Port this to something else than gdk_event_send_clientmessage_toall */
150
151 #else
152 GdkEventClient event;
153 event.type = GDK_CLIENT_EVENT;
154 event.send_event = TRUE;
155 event.window = NULL;
156
157 if( app.use_lxsession )
158 {
159 event.message_type = gdk_atom_intern_static_string("_LXSESSION");
160 event.data.b[0] = 0; /* LXS_RELOAD */
161 }
162 else
163 {
164 /* if( icon_only )
165 event.message_type = gdk_atom_intern("_GTK_LOAD_ICONTHEMES", FALSE);
166 */
167 event.message_type = gdk_atom_intern("_GTK_READ_RCFILES", FALSE);
168 }
169 event.data_format = 8;
170 gdk_event_send_clientmessage_toall((GdkEvent *)&event);
171 #endif
172 }
173
174 static void lxappearance_save_gtkrc()
175 {
176 static const char* tb_styles[]={
177 "GTK_TOOLBAR_ICONS",
178 "GTK_TOOLBAR_TEXT",
179 "GTK_TOOLBAR_BOTH",
180 "GTK_TOOLBAR_BOTH_HORIZ"
181 };
182 static const char* tb_icon_sizes[]={
183 "GTK_ICON_SIZE_INVALID",
184 "GTK_ICON_SIZE_MENU",
185 "GTK_ICON_SIZE_SMALL_TOOLBAR",
186 "GTK_ICON_SIZE_LARGE_TOOLBAR",
187 "GTK_ICON_SIZE_BUTTON",
188 "GTK_ICON_SIZE_DND",
189 "GTK_ICON_SIZE_DIALOG"
190 };
191
192 char* file_path = g_build_filename(g_get_home_dir(), ".gtkrc-2.0", NULL);
193 GString* content = g_string_sized_new(512);
194 g_string_append(content,
195 "# DO NOT EDIT! This file will be overwritten by LXAppearance.\n"
196 "# Any customization should be done in ~/.gtkrc-2.0.mine instead.\n\n");
197 if(app.widget_theme)
198 g_string_append_printf(content,
199 "gtk-theme-name=\"%s\"\n", app.widget_theme);
200 if(app.icon_theme)
201 g_string_append_printf(content,
202 "gtk-icon-theme-name=\"%s\"\n", app.icon_theme);
203 if(app.default_font)
204 g_string_append_printf(content,
205 "gtk-font-name=\"%s\"\n", app.default_font);
206 if(app.cursor_theme)
207 g_string_append_printf(content,
208 "gtk-cursor-theme-name=\"%s\"\n", app.cursor_theme);
209 save_cursor_theme_name();
210
211 g_string_append_printf(content,
212 "gtk-cursor-theme-size=%d\n"
213 "gtk-toolbar-style=%s\n"
214 "gtk-toolbar-icon-size=%s\n"
215 "gtk-button-images=%d\n"
216 "gtk-menu-images=%d\n"
217 #if GTK_CHECK_VERSION(2, 14, 0)
218 "gtk-enable-event-sounds=%d\n"
219 "gtk-enable-input-feedback-sounds=%d\n"
220 #endif
221 "gtk-xft-antialias=%d\n"
222 "gtk-xft-hinting=%d\n"
223
224 , app.cursor_theme_size,
225 tb_styles[app.toolbar_style],
226 tb_icon_sizes[app.toolbar_icon_size],
227 app.button_images ? 1 : 0,
228 app.menu_images ? 1 : 0,
229 #if GTK_CHECK_VERSION(2, 14, 0)
230 app.enable_event_sound ? 1 : 0,
231 app.enable_input_feedback ? 1 : 0,
232 #endif
233 app.enable_antialising ? 1 : 0,
234 app.enable_hinting ? 1 : 0
235 );
236
237 if(app.hinting_style)
238 g_string_append_printf(content,
239 "gtk-xft-hintstyle=\"%s\"\n", app.hinting_style);
240
241 if(app.font_rgba)
242 g_string_append_printf(content,
243 "gtk-xft-rgba=\"%s\"\n", app.font_rgba);
244
245 #if 0
246 /* unfortunately we cannot set colors without XSETTINGS daemon,
247 themes will override any custom settings in .gtkrc-2.0 file */
248 /* FIXME: we should support other xsettings daemons too */
249 if(app.color_scheme)
250 {
251 char* escaped = g_strescape(app.color_scheme, NULL);
252 g_string_append_printf(content,
253 "gtk-color-scheme=\"%s\"\n",
254 escaped);
255 g_free(escaped);
256 }
257 #endif
258
259 g_string_append_printf(content,
260 "include \"%s/.gtkrc-2.0.mine\"\n",
261 g_get_home_dir());
262
263 g_file_set_contents(file_path, content->str, content->len, NULL);
264
265 /* Save also in GTK3 folder
266 Content shold be different from the gtk2 one
267 */
268 GKeyFile *content_gtk3 = g_key_file_new();
269 char* file_path_gtk3 = g_build_filename(g_get_user_config_dir(), "gtk-3.0", NULL);
270 char* file_path_settings = g_build_filename(file_path_gtk3, "settings.ini", NULL);
271
272 if (!g_file_test(file_path_gtk3, G_FILE_TEST_IS_DIR))
273 {
274 g_mkdir_with_parents(file_path_gtk3, 0755);
275 }
276
277 g_key_file_load_from_file(content_gtk3, file_path_settings, /* ignoring errors */
278 G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
279
280 if(app.widget_theme)
281 g_key_file_set_string(content_gtk3, "Settings",
282 "gtk-theme-name", app.widget_theme);
283 if(app.icon_theme)
284 g_key_file_set_string(content_gtk3, "Settings",
285 "gtk-icon-theme-name", app.icon_theme);
286 if(app.default_font)
287 g_key_file_set_string(content_gtk3, "Settings",
288 "gtk-font-name", app.default_font);
289 if(app.cursor_theme)
290 g_key_file_set_string(content_gtk3, "Settings",
291 "gtk-cursor-theme-name", app.cursor_theme);
292 save_cursor_theme_name();
293
294 g_key_file_set_integer(content_gtk3, "Settings",
295 "gtk-cursor-theme-size", app.cursor_theme_size);
296 g_key_file_set_string(content_gtk3, "Settings",
297 "gtk-toolbar-style", tb_styles[app.toolbar_style]);
298 g_key_file_set_string(content_gtk3, "Settings",
299 "gtk-toolbar-icon-size", tb_icon_sizes[app.toolbar_icon_size]);
300 g_key_file_set_boolean(content_gtk3, "Settings",
301 "gtk-button-images", app.button_images);
302 g_key_file_set_boolean(content_gtk3, "Settings",
303 "gtk-menu-images", app.menu_images);
304 #if GTK_CHECK_VERSION(2, 14, 0)
305 g_key_file_set_boolean(content_gtk3, "Settings",
306 "gtk-enable-event-sounds", app.enable_event_sound);
307 g_key_file_set_boolean(content_gtk3, "Settings",
308 "gtk-enable-input-feedback-sounds", app.enable_input_feedback);
309 #endif
310 g_key_file_set_boolean(content_gtk3, "Settings",
311 "gtk-xft-antialias", app.enable_antialising);
312 g_key_file_set_boolean(content_gtk3, "Settings",
313 "gtk-xft-hinting", app.enable_hinting);
314
315 if(app.hinting_style)
316 g_key_file_set_string(content_gtk3, "Settings",
317 "gtk-xft-hintstyle", app.hinting_style);
318
319 if(app.font_rgba)
320 g_key_file_set_string(content_gtk3, "Settings",
321 "gtk-xft-rgba", app.font_rgba);
322
323 #if 0
324 /* unfortunately we cannot set colors without XSETTINGS daemon,
325 themes will override any custom settings in .gtkrc-2.0 file */
326 /* FIXME: we should support other xsettings daemons too */
327 if(app.color_scheme)
328 {
329 char* escaped = g_strescape(app.color_scheme, NULL);
330 g_string_append_printf(content_gtk3,
331 "gtk-color-scheme=%s\n",
332 escaped);
333 g_free(escaped);
334 }
335 #endif
336
337 #if GLIB_CHECK_VERSION(2, 40, 0)
338 g_key_file_save_to_file(content_gtk3, file_path_settings, NULL);
339 #else
340 char *contents;
341 gsize s;
342
343 contents = g_key_file_to_data(content_gtk3, &s, NULL);
344 if (contents)
345 g_file_set_contents(file_path_settings, contents, s, NULL);
346 g_free(contents);
347 #endif
348
349 g_free(file_path_gtk3);
350 g_free(file_path_settings);
351 g_string_free(content, TRUE);
352 g_key_file_free(content_gtk3);
353 g_free(file_path);
354 }
355
356 static void lxappearance_save_lxsession()
357 {
358 char* rel_path = g_strconcat("lxsession/", lxsession_name, "/desktop.conf", NULL);
359 char* user_config_file = g_build_filename(g_get_user_config_dir(), rel_path, NULL);
360 char* buf;
361 gsize len;
362 GKeyFile* kf = g_key_file_new();
363
364 if(!g_key_file_load_from_file(kf, user_config_file, G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS, NULL))
365 {
366 /* the user config file doesn't exist, create its parent dir */
367 len = strlen(user_config_file) - strlen("/desktop.conf");
368 user_config_file[len] = '\0';
369 g_debug("user_config_file = %s", user_config_file);
370 g_mkdir_with_parents(user_config_file, 0700);
371 user_config_file[len] = '/';
372
373 g_key_file_load_from_dirs(kf, rel_path, (const char**)g_get_system_config_dirs(), NULL,
374 G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
375 }
376
377 g_free(rel_path);
378
379 g_key_file_set_string( kf, "GTK", "sNet/ThemeName", app.widget_theme );
380 g_key_file_set_string( kf, "GTK", "sGtk/FontName", app.default_font );
381
382 g_key_file_set_string( kf, "GTK", "sGtk/ColorScheme", app.color_scheme ? app.color_scheme : "" );
383
384 g_key_file_set_string( kf, "GTK", "sNet/IconThemeName", app.icon_theme );
385
386 g_key_file_set_string( kf, "GTK", "sGtk/CursorThemeName", app.cursor_theme );
387 g_key_file_set_integer( kf, "GTK", "iGtk/CursorThemeSize", app.cursor_theme_size );
388 save_cursor_theme_name();
389
390 g_key_file_set_integer( kf, "GTK", "iGtk/ToolbarStyle", app.toolbar_style );
391 g_key_file_set_integer( kf, "GTK", "iGtk/ToolbarIconSize", app.toolbar_icon_size );
392
393 g_key_file_set_integer( kf, "GTK", "iGtk/ToolbarStyle", app.toolbar_style );
394 g_key_file_set_integer( kf, "GTK", "iGtk/ToolbarIconSize", app.toolbar_icon_size );
395
396 g_key_file_set_integer( kf, "GTK", "iGtk/ButtonImages", app.button_images );
397 g_key_file_set_integer( kf, "GTK", "iGtk/MenuImages", app.menu_images );
398
399 #if GTK_CHECK_VERSION(2, 14, 0)
400 /* "Net/SoundThemeName\0" "gtk-sound-theme-name\0" */
401 g_key_file_set_integer( kf, "GTK", "iNet/EnableEventSounds", app.enable_event_sound);
402 g_key_file_set_integer( kf, "GTK", "iNet/EnableInputFeedbackSounds", app.enable_input_feedback);
403 #endif
404 g_key_file_set_integer( kf, "GTK", "iXft/Antialias", app.enable_antialising);
405 g_key_file_set_integer( kf, "GTK", "iXft/Hinting", app.enable_hinting);
406 g_key_file_set_string( kf, "GTK", "sXft/HintStyle", app.hinting_style);
407 g_key_file_set_string( kf, "GTK", "sXft/RGBA", app.font_rgba);
408
409 buf = g_key_file_to_data( kf, &len, NULL );
410 g_key_file_free(kf);
411
412 g_file_set_contents(user_config_file, buf, len, NULL);
413 g_free(buf);
414 g_free(user_config_file);
415 }
416
417 static void on_dlg_response(GtkDialog* dlg, int res, gpointer user_data)
418 {
419 switch(res)
420 {
421 case GTK_RESPONSE_APPLY:
422
423 if(app.use_lxsession)
424 lxappearance_save_lxsession();
425 else
426 lxappearance_save_gtkrc();
427
428 reload_all_programs();
429
430 app.changed = FALSE;
431 gtk_dialog_set_response_sensitive(GTK_DIALOG(app.dlg), GTK_RESPONSE_APPLY, FALSE);
432 break;
433 case 1: /* about dialog */
434 {
435 GtkBuilder* b = gtk_builder_new();
436 if(gtk_builder_add_from_file(b, PACKAGE_UI_DIR "/about.ui", NULL))
437 {
438 GtkWidget* dlg = GTK_WIDGET(gtk_builder_get_object(b, "dlg"));
439 gtk_dialog_run(GTK_DIALOG(dlg));
440 gtk_widget_destroy(dlg);
441 }
442 g_object_unref(b);
443 }
444 break;
445 default:
446 gtk_main_quit();
447 }
448 }
449
450 static void settings_init()
451 {
452 GtkSettings* settings = gtk_settings_get_default();
453 g_object_get(settings,
454 "gtk-theme-name", &app.widget_theme,
455 "gtk-font-name", &app.default_font,
456 "gtk-icon-theme-name", &app.icon_theme,
457 "gtk-cursor-theme-name", &app.cursor_theme,
458 "gtk-cursor-theme-size", &app.cursor_theme_size,
459 "gtk-toolbar-style", &app.toolbar_style,
460 "gtk-toolbar-icon-size", &app.toolbar_icon_size,
461 "gtk-button-images", &app.button_images,
462 "gtk-menu-images", &app.menu_images,
463 #if GTK_CHECK_VERSION(2, 14, 0)
464 "gtk-enable-event-sounds", &app.enable_event_sound,
465 "gtk-enable-input-feedback-sounds", &app.enable_input_feedback,
466 #endif
467 "gtk-xft-antialias", &app.enable_antialising,
468 "gtk-xft-hinting", &app.enable_hinting,
469 "gtk-xft-hintstyle", &app.hinting_style,
470 "gtk-xft-rgba", &app.font_rgba,
471 NULL);
472 /* try to figure out cursor theme used. */
473 if(!app.cursor_theme || g_strcmp0(app.cursor_theme, "default") == 0)
474 {
475 /* get the real theme name from default. */
476 GKeyFile* kf = g_key_file_new();
477 char* fpath = g_build_filename(g_get_home_dir(), ".icons/default/index.theme", NULL);
478 gboolean ret = g_key_file_load_from_file(kf, fpath, 0, NULL);
479 g_free(fpath);
480
481 if(!ret)
482 ret = g_key_file_load_from_data_dirs(kf, "icons/default/index.theme", NULL, 0, NULL);
483
484 if(ret)
485 {
486 g_free(app.cursor_theme);
487 app.cursor_theme = g_key_file_get_string(kf, "Icon Theme", "Inherits", NULL);
488 g_debug("cursor theme name: %s", app.cursor_theme);
489 }
490 g_key_file_free(kf);
491 }
492
493 app.color_scheme_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
494 /* try to load custom color scheme if available */
495 if(app.use_lxsession)
496 {
497 char* rel_path = g_strconcat("lxsession/", lxsession_name, "/desktop.conf", NULL);
498 char* user_config_file = g_build_filename(g_get_user_config_dir(), rel_path, NULL);
499 GKeyFile* kf = g_key_file_new();
500 if(g_key_file_load_from_file(kf, user_config_file, 0, NULL))
501 app.color_scheme = g_key_file_get_string(kf, "GTK", "sGtk/ColorScheme", NULL);
502 else if(g_key_file_load_from_dirs(kf, rel_path, (const char**)g_get_system_config_dirs(), NULL, 0, NULL))
503 app.color_scheme = g_key_file_get_string(kf, "GTK", "sGtk/ColorScheme", NULL);
504 g_key_file_free(kf);
505 g_free(rel_path);
506 g_free(user_config_file);
507
508 if(app.color_scheme)
509 {
510 if(*app.color_scheme)
511 color_scheme_str_to_hash(app.color_scheme_hash, app.color_scheme);
512 else
513 {
514 g_free(app.color_scheme);
515 app.color_scheme = NULL;
516 }
517 }
518 }
519 #if 0
520 /* unfortunately we cannot set colors without XSETTINGS daemon,
521 themes will override any custom settings in .gtkrc-2.0 file */
522 /* FIXME: we should support other xsettings daemons too */
523 else
524 {
525 char* gtkrc_file = g_build_filename(g_get_home_dir(), ".gtkrc-2.0", NULL);
526 gtkrc_file_get_color_scheme(gtkrc_file, app.color_scheme_hash);
527 g_free(gtkrc_file);
528 if(g_hash_table_size(app.color_scheme_hash) > 0)
529 app.color_scheme = color_scheme_hash_to_str(app.color_scheme_hash);
530 }
531 #endif
532 }
533
534 int main(int argc, char** argv)
535 {
536 GError* err = NULL;
537 GtkBuilder* b;
538
539 /* gettext support */
540 #ifdef ENABLE_NLS
541 bindtextdomain ( GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR );
542 bind_textdomain_codeset ( GETTEXT_PACKAGE, "UTF-8" );
543 textdomain ( GETTEXT_PACKAGE );
544 #endif
545
546 #if !GLIB_CHECK_VERSION(2, 32, 0)
547 g_thread_init(NULL);
548 #endif
549 /* initialize GTK+ and parse the command line arguments */
550 if( G_UNLIKELY( ! gtk_init_with_args( &argc, &argv, "", option_entries, GETTEXT_PACKAGE, &err ) ) )
551 {
552 g_print( "Error: %s\n", err->message );
553 return 1;
554 }
555
556 app.abi_version = LXAPPEARANCE_ABI_VERSION;
557
558 /* check if we're under LXSession */
559 check_lxsession();
560
561 /* create GUI here */
562 b = gtk_builder_new();
563 if(!gtk_builder_add_from_file(b, PACKAGE_UI_DIR "/lxappearance.ui", NULL))
564 return 1;
565
566 /* NOTE: GUI must be created prior to loading settings from GtkSettings object.
567 * Some properties of GtkSettings class are installed by some other gtk classes.
568 * For example, "gtk-menu-images" property is actually installed by initialization
569 * of GtkImageMenuItem class. If we load the GUI first, then when the menu items
570 * are created, this property gets correctly registered. So later it can be read. */
571
572 /* load config values */
573 settings_init();
574
575 app.dlg = GTK_WIDGET(gtk_builder_get_object(b, "dlg"));
576
577 widget_theme_init(b);
578 color_scheme_init(b);
579 icon_theme_init(b);
580 cursor_theme_init(b);
581 font_init(b);
582 other_init(b);
583 /* the page for window manager plugins */
584 app.wm_page = GTK_WIDGET(gtk_builder_get_object(b, "wm_page"));
585
586 plugins_init(b);
587
588 g_signal_connect(app.dlg, "response", G_CALLBACK(on_dlg_response), NULL);
589
590 gtk_window_present(GTK_WINDOW(app.dlg));
591 g_object_unref(b);
592
593 gtk_main();
594
595 plugins_finalize();
596
597 return 0;
598 }
599
600 void lxappearance_changed()
601 {
602 if(!app.changed)
603 {
604 app.changed = TRUE;
605 gtk_dialog_set_response_sensitive(GTK_DIALOG(app.dlg), GTK_RESPONSE_APPLY, TRUE);
606 }
607 }
608
609 void on_check_button_toggled(GtkToggleButton* btn, gpointer user_data)
610 {
611 gboolean* val = (gboolean*)user_data;
612 gboolean new_val = gtk_toggle_button_get_active(btn);
613 if(new_val != *val)
614 {
615 *val = new_val;
616 lxappearance_changed();
617 }
618 }