1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2010 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
;
43 const char * terminal
;
45 autostart_studio_button
= GTK_TOGGLE_BUTTON(get_gtk_builder_widget("settings_studio_autostart_checkbutton"));
46 send_notifications_button
= GTK_TOGGLE_BUTTON(get_gtk_builder_widget("settings_send_notifications_checkbutton"));
47 shell_entry
= GTK_ENTRY(get_gtk_builder_widget("settings_shell_entry"));
48 terminal_entry
= GTK_ENTRY(get_gtk_builder_widget("settings_terminal_entry"));
50 dialog
= GTK_DIALOG(get_gtk_builder_widget("settings_dialog"));
52 if (!conf_get_bool(LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART
, &autostart
))
54 autostart
= LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART_DEFAULT
;
57 if (!conf_get_bool(LADISH_CONF_KEY_DAEMON_NOTIFY
, ¬ify
))
59 notify
= LADISH_CONF_KEY_DAEMON_NOTIFY_DEFAULT
;
62 if (!conf_get(LADISH_CONF_KEY_DAEMON_SHELL
, &shell
))
64 shell
= LADISH_CONF_KEY_DAEMON_SHELL_DEFAULT
;
67 if (!conf_get(LADISH_CONF_KEY_DAEMON_TERMINAL
, &terminal
))
69 terminal
= LADISH_CONF_KEY_DAEMON_TERMINAL_DEFAULT
;
72 gtk_toggle_button_set_active(autostart_studio_button
, autostart
);
73 gtk_toggle_button_set_active(send_notifications_button
, notify
);
75 gtk_entry_set_text(shell_entry
, shell
);
76 gtk_entry_set_text(terminal_entry
, terminal
);
78 gtk_widget_show(GTK_WIDGET(dialog
));
79 result
= gtk_dialog_run(GTK_DIALOG(dialog
));
80 gtk_widget_hide(GTK_WIDGET(dialog
));
81 if (result
!= GTK_RESPONSE_OK
)
86 autostart
= gtk_toggle_button_get_active(autostart_studio_button
);
87 notify
= gtk_toggle_button_get_active(send_notifications_button
);
88 shell
= gtk_entry_get_text(shell_entry
);
89 terminal
= gtk_entry_get_text(terminal_entry
);
91 if (!conf_set_bool(LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART
, autostart
) ||
92 !conf_set_bool(LADISH_CONF_KEY_DAEMON_NOTIFY
, notify
) ||
93 !conf_set(LADISH_CONF_KEY_DAEMON_SHELL
, shell
) ||
94 !conf_set(LADISH_CONF_KEY_DAEMON_TERMINAL
, terminal
))
96 error_message_box("Storing settings");