gladish dialog for ladishd settings

This commit is contained in:
Nedko Arnaudov 2010-09-28 00:18:44 +03:00
parent 1f2972377e
commit 6c3ef670b6
10 changed files with 315 additions and 6 deletions

View File

@ -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 */

View File

@ -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)

View File

@ -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";

View File

@ -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)
{

View File

@ -319,12 +319,21 @@
<child>
<object class="GtkImageMenuItem" id="menu_item_jack_clear">
<property name="visible">True</property>
<property name="use_action_appearance">True</property>
<property name="related_action">clear_xruns_and_max_dsp_load_action</property>
<property name="use_action_appearance">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_item_settings">
<property name="label" translatable="yes">_Settings</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="image">image1</property>
<property name="use_stock">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_item_jack_configure">
<property name="label">_Configure JACK</property>
@ -467,8 +476,8 @@
<child>
<object class="GtkToolButton" id="clear_load_button">
<property name="visible">True</property>
<property name="use_action_appearance">True</property>
<property name="related_action">clear_xruns_and_max_dsp_load_action</property>
<property name="use_action_appearance">True</property>
<property name="label" translatable="yes">Clear XRuns</property>
</object>
<packing>
@ -1623,4 +1632,164 @@ along with LADI Session Handler; if not, write to the Free Software Foundation,
<action-widget response="-5">project_save_as_ok_button</action-widget>
</action-widgets>
</object>
<object class="GtkDialog" id="settings_dialog">
<property name="border_width">5</property>
<property name="type_hint">normal</property>
<property name="transient_for">main_win</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="settings_dialog-vbox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkTable" id="settings_top_table">
<property name="visible">True</property>
<property name="n_columns">2</property>
<property name="column_spacing">20</property>
<property name="row_spacing">5</property>
<child>
<object class="GtkVBox" id="settings_bool_vbox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkCheckButton" id="settings_studio_autostart_checkbutton">
<property name="label" translatable="yes">Start studio on load</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="settings_send_notifications_checkbutton">
<property name="label" translatable="yes">Send notifications</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkTable" id="settings_string_table">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
<object class="GtkLabel" id="settings_shell_label">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Shell to use:</property>
</object>
</child>
<child>
<object class="GtkLabel" id="settings_terminal_label">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Terminal to use:</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="settings_shell_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="settings_terminal_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="settings_dialog-action_area">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="settings_cancel_button">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="settings_ok_button">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">settings_cancel_button</action-widget>
<action-widget response="-5">settings_ok_button</action-widget>
</action-widgets>
</object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="stock">gtk-preferences</property>
</object>
</interface>

View File

@ -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;

View File

@ -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);

View File

@ -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);

98
gui/settings.c Normal file
View File

@ -0,0 +1,98 @@
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name>
*
**************************************************************************
* 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 <http://www.gnu.org/licenses/>
* 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, &notify))
{
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");
}
}

View File

@ -448,6 +448,7 @@ def build(bld):
'room.c',
'statusbar.c',
'action.c',
'settings.c',
]:
gladish.source.append(os.path.join("gui", source))