maemo-ui-old/src/mmyth_main.c
author renatofilho
Fri Jan 04 16:46:07 2008 +0000 (2008-01-04)
branchtrunk
changeset 887 9434eecdece9
parent 754 cb885ee44618
permissions -rw-r--r--
[svn r893] automatized changelog dist var
     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,
    37                  const gchar * message, gpointer user_data)
    38 {
    39     /*
    40      * leave this with NO print out messages, once you need to disable
    41      * debug messages! 
    42      */
    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     /*
    57      * init threads 
    58      */
    59     g_thread_init(NULL);
    60 
    61     /*
    62      * Initializes GTK 
    63      */
    64     gtk_init(&argc, &argv);
    65     gst_init(&argc, &argv);
    66 #ifdef NDEBUG
    67     g_log_set_default_handler(debug_error_func, NULL);
    68 #endif
    69 
    70     /*
    71      * Init libmmyth context 
    72      */
    73     /*
    74      * TODO 
    75      */
    76 #ifndef MAEMO_PLATFORM
    77     /*
    78      * create the main window 
    79      */
    80     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    81     gtk_widget_set_size_request(window, MAIN_WINDOW_WIDTH,
    82                                 MAIN_WINDOW_HEIGHT);
    83     gtk_window_set_title(GTK_WINDOW(window), "Mythtv Frontend");
    84 #else
    85     /*
    86      * Creating Hildonized main view 
    87      */
    88     program = HILDON_PROGRAM(hildon_program_get_instance());
    89     window = hildon_window_new();
    90 
    91     // g_signal_connect(G_OBJECT(window), "delete_event", gtk_main_quit,
    92     // NULL);
    93 
    94     hildon_program_add_window(program, HILDON_WINDOW(window));
    95     g_set_application_name("Maemo Mythtv");
    96 #endif
    97 
    98     /*
    99      * Initializes MMyth Widgets 
   100      */
   101 #ifdef MAEMO_PLATFORM
   102     mmyth_ui = mmyth_ui_initialize(program, window);
   103 #else
   104     mmyth_ui = mmyth_ui_initialize(window);
   105 #endif
   106 
   107     // mmyth_ui->loop = g_main_loop_new (NULL, FALSE);
   108 
   109     /*
   110      * Connect destroy signal handling 
   111      */
   112     g_signal_connect(window, "destroy", G_CALLBACK(cb_destroy), mmyth_ui);
   113 
   114     /*
   115      * Shows main window and start gtk loop 
   116      */
   117     gtk_widget_show(window);
   118 
   119     gtk_main();
   120 
   121     return 0;
   122 }