diff -r c88244670b08 -r 361cb0686ff7 maemo-ui/src/mmyth_uicommon.c --- a/maemo-ui/src/mmyth_uicommon.c Fri Jan 05 19:27:27 2007 +0000 +++ b/maemo-ui/src/mmyth_uicommon.c Wed Jul 04 08:33:19 2007 +0100 @@ -7,128 +7,150 @@ #include "mmyth_ui.h" static void -refresh_time_on_screen (GtkWidget *label) +refresh_time_on_screen(GtkWidget * label) { - time_t real_time; - struct tm sched_time; - GString *time_showed; + time_t real_time; + struct tm sched_time; + GString *time_showed; - time_showed = g_string_new(""); - time(&real_time); + time_showed = g_string_new(""); + time(&real_time); - if (localtime_r((time_t *)&real_time, &sched_time) == NULL) { - g_error ("localtime_r error in mmyth_epg_grid_view!\n"); + if (localtime_r((time_t *) & real_time, &sched_time) == NULL) { + g_error("localtime_r error in mmyth_epg_grid_view!\n"); return; } - g_string_printf(time_showed, "%d:%02d:%02d", - sched_time.tm_hour, - sched_time.tm_min, - sched_time.tm_sec); + g_string_printf(time_showed, "%d:%02d:%02d", + sched_time.tm_hour, + sched_time.tm_min, sched_time.tm_sec); - gtk_label_set_text (GTK_LABEL(label), time_showed->str); + gtk_label_set_text(GTK_LABEL(label), time_showed->str); } -MMythUiCommon * -mmyth_uicommon_new (GtkWidget * main_widget, const gchar * label1, - const gchar * label2, const gchar * label3) +MMythUiCommon * +mmyth_uicommon_new(GtkWidget * main_widget, const gchar * label1, + const gchar * label2, const gchar * label3) { - MMythUiCommon *ui_common = g_new0 (MMythUiCommon, 1); - + MMythUiCommon *ui_common = g_new0(MMythUiCommon, 1); + if (!main_widget) { - g_warning ("MMythUICommon created with a NULL main widget\n"); + g_warning("MMythUICommon created with a NULL main widget\n"); } - + ui_common->main_widget = main_widget; ui_common->event_box = gtk_event_box_new(); - - /* Vertical box that divides the control area into two (buttons + clock) */ - ui_common->vbox = gtk_vbox_new (FALSE, 0); /* spacing */ - gtk_container_set_border_width(GTK_CONTAINER (ui_common->vbox), 4); - - gtk_container_add (GTK_CONTAINER (ui_common->event_box), - ui_common->vbox); - gtk_widget_modify_bg(ui_common->event_box, GTK_STATE_NORMAL, &main_bg_color); - - /* Vertical box that divides the control area into four */ - ui_common->button_vbox = gtk_vbox_new (TRUE, 0); /* spacing */ - gtk_container_set_border_width (GTK_CONTAINER (ui_common->button_vbox), 0); + /* + * Vertical box that divides the control area into two (buttons + + * clock) + */ + ui_common->vbox = gtk_vbox_new(FALSE, 0); /* spacing */ + gtk_container_set_border_width(GTK_CONTAINER(ui_common->vbox), 4); - /* The button 1 */ - ui_common->button1 = gtk_button_new_with_label (label1); - gtk_widget_modify_bg(ui_common->button1, GTK_STATE_NORMAL, &main_bg_color); - gtk_widget_set_size_request (ui_common->button1, BUTTON_WIDTH, - BUTTON_HEIGHT); + gtk_container_add(GTK_CONTAINER(ui_common->event_box), + ui_common->vbox); + gtk_widget_modify_bg(ui_common->event_box, GTK_STATE_NORMAL, + &main_bg_color); - /* The button 2 */ - ui_common->button2 = gtk_button_new_with_label (label2); - gtk_widget_modify_bg(ui_common->button2, GTK_STATE_NORMAL, &main_bg_color); - gtk_widget_set_size_request (ui_common->button2, BUTTON_WIDTH, - BUTTON_HEIGHT); + /* + * Vertical box that divides the control area into four + */ + ui_common->button_vbox = gtk_vbox_new(TRUE, 0); /* spacing */ - /* The button 3 */ - ui_common->button3 = gtk_button_new_with_label (label3); - gtk_widget_modify_bg(ui_common->button3, GTK_STATE_NORMAL, &main_bg_color); - gtk_widget_set_size_request (ui_common->button3, BUTTON_WIDTH, - BUTTON_HEIGHT); + gtk_container_set_border_width(GTK_CONTAINER(ui_common->button_vbox), + 0); - /* The clock label */ - ui_common->label = gtk_label_new ("Starting..."); - gtk_widget_show (ui_common->label); - ui_common->source_id = g_timeout_add(500, (GSourceFunc) refresh_time_on_screen, ui_common->label); + /* + * The button 1 + */ + ui_common->button1 = gtk_button_new_with_label(label1); + gtk_widget_modify_bg(ui_common->button1, GTK_STATE_NORMAL, + &main_bg_color); + gtk_widget_set_size_request(ui_common->button1, BUTTON_WIDTH, + BUTTON_HEIGHT); - /* Packing components */ - gtk_box_pack_start (GTK_BOX (ui_common->vbox), - ui_common->button_vbox, TRUE, TRUE, 0); + /* + * The button 2 + */ + ui_common->button2 = gtk_button_new_with_label(label2); + gtk_widget_modify_bg(ui_common->button2, GTK_STATE_NORMAL, + &main_bg_color); + gtk_widget_set_size_request(ui_common->button2, BUTTON_WIDTH, + BUTTON_HEIGHT); - gtk_box_pack_start (GTK_BOX (ui_common->vbox), - ui_common->label, FALSE, FALSE, 0); + /* + * The button 3 + */ + ui_common->button3 = gtk_button_new_with_label(label3); + gtk_widget_modify_bg(ui_common->button3, GTK_STATE_NORMAL, + &main_bg_color); + gtk_widget_set_size_request(ui_common->button3, BUTTON_WIDTH, + BUTTON_HEIGHT); - gtk_box_pack_start (GTK_BOX (ui_common->button_vbox), - ui_common->button1, FALSE, FALSE, 0); + /* + * The clock label + */ + ui_common->label = gtk_label_new("Starting..."); + gtk_widget_show(ui_common->label); + ui_common->source_id = + g_timeout_add(500, (GSourceFunc) refresh_time_on_screen, + ui_common->label); - gtk_box_pack_start (GTK_BOX (ui_common->button_vbox), - ui_common->button2, FALSE, FALSE, 0); + /* + * Packing components + */ + gtk_box_pack_start(GTK_BOX(ui_common->vbox), + ui_common->button_vbox, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (ui_common->button_vbox), - ui_common->button3, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(ui_common->vbox), + ui_common->label, FALSE, FALSE, 0); - gtk_widget_show_all (ui_common->event_box); + gtk_box_pack_start(GTK_BOX(ui_common->button_vbox), + ui_common->button1, FALSE, FALSE, 0); - /* FIXME: mmyth_ui->video_alignment == NULL when mmyth_player_init fails */ - if(ui_common->main_widget != NULL) - g_object_ref (ui_common->main_widget); - - g_object_ref (ui_common->vbox); - g_object_ref (ui_common->button_vbox); - g_object_ref (ui_common->label); - g_object_ref (ui_common->button1); - g_object_ref (ui_common->button2); - g_object_ref (ui_common->button3); - g_object_ref (ui_common->event_box); + gtk_box_pack_start(GTK_BOX(ui_common->button_vbox), + ui_common->button2, FALSE, FALSE, 0); + + gtk_box_pack_start(GTK_BOX(ui_common->button_vbox), + ui_common->button3, FALSE, FALSE, 0); + + gtk_widget_show_all(ui_common->event_box); + + /* + * FIXME: mmyth_ui->video_alignment == NULL when mmyth_player_init + * fails + */ + if (ui_common->main_widget != NULL) + g_object_ref(ui_common->main_widget); + + g_object_ref(ui_common->vbox); + g_object_ref(ui_common->button_vbox); + g_object_ref(ui_common->label); + g_object_ref(ui_common->button1); + g_object_ref(ui_common->button2); + g_object_ref(ui_common->button3); + g_object_ref(ui_common->event_box); return ui_common; } void -mmyth_uicommon_free (MMythUiCommon *ui_common) +mmyth_uicommon_free(MMythUiCommon * ui_common) { - g_debug ("[%s] Clean uicommon used memory", __FUNCTION__); + g_debug("[%s] Clean uicommon used memory", __FUNCTION__); - g_source_remove (ui_common->source_id); - - g_object_unref (ui_common->main_widget); - g_object_unref (ui_common->vbox); - g_object_unref (ui_common->button_vbox); - g_object_unref (ui_common->label); - g_object_unref (ui_common->button1); - g_object_unref (ui_common->button2); - g_object_unref (ui_common->button3); - g_object_unref (ui_common->event_box); - - g_free (ui_common); + g_source_remove(ui_common->source_id); + + g_object_unref(ui_common->main_widget); + g_object_unref(ui_common->vbox); + g_object_unref(ui_common->button_vbox); + g_object_unref(ui_common->label); + g_object_unref(ui_common->button1); + g_object_unref(ui_common->button2); + g_object_unref(ui_common->button3); + g_object_unref(ui_common->event_box); + + g_free(ui_common); } - -