1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2010,2011,2012 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains implementation of the settings dialog
9 **************************************************************************
11 * LADI Session Handler is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * LADI Session Handler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 * or write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "gtk_builder.h"
29 #include "../proxies/conf_proxy.h"
30 #include "../daemon/conf.h"
32 void menu_request_settings(void)
36 GtkToggleButton
* autostart_studio_button
;
37 GtkToggleButton
* send_notifications_button
;
38 GtkEntry
* shell_entry
;
39 GtkEntry
* terminal_entry
;
40 GtkSpinButton
* js_delay_spin
;
41 GtkEntry
* jack_conf_tool_entry
;
45 const char * terminal
;
46 unsigned int js_delay
;
47 const char * jack_conf_tool
;
49 autostart_studio_button
= GTK_TOGGLE_BUTTON(get_gtk_builder_widget("settings_studio_autostart_checkbutton"));
50 send_notifications_button
= GTK_TOGGLE_BUTTON(get_gtk_builder_widget("settings_send_notifications_checkbutton"));
51 shell_entry
= GTK_ENTRY(get_gtk_builder_widget("settings_shell_entry"));
52 terminal_entry
= GTK_ENTRY(get_gtk_builder_widget("settings_terminal_entry"));
53 js_delay_spin
= GTK_SPIN_BUTTON(get_gtk_builder_widget("settings_js_delay_spin"));
54 jack_conf_tool_entry
= GTK_ENTRY(get_gtk_builder_widget("settings_jack_conf_tool_entry"));
56 dialog
= GTK_DIALOG(get_gtk_builder_widget("settings_dialog"));
58 if (!conf_get_bool(LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART
, &autostart
))
60 autostart
= LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART_DEFAULT
;
63 if (!conf_get_bool(LADISH_CONF_KEY_DAEMON_NOTIFY
, ¬ify
))
65 notify
= LADISH_CONF_KEY_DAEMON_NOTIFY_DEFAULT
;
68 if (!conf_get(LADISH_CONF_KEY_DAEMON_SHELL
, &shell
))
70 shell
= LADISH_CONF_KEY_DAEMON_SHELL_DEFAULT
;
73 if (!conf_get(LADISH_CONF_KEY_DAEMON_TERMINAL
, &terminal
))
75 terminal
= LADISH_CONF_KEY_DAEMON_TERMINAL_DEFAULT
;
78 if (!conf_get_uint(LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY
, &js_delay
))
80 js_delay
= LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY_DEFAULT
;
83 if (!conf_get(LADISH_CONF_KEY_JACK_CONF_TOOL
, &jack_conf_tool
))
85 jack_conf_tool
= LADISH_CONF_KEY_JACK_CONF_TOOL_DEFAULT
;
88 gtk_toggle_button_set_active(autostart_studio_button
, autostart
);
89 gtk_toggle_button_set_active(send_notifications_button
, notify
);
91 gtk_entry_set_text(shell_entry
, shell
);
92 gtk_entry_set_text(terminal_entry
, terminal
);
93 gtk_entry_set_text(jack_conf_tool_entry
, jack_conf_tool
);
95 gtk_spin_button_set_range(js_delay_spin
, 0, 1000);
96 gtk_spin_button_set_increments(js_delay_spin
, 1, 2);
97 gtk_spin_button_set_value(js_delay_spin
, js_delay
);
99 gtk_widget_show(GTK_WIDGET(dialog
));
100 result
= gtk_dialog_run(GTK_DIALOG(dialog
));
101 gtk_widget_hide(GTK_WIDGET(dialog
));
102 if (result
!= GTK_RESPONSE_OK
)
107 autostart
= gtk_toggle_button_get_active(autostart_studio_button
);
108 notify
= gtk_toggle_button_get_active(send_notifications_button
);
109 shell
= gtk_entry_get_text(shell_entry
);
110 terminal
= gtk_entry_get_text(terminal_entry
);
111 js_delay
= gtk_spin_button_get_value(js_delay_spin
);
112 jack_conf_tool
= gtk_entry_get_text(jack_conf_tool_entry
);
114 if (!conf_set_bool(LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART
, autostart
) ||
115 !conf_set_bool(LADISH_CONF_KEY_DAEMON_NOTIFY
, notify
) ||
116 !conf_set(LADISH_CONF_KEY_DAEMON_SHELL
, shell
) ||
117 !conf_set(LADISH_CONF_KEY_DAEMON_TERMINAL
, terminal
) ||
118 !conf_set_uint(LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY
, js_delay
) ||
119 !conf_set(LADISH_CONF_KEY_JACK_CONF_TOOL
, jack_conf_tool
))
121 error_message_box(_("Storing settings"));