ladishd: actually remove app ports, simply logging does not make it happen
[ladish.git] / gui / main.c
blob41618e78cea1d96b0381e793e66eacc06edfbd6f
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2008, 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains the code that implements main() and other top-level functionality
9 **************************************************************************
11 * LADI Session Handler is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * LADI Session Handler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 * or write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "internal.h"
29 #include "gtk_builder.h"
30 #include "canvas.h"
31 #include "../proxies/control_proxy.h"
32 #include "world_tree.h"
33 #include "graph_view.h"
34 #include "../common/catdup.h"
35 #include "../proxies/studio_proxy.h"
36 #include "../proxies/conf_proxy.h"
37 #include "create_room_dialog.h"
38 #include "menu.h"
39 #include "about.h"
40 #include "statusbar.h"
41 #include "action.h"
42 #include "studio.h"
43 #include "jack.h"
44 #include "../daemon/conf.h"
45 #include "toolbar.h"
47 GtkWidget * g_main_win;
49 void
50 set_main_window_title(
51 graph_view_handle view)
53 char * title;
55 if (view != NULL)
57 title = catdup(get_view_name(view), " - LADI Session Handler");
58 gtk_window_set_title(GTK_WINDOW(g_main_win), title);
59 free(title);
61 else
63 gtk_window_set_title(GTK_WINDOW(g_main_win), "LADI Session Handler");
67 void arrange(void)
69 canvas_handle canvas;
71 log_info("arrange request");
73 canvas = get_current_canvas();
74 if (canvas != NULL)
76 canvas_arrange(canvas);
80 int main(int argc, char** argv)
82 gtk_init(&argc, &argv);
84 dbus_init();
86 if (!conf_proxy_init())
88 return 1;
91 if (!canvas_init())
93 log_error("Canvas initialization failed.");
94 return 1;
97 if (!init_gtk_builder())
99 return 1;
102 g_main_win = get_gtk_builder_widget("main_win");
104 init_dialogs();
106 if (!create_studio_lists())
108 return 1;
111 init_statusbar();
112 init_jack_widgets();
114 create_room_dialog_init();
116 world_tree_init();
117 view_init();
119 init_actions_and_accelerators();
121 if (!menu_init())
123 return 1;
126 buffer_size_clear();
128 if (!toolbar_init())
130 return 1;
133 if (!conf_register(LADISH_CONF_KEY_DAEMON_NOTIFY, NULL, NULL))
135 return 1;
138 if (!conf_register(LADISH_CONF_KEY_DAEMON_SHELL, NULL, NULL))
140 return 1;
143 if (!conf_register(LADISH_CONF_KEY_DAEMON_TERMINAL, NULL, NULL))
145 return 1;
148 if (!conf_register(LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART, NULL, NULL))
150 return 1;
153 if (!init_jack())
155 return 1;
158 if (!control_proxy_init())
160 return 1;
163 if (!studio_proxy_init())
165 return 1;
168 set_studio_callbacks();
169 set_room_callbacks();
171 g_signal_connect(G_OBJECT(g_main_win), "destroy", G_CALLBACK(gtk_main_quit), NULL);
172 g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_quit")), "activate", G_CALLBACK(gtk_main_quit), NULL);
173 g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_view_arrange")), "activate", G_CALLBACK(arrange), NULL);
174 g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_help_about")), "activate", G_CALLBACK(show_about), NULL);
176 gtk_widget_show(g_main_win);
178 gtk_main();
180 studio_proxy_uninit();
181 control_proxy_uninit();
182 uninit_jack();
183 menu_uninit();
184 create_room_dialog_uninit();
185 destroy_studio_lists();
186 uninit_gtk_builder();
188 conf_proxy_uninit();
189 dbus_uninit();
191 return 0;