4 #include <gst/interfaces/xoverlay.h>
7 #include "mmyth_uicommon.h"
9 #include "mmyth_videoplayer.h"
10 #include "mmyth_esg_grid_view.h"
11 #include "mmyth_common.h"
14 static gint button_press_handler (GtkWidget *widget, GdkEvent *event);
16 MMythUiCommon *create_main_view (MMythUi * mmyth_ui);
17 MMythUiCommon *create_video_view (MMythUi * mmyth_ui);
18 MMythUiCommon *create_esg_grid_view (MMythUi * mmyth_ui);
19 static void cb_video_close_button (GtkButton * button, gpointer user_data);
21 /* main box from button box separator*/
22 static GtkWidget *main_vseparator = NULL;
24 GdkPixbuf *icon_sports, *icon_news,
25 *icon_movies, *icon_shows, *icon_default;
27 /* FIXME: UGLY HACK */
28 MMythUi *popup_mmyth_ui;
31 mmyth_ui_initialize_icons ()
37 gdk_pixbuf_new_from_file ("../pixmaps/ico_sports.png", &error);
39 icon_sports = gdk_pixbuf_new_from_file (PIX_DIR "ico_sports.png", &error);
43 g_warning ("Could not load icon sports: %s\n", error->message);
49 icon_news = gdk_pixbuf_new_from_file ("../pixmaps/ico_news.png", &error);
51 icon_news = gdk_pixbuf_new_from_file (PIX_DIR "ico_news.png", &error);
55 g_warning ("Could not load icon news: %s\n", error->message);
62 gdk_pixbuf_new_from_file ("../pixmaps/ico_movies.png", &error);
64 icon_movies = gdk_pixbuf_new_from_file (PIX_DIR "ico_movies.png", &error);
67 g_warning ("Could not load icon movies: %s\n", error->message);
73 icon_shows = gdk_pixbuf_new_from_file ("../pixmaps/ico_shows.png", &error);
75 icon_shows = gdk_pixbuf_new_from_file (PIX_DIR "ico_shows.png", &error);
78 g_warning ("Could not load icon shows: %s\n", error->message);
85 gdk_pixbuf_new_from_file ("../pixmaps/ico_default.png", &error);
87 icon_default = gdk_pixbuf_new_from_file (PIX_DIR "ico_default.png", &error);
91 g_warning ("Could not load icon default: %s\n", error->message);
99 mmyth_ui_initialize (GtkWidget * main_window)
104 //mmyth_settings_load ( );
106 mmyth_ui = g_new0 (MMythUi, 1);
108 mmyth_ui->main_window = main_window;
110 /* Horizontal box that divides the view into control and video area */
111 mmyth_ui->main_hbox = gtk_hbox_new (FALSE, 0);
112 gtk_widget_show (mmyth_ui->main_hbox);
113 g_object_ref (mmyth_ui->main_hbox);
115 mmyth_ui_initialize_icons ();
117 main_bg_color.red = 65000;
118 main_bg_color.green = 65000;
119 main_bg_color.blue = 65000;
121 // Main widget is mmyth_ui->main_hbox
122 mmyth_ui->main_uicommon = create_main_view (mmyth_ui);
123 mmyth_ui->video_uicommon = create_video_view (mmyth_ui);
124 mmyth_ui->esg_grid_uicommon = create_esg_grid_view (mmyth_ui);
127 /* FIXME: URGENT ugly, ugly hack */
128 popup_mmyth_ui = mmyth_ui;
129 g_signal_connect (G_OBJECT (mmyth_ui->main_hbox), "event",
130 G_CALLBACK (button_press_handler),
131 G_OBJECT (mmyth_ui->main_hbox));
133 gtk_container_add (GTK_CONTAINER (mmyth_ui->main_window),
134 mmyth_ui->main_hbox);
136 /* Add the gst video widget to hbox. It should never be removed. */
137 /* FIXME: mmyth_ui->video_alignment == NULL when mmyth_player_init fails */
138 if(mmyth_ui->video_alignment != NULL)
139 gtk_box_pack_start (GTK_BOX (mmyth_ui->main_hbox),
140 mmyth_ui->video_alignment, TRUE, TRUE, 0);
142 mmyth_ui_set_widget (mmyth_ui, mmyth_ui->main_uicommon);
148 mmyth_ui_finalize (MMythUi * mmyth_ui)
150 if (mmyth_ui != NULL)
153 mmyth_uicommon_unref_all (mmyth_ui->main_uicommon);
154 mmyth_uicommon_unref_all (mmyth_ui->video_uicommon);
155 mmyth_uicommon_unref_all (mmyth_ui->esgcurrent_uicommon);
159 mmyth_ui_set_widget (MMythUi * mmyth_ui, MMythUiCommon * new_uicommon)
161 if (mmyth_ui->current_uicommon) {
162 if (mmyth_ui->current_uicommon == mmyth_ui->video_uicommon) {
163 gtk_widget_hide (mmyth_ui->current_uicommon->main_widget);
164 gtk_widget_hide (mmyth_ui->videow);
167 gtk_container_remove (GTK_CONTAINER (mmyth_ui->main_hbox),
168 mmyth_ui->current_uicommon->main_widget);
171 gtk_container_remove (GTK_CONTAINER (mmyth_ui->main_hbox),
172 mmyth_ui->current_uicommon->event_box);
173 gtk_container_remove (GTK_CONTAINER (mmyth_ui->main_hbox),
178 if (new_uicommon->main_widget == mmyth_ui->video_alignment) {
179 //gst_player_video_show (GST_PLAYER_VIDEO(mmyth_ui->videow));
180 gtk_widget_show (mmyth_ui->video_alignment);
181 gtk_widget_show (mmyth_ui->videow);
184 /* FIXME: Fst call is NULL when mmyth_player_init fails */
185 if(mmyth_ui->video_alignment != NULL)
186 gtk_widget_hide (mmyth_ui->video_alignment);
187 /* FIXME: Fst call is NULL when mmyth_player_init fails */
188 if(mmyth_ui->videow != NULL)
189 gtk_widget_hide (mmyth_ui->videow);
191 gtk_box_pack_start (GTK_BOX (mmyth_ui->main_hbox),
192 new_uicommon->main_widget, TRUE, TRUE, 0);
195 if(main_vseparator == NULL) {
196 /* FIXME: should free this variable*/
197 main_vseparator = gtk_vseparator_new();
198 g_object_ref (main_vseparator);
200 gtk_box_pack_start (GTK_BOX (mmyth_ui->main_hbox),
201 main_vseparator, FALSE, FALSE, 0);
202 gtk_widget_show (main_vseparator);
204 gtk_box_pack_end (GTK_BOX (mmyth_ui->main_hbox), new_uicommon->event_box, FALSE,
207 mmyth_ui->current_uicommon = new_uicommon;
211 /* The close callback is the same for all windows*/
213 cb_not_impl_button (GtkButton * button, gpointer user_data)
215 MMythUi *mmyth_ui = (MMythUi *) user_data;
217 GtkWidget *msg_dialog = gtk_message_dialog_new (
218 GTK_WINDOW(mmyth_ui->main_window),
220 GTK_DIALOG_DESTROY_WITH_PARENT,
223 "Feature not implemented yet");
224 gtk_widget_set_size_request (msg_dialog, 300, 120);
226 gtk_dialog_run (GTK_DIALOG (msg_dialog));
228 gtk_widget_destroy(GTK_WIDGET(msg_dialog));
231 /******************************************************************************
232 * POPUP MENU WIDGET METHODS *
233 *****************************************************************************/
236 detacher (GtkWidget *attach_widget,GtkMenu *menu)
241 menu_item_settings_cb (GtkMenuItem *menuitem,
244 /* MMythUi *mmyth_ui = (MMythUi *) user_data; */
247 MMythUi *mmyth_ui = popup_mmyth_ui;
249 settings_show_dialog (GTK_WINDOW (mmyth_ui->main_window));
254 do_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
257 int button, event_time;
259 popup = gtk_menu_new ();
261 /* ... add menu items ... */
262 GtkWidget *menu_item = gtk_menu_item_new_with_label("Settings");
263 gtk_menu_append(popup, menu_item);
265 g_signal_connect (G_OBJECT(menu_item), "activate",
266 G_CALLBACK (menu_item_settings_cb), NULL);
270 button = event->button;
271 event_time = event->time;
276 event_time = gtk_get_current_event_time ();
279 //gtk_menu_attach_to_widget (GTK_MENU (popup), my_widget, detacher);
280 gtk_menu_popup (GTK_MENU (popup), NULL, NULL, NULL, NULL,
282 gtk_widget_show_all(popup);
285 /* Respond to a button-press by posting a menu passed in as widget.
287 * Note that the "widget" argument is the menu being posted, NOT
288 * the button that was pressed.
292 button_press_handler (GtkWidget *widget, GdkEvent *event)
295 if (event->type == GDK_BUTTON_PRESS) {
296 GdkEventButton *bevent = (GdkEventButton *) event;
297 /* Ignore double-clicks and triple-clicks */
298 if (bevent->button == 3)
300 do_popup_menu (widget, bevent);
305 /* Tell calling code that we have not handled this event; pass it on. */
310 /******************************************************************************
311 * MAIN APP VIEW METHODS *
312 *****************************************************************************/
314 /* The close callback is the same for all windows*/
316 cb_close_button (GtkButton * button, gpointer user_data)
318 MMythUi *mmyth_ui = (MMythUi *) user_data;
320 mmyth_ui_set_widget (mmyth_ui, mmyth_ui->main_uicommon);
325 cb_esg_today_button (GtkButton * button, gpointer user_data)
327 MMythUi *mmyth_ui = (MMythUi *) user_data;
329 mmyth_ui_set_widget (mmyth_ui, mmyth_ui->esg_grid_uicommon);
334 create_main_view (MMythUi * mmyth_ui)
336 MMythUiCommon *ui_common;
337 GtkWidget *main_widget;
342 image = gtk_image_new_from_file ("../pixmaps/main_logo.gif");
344 image = gtk_image_new_from_file ("../pixmaps/main_logo.gif");
347 main_widget = gtk_event_box_new();
349 gtk_container_add (GTK_CONTAINER (main_widget),
353 gtk_widget_show_all (main_widget);
354 g_object_ref (main_widget);
356 ui_common = mmyth_uicommon_new (main_widget,
357 "Channels", "Current", "Today");
361 g_signal_connect (G_OBJECT (ui_common->button1), "clicked",
362 G_CALLBACK (cb_channels_button), mmyth_ui);
363 g_signal_connect (G_OBJECT (ui_common->button2), "clicked",
364 G_CALLBACK (cb_esg_current_button), mmyth_ui);
365 g_signal_connect (G_OBJECT (ui_common->button3), "clicked",
366 G_CALLBACK (cb_esg_today_button), mmyth_ui);
373 /******************************************************************************
374 * ESG GRID VIEW METHODS *
375 *****************************************************************************/
378 cb_esg_grid_view_button (GtkButton * button, gpointer user_data)
381 MMythUi *mmyth_ui = (MMythUi *) user_data;
382 guint32 service_id = -1;
384 // Retrieves the user selected service ID
385 DVBHScheduleEvent *schedule = (DVBHScheduleEvent *) mmyth_esg_grid_view_get_selected_schedule();
387 if(schedule != NULL) {
388 service_id = schedule->service->number;
389 mmyth_play_channel (mmyth_ui, service_id);
395 create_esg_grid_view (MMythUi * mmyth_ui)
397 MMythUiCommon *ui_common;
399 GtkWidget *esg_grid_view = GTK_WIDGET (esg_grid_view_new (mmyth_ui));
402 ui_common = mmyth_uicommon_new (esg_grid_view,
408 g_signal_connect (G_OBJECT (ui_common->button1), "clicked",
409 G_CALLBACK (cb_esg_grid_view_button), mmyth_ui);
410 g_signal_connect (G_OBJECT (ui_common->button2), "clicked",
411 G_CALLBACK (cb_not_impl_button), mmyth_ui);
412 g_signal_connect (G_OBJECT (ui_common->button3), "clicked",
413 G_CALLBACK (cb_close_button), mmyth_ui);
418 /******************************************************************************
419 * GST VIDEO WIDGET METHODS *
420 *****************************************************************************/
423 cb_video_close_button (GtkButton * button, gpointer user_data)
425 MMythUi *mmyth_ui = (MMythUi *) user_data;
428 mmyth_player_stop (mmyth_ui);
431 mmyth_ui_set_widget (mmyth_ui, mmyth_ui->main_uicommon);
435 create_video_view (MMythUi * mmyth_ui)
438 MMythUiCommon *ui_common;
441 mmyth_player_init (mmyth_ui);
444 ui_common = mmyth_uicommon_new (mmyth_ui->video_alignment,
445 " Full\nScreen", "Other\nServices",
448 g_signal_connect (G_OBJECT (ui_common->button1), "clicked",
449 G_CALLBACK (cb_not_impl_button), mmyth_ui);
450 g_signal_connect (G_OBJECT (ui_common->button2), "clicked",
451 G_CALLBACK (cb_not_impl_button), mmyth_ui);
452 g_signal_connect (G_OBJECT (ui_common->button3), "clicked",
453 G_CALLBACK (cb_video_close_button), mmyth_ui);