maemo-ui/src/mmyth_main.c
branchtrunk
changeset 57 c83c59b22fe1
child 64 f926338c6952
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/maemo-ui/src/mmyth_main.c	Fri Oct 27 00:11:21 2006 +0100
     1.3 @@ -0,0 +1,104 @@
     1.4 +
     1.5 +#include <gtk/gtk.h>
     1.6 +
     1.7 +#include "config.h"
     1.8 +
     1.9 +#ifdef MAEMO_PLATFORM
    1.10 +#include "hildon-widgets/hildon-program.h"
    1.11 +#include "hildon-widgets/hildon-window.h"
    1.12 +#endif
    1.13 +
    1.14 +
    1.15 +#include "gmyth_remote_encoder.h"
    1.16 +#include "gmyth_settings.h"
    1.17 +#include "gmyth_context.h"
    1.18 +#include "gmyth_tvchain.h"
    1.19 +#include "gmyth_remote_util.h"
    1.20 +
    1.21 +#include "mmyth_ui.h"
    1.22 +#include "mmyth_tvplayer.h"
    1.23 +
    1.24 +static void
    1.25 +cb_destroy (GtkWidget * widget, gpointer data)
    1.26 +{
    1.27 +    MMythUi *mmyth_ui = (MMythUi *) data;
    1.28 +
    1.29 +    if (mmyth_ui->tvplayer != NULL) {
    1.30 +    	if (mmyth_tvplayer_is_playing (mmyth_ui->tvplayer) )
    1.31 +    		mmyth_tvplayer_stop_playing (mmyth_ui->tvplayer);
    1.32 +    }
    1.33 +
    1.34 +	mmyth_ui_finalize (mmyth_ui);
    1.35 +	
    1.36 +    gtk_main_quit ();
    1.37 +}
    1.38 +
    1.39 +#ifdef NDEBUG
    1.40 +static void
    1.41 +debug_error_func( const gchar*log_domain, GLogLevelFlags log_level, const gchar *message,
    1.42 +	gpointer user_data )
    1.43 +
    1.44 +{
    1.45 +	/* leave this with NO print out messages, once you need to disable debug messages! */
    1.46 +	//g_print ( "[%s] DEBUG messages disabled!\n", __FUNCTION__ );
    1.47 +}
    1.48 +#endif
    1.49 +
    1.50 +gint
    1.51 +main (gint argc, gchar * argv[])
    1.52 +{
    1.53 +    GtkWidget *window;
    1.54 +    MMythUi *mmyth_ui;
    1.55 +#ifdef MAEMO_PLATFORM
    1.56 +    HildonProgram *program = NULL;
    1.57 +#endif
    1.58 +
    1.59 +    /* init threads */
    1.60 +    g_thread_init (NULL);
    1.61 +
    1.62 +    /* Initializes GTK */
    1.63 +    gtk_init (&argc, &argv);
    1.64 +    gst_init (&argc, &argv);
    1.65 +#ifdef NDEBUG
    1.66 + g_log_set_default_handler( debug_error_func, NULL );
    1.67 +#endif
    1.68 +
    1.69 +    /* Init libmmyth context */
    1.70 +    gmyth_context_initialize ();
    1.71 +	
    1.72 +#ifndef MAEMO_PLATFORM
    1.73 +    /* create the main window */
    1.74 +    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    1.75 +    gtk_widget_set_size_request (window, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT);
    1.76 +    gtk_window_set_title (GTK_WINDOW (window), "Mythtv Frontend");
    1.77 +#else
    1.78 +    /* Creating Hildonized main view */
    1.79 +    program = HILDON_PROGRAM(hildon_program_get_instance());
    1.80 +    window = hildon_window_new();
    1.81 +
    1.82 +    //g_signal_connect(G_OBJECT(window), "delete_event", gtk_main_quit, NULL);
    1.83 +
    1.84 +    hildon_program_add_window(program, HILDON_WINDOW (window));
    1.85 +    g_set_application_name("Maemo Mythtv"); 
    1.86 +#endif
    1.87 +   
    1.88 +    /* Initializes MMyth Widgets */
    1.89 +#ifdef MAEMO_PLATFORM
    1.90 +    mmyth_ui = mmyth_ui_initialize (program, window);
    1.91 +#else    
    1.92 +    mmyth_ui = mmyth_ui_initialize (window);
    1.93 +#endif
    1.94 +    
    1.95 +    //mmyth_ui->loop = g_main_loop_new (NULL, FALSE);
    1.96 +
    1.97 +    /* Connect destroy signal handling */
    1.98 +    g_signal_connect (window, "destroy", G_CALLBACK (cb_destroy), mmyth_ui);
    1.99 +
   1.100 +    /* Shows main window and start gtk loop */
   1.101 +    gtk_widget_show (window);
   1.102 +
   1.103 +    gtk_main ();
   1.104 +
   1.105 +    return 0;
   1.106 +}
   1.107 +