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