Initial load
[melted_gui] / src / main.c
1 /*
2 * main.c -- GTK+ 2 omnplay
3 * Copyright (C) 2011 Maksym Veremeyenko <verem@m1stereo.tv>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
23
24 #include <gtk/gtk.h>
25 #include <unistd.h>
26 #include <string.h>
27
28 #ifdef ENABLE_NLS
29 #include <libintl.h>
30 #endif
31
32 #include <stdio.h>
33 #include "ui.h"
34 #include "omnplay.h"
35 #include "support.h"
36
37 int main(int argc, char **argv)
38 {
39 char path[ 512 ];
40 omnplay_instance_t *app = NULL;
41
42 #ifdef ENABLE_NLS
43 bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
44 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
45 textdomain (GETTEXT_PACKAGE);
46 #endif
47
48 g_thread_init(NULL);
49 gdk_threads_init();
50 gtk_set_locale();
51 gtk_init(&argc, &argv);
52
53 #ifdef _WIN32
54 #else
55 // Linux hack to determine path of the executable
56 readlink( "/proc/self/exe", path, 512);
57 if ( strstr( path, "/bin/rugen" ) )
58 {
59 ( *strstr( path, "/bin/rugen" ) ) = '\0';
60 strcat( path, "/share/rugen/pixmaps" );
61 add_pixmap_directory( path );
62 }
63 else
64 {
65 add_pixmap_directory( PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps" );
66 }
67 #endif /* _WIN32 */
68
69 app = omnplay_create(argc, argv);
70 gtk_widget_show (app->window);
71
72 gdk_threads_enter();
73 omnplay_init(app);
74 gtk_main ();
75 gdk_threads_leave();
76
77 omnplay_close(app);
78
79 return 0;
80 }
81