4 #include <glib/gprintf.h>
6 #include "mmyth_uicommon.h"
10 refresh_time_on_screen(GtkWidget * label)
16 time_showed = g_string_new("");
19 if (localtime_r((time_t *) & real_time, &sched_time) == NULL) {
20 g_error("localtime_r error in mmyth_epg_grid_view!\n");
24 g_string_printf(time_showed, "%d:%02d:%02d",
26 sched_time.tm_min, sched_time.tm_sec);
28 gtk_label_set_text(GTK_LABEL(label), time_showed->str);
32 mmyth_uicommon_new(GtkWidget * main_widget, const gchar * label1,
33 const gchar * label2, const gchar * label3)
36 MMythUiCommon *ui_common = g_new0(MMythUiCommon, 1);
39 g_warning("MMythUICommon created with a NULL main widget\n");
42 ui_common->main_widget = main_widget;
44 ui_common->event_box = gtk_event_box_new();
47 * Vertical box that divides the control area into two (buttons +
50 ui_common->vbox = gtk_vbox_new(FALSE, 0); /* spacing */
51 gtk_container_set_border_width(GTK_CONTAINER(ui_common->vbox), 4);
53 gtk_container_add(GTK_CONTAINER(ui_common->event_box),
55 gtk_widget_modify_bg(ui_common->event_box, GTK_STATE_NORMAL,
59 * Vertical box that divides the control area into four
61 ui_common->button_vbox = gtk_vbox_new(TRUE, 0); /* spacing */
63 gtk_container_set_border_width(GTK_CONTAINER(ui_common->button_vbox),
69 ui_common->button1 = gtk_button_new_with_label(label1);
70 gtk_widget_modify_bg(ui_common->button1, GTK_STATE_NORMAL,
72 gtk_widget_set_size_request(ui_common->button1, BUTTON_WIDTH,
78 ui_common->button2 = gtk_button_new_with_label(label2);
79 gtk_widget_modify_bg(ui_common->button2, GTK_STATE_NORMAL,
81 gtk_widget_set_size_request(ui_common->button2, BUTTON_WIDTH,
87 ui_common->button3 = gtk_button_new_with_label(label3);
88 gtk_widget_modify_bg(ui_common->button3, GTK_STATE_NORMAL,
90 gtk_widget_set_size_request(ui_common->button3, BUTTON_WIDTH,
96 ui_common->label = gtk_label_new("Starting...");
97 gtk_widget_show(ui_common->label);
98 ui_common->source_id =
99 g_timeout_add(500, (GSourceFunc) refresh_time_on_screen,
105 gtk_box_pack_start(GTK_BOX(ui_common->vbox),
106 ui_common->button_vbox, TRUE, TRUE, 0);
108 gtk_box_pack_start(GTK_BOX(ui_common->vbox),
109 ui_common->label, FALSE, FALSE, 0);
111 gtk_box_pack_start(GTK_BOX(ui_common->button_vbox),
112 ui_common->button1, FALSE, FALSE, 0);
114 gtk_box_pack_start(GTK_BOX(ui_common->button_vbox),
115 ui_common->button2, FALSE, FALSE, 0);
117 gtk_box_pack_start(GTK_BOX(ui_common->button_vbox),
118 ui_common->button3, FALSE, FALSE, 0);
120 gtk_widget_show_all(ui_common->event_box);
123 * FIXME: mmyth_ui->video_alignment == NULL when mmyth_player_init
126 if (ui_common->main_widget != NULL)
127 g_object_ref(ui_common->main_widget);
129 g_object_ref(ui_common->vbox);
130 g_object_ref(ui_common->button_vbox);
131 g_object_ref(ui_common->label);
132 g_object_ref(ui_common->button1);
133 g_object_ref(ui_common->button2);
134 g_object_ref(ui_common->button3);
135 g_object_ref(ui_common->event_box);
140 mmyth_uicommon_free(MMythUiCommon * ui_common)
142 g_debug("[%s] Clean uicommon used memory", __FUNCTION__);
144 g_source_remove(ui_common->source_id);
146 g_object_unref(ui_common->main_widget);
147 g_object_unref(ui_common->vbox);
148 g_object_unref(ui_common->button_vbox);
149 g_object_unref(ui_common->label);
150 g_object_unref(ui_common->button1);
151 g_object_unref(ui_common->button2);
152 g_object_unref(ui_common->button3);
153 g_object_unref(ui_common->event_box);