[SF#822] Use gtk_rc_get_default_files() for gtkrc file, so GTK2_RC_FILES is checked.
[lxde/lxappearance.git] / src / other.c
CommitLineData
e597424e
HJYP
1// other.c
2//
3// Copyright 2010 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18// MA 02110-1301, USA.
19
20
3a7d812e 21#include "lxappearance.h"
e597424e
HJYP
22#include "other.h"
23#include <glib/gi18n.h>
24
25static void on_tb_style_changed(GtkComboBox* combo, gpointer user_data)
26{
27 app.toolbar_style = gtk_combo_box_get_active(combo) + GTK_TOOLBAR_ICONS;
28 lxappearance_changed();
29}
30
31static void on_tb_icon_size_changed(GtkComboBox* combo, gpointer user_data)
32{
33 app.toolbar_icon_size = gtk_combo_box_get_active(combo) + GTK_ICON_SIZE_MENU;
34 lxappearance_changed();
35}
36
afcecf68
AG
37static void on_enable_accessibility_toggled(GtkToggleButton* btn, gpointer user_data)
38{
39 char **modules_list, **ml, **new_modules_list;
40 gsize i;
41
42 if (app.modules)
43 modules_list = g_strsplit(app.modules, ":", -1);
44 else
45 modules_list = g_strsplit("", ":", -1);
46 new_modules_list = g_new0(char *, g_strv_length(modules_list) + 3);
47 for (i = 0, ml = modules_list; *ml != NULL; ml++)
48 {
49 if (strcmp(*ml, "gail") != 0 && strcmp(*ml, "atk-bridge") != 0)
50 new_modules_list[i++] = *ml;
51 else
52 g_free(*ml);
53 }
54 if (gtk_toggle_button_get_active(btn))
55 {
56 new_modules_list[i++] = g_strdup("gail");
57 new_modules_list[i++] = g_strdup("atk-bridge");
58 }
59 g_free(app.modules);
60 app.modules = g_strjoinv(":", new_modules_list);
61 g_free(modules_list);
62 g_strfreev(new_modules_list);
63 lxappearance_changed();
64}
65
e597424e
HJYP
66void other_init(GtkBuilder* b)
67{
68 int idx;
69 app.tb_style_combo = GTK_WIDGET(gtk_builder_get_object(b, "tb_style"));
70 idx = app.toolbar_style - GTK_TOOLBAR_ICONS;
71 gtk_combo_box_set_active(GTK_COMBO_BOX(app.tb_style_combo), idx);
72 g_signal_connect(app.tb_style_combo, "changed", G_CALLBACK(on_tb_style_changed), NULL);
73
74 app.tb_icon_size_combo = GTK_WIDGET(gtk_builder_get_object(b, "tb_icon_size"));
75 idx = app.toolbar_icon_size - GTK_ICON_SIZE_MENU;
76 gtk_combo_box_set_active(GTK_COMBO_BOX(app.tb_icon_size_combo), idx);
77 g_signal_connect(app.tb_icon_size_combo, "changed", G_CALLBACK(on_tb_icon_size_changed), NULL);
9bb12c12 78
6b54b65a
HJYP
79 app.button_images_check = GTK_WIDGET(gtk_builder_get_object(b, "button_images"));
80 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(app.button_images_check), app.button_images);
81 g_signal_connect(app.button_images_check, "toggled", G_CALLBACK(on_check_button_toggled), &app.button_images);
82
83 app.menu_images_check = GTK_WIDGET(gtk_builder_get_object(b, "menu_images"));
84 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(app.menu_images_check), app.menu_images);
85 g_signal_connect(app.menu_images_check, "toggled", G_CALLBACK(on_check_button_toggled), &app.menu_images);
86
9bb12c12
HJYP
87#if GTK_CHECK_VERSION(2, 14, 0)
88 app.event_sound_check = GTK_WIDGET(gtk_builder_get_object(b, "event_sound"));
89 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(app.event_sound_check), app.enable_event_sound);
90 g_signal_connect(app.event_sound_check, "toggled", G_CALLBACK(on_check_button_toggled), &app.enable_event_sound);
91
92 app.input_feedback_check = GTK_WIDGET(gtk_builder_get_object(b, "input_feedback_sound"));
93 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(app.input_feedback_check), app.enable_input_feedback);
94 g_signal_connect(app.input_feedback_check, "toggled", G_CALLBACK(on_check_button_toggled), &app.enable_input_feedback);
95
96 /* event sound support */
97 gtk_widget_show_all(GTK_WIDGET(gtk_builder_get_object(b, "sound_effect")));
98#endif
2d9128f0 99
afcecf68
AG
100 gtk_widget_show(GTK_WIDGET(gtk_builder_get_object(b, "accessibility_options")));
101 app.enable_accessibility_button = GTK_WIDGET(gtk_builder_get_object(b, "enable_accessibility"));
102 if (app.modules)
103 {
104 char **modules_list = g_strsplit(app.modules, ":", -1), **ml;
105
106 for (ml = modules_list; *ml != NULL; ml++)
107 if (strcmp(*ml, "gail") == 0)
108 break;
109 if (*ml != NULL)
110 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(app.enable_accessibility_button),
111 TRUE);
112 g_strfreev(modules_list);
113 }
114 g_signal_connect(app.enable_accessibility_button, "toggled",
115 G_CALLBACK(on_enable_accessibility_toggled), &app.modules);
e597424e
HJYP
116}
117