Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

main.c

Go to the documentation of this file.
00001 /*
00002 * Copyright (C) 2000 Arne Schirmacher <arne@schirmacher.de>
00003 * Copyright (C) 2001-2007 Dan Dennedy <dan@dennedy.org>
00004 *
00005 * This program is free software; you can redistribute it and/or modify
00006 * it under the terms of the GNU General Public License as published by
00007 * the Free Software Foundation; either version 2 of the License, or
00008 * (at your option) any later version.
00009 *
00010 * This program is distributed in the hope that it will be useful,
00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 * GNU General Public License for more details.
00014 *
00015 * You should have received a copy of the GNU General Public License
00016 * along with this program; if not, write to the Free Software Foundation,
00017 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 */
00019 
00020 /*
00021  * Initial main.c file generated by Glade. Edit as required.
00022  * Glade will not overwrite this file.
00023  */
00024 
00025 #ifdef HAVE_CONFIG_H
00026 #include <config.h>
00027 #endif
00028 
00029 #ifdef HAVE_EXECINFO_H
00030 #include <execinfo.h>
00031 #endif
00032 
00033 #include <gtk/gtk.h>
00034 #include <signal.h>
00035 #include <stdio.h>
00036 #include <stdlib.h>
00037 #ifdef ENABLE_NLS
00038 #include <libintl.h>
00039 #endif
00040 #include <glade/glade.h>
00041 #include <string.h>
00042 
00043 #include "commands.h"
00044 
00045 GtkWidget *main_window;
00046 GladeXML *magick_glade;
00047 GladeXML *kino_glade;
00048 char* g_help_language;
00049 
00050 static int sigpipe = 0;
00051 void sigpipe_clear( void );
00052 int sigpipe_get( void );
00053 
00054 void sigpipe_clear( void )
00055 {
00056     sigpipe = 0;
00057 }
00058 
00059 int sigpipe_get( void )
00060 {
00061     return sigpipe;
00062 }
00063 
00064 static void sigpipe_handler( int value )
00065 {
00066     fprintf( stderr, "SIGPIPE Received (%d) - setting indicator\n", value );
00067     sigpipe ++;
00068 }
00069 
00070 static void sigusr2_handler( int value )
00071 {
00072     fprintf( stderr, "SIGUSR2 Received (%d) - scanning for jog/shuttle controllers\n", value );
00073     startJogShuttle();
00074 }
00075 
00082 #ifdef HAVE_EXECINFO_H
00083 static void sigsegv_handler()
00084 {
00085     void *array[ 10 ];
00086     size_t size;
00087     char **strings;
00088     size_t i;
00089 
00090     fprintf( stderr, "\nKino experienced a segmentation fault.\n"
00091         "Dumping stack from the offending thread\n\n" );
00092     size = backtrace( array, 10 );
00093     strings = backtrace_symbols( array, size );
00094 
00095     fprintf( stderr, "Obtained %zd stack frames.\n", size );
00096 
00097     for ( i = 0; i < size; i++ )
00098         fprintf( stderr, "%s\n", strings[ i ] );
00099 
00100     free( strings );
00101 
00102     fprintf( stderr, "\nDone dumping - exiting.\n" );
00103     exit( 1 );
00104 }
00105 #endif
00106 
00107 
00108 
00109 int
00110 main ( int argc, char *argv[] )
00111 {
00112     if ( strstr( argv[0], "kino2raw" ) )
00113     {
00114         if ( argc > 1 )
00115             exit( kino2raw( argv[1], argc > 2 ? argv[2] : NULL ) );
00116         else
00117             exit( 1 );
00118     }
00119 #ifdef ENABLE_NLS
00120     bindtextdomain ( PACKAGE, DATADIR "/locale" );
00121     bind_textdomain_codeset( PACKAGE, "UTF-8" );
00122     textdomain ( PACKAGE );
00123 #endif
00124 
00125     signal( SIGPIPE, sigpipe_handler );
00126     signal( SIGUSR2, sigusr2_handler );
00127 #ifdef HAVE_EXECINFO_H
00128     signal( SIGSEGV,  sigsegv_handler );
00129 #endif
00130 
00131     g_help_language = strdup( "\0\0" );
00132 #ifdef HELP_LINGUAS
00133     gchar** translations = g_strsplit( HELP_LINGUAS, " ", 0 );
00134     const gchar* const * locales = g_get_language_names();
00135     int i, j;
00136     for ( i = 0; translations[i] && !g_help_language[0]; ++i )
00137     {
00138         for ( j = 0; locales[j]; ++j )
00139         {
00140             gchar** parts = g_strsplit_set( locales[j], "._", 0 );
00141             if ( parts[0] && strncmp( parts[0], translations[i], 2 ) == 0 )
00142             {
00143                 strncpy( g_help_language, parts[0], 2 );
00144                 g_strfreev( parts );
00145                 break;
00146             }
00147             g_strfreev( parts );
00148         }
00149     }
00150     g_strfreev( translations );
00151 #endif
00152     if ( !g_help_language[0] )
00153         strncpy( g_help_language, "en", 2 );
00154     fprintf( stderr, "> help language code %s\n", g_help_language);
00155 
00156     g_thread_init( NULL );
00157     gdk_threads_init();
00158     gdk_rgb_init();
00159     gtk_init( &argc, &argv );
00160     glade_init();
00161 
00162     magick_glade = glade_xml_new( DATADIR "/kino/magick.glade", NULL, NULL );
00163     kino_glade = glade_xml_new( DATADIR "/kino/kino.glade", NULL, NULL );
00164     glade_xml_signal_autoconnect( magick_glade );
00165     glade_xml_signal_autoconnect( kino_glade );
00166     main_window = glade_xml_get_widget( kino_glade, "main_window" );
00167     gtk_widget_set_events( main_window, GDK_KEY_RELEASE_MASK );
00168     gtk_window_set_default_icon_from_file( DATADIR "/kino/kino.png", NULL );
00169 
00170     kinoInitialise( main_window );
00171     gtk_widget_show_all( main_window );
00172     kinoPostInit();
00173 
00174     gdk_threads_enter();
00175     bulkLoad( argc, argv );
00176     gtk_main();
00177     gdk_threads_leave();
00178     free( g_help_language );
00179 
00180     return 0;
00181 }

Generated on Sun Mar 11 22:11:46 2007 for Kino by  doxygen 1.4.2