maemo-ui/src/mmyth_main.c
author rosfran
Wed Nov 22 20:21:46 2006 +0000 (2006-11-22)
branchtrunk
changeset 102 4f7789e3bfd4
parent 20 7174e23f7617
child 208 c3c073032757
permissions -rw-r--r--
[svn r103] Changed the way buffers are received from the MythTV backend; size can increase.
     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_recorder.h"
    12 #include "gmyth_settings.h"
    13 #include "gmyth_context.h"
    14 #include "gmyth_tvchain.h"
    15 #include "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     gmyth_context_initialize ();
    67 	
    68 #ifndef MAEMO_PLATFORM
    69     /* create the main window */
    70     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    71     gtk_widget_set_size_request (window, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT);
    72     gtk_window_set_title (GTK_WINDOW (window), "Mythtv Frontend");
    73 #else
    74     /* Creating Hildonized main view */
    75     program = HILDON_PROGRAM(hildon_program_get_instance());
    76     window = hildon_window_new();
    77 
    78     //g_signal_connect(G_OBJECT(window), "delete_event", gtk_main_quit, NULL);
    79 
    80     hildon_program_add_window(program, HILDON_WINDOW (window));
    81     g_set_application_name("Maemo Mythtv"); 
    82 #endif
    83    
    84     /* Initializes MMyth Widgets */
    85 #ifdef MAEMO_PLATFORM
    86     mmyth_ui = mmyth_ui_initialize (program, window);
    87 #else    
    88     mmyth_ui = mmyth_ui_initialize (window);
    89 #endif
    90     
    91     //mmyth_ui->loop = g_main_loop_new (NULL, FALSE);
    92 
    93     /* Connect destroy signal handling */
    94     g_signal_connect (window, "destroy", G_CALLBACK (cb_destroy), mmyth_ui);
    95 
    96     /* Shows main window and start gtk loop */
    97     gtk_widget_show (window);
    98 
    99     gtk_main ();
   100 
   101     return 0;
   102 }
   103