ladishd: fix hidden connection save. Fix for #151
[ladish.git] / gui / main.c
blobdb543ea7cf1100722a60742b56c6b23f7c4bdad0
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 "../proxies/a2j_proxy.h"
33 #include "world_tree.h"
34 #include "graph_view.h"
35 #include "../common/catdup.h"
36 #include "../proxies/studio_proxy.h"
37 #include "../proxies/conf_proxy.h"
38 #include "create_room_dialog.h"
39 #include "menu.h"
40 #include "about.h"
41 #include "statusbar.h"
42 #include "action.h"
43 #include "studio.h"
44 #include "jack.h"
45 #include "../daemon/conf.h"
46 #include "toolbar.h"
48 #define GETTEXT_PACKAGE "ladish"
50 #define ENABLE_NLS 1
52 GtkWidget * g_main_win;
54 void
55 set_main_window_title(
56 graph_view_handle view)
58 char * title;
60 if (view != NULL)
62 title = catdup3(get_view_name(view), " - ", _("LADI Session Handler"));
63 gtk_window_set_title(GTK_WINDOW(g_main_win), title);
64 free(title);
66 else
68 gtk_window_set_title(GTK_WINDOW(g_main_win), _("LADI Session Handler"));
72 void arrange(void)
74 canvas_handle canvas;
76 log_info("arrange request");
78 canvas = get_current_canvas();
79 if (canvas != NULL)
81 canvas_arrange(canvas);
85 int main(int argc, char** argv)
87 #if ENABLE_NLS
88 bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
89 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
90 textdomain (GETTEXT_PACKAGE);
91 #endif
93 gtk_init(&argc, &argv);
95 dbus_init();
97 if (!conf_proxy_init())
99 return 1;
102 if (!canvas_init())
104 log_error("Canvas initialization failed.");
105 return 1;
108 if (!init_gtk_builder())
110 return 1;
113 g_main_win = get_gtk_builder_widget("main_win");
115 init_dialogs();
117 if (!create_studio_lists())
119 return 1;
122 init_statusbar();
123 init_jack_widgets();
125 create_room_dialog_init();
127 world_tree_init();
128 view_init();
130 init_actions_and_accelerators();
132 if (!menu_init())
134 return 1;
137 buffer_size_clear();
139 if (!toolbar_init())
141 return 1;
144 if (!conf_register(LADISH_CONF_KEY_DAEMON_NOTIFY, NULL, NULL))
146 return 1;
149 if (!conf_register(LADISH_CONF_KEY_DAEMON_SHELL, NULL, NULL))
151 return 1;
154 if (!conf_register(LADISH_CONF_KEY_DAEMON_TERMINAL, NULL, NULL))
156 return 1;
159 if (!conf_register(LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART, NULL, NULL))
161 return 1;
164 if (!init_jack())
166 return 1;
169 if (!a2j_proxy_init())
171 return 1;
174 if (!control_proxy_init())
176 return 1;
179 if (!studio_proxy_init())
181 return 1;
184 set_studio_callbacks();
185 set_room_callbacks();
187 g_signal_connect(G_OBJECT(g_main_win), "destroy", G_CALLBACK(gtk_main_quit), NULL);
188 g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_quit")), "activate", G_CALLBACK(gtk_main_quit), NULL);
189 g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_view_arrange")), "activate", G_CALLBACK(arrange), NULL);
190 g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_help_about")), "activate", G_CALLBACK(show_about), NULL);
192 gtk_widget_show(g_main_win);
194 gtk_main();
196 studio_proxy_uninit();
197 control_proxy_uninit();
198 a2j_proxy_uninit();
199 uninit_jack();
200 menu_uninit();
201 create_room_dialog_uninit();
202 destroy_studio_lists();
203 uninit_gtk_builder();
205 conf_proxy_uninit();
206 dbus_uninit();
208 return 0;