Adding upstream version 0.5.0.
[debian/lxappearance.git] / src / other.c
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
21 #include "lxappearance.h"
22 #include "other.h"
23 #include <glib/gi18n.h>
24
25 static 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
31 static 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
37 static void on_check_button_toggled(GtkToggleButton* btn, gpointer user_data)
38 {
39 gboolean* val = (gboolean*)user_data;
40 gboolean new_val = gtk_toggle_button_get_active(btn);
41 if(new_val != *val)
42 {
43 *val = new_val;
44 lxappearance_changed();
45 }
46 }
47
48 void other_init(GtkBuilder* b)
49 {
50 int idx;
51 app.tb_style_combo = GTK_WIDGET(gtk_builder_get_object(b, "tb_style"));
52 idx = app.toolbar_style - GTK_TOOLBAR_ICONS;
53 gtk_combo_box_set_active(GTK_COMBO_BOX(app.tb_style_combo), idx);
54 g_signal_connect(app.tb_style_combo, "changed", G_CALLBACK(on_tb_style_changed), NULL);
55
56 app.tb_icon_size_combo = GTK_WIDGET(gtk_builder_get_object(b, "tb_icon_size"));
57 idx = app.toolbar_icon_size - GTK_ICON_SIZE_MENU;
58 gtk_combo_box_set_active(GTK_COMBO_BOX(app.tb_icon_size_combo), idx);
59 g_signal_connect(app.tb_icon_size_combo, "changed", G_CALLBACK(on_tb_icon_size_changed), NULL);
60
61 app.button_images_check = GTK_WIDGET(gtk_builder_get_object(b, "button_images"));
62 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(app.button_images_check), app.button_images);
63 g_signal_connect(app.button_images_check, "toggled", G_CALLBACK(on_check_button_toggled), &app.button_images);
64
65 app.menu_images_check = GTK_WIDGET(gtk_builder_get_object(b, "menu_images"));
66 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(app.menu_images_check), app.menu_images);
67 g_signal_connect(app.menu_images_check, "toggled", G_CALLBACK(on_check_button_toggled), &app.menu_images);
68
69 #if GTK_CHECK_VERSION(2, 14, 0)
70 app.event_sound_check = GTK_WIDGET(gtk_builder_get_object(b, "event_sound"));
71 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(app.event_sound_check), app.enable_event_sound);
72 g_signal_connect(app.event_sound_check, "toggled", G_CALLBACK(on_check_button_toggled), &app.enable_event_sound);
73
74 app.input_feedback_check = GTK_WIDGET(gtk_builder_get_object(b, "input_feedback_sound"));
75 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(app.input_feedback_check), app.enable_input_feedback);
76 g_signal_connect(app.input_feedback_check, "toggled", G_CALLBACK(on_check_button_toggled), &app.enable_input_feedback);
77
78 /* event sound support */
79 gtk_widget_show_all(GTK_WIDGET(gtk_builder_get_object(b, "sound_effect")));
80 #endif
81 }
82