1.1 --- a/maemo-ui/src/mmyth_uicommon.c Fri Jan 05 19:27:27 2007 +0000
1.2 +++ b/maemo-ui/src/mmyth_uicommon.c Wed Jul 04 08:33:19 2007 +0100
1.3 @@ -7,128 +7,150 @@
1.4 #include "mmyth_ui.h"
1.5
1.6 static void
1.7 -refresh_time_on_screen (GtkWidget *label)
1.8 +refresh_time_on_screen(GtkWidget * label)
1.9 {
1.10 - time_t real_time;
1.11 - struct tm sched_time;
1.12 - GString *time_showed;
1.13 + time_t real_time;
1.14 + struct tm sched_time;
1.15 + GString *time_showed;
1.16
1.17 - time_showed = g_string_new("");
1.18 - time(&real_time);
1.19 + time_showed = g_string_new("");
1.20 + time(&real_time);
1.21
1.22 - if (localtime_r((time_t *)&real_time, &sched_time) == NULL) {
1.23 - g_error ("localtime_r error in mmyth_epg_grid_view!\n");
1.24 + if (localtime_r((time_t *) & real_time, &sched_time) == NULL) {
1.25 + g_error("localtime_r error in mmyth_epg_grid_view!\n");
1.26 return;
1.27 }
1.28
1.29 - g_string_printf(time_showed, "%d:%02d:%02d",
1.30 - sched_time.tm_hour,
1.31 - sched_time.tm_min,
1.32 - sched_time.tm_sec);
1.33 + g_string_printf(time_showed, "%d:%02d:%02d",
1.34 + sched_time.tm_hour,
1.35 + sched_time.tm_min, sched_time.tm_sec);
1.36
1.37 - gtk_label_set_text (GTK_LABEL(label), time_showed->str);
1.38 + gtk_label_set_text(GTK_LABEL(label), time_showed->str);
1.39 }
1.40
1.41 -MMythUiCommon *
1.42 -mmyth_uicommon_new (GtkWidget * main_widget, const gchar * label1,
1.43 - const gchar * label2, const gchar * label3)
1.44 +MMythUiCommon *
1.45 +mmyth_uicommon_new(GtkWidget * main_widget, const gchar * label1,
1.46 + const gchar * label2, const gchar * label3)
1.47 {
1.48
1.49 - MMythUiCommon *ui_common = g_new0 (MMythUiCommon, 1);
1.50 -
1.51 + MMythUiCommon *ui_common = g_new0(MMythUiCommon, 1);
1.52 +
1.53 if (!main_widget) {
1.54 - g_warning ("MMythUICommon created with a NULL main widget\n");
1.55 + g_warning("MMythUICommon created with a NULL main widget\n");
1.56 }
1.57 -
1.58 +
1.59 ui_common->main_widget = main_widget;
1.60
1.61 ui_common->event_box = gtk_event_box_new();
1.62 -
1.63 - /* Vertical box that divides the control area into two (buttons + clock) */
1.64 - ui_common->vbox = gtk_vbox_new (FALSE, 0); /* spacing */
1.65 - gtk_container_set_border_width(GTK_CONTAINER (ui_common->vbox), 4);
1.66 -
1.67 - gtk_container_add (GTK_CONTAINER (ui_common->event_box),
1.68 - ui_common->vbox);
1.69 - gtk_widget_modify_bg(ui_common->event_box, GTK_STATE_NORMAL, &main_bg_color);
1.70 -
1.71 - /* Vertical box that divides the control area into four */
1.72 - ui_common->button_vbox = gtk_vbox_new (TRUE, 0); /* spacing */
1.73
1.74 - gtk_container_set_border_width (GTK_CONTAINER (ui_common->button_vbox), 0);
1.75 + /*
1.76 + * Vertical box that divides the control area into two (buttons +
1.77 + * clock)
1.78 + */
1.79 + ui_common->vbox = gtk_vbox_new(FALSE, 0); /* spacing */
1.80 + gtk_container_set_border_width(GTK_CONTAINER(ui_common->vbox), 4);
1.81
1.82 - /* The button 1 */
1.83 - ui_common->button1 = gtk_button_new_with_label (label1);
1.84 - gtk_widget_modify_bg(ui_common->button1, GTK_STATE_NORMAL, &main_bg_color);
1.85 - gtk_widget_set_size_request (ui_common->button1, BUTTON_WIDTH,
1.86 - BUTTON_HEIGHT);
1.87 + gtk_container_add(GTK_CONTAINER(ui_common->event_box),
1.88 + ui_common->vbox);
1.89 + gtk_widget_modify_bg(ui_common->event_box, GTK_STATE_NORMAL,
1.90 + &main_bg_color);
1.91
1.92 - /* The button 2 */
1.93 - ui_common->button2 = gtk_button_new_with_label (label2);
1.94 - gtk_widget_modify_bg(ui_common->button2, GTK_STATE_NORMAL, &main_bg_color);
1.95 - gtk_widget_set_size_request (ui_common->button2, BUTTON_WIDTH,
1.96 - BUTTON_HEIGHT);
1.97 + /*
1.98 + * Vertical box that divides the control area into four
1.99 + */
1.100 + ui_common->button_vbox = gtk_vbox_new(TRUE, 0); /* spacing */
1.101
1.102 - /* The button 3 */
1.103 - ui_common->button3 = gtk_button_new_with_label (label3);
1.104 - gtk_widget_modify_bg(ui_common->button3, GTK_STATE_NORMAL, &main_bg_color);
1.105 - gtk_widget_set_size_request (ui_common->button3, BUTTON_WIDTH,
1.106 - BUTTON_HEIGHT);
1.107 + gtk_container_set_border_width(GTK_CONTAINER(ui_common->button_vbox),
1.108 + 0);
1.109
1.110 - /* The clock label */
1.111 - ui_common->label = gtk_label_new ("Starting...");
1.112 - gtk_widget_show (ui_common->label);
1.113 - ui_common->source_id = g_timeout_add(500, (GSourceFunc) refresh_time_on_screen, ui_common->label);
1.114 + /*
1.115 + * The button 1
1.116 + */
1.117 + ui_common->button1 = gtk_button_new_with_label(label1);
1.118 + gtk_widget_modify_bg(ui_common->button1, GTK_STATE_NORMAL,
1.119 + &main_bg_color);
1.120 + gtk_widget_set_size_request(ui_common->button1, BUTTON_WIDTH,
1.121 + BUTTON_HEIGHT);
1.122
1.123 - /* Packing components */
1.124 - gtk_box_pack_start (GTK_BOX (ui_common->vbox),
1.125 - ui_common->button_vbox, TRUE, TRUE, 0);
1.126 + /*
1.127 + * The button 2
1.128 + */
1.129 + ui_common->button2 = gtk_button_new_with_label(label2);
1.130 + gtk_widget_modify_bg(ui_common->button2, GTK_STATE_NORMAL,
1.131 + &main_bg_color);
1.132 + gtk_widget_set_size_request(ui_common->button2, BUTTON_WIDTH,
1.133 + BUTTON_HEIGHT);
1.134
1.135 - gtk_box_pack_start (GTK_BOX (ui_common->vbox),
1.136 - ui_common->label, FALSE, FALSE, 0);
1.137 + /*
1.138 + * The button 3
1.139 + */
1.140 + ui_common->button3 = gtk_button_new_with_label(label3);
1.141 + gtk_widget_modify_bg(ui_common->button3, GTK_STATE_NORMAL,
1.142 + &main_bg_color);
1.143 + gtk_widget_set_size_request(ui_common->button3, BUTTON_WIDTH,
1.144 + BUTTON_HEIGHT);
1.145
1.146 - gtk_box_pack_start (GTK_BOX (ui_common->button_vbox),
1.147 - ui_common->button1, FALSE, FALSE, 0);
1.148 + /*
1.149 + * The clock label
1.150 + */
1.151 + ui_common->label = gtk_label_new("Starting...");
1.152 + gtk_widget_show(ui_common->label);
1.153 + ui_common->source_id =
1.154 + g_timeout_add(500, (GSourceFunc) refresh_time_on_screen,
1.155 + ui_common->label);
1.156
1.157 - gtk_box_pack_start (GTK_BOX (ui_common->button_vbox),
1.158 - ui_common->button2, FALSE, FALSE, 0);
1.159 + /*
1.160 + * Packing components
1.161 + */
1.162 + gtk_box_pack_start(GTK_BOX(ui_common->vbox),
1.163 + ui_common->button_vbox, TRUE, TRUE, 0);
1.164
1.165 - gtk_box_pack_start (GTK_BOX (ui_common->button_vbox),
1.166 - ui_common->button3, FALSE, FALSE, 0);
1.167 + gtk_box_pack_start(GTK_BOX(ui_common->vbox),
1.168 + ui_common->label, FALSE, FALSE, 0);
1.169
1.170 - gtk_widget_show_all (ui_common->event_box);
1.171 + gtk_box_pack_start(GTK_BOX(ui_common->button_vbox),
1.172 + ui_common->button1, FALSE, FALSE, 0);
1.173
1.174 - /* FIXME: mmyth_ui->video_alignment == NULL when mmyth_player_init fails */
1.175 - if(ui_common->main_widget != NULL)
1.176 - g_object_ref (ui_common->main_widget);
1.177 -
1.178 - g_object_ref (ui_common->vbox);
1.179 - g_object_ref (ui_common->button_vbox);
1.180 - g_object_ref (ui_common->label);
1.181 - g_object_ref (ui_common->button1);
1.182 - g_object_ref (ui_common->button2);
1.183 - g_object_ref (ui_common->button3);
1.184 - g_object_ref (ui_common->event_box);
1.185 + gtk_box_pack_start(GTK_BOX(ui_common->button_vbox),
1.186 + ui_common->button2, FALSE, FALSE, 0);
1.187 +
1.188 + gtk_box_pack_start(GTK_BOX(ui_common->button_vbox),
1.189 + ui_common->button3, FALSE, FALSE, 0);
1.190 +
1.191 + gtk_widget_show_all(ui_common->event_box);
1.192 +
1.193 + /*
1.194 + * FIXME: mmyth_ui->video_alignment == NULL when mmyth_player_init
1.195 + * fails
1.196 + */
1.197 + if (ui_common->main_widget != NULL)
1.198 + g_object_ref(ui_common->main_widget);
1.199 +
1.200 + g_object_ref(ui_common->vbox);
1.201 + g_object_ref(ui_common->button_vbox);
1.202 + g_object_ref(ui_common->label);
1.203 + g_object_ref(ui_common->button1);
1.204 + g_object_ref(ui_common->button2);
1.205 + g_object_ref(ui_common->button3);
1.206 + g_object_ref(ui_common->event_box);
1.207 return ui_common;
1.208 }
1.209
1.210 void
1.211 -mmyth_uicommon_free (MMythUiCommon *ui_common)
1.212 +mmyth_uicommon_free(MMythUiCommon * ui_common)
1.213 {
1.214 - g_debug ("[%s] Clean uicommon used memory", __FUNCTION__);
1.215 + g_debug("[%s] Clean uicommon used memory", __FUNCTION__);
1.216
1.217 - g_source_remove (ui_common->source_id);
1.218 -
1.219 - g_object_unref (ui_common->main_widget);
1.220 - g_object_unref (ui_common->vbox);
1.221 - g_object_unref (ui_common->button_vbox);
1.222 - g_object_unref (ui_common->label);
1.223 - g_object_unref (ui_common->button1);
1.224 - g_object_unref (ui_common->button2);
1.225 - g_object_unref (ui_common->button3);
1.226 - g_object_unref (ui_common->event_box);
1.227 -
1.228 - g_free (ui_common);
1.229 + g_source_remove(ui_common->source_id);
1.230 +
1.231 + g_object_unref(ui_common->main_widget);
1.232 + g_object_unref(ui_common->vbox);
1.233 + g_object_unref(ui_common->button_vbox);
1.234 + g_object_unref(ui_common->label);
1.235 + g_object_unref(ui_common->button1);
1.236 + g_object_unref(ui_common->button2);
1.237 + g_object_unref(ui_common->button3);
1.238 + g_object_unref(ui_common->event_box);
1.239 +
1.240 + g_free(ui_common);
1.241 }
1.242 -
1.243 -