diff --git a/daemon/conf.h b/daemon/conf.h index d6842e50..3d59fd02 100644 --- a/daemon/conf.h +++ b/daemon/conf.h @@ -32,4 +32,9 @@ #define LADISH_CONF_KEY_DAEMON_TERMINAL "/org/ladish/daemon/terminal" #define LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART "/org/ladish/daemon/studio_autostart" +#define LADISH_CONF_KEY_DAEMON_NOTIFY_DEFAULT true +#define LADISH_CONF_KEY_DAEMON_SHELL_DEFAULT "sh" +#define LADISH_CONF_KEY_DAEMON_TERMINAL_DEFAULT "xterm" +#define LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART_DEFAULT true + #endif /* #ifndef CONF_H__795797BE_4EB8_44F8_BD9C_B8A9CB975228__INCLUDED */ diff --git a/daemon/control.c b/daemon/control.c index 5cdb433b..4419a016 100644 --- a/daemon/control.c +++ b/daemon/control.c @@ -642,7 +642,7 @@ static void ladish_load_studio(struct dbus_method_call * call_ptr) if (!conf_get_bool(LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART, &autostart)) { - autostart = true; + autostart = LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART_DEFAULT; } if (autostart) diff --git a/daemon/loader.c b/daemon/loader.c index 0a0f288b..4d880982 100644 --- a/daemon/loader.c +++ b/daemon/loader.c @@ -280,7 +280,7 @@ static void loader_exec_program(const char * commandline, const char * working_d { if (!conf_get(LADISH_CONF_KEY_DAEMON_TERMINAL, argv)) { - argv[0] = "xterm"; + argv[0] = LADISH_CONF_KEY_DAEMON_TERMINAL_DEFAULT; } argv[1] = "-e"; @@ -289,7 +289,7 @@ static void loader_exec_program(const char * commandline, const char * working_d { if (!conf_get(LADISH_CONF_KEY_DAEMON_SHELL, argv)) { - argv[0] = "sh"; + argv[0] = LADISH_CONF_KEY_DAEMON_SHELL_DEFAULT; } argv[1] = "-c"; diff --git a/daemon/main.c b/daemon/main.c index 58b2e5fa..d8fab925 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -249,7 +249,18 @@ void uninit_paths(void) static void on_conf_notify_changed(void * context, const char * key, const char * value) { - if (value == NULL || conf_string2bool(value)) + bool notify_enable; + + if (value == NULL) + { + notify_enable = LADISH_CONF_KEY_DAEMON_NOTIFY_DEFAULT; + } + else + { + notify_enable = conf_string2bool(value); + } + + if (notify_enable) { if (!g_use_notify) { diff --git a/gui/gladish.ui b/gui/gladish.ui index b9871890..91a5011c 100644 --- a/gui/gladish.ui +++ b/gui/gladish.ui @@ -319,12 +319,21 @@ True - True clear_xruns_and_max_dsp_load_action + True True True + + + _Settings + True + True + image1 + False + + _Configure JACK @@ -467,8 +476,8 @@ True - True clear_xruns_and_max_dsp_load_action + True Clear XRuns @@ -1623,4 +1632,164 @@ along with LADI Session Handler; if not, write to the Free Software Foundation, project_save_as_ok_button + + 5 + normal + main_win + False + + + True + vertical + 2 + + + True + 2 + 20 + 5 + + + True + vertical + 5 + True + + + Start studio on load + True + True + False + True + + + 0 + + + + + Send notifications + True + True + False + True + + + 1 + + + + + + + True + 2 + 2 + 5 + 5 + + + True + 0 + Shell to use: + + + + + True + 0 + Terminal to use: + + + 1 + 2 + + + + + True + True + + + + 1 + 2 + + + + + True + True + + + + 1 + 2 + 1 + 2 + + + + + 1 + 2 + GTK_FILL + + + + + False + 1 + + + + + True + end + + + gtk-cancel + True + True + True + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + settings_cancel_button + settings_ok_button + + + + True + gtk-preferences + diff --git a/gui/main.c b/gui/main.c index 3bc51094..addf2d99 100644 --- a/gui/main.c +++ b/gui/main.c @@ -41,6 +41,7 @@ #include "action.h" #include "studio.h" #include "jack.h" +#include "../daemon/conf.h" GtkWidget * g_main_win; GtkWidget * g_toolbar; @@ -164,6 +165,26 @@ int main(int argc, char** argv) return 1; } + if (!conf_register(LADISH_CONF_KEY_DAEMON_NOTIFY, NULL, NULL)) + { + return 1; + } + + if (!conf_register(LADISH_CONF_KEY_DAEMON_SHELL, NULL, NULL)) + { + return 1; + } + + if (!conf_register(LADISH_CONF_KEY_DAEMON_TERMINAL, NULL, NULL)) + { + return 1; + } + + if (!conf_register(LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART, NULL, NULL)) + { + return 1; + } + if (!init_jack()) { return 1; diff --git a/gui/menu.c b/gui/menu.c index d58e9c3d..e1d57cac 100644 --- a/gui/menu.c +++ b/gui/menu.c @@ -44,6 +44,7 @@ static GtkWidget * g_menu_item_save_project; static GtkWidget * g_menu_item_save_as_project; static GtkWidget * g_menu_item_daemon_exit; static GtkWidget * g_menu_item_jack_configure; +static GtkWidget * g_menu_item_settings; static GtkCheckMenuItem * g_menu_item_jack_latency_32; static GtkCheckMenuItem * g_menu_item_jack_latency_64; static GtkCheckMenuItem * g_menu_item_jack_latency_128; @@ -99,6 +100,7 @@ void menu_init(void) g_menu_item_save_as_project = get_gtk_builder_widget("menu_item_save_as_project"); g_menu_item_daemon_exit = get_gtk_builder_widget("menu_item_daemon_exit"); g_menu_item_jack_configure = get_gtk_builder_widget("menu_item_jack_configure"); + g_menu_item_settings = get_gtk_builder_widget("menu_item_settings"); g_menu_item_view_toolbar = get_gtk_builder_widget("menu_item_view_toolbar"); g_menu_item_view_raw_jack = get_gtk_builder_widget("menu_item_view_raw_jack"); @@ -124,6 +126,7 @@ void menu_init(void) g_signal_connect(G_OBJECT(g_menu_item_rename_studio), "activate", G_CALLBACK(menu_request_rename_studio), NULL); g_signal_connect(G_OBJECT(g_menu_item_daemon_exit), "activate", G_CALLBACK(menu_request_daemon_exit), NULL); g_signal_connect(G_OBJECT(g_menu_item_jack_configure), "activate", G_CALLBACK(menu_request_jack_configure), NULL); + g_signal_connect(G_OBJECT(g_menu_item_settings), "activate", G_CALLBACK(menu_request_settings), NULL); g_signal_connect(G_OBJECT(g_menu_item_start_app), "activate", G_CALLBACK(menu_request_start_app), NULL); g_signal_connect(G_OBJECT(g_menu_item_create_room), "activate", G_CALLBACK(menu_request_create_room), NULL); g_signal_connect(G_OBJECT(g_menu_item_destroy_room), "activate", G_CALLBACK(menu_request_destroy_room), NULL); diff --git a/gui/menu.h b/gui/menu.h index ee140688..c2de4c91 100644 --- a/gui/menu.h +++ b/gui/menu.h @@ -39,6 +39,7 @@ void fill_view_popup_menu(GtkMenu * menu, graph_view_handle view); void menu_request_daemon_exit(void); void menu_request_jack_configure(void); +void menu_request_settings(void); void menu_request_save_studio(void); void menu_request_save_as_studio(void); void menu_request_new_studio(void); diff --git a/gui/settings.c b/gui/settings.c new file mode 100644 index 00000000..454b8386 --- /dev/null +++ b/gui/settings.c @@ -0,0 +1,98 @@ +/* -*- Mode: C ; c-basic-offset: 2 -*- */ +/* + * LADI Session Handler (ladish) + * + * Copyright (C) 2010 Nedko Arnaudov + * + ************************************************************************** + * This file contains implementation of the settings dialog + ************************************************************************** + * + * LADI Session Handler is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * LADI Session Handler is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with LADI Session Handler. If not, see + * or write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "menu.h" +#include "gtk_builder.h" +#include "../proxies/conf_proxy.h" +#include "../daemon/conf.h" + +void menu_request_settings(void) +{ + guint result; + GtkDialog * dialog; + GtkToggleButton * autostart_studio_button; + GtkToggleButton * send_notifications_button; + GtkEntry * shell_entry; + GtkEntry * terminal_entry; + bool autostart; + bool notify; + const char * shell; + const char * terminal; + + autostart_studio_button = GTK_TOGGLE_BUTTON(get_gtk_builder_widget("settings_studio_autostart_checkbutton")); + send_notifications_button = GTK_TOGGLE_BUTTON(get_gtk_builder_widget("settings_send_notifications_checkbutton")); + shell_entry = GTK_ENTRY(get_gtk_builder_widget("settings_shell_entry")); + terminal_entry = GTK_ENTRY(get_gtk_builder_widget("settings_terminal_entry")); + + dialog = GTK_DIALOG(get_gtk_builder_widget("settings_dialog")); + + if (!conf_get_bool(LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART, &autostart)) + { + autostart = LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART_DEFAULT; + } + + if (!conf_get_bool(LADISH_CONF_KEY_DAEMON_NOTIFY, ¬ify)) + { + notify = LADISH_CONF_KEY_DAEMON_NOTIFY_DEFAULT; + } + + if (!conf_get(LADISH_CONF_KEY_DAEMON_SHELL, &shell)) + { + shell = LADISH_CONF_KEY_DAEMON_SHELL_DEFAULT; + } + + if (!conf_get(LADISH_CONF_KEY_DAEMON_TERMINAL, &terminal)) + { + terminal = LADISH_CONF_KEY_DAEMON_TERMINAL_DEFAULT; + } + + gtk_toggle_button_set_active(autostart_studio_button, autostart); + gtk_toggle_button_set_active(send_notifications_button, notify); + + gtk_entry_set_text(shell_entry, shell); + gtk_entry_set_text(terminal_entry, terminal); + + gtk_widget_show(GTK_WIDGET(dialog)); + result = gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_hide(GTK_WIDGET(dialog)); + if (result != GTK_RESPONSE_OK) + { + return; + } + + autostart = gtk_toggle_button_get_active(autostart_studio_button); + notify = gtk_toggle_button_get_active(send_notifications_button); + shell = gtk_entry_get_text(shell_entry); + terminal = gtk_entry_get_text(terminal_entry); + + if (!conf_set_bool(LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART, autostart) || + !conf_set_bool(LADISH_CONF_KEY_DAEMON_NOTIFY, notify) || + !conf_set(LADISH_CONF_KEY_DAEMON_SHELL, shell) || + !conf_set(LADISH_CONF_KEY_DAEMON_TERMINAL, terminal)) + { + error_message_box("Storing settings"); + } +} diff --git a/wscript b/wscript index 9dbacc47..215f1739 100644 --- a/wscript +++ b/wscript @@ -448,6 +448,7 @@ def build(bld): 'room.c', 'statusbar.c', 'action.c', + 'settings.c', ]: gladish.source.append(os.path.join("gui", source))