| 1 | /* -*- Mode: C ; c-basic-offset: 2 -*- */ |
|---|
| 2 | /* |
|---|
| 3 | * LADI Session Handler (ladish) |
|---|
| 4 | * |
|---|
| 5 | * Copyright (C) 2008,2009,2010,2011 Nedko Arnaudov <nedko@arnaudov.name> |
|---|
| 6 | * |
|---|
| 7 | ************************************************************************** |
|---|
| 8 | * This file contains the code that implements main() and other top-level functionality |
|---|
| 9 | ************************************************************************** |
|---|
| 10 | * |
|---|
| 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. |
|---|
| 15 | * |
|---|
| 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. |
|---|
| 20 | * |
|---|
| 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. |
|---|
| 25 | */ |
|---|
| 26 | |
|---|
| 27 | #include "internal.h" |
|---|
| 28 | |
|---|
| 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" |
|---|
| 47 | |
|---|
| 48 | #define GETTEXT_PACKAGE "ladish" |
|---|
| 49 | |
|---|
| 50 | #define ENABLE_NLS 1 |
|---|
| 51 | |
|---|
| 52 | GtkWidget * g_main_win; |
|---|
| 53 | |
|---|
| 54 | void |
|---|
| 55 | set_main_window_title( |
|---|
| 56 | graph_view_handle view) |
|---|
| 57 | { |
|---|
| 58 | char * title; |
|---|
| 59 | |
|---|
| 60 | if (view != NULL) |
|---|
| 61 | { |
|---|
| 62 | title = catdup3(get_view_name(view), " - ", _("LADI Session Handler")); |
|---|
| 63 | gtk_window_set_title(GTK_WINDOW(g_main_win), title); |
|---|
| 64 | free(title); |
|---|
| 65 | } |
|---|
| 66 | else |
|---|
| 67 | { |
|---|
| 68 | gtk_window_set_title(GTK_WINDOW(g_main_win), _("LADI Session Handler")); |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | void arrange(void) |
|---|
| 73 | { |
|---|
| 74 | canvas_handle canvas; |
|---|
| 75 | |
|---|
| 76 | log_info("arrange request"); |
|---|
| 77 | |
|---|
| 78 | canvas = get_current_canvas(); |
|---|
| 79 | if (canvas != NULL) |
|---|
| 80 | { |
|---|
| 81 | canvas_arrange(canvas); |
|---|
| 82 | } |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | int main(int argc, char** argv) |
|---|
| 86 | { |
|---|
| 87 | #if ENABLE_NLS |
|---|
| 88 | bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR); |
|---|
| 89 | bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); |
|---|
| 90 | textdomain (GETTEXT_PACKAGE); |
|---|
| 91 | #endif |
|---|
| 92 | |
|---|
| 93 | gtk_init(&argc, &argv); |
|---|
| 94 | |
|---|
| 95 | dbus_init(); |
|---|
| 96 | |
|---|
| 97 | if (!conf_proxy_init()) |
|---|
| 98 | { |
|---|
| 99 | return 1; |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | if (!canvas_init()) |
|---|
| 103 | { |
|---|
| 104 | log_error("Canvas initialization failed."); |
|---|
| 105 | return 1; |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | if (!init_gtk_builder()) |
|---|
| 109 | { |
|---|
| 110 | return 1; |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | g_main_win = get_gtk_builder_widget("main_win"); |
|---|
| 114 | |
|---|
| 115 | init_dialogs(); |
|---|
| 116 | |
|---|
| 117 | if (!create_studio_lists()) |
|---|
| 118 | { |
|---|
| 119 | return 1; |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | init_statusbar(); |
|---|
| 123 | init_jack_widgets(); |
|---|
| 124 | |
|---|
| 125 | create_room_dialog_init(); |
|---|
| 126 | |
|---|
| 127 | world_tree_init(); |
|---|
| 128 | view_init(); |
|---|
| 129 | |
|---|
| 130 | init_actions_and_accelerators(); |
|---|
| 131 | |
|---|
| 132 | if (!menu_init()) |
|---|
| 133 | { |
|---|
| 134 | return 1; |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | buffer_size_clear(); |
|---|
| 138 | |
|---|
| 139 | if (!toolbar_init()) |
|---|
| 140 | { |
|---|
| 141 | return 1; |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | if (!conf_register(LADISH_CONF_KEY_DAEMON_NOTIFY, NULL, NULL)) |
|---|
| 145 | { |
|---|
| 146 | return 1; |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | if (!conf_register(LADISH_CONF_KEY_DAEMON_SHELL, NULL, NULL)) |
|---|
| 150 | { |
|---|
| 151 | return 1; |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | if (!conf_register(LADISH_CONF_KEY_DAEMON_TERMINAL, NULL, NULL)) |
|---|
| 155 | { |
|---|
| 156 | return 1; |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | if (!conf_register(LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART, NULL, NULL)) |
|---|
| 160 | { |
|---|
| 161 | return 1; |
|---|
| 162 | } |
|---|
| 163 | |
|---|
| 164 | if (!conf_register(LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY, NULL, NULL)) |
|---|
| 165 | { |
|---|
| 166 | return 1; |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | if (!conf_register(LADISH_CONF_KEY_JACK_CONF_TOOL, NULL, NULL)) |
|---|
| 170 | { |
|---|
| 171 | return 1; |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | if (!init_jack()) |
|---|
| 175 | { |
|---|
| 176 | return 1; |
|---|
| 177 | } |
|---|
| 178 | |
|---|
| 179 | if (!a2j_proxy_init()) |
|---|
| 180 | { |
|---|
| 181 | return 1; |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | if (!control_proxy_init()) |
|---|
| 185 | { |
|---|
| 186 | return 1; |
|---|
| 187 | } |
|---|
| 188 | |
|---|
| 189 | if (!studio_proxy_init()) |
|---|
| 190 | { |
|---|
| 191 | return 1; |
|---|
| 192 | } |
|---|
| 193 | |
|---|
| 194 | set_studio_callbacks(); |
|---|
| 195 | set_room_callbacks(); |
|---|
| 196 | |
|---|
| 197 | g_signal_connect(G_OBJECT(g_main_win), "destroy", G_CALLBACK(gtk_main_quit), NULL); |
|---|
| 198 | g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_quit")), "activate", G_CALLBACK(gtk_main_quit), NULL); |
|---|
| 199 | g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_view_arrange")), "activate", G_CALLBACK(arrange), NULL); |
|---|
| 200 | g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_help_about")), "activate", G_CALLBACK(show_about), NULL); |
|---|
| 201 | |
|---|
| 202 | gtk_widget_show(g_main_win); |
|---|
| 203 | |
|---|
| 204 | gtk_main(); |
|---|
| 205 | |
|---|
| 206 | studio_proxy_uninit(); |
|---|
| 207 | control_proxy_uninit(); |
|---|
| 208 | a2j_proxy_uninit(); |
|---|
| 209 | uninit_jack(); |
|---|
| 210 | menu_uninit(); |
|---|
| 211 | create_room_dialog_uninit(); |
|---|
| 212 | destroy_studio_lists(); |
|---|
| 213 | uninit_gtk_builder(); |
|---|
| 214 | |
|---|
| 215 | conf_proxy_uninit(); |
|---|
| 216 | dbus_uninit(); |
|---|
| 217 | |
|---|
| 218 | return 0; |
|---|
| 219 | } |
|---|