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