2009-07-30 01:16:07 +03:00
|
|
|
/* -*- Mode: C ; c-basic-offset: 2 -*- */
|
2009-07-20 04:50:15 +03:00
|
|
|
/*
|
2009-07-30 01:16:07 +03:00
|
|
|
* LADI Session Handler (ladish)
|
2009-07-20 04:50:15 +03:00
|
|
|
*
|
2010-02-07 19:37:23 +02:00
|
|
|
* Copyright (C) 2008, 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name>
|
2009-07-30 01:16:07 +03:00
|
|
|
*
|
|
|
|
**************************************************************************
|
|
|
|
* This file contains the code that implements main() and other top-level functionality
|
|
|
|
**************************************************************************
|
|
|
|
*
|
|
|
|
* 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.
|
2006-06-09 05:18:57 +03:00
|
|
|
*/
|
|
|
|
|
2010-03-21 18:08:42 +02:00
|
|
|
#include "internal.h"
|
2009-08-22 18:41:10 +03:00
|
|
|
|
2010-02-07 19:37:23 +02:00
|
|
|
#include "gtk_builder.h"
|
2009-08-17 05:30:31 +03:00
|
|
|
#include "canvas.h"
|
2009-12-13 18:10:57 +02:00
|
|
|
#include "../proxies/control_proxy.h"
|
2009-08-22 04:42:54 +03:00
|
|
|
#include "world_tree.h"
|
2009-08-22 14:11:38 +03:00
|
|
|
#include "graph_view.h"
|
2010-09-19 17:15:11 +03:00
|
|
|
#include "../common/catdup.h"
|
2009-12-13 18:10:57 +02:00
|
|
|
#include "../proxies/studio_proxy.h"
|
2010-09-27 22:48:35 +03:00
|
|
|
#include "../proxies/conf_proxy.h"
|
2010-03-21 16:33:39 +02:00
|
|
|
#include "create_room_dialog.h"
|
2010-03-21 18:08:42 +02:00
|
|
|
#include "menu.h"
|
2010-09-07 01:02:12 +03:00
|
|
|
#include "about.h"
|
|
|
|
#include "statusbar.h"
|
|
|
|
#include "action.h"
|
|
|
|
#include "studio.h"
|
|
|
|
#include "jack.h"
|
2009-08-17 04:08:32 +03:00
|
|
|
|
2009-08-22 18:41:10 +03:00
|
|
|
GtkWidget * g_main_win;
|
2009-09-01 00:11:49 +03:00
|
|
|
GtkWidget * g_toolbar;
|
2010-03-07 13:49:39 +02:00
|
|
|
|
2010-09-27 22:48:35 +03:00
|
|
|
#define LADISH_CONF_KEY_GLADISH_TOOLBAR_VISIBILITY "/org/ladish/gladish/toolbar_visibility"
|
|
|
|
|
2009-08-22 16:59:40 +03:00
|
|
|
void
|
|
|
|
set_main_window_title(
|
|
|
|
graph_view_handle view)
|
2009-07-20 04:50:15 +03:00
|
|
|
{
|
2009-10-11 18:25:49 +03:00
|
|
|
char * title;
|
|
|
|
|
|
|
|
if (view != NULL)
|
|
|
|
{
|
|
|
|
title = catdup(get_view_name(view), " - LADI Session Handler");
|
|
|
|
gtk_window_set_title(GTK_WINDOW(g_main_win), title);
|
|
|
|
free(title);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_window_set_title(GTK_WINDOW(g_main_win), "LADI Session Handler");
|
|
|
|
}
|
2009-08-22 16:59:40 +03:00
|
|
|
}
|
2009-07-20 04:50:15 +03:00
|
|
|
|
2010-09-07 01:02:12 +03:00
|
|
|
void arrange(void)
|
2009-08-30 14:36:27 +03:00
|
|
|
{
|
2010-09-07 01:02:12 +03:00
|
|
|
canvas_handle canvas;
|
|
|
|
|
|
|
|
log_info("arrange request");
|
|
|
|
|
|
|
|
canvas = get_current_canvas();
|
|
|
|
if (canvas != NULL)
|
|
|
|
{
|
|
|
|
canvas_arrange(canvas);
|
|
|
|
}
|
2009-08-30 14:36:27 +03:00
|
|
|
}
|
|
|
|
|
2010-03-21 18:08:42 +02:00
|
|
|
void menu_request_toggle_toolbar(bool visible)
|
2009-09-01 00:11:49 +03:00
|
|
|
{
|
2010-03-21 18:08:42 +02:00
|
|
|
if (visible)
|
2009-09-01 00:11:49 +03:00
|
|
|
{
|
|
|
|
gtk_widget_show(g_toolbar);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_hide(g_toolbar);
|
|
|
|
}
|
2010-09-27 22:48:35 +03:00
|
|
|
|
|
|
|
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);
|
2009-09-01 00:11:49 +03:00
|
|
|
}
|
|
|
|
|
2009-08-22 16:59:40 +03:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2009-08-17 05:30:31 +03:00
|
|
|
gtk_init(&argc, &argv);
|
2009-07-20 04:50:15 +03:00
|
|
|
|
2010-09-27 22:48:35 +03:00
|
|
|
dbus_init();
|
|
|
|
|
|
|
|
if (!conf_proxy_init())
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-08-17 04:35:25 +03:00
|
|
|
if (!canvas_init())
|
|
|
|
{
|
2009-09-20 18:23:42 +03:00
|
|
|
log_error("Canvas initialization failed.");
|
2009-08-17 04:17:26 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-02-07 19:37:23 +02:00
|
|
|
if (!init_gtk_builder())
|
2009-08-17 04:35:25 +03:00
|
|
|
{
|
2009-07-20 04:59:25 +03:00
|
|
|
return 1;
|
|
|
|
}
|
2006-06-09 05:18:57 +03:00
|
|
|
|
2010-02-07 19:37:23 +02:00
|
|
|
g_main_win = get_gtk_builder_widget("main_win");
|
|
|
|
g_toolbar = get_gtk_builder_widget("toolbar");
|
2009-08-23 12:13:43 +03:00
|
|
|
|
2010-09-07 01:02:12 +03:00
|
|
|
init_dialogs();
|
2009-08-28 21:59:45 +03:00
|
|
|
|
2010-09-07 01:02:12 +03:00
|
|
|
init_studio_lists();
|
2010-02-20 03:09:37 +02:00
|
|
|
|
2010-09-07 01:02:12 +03:00
|
|
|
init_statusbar();
|
|
|
|
init_jack_widgets();
|
2010-02-20 01:52:49 +02:00
|
|
|
|
2010-03-21 16:33:39 +02:00
|
|
|
create_room_dialog_init();
|
|
|
|
|
2009-08-22 04:42:54 +03:00
|
|
|
world_tree_init();
|
2009-08-22 14:11:38 +03:00
|
|
|
view_init();
|
2009-08-22 04:42:54 +03:00
|
|
|
|
2010-09-07 01:02:12 +03:00
|
|
|
init_actions_and_accelerators();
|
2010-02-28 17:13:54 +02:00
|
|
|
|
2010-03-21 18:08:42 +02:00
|
|
|
menu_init();
|
2010-04-03 04:22:29 +03:00
|
|
|
buffer_size_clear();
|
2010-03-21 18:08:42 +02:00
|
|
|
|
2010-09-27 22:48:35 +03:00
|
|
|
if (!conf_register(LADISH_CONF_KEY_GLADISH_TOOLBAR_VISIBILITY, on_dbus_toggle_toobar, NULL))
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2009-08-17 05:30:31 +03:00
|
|
|
|
2010-09-07 01:02:12 +03:00
|
|
|
if (!init_jack())
|
2009-08-22 15:06:29 +03:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-08-20 00:51:27 +03:00
|
|
|
if (!control_proxy_init())
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-08-23 12:58:01 +03:00
|
|
|
if (!studio_proxy_init())
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-09-07 01:02:12 +03:00
|
|
|
set_studio_callbacks();
|
|
|
|
set_room_callbacks();
|
2009-08-23 12:58:01 +03:00
|
|
|
|
2009-08-22 16:59:40 +03:00
|
|
|
g_signal_connect(G_OBJECT(g_main_win), "destroy", G_CALLBACK(gtk_main_quit), NULL);
|
2010-02-07 19:37:23 +02:00
|
|
|
g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_quit")), "activate", G_CALLBACK(gtk_main_quit), NULL);
|
|
|
|
g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_view_arrange")), "activate", G_CALLBACK(arrange), NULL);
|
|
|
|
g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_help_about")), "activate", G_CALLBACK(show_about), NULL);
|
2010-02-19 01:28:51 +02:00
|
|
|
|
2009-08-22 16:59:40 +03:00
|
|
|
gtk_widget_show(g_main_win);
|
2009-08-17 05:30:31 +03:00
|
|
|
|
|
|
|
gtk_main();
|
|
|
|
|
2009-08-23 12:58:01 +03:00
|
|
|
studio_proxy_uninit();
|
2009-08-20 00:51:27 +03:00
|
|
|
control_proxy_uninit();
|
2010-09-07 01:02:12 +03:00
|
|
|
uninit_jack();
|
2010-03-21 16:33:39 +02:00
|
|
|
create_room_dialog_uninit();
|
2010-02-07 19:37:23 +02:00
|
|
|
uninit_gtk_builder();
|
2009-08-17 05:30:31 +03:00
|
|
|
|
2010-09-27 22:48:35 +03:00
|
|
|
conf_proxy_uninit();
|
|
|
|
dbus_uninit();
|
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
return 0;
|
2006-06-09 05:18:57 +03:00
|
|
|
}
|