maemo-ui/src/mmyth_main.c
author rosfran
Fri Oct 27 00:11:21 2006 +0100 (2006-10-27)
branchtrunk
changeset 57 c83c59b22fe1
child 64 f926338c6952
permissions -rw-r--r--
[svn r58] Fixed delay on audio frames's timestamps, and refactoring the autotools usage.
     1 
     2 #include <gtk/gtk.h>
     3 
     4 #include "config.h"
     5 
     6 #ifdef MAEMO_PLATFORM
     7 #include "hildon-widgets/hildon-program.h"
     8 #include "hildon-widgets/hildon-window.h"
     9 #endif
    10 
    11 
    12 #include "gmyth_remote_encoder.h"
    13 #include "gmyth_settings.h"
    14 #include "gmyth_context.h"
    15 #include "gmyth_tvchain.h"
    16 #include "gmyth_remote_util.h"
    17 
    18 #include "mmyth_ui.h"
    19 #include "mmyth_tvplayer.h"
    20 
    21 static void
    22 cb_destroy (GtkWidget * widget, gpointer data)
    23 {
    24     MMythUi *mmyth_ui = (MMythUi *) data;
    25 
    26     if (mmyth_ui->tvplayer != NULL) {
    27     	if (mmyth_tvplayer_is_playing (mmyth_ui->tvplayer) )
    28     		mmyth_tvplayer_stop_playing (mmyth_ui->tvplayer);
    29     }
    30 
    31 	mmyth_ui_finalize (mmyth_ui);
    32 	
    33     gtk_main_quit ();
    34 }
    35 
    36 #ifdef NDEBUG
    37 static void
    38 debug_error_func( const gchar*log_domain, GLogLevelFlags log_level, const gchar *message,
    39 	gpointer user_data )
    40 
    41 {
    42 	/* leave this with NO print out messages, once you need to disable debug messages! */
    43 	//g_print ( "[%s] DEBUG messages disabled!\n", __FUNCTION__ );
    44 }
    45 #endif
    46 
    47 gint
    48 main (gint argc, gchar * argv[])
    49 {
    50     GtkWidget *window;
    51     MMythUi *mmyth_ui;
    52 #ifdef MAEMO_PLATFORM
    53     HildonProgram *program = NULL;
    54 #endif
    55 
    56     /* init threads */
    57     g_thread_init (NULL);
    58 
    59     /* Initializes GTK */
    60     gtk_init (&argc, &argv);
    61     gst_init (&argc, &argv);
    62 #ifdef NDEBUG
    63  g_log_set_default_handler( debug_error_func, NULL );
    64 #endif
    65 
    66     /* Init libmmyth context */
    67     gmyth_context_initialize ();
    68 	
    69 #ifndef MAEMO_PLATFORM
    70     /* create the main window */
    71     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    72     gtk_widget_set_size_request (window, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT);
    73     gtk_window_set_title (GTK_WINDOW (window), "Mythtv Frontend");
    74 #else
    75     /* Creating Hildonized main view */
    76     program = HILDON_PROGRAM(hildon_program_get_instance());
    77     window = hildon_window_new();
    78 
    79     //g_signal_connect(G_OBJECT(window), "delete_event", gtk_main_quit, NULL);
    80 
    81     hildon_program_add_window(program, HILDON_WINDOW (window));
    82     g_set_application_name("Maemo Mythtv"); 
    83 #endif
    84    
    85     /* Initializes MMyth Widgets */
    86 #ifdef MAEMO_PLATFORM
    87     mmyth_ui = mmyth_ui_initialize (program, window);
    88 #else    
    89     mmyth_ui = mmyth_ui_initialize (window);
    90 #endif
    91     
    92     //mmyth_ui->loop = g_main_loop_new (NULL, FALSE);
    93 
    94     /* Connect destroy signal handling */
    95     g_signal_connect (window, "destroy", G_CALLBACK (cb_destroy), mmyth_ui);
    96 
    97     /* Shows main window and start gtk loop */
    98     gtk_widget_show (window);
    99 
   100     gtk_main ();
   101 
   102     return 0;
   103 }
   104