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