[svn r261] A lot of fixes to the gmyth-0.1 library's external references.
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",
29 gtk_label_set_text (GTK_LABEL(label), time_showed->str);
33 mmyth_uicommon_new (GtkWidget * main_widget, const gchar * label1,
34 const gchar * label2, const gchar * label3)
37 MMythUiCommon *ui_common = g_new0 (MMythUiCommon, 1);
40 g_warning ("MMythUICommon created with a NULL main widget\n");
43 ui_common->main_widget = main_widget;
45 ui_common->event_box = gtk_event_box_new();
47 /* Vertical box that divides the control area into two (buttons + clock) */
48 ui_common->vbox = gtk_vbox_new (FALSE, 0); /* spacing */
49 gtk_container_set_border_width(GTK_CONTAINER (ui_common->vbox), 4);
51 gtk_container_add (GTK_CONTAINER (ui_common->event_box),
53 gtk_widget_modify_bg(ui_common->event_box, GTK_STATE_NORMAL, &main_bg_color);
55 /* Vertical box that divides the control area into four */
56 ui_common->button_vbox = gtk_vbox_new (TRUE, 0); /* spacing */
58 gtk_container_set_border_width (GTK_CONTAINER (ui_common->button_vbox), 0);
61 ui_common->button1 = gtk_button_new_with_label (label1);
62 gtk_widget_modify_bg(ui_common->button1, GTK_STATE_NORMAL, &main_bg_color);
63 gtk_widget_set_size_request (ui_common->button1, BUTTON_WIDTH,
67 ui_common->button2 = gtk_button_new_with_label (label2);
68 gtk_widget_modify_bg(ui_common->button2, GTK_STATE_NORMAL, &main_bg_color);
69 gtk_widget_set_size_request (ui_common->button2, BUTTON_WIDTH,
73 ui_common->button3 = gtk_button_new_with_label (label3);
74 gtk_widget_modify_bg(ui_common->button3, GTK_STATE_NORMAL, &main_bg_color);
75 gtk_widget_set_size_request (ui_common->button3, BUTTON_WIDTH,
79 ui_common->label = gtk_label_new ("Starting...");
80 gtk_widget_show (ui_common->label);
81 ui_common->source_id = g_timeout_add(500, (GSourceFunc) refresh_time_on_screen, ui_common->label);
83 /* Packing components */
84 gtk_box_pack_start (GTK_BOX (ui_common->vbox),
85 ui_common->button_vbox, TRUE, TRUE, 0);
87 gtk_box_pack_start (GTK_BOX (ui_common->vbox),
88 ui_common->label, FALSE, FALSE, 0);
90 gtk_box_pack_start (GTK_BOX (ui_common->button_vbox),
91 ui_common->button1, FALSE, FALSE, 0);
93 gtk_box_pack_start (GTK_BOX (ui_common->button_vbox),
94 ui_common->button2, FALSE, FALSE, 0);
96 gtk_box_pack_start (GTK_BOX (ui_common->button_vbox),
97 ui_common->button3, FALSE, FALSE, 0);
99 gtk_widget_show_all (ui_common->event_box);
101 /* FIXME: mmyth_ui->video_alignment == NULL when mmyth_player_init fails */
102 if(ui_common->main_widget != NULL)
103 g_object_ref (ui_common->main_widget);
105 g_object_ref (ui_common->vbox);
106 g_object_ref (ui_common->button_vbox);
107 g_object_ref (ui_common->label);
108 g_object_ref (ui_common->button1);
109 g_object_ref (ui_common->button2);
110 g_object_ref (ui_common->button3);
111 g_object_ref (ui_common->event_box);
116 mmyth_uicommon_free (MMythUiCommon *ui_common)
118 g_debug ("[%s] Clean uicommon used memory", __FUNCTION__);
120 g_source_remove (ui_common->source_id);
122 g_object_unref (ui_common->main_widget);
123 g_object_unref (ui_common->vbox);
124 g_object_unref (ui_common->button_vbox);
125 g_object_unref (ui_common->label);
126 g_object_unref (ui_common->button1);
127 g_object_unref (ui_common->button2);
128 g_object_unref (ui_common->button3);
129 g_object_unref (ui_common->event_box);