diff --git a/gui/main.c b/gui/main.c index addf2d99..ab20e855 100644 --- a/gui/main.c +++ b/gui/main.c @@ -42,11 +42,9 @@ #include "studio.h" #include "jack.h" #include "../daemon/conf.h" +#include "toolbar.h" GtkWidget * g_main_win; -GtkWidget * g_toolbar; - -#define LADISH_CONF_KEY_GLADISH_TOOLBAR_VISIBILITY "/org/ladish/gladish/toolbar_visibility" void set_main_window_title( @@ -79,45 +77,6 @@ void arrange(void) } } -void menu_request_toggle_toolbar(bool visible) -{ - if (visible) - { - gtk_widget_show(g_toolbar); - } - else - { - gtk_widget_hide(g_toolbar); - } - - conf_set_bool(LADISH_CONF_KEY_GLADISH_TOOLBAR_VISIBILITY, visible); -} - -void on_dbus_toggle_toobar(void * context, const char * key, const char * value) -{ - bool toolbar_visible; - - if (value == NULL) - { - toolbar_visible = false; - } - else - { - toolbar_visible = conf_string2bool(value); - } - - if (toolbar_visible) - { - gtk_widget_show(g_toolbar); - } - else - { - gtk_widget_hide(g_toolbar); - } - - menu_set_toolbar_visibility(toolbar_visible); -} - int main(int argc, char** argv) { gtk_init(&argc, &argv); @@ -141,7 +100,6 @@ int main(int argc, char** argv) } g_main_win = get_gtk_builder_widget("main_win"); - g_toolbar = get_gtk_builder_widget("toolbar"); init_dialogs(); @@ -160,7 +118,7 @@ int main(int argc, char** argv) menu_init(); buffer_size_clear(); - if (!conf_register(LADISH_CONF_KEY_GLADISH_TOOLBAR_VISIBILITY, on_dbus_toggle_toobar, NULL)) + if (!toolbar_init()) { return 1; } diff --git a/gui/toolbar.c b/gui/toolbar.c new file mode 100644 index 00000000..1d2c7076 --- /dev/null +++ b/gui/toolbar.c @@ -0,0 +1,85 @@ +/* -*- Mode: C ; c-basic-offset: 2 -*- */ +/* + * LADI Session Handler (ladish) + * + * Copyright (C) 2010 Nedko Arnaudov + * + ************************************************************************** + * This file contains toolbar related code + ************************************************************************** + * + * 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 "toolbar.h" +#include "../proxies/conf_proxy.h" +#include "menu.h" +#include "gtk_builder.h" + +#define LADISH_CONF_KEY_GLADISH_TOOLBAR_VISIBILITY "/org/ladish/gladish/toolbar_visibility" + +static GtkWidget * g_toolbar; + +void menu_request_toggle_toolbar(bool visible) +{ + if (visible) + { + gtk_widget_show(g_toolbar); + } + else + { + gtk_widget_hide(g_toolbar); + } + + conf_set_bool(LADISH_CONF_KEY_GLADISH_TOOLBAR_VISIBILITY, visible); +} + +void on_dbus_toggle_toobar(void * context, const char * key, const char * value) +{ + bool toolbar_visible; + + if (value == NULL) + { + toolbar_visible = false; + } + else + { + toolbar_visible = conf_string2bool(value); + } + + if (toolbar_visible) + { + gtk_widget_show(g_toolbar); + } + else + { + gtk_widget_hide(g_toolbar); + } + + menu_set_toolbar_visibility(toolbar_visible); +} + +bool toolbar_init(void) +{ + g_toolbar = get_gtk_builder_widget("toolbar"); + + if (!conf_register(LADISH_CONF_KEY_GLADISH_TOOLBAR_VISIBILITY, on_dbus_toggle_toobar, NULL)) + { + return false; + } + + return true; +} diff --git a/gui/toolbar.h b/gui/toolbar.h new file mode 100644 index 00000000..2910200e --- /dev/null +++ b/gui/toolbar.h @@ -0,0 +1,34 @@ +/* -*- Mode: C ; c-basic-offset: 2 -*- */ +/* + * LADI Session Handler (ladish) + * + * Copyright (C) 2010 Nedko Arnaudov + * + ************************************************************************** + * This file contains interface to the toolbar related code + ************************************************************************** + * + * 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. + */ + +#ifndef TOOLBAR_H__098627B9_B605_4AEB_8D63_3144C5F22785__INCLUDED +#define TOOLBAR_H__098627B9_B605_4AEB_8D63_3144C5F22785__INCLUDED + +#include "common.h" + +bool toolbar_init(void); + +#endif /* #ifndef TOOLBAR_H__098627B9_B605_4AEB_8D63_3144C5F22785__INCLUDED */ diff --git a/wscript b/wscript index 215f1739..8b47a6a7 100644 --- a/wscript +++ b/wscript @@ -437,6 +437,7 @@ def build(bld): 'ask_dialog.c', 'create_room_dialog.c', 'menu.c', + 'toolbar.c', 'about.c', 'dbus.c', 'studio.c',