ladish/gui/main.c

223 lines
4.5 KiB
C
Raw Normal View History

/* -*- Mode: C ; c-basic-offset: 2 -*- */
2009-07-20 04:50:15 +03:00
/*
* LADI Session Handler (ladish)
2009-07-20 04:50:15 +03:00
*
* Copyright (C) 2008,2009,2010,2011,2014 Nedko Arnaudov <nedko@arnaudov.name>
*
**************************************************************************
* 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.
*/
#include "internal.h"
2009-08-22 18:41:10 +03:00
#include "gtk_builder.h"
#include "canvas.h"
#include "../proxies/control_proxy.h"
#include "../proxies/a2j_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"
#include "../proxies/studio_proxy.h"
#include "../proxies/conf_proxy.h"
2010-03-21 16:33:39 +02:00
#include "create_room_dialog.h"
#include "menu.h"
#include "about.h"
#include "statusbar.h"
#include "action.h"
#include "studio.h"
#include "jack.h"
2010-09-28 00:18:44 +03:00
#include "../daemon/conf.h"
#include "toolbar.h"
#define GETTEXT_PACKAGE "ladish"
2010-12-11 18:45:06 +02:00
#define ENABLE_NLS 1
2009-08-22 18:41:10 +03:00
GtkWidget * g_main_win;
void
set_main_window_title(
graph_view_handle view)
2009-07-20 04:50:15 +03:00
{
char * title;
if (view != NULL)
{
2010-12-11 18:45:06 +02:00
title = catdup3(get_view_name(view), " - ", _("LADI Session Handler"));
gtk_window_set_title(GTK_WINDOW(g_main_win), title);
free(title);
}
else
{
2010-12-11 18:45:06 +02:00
gtk_window_set_title(GTK_WINDOW(g_main_win), _("LADI Session Handler"));
}
}
2009-07-20 04:50:15 +03:00
void arrange(void)
2009-08-30 14:36:27 +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
}
int main(int argc, char** argv)
{
2010-12-19 13:24:55 +02:00
#if ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
2010-12-11 18:45:06 +02:00
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif
gtk_init(&argc, &argv);
2009-07-20 04:50:15 +03:00
if (!dbus_init())
{
return 1;
}
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.");
return 1;
}
if (!init_gtk_builder())
2009-08-17 04:35:25 +03:00
{
2009-07-20 04:59:25 +03:00
return 1;
}
g_main_win = get_gtk_builder_widget("main_win");
2009-08-23 12:13:43 +03:00
init_dialogs();
2009-08-28 21:59:45 +03:00
2010-10-16 01:39:06 +03:00
if (!create_studio_lists())
{
return 1;
}
init_statusbar();
init_jack_widgets();
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
init_actions_and_accelerators();
if (!menu_init())
{
return 1;
}
buffer_size_clear();
if (!toolbar_init())
{
return 1;
}
2010-09-28 00:18:44 +03:00
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 (!conf_register(LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY, NULL, NULL))
{
return 1;
}
2011-12-19 00:16:51 +02:00
if (!conf_register(LADISH_CONF_KEY_JACK_CONF_TOOL, NULL, NULL))
{
return 1;
}
if (!init_jack())
{
return 1;
}
if (!a2j_proxy_init())
{
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;
}
set_studio_callbacks();
set_room_callbacks();
2009-08-23 12:58:01 +03:00
g_signal_connect(G_OBJECT(g_main_win), "destroy", G_CALLBACK(gtk_main_quit), NULL);
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
gtk_widget_show(g_main_win);
gtk_main();
2009-08-23 12:58:01 +03:00
studio_proxy_uninit();
2009-08-20 00:51:27 +03:00
control_proxy_uninit();
a2j_proxy_uninit();
uninit_jack();
menu_uninit();
2010-03-21 16:33:39 +02:00
create_room_dialog_uninit();
2010-10-16 01:39:06 +03:00
destroy_studio_lists();
uninit_gtk_builder();
conf_proxy_uninit();
dbus_uninit();
2009-07-20 04:59:25 +03:00
return 0;
}