1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/maemo-ui-old/src/mmyth_main.c Thu Jan 31 19:56:16 2008 +0000
1.3 @@ -0,0 +1,122 @@
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 +#include <gmyth/gmyth_recorder.h>
1.15 +#include <gmyth/gmyth_backendinfo.h>
1.16 +#include <gmyth/gmyth_tvchain.h>
1.17 +#include <gmyth/gmyth_remote_util.h>
1.18 +
1.19 +#include "mmyth_ui.h"
1.20 +#include "mmyth_tvplayer.h"
1.21 +
1.22 +static void
1.23 +cb_destroy(GtkWidget * widget, gpointer data)
1.24 +{
1.25 + MMythUi *mmyth_ui = (MMythUi *) data;
1.26 +
1.27 + if (mmyth_ui->tvplayer != NULL) {
1.28 + if (mmyth_tvplayer_is_playing(mmyth_ui->tvplayer))
1.29 + mmyth_tvplayer_stop_playing(mmyth_ui->tvplayer);
1.30 + }
1.31 +
1.32 + mmyth_ui_finalize(mmyth_ui);
1.33 +
1.34 + gtk_main_quit();
1.35 +}
1.36 +
1.37 +#ifdef NDEBUG
1.38 +static void
1.39 +debug_error_func(const gchar * log_domain, GLogLevelFlags log_level,
1.40 + const gchar * message, gpointer user_data)
1.41 +{
1.42 + /*
1.43 + * leave this with NO print out messages, once you need to disable
1.44 + * debug messages!
1.45 + */
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 + /*
1.60 + * init threads
1.61 + */
1.62 + g_thread_init(NULL);
1.63 +
1.64 + /*
1.65 + * Initializes GTK
1.66 + */
1.67 + gtk_init(&argc, &argv);
1.68 + gst_init(&argc, &argv);
1.69 +#ifdef NDEBUG
1.70 + g_log_set_default_handler(debug_error_func, NULL);
1.71 +#endif
1.72 +
1.73 + /*
1.74 + * Init libmmyth context
1.75 + */
1.76 + /*
1.77 + * TODO
1.78 + */
1.79 +#ifndef MAEMO_PLATFORM
1.80 + /*
1.81 + * create the main window
1.82 + */
1.83 + window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1.84 + gtk_widget_set_size_request(window, MAIN_WINDOW_WIDTH,
1.85 + MAIN_WINDOW_HEIGHT);
1.86 + gtk_window_set_title(GTK_WINDOW(window), "Mythtv Frontend");
1.87 +#else
1.88 + /*
1.89 + * Creating Hildonized main view
1.90 + */
1.91 + program = HILDON_PROGRAM(hildon_program_get_instance());
1.92 + window = hildon_window_new();
1.93 +
1.94 + // g_signal_connect(G_OBJECT(window), "delete_event", gtk_main_quit,
1.95 + // NULL);
1.96 +
1.97 + hildon_program_add_window(program, HILDON_WINDOW(window));
1.98 + g_set_application_name("Maemo Mythtv");
1.99 +#endif
1.100 +
1.101 + /*
1.102 + * Initializes MMyth Widgets
1.103 + */
1.104 +#ifdef MAEMO_PLATFORM
1.105 + mmyth_ui = mmyth_ui_initialize(program, window);
1.106 +#else
1.107 + mmyth_ui = mmyth_ui_initialize(window);
1.108 +#endif
1.109 +
1.110 + // mmyth_ui->loop = g_main_loop_new (NULL, FALSE);
1.111 +
1.112 + /*
1.113 + * Connect destroy signal handling
1.114 + */
1.115 + g_signal_connect(window, "destroy", G_CALLBACK(cb_destroy), mmyth_ui);
1.116 +
1.117 + /*
1.118 + * Shows main window and start gtk loop
1.119 + */
1.120 + gtk_widget_show(window);
1.121 +
1.122 + gtk_main();
1.123 +
1.124 + return 0;
1.125 +}