gladish: move toolbar related code to separate file

This commit is contained in:
Nedko Arnaudov 2010-09-28 00:38:49 +03:00
parent 1ee3607bd8
commit 482265c5c7
4 changed files with 122 additions and 44 deletions

View File

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

85
gui/toolbar.c Normal file
View File

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

34
gui/toolbar.h Normal file
View File

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

View File

@ -437,6 +437,7 @@ def build(bld):
'ask_dialog.c',
'create_room_dialog.c',
'menu.c',
'toolbar.c',
'about.c',
'dbus.c',
'studio.c',