maemo-ui/src/mmyth_schedulerui.c
branchtrunk
changeset 772 47de5c5976bf
parent 244 c88244670b08
     1.1 --- a/maemo-ui/src/mmyth_schedulerui.c	Fri Jan 05 19:27:27 2007 +0000
     1.2 +++ b/maemo-ui/src/mmyth_schedulerui.c	Tue Jul 03 22:45:24 2007 +0100
     1.3 @@ -12,361 +12,432 @@
     1.4  #include "mmyth_recordui.h"
     1.5  #include "mmyth_schedulerui.h"
     1.6  
     1.7 -/* GMyth library includes */
     1.8 +/*
     1.9 + * GMyth library includes 
    1.10 + */
    1.11  #include <gmyth/gmyth_scheduler.h>
    1.12  #include <gmyth/gmyth_common.h>
    1.13  #include <gmyth/gmyth_epg.h>
    1.14  
    1.15 -static void run_calendar_dialog (GtkButton *button, gpointer data);
    1.16 +static void     run_calendar_dialog(GtkButton * button, gpointer data);
    1.17  
    1.18 -static void add_channel_field (MMythSchedulerUI *scheduler_ui, GtkWidget *vbox);
    1.19 -static void add_time_field (MMythSchedulerUI *scheduler_ui, GtkWidget *vbox);
    1.20 -static void add_date_field (MMythSchedulerUI *scheduler_ui, GtkWidget *vbox);
    1.21 -static void add_duration_field (MMythSchedulerUI *scheduler_ui, GtkWidget *vbox);
    1.22 -static void add_frequency_field (MMythSchedulerUI *scheduler_ui, GtkWidget *vbox);
    1.23 -static void add_title_field (MMythSchedulerUI *scheduler_ui, GtkWidget *vbox);
    1.24 +static void     add_channel_field(MMythSchedulerUI * scheduler_ui,
    1.25 +                                  GtkWidget * vbox);
    1.26 +static void     add_time_field(MMythSchedulerUI * scheduler_ui,
    1.27 +                               GtkWidget * vbox);
    1.28 +static void     add_date_field(MMythSchedulerUI * scheduler_ui,
    1.29 +                               GtkWidget * vbox);
    1.30 +static void     add_duration_field(MMythSchedulerUI * scheduler_ui,
    1.31 +                                   GtkWidget * vbox);
    1.32 +static void     add_frequency_field(MMythSchedulerUI * scheduler_ui,
    1.33 +                                    GtkWidget * vbox);
    1.34 +static void     add_title_field(MMythSchedulerUI * scheduler_ui,
    1.35 +                                GtkWidget * vbox);
    1.36  
    1.37 -MMythSchedulerUI*
    1.38 -mmyth_schedulerui_new ( GMythBackendInfo *backend_info )
    1.39 +MMythSchedulerUI *
    1.40 +mmyth_schedulerui_new(GMythBackendInfo * backend_info)
    1.41  {
    1.42 -	GtkWidget *scrolledwindow;	
    1.43 -	GtkWidget *viewport;	
    1.44 -	GtkWidget *head_hbox;
    1.45 -	GtkWidget *fields_vbox;
    1.46 -	GtkWidget *hseparator;
    1.47 -	GtkWidget *label;
    1.48 +    GtkWidget      *scrolledwindow;
    1.49 +    GtkWidget      *viewport;
    1.50 +    GtkWidget      *head_hbox;
    1.51 +    GtkWidget      *fields_vbox;
    1.52 +    GtkWidget      *hseparator;
    1.53 +    GtkWidget      *label;
    1.54  
    1.55 -	MMythSchedulerUI *scheduler_ui = g_new0 (MMythSchedulerUI, 1);
    1.56 +    MMythSchedulerUI *scheduler_ui = g_new0(MMythSchedulerUI, 1);
    1.57  
    1.58 -	scheduler_ui->backend_info = backend_info;
    1.59 -	
    1.60 -	scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
    1.61 -	scheduler_ui->main_widget = scrolledwindow;
    1.62 -	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
    1.63 -  			GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    1.64 +    scheduler_ui->backend_info = backend_info;
    1.65  
    1.66 -	//Is this needed?  
    1.67 -	viewport = gtk_viewport_new (NULL, NULL);
    1.68 -	gtk_container_add (GTK_CONTAINER (scrolledwindow), viewport);
    1.69 +    scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
    1.70 +    scheduler_ui->main_widget = scrolledwindow;
    1.71 +    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
    1.72 +                                   GTK_POLICY_AUTOMATIC,
    1.73 +                                   GTK_POLICY_AUTOMATIC);
    1.74  
    1.75 -	//Is this needed?
    1.76 -	head_hbox = gtk_hbox_new (FALSE, 0);
    1.77 -	gtk_container_add (GTK_CONTAINER (viewport), head_hbox);
    1.78 +    // Is this needed? 
    1.79 +    viewport = gtk_viewport_new(NULL, NULL);
    1.80 +    gtk_container_add(GTK_CONTAINER(scrolledwindow), viewport);
    1.81  
    1.82 -	fields_vbox = gtk_vbox_new (FALSE, 0);
    1.83 -	gtk_box_pack_start (GTK_BOX (head_hbox), fields_vbox, TRUE, TRUE, 0);
    1.84 -	gtk_container_set_border_width (GTK_CONTAINER (fields_vbox), 10);
    1.85 +    // Is this needed?
    1.86 +    head_hbox = gtk_hbox_new(FALSE, 0);
    1.87 +    gtk_container_add(GTK_CONTAINER(viewport), head_hbox);
    1.88  
    1.89 -	label = gtk_label_new_with_mnemonic (("Manual Schedule Recording"));
    1.90 -	gtk_box_pack_start (GTK_BOX (fields_vbox), label, FALSE, FALSE, 0);
    1.91 -	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
    1.92 +    fields_vbox = gtk_vbox_new(FALSE, 0);
    1.93 +    gtk_box_pack_start(GTK_BOX(head_hbox), fields_vbox, TRUE, TRUE, 0);
    1.94 +    gtk_container_set_border_width(GTK_CONTAINER(fields_vbox), 10);
    1.95  
    1.96 -	hseparator = gtk_hseparator_new ();
    1.97 -	gtk_box_pack_start (GTK_BOX (fields_vbox), hseparator, FALSE, TRUE, 0);
    1.98 +    label = gtk_label_new_with_mnemonic(("Manual Schedule Recording"));
    1.99 +    gtk_box_pack_start(GTK_BOX(fields_vbox), label, FALSE, FALSE, 0);
   1.100 +    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
   1.101  
   1.102 -	add_channel_field (scheduler_ui, fields_vbox);
   1.103 -	add_time_field (scheduler_ui, fields_vbox);
   1.104 -	add_date_field (scheduler_ui, fields_vbox);
   1.105 -	add_duration_field (scheduler_ui, fields_vbox);
   1.106 -	add_frequency_field (scheduler_ui, fields_vbox);
   1.107 -	add_title_field (scheduler_ui, fields_vbox);
   1.108 -	
   1.109 -	return scheduler_ui;
   1.110 +    hseparator = gtk_hseparator_new();
   1.111 +    gtk_box_pack_start(GTK_BOX(fields_vbox), hseparator, FALSE, TRUE, 0);
   1.112 +
   1.113 +    add_channel_field(scheduler_ui, fields_vbox);
   1.114 +    add_time_field(scheduler_ui, fields_vbox);
   1.115 +    add_date_field(scheduler_ui, fields_vbox);
   1.116 +    add_duration_field(scheduler_ui, fields_vbox);
   1.117 +    add_frequency_field(scheduler_ui, fields_vbox);
   1.118 +    add_title_field(scheduler_ui, fields_vbox);
   1.119 +
   1.120 +    return scheduler_ui;
   1.121  }
   1.122  
   1.123  static void
   1.124 -set_date_from_calendar (GtkCalendar *calendar, gpointer data)
   1.125 +set_date_from_calendar(GtkCalendar * calendar, gpointer data)
   1.126  {
   1.127 -	char sched_date[24];
   1.128 +    char            sched_date[24];
   1.129  
   1.130 -	MMythSchedulerUI *scheduler_ui = (MMythSchedulerUI*) data;
   1.131 +    MMythSchedulerUI *scheduler_ui = (MMythSchedulerUI *) data;
   1.132  
   1.133 -	// FIXME: Change this, save another value instead of month_temp, day_temp, ...	
   1.134 -	gtk_calendar_get_date(GTK_CALENDAR(calendar), 
   1.135 -		&(scheduler_ui->year_temp), &(scheduler_ui->month_temp), &(scheduler_ui->day_temp));
   1.136 +    // FIXME: Change this, save another value instead of month_temp,
   1.137 +    // day_temp, ... 
   1.138 +    gtk_calendar_get_date(GTK_CALENDAR(calendar),
   1.139 +                          &(scheduler_ui->year_temp),
   1.140 +                          &(scheduler_ui->month_temp),
   1.141 +                          &(scheduler_ui->day_temp));
   1.142  
   1.143 -	sched_date[23]='\0';
   1.144 -	g_sprintf(sched_date, "%04d %02d %02d (yyyy mm dd)",
   1.145 -		scheduler_ui->year_temp, scheduler_ui->month_temp+1, scheduler_ui->day_temp);
   1.146 +    sched_date[23] = '\0';
   1.147 +    g_sprintf(sched_date, "%04d %02d %02d (yyyy mm dd)",
   1.148 +              scheduler_ui->year_temp, scheduler_ui->month_temp + 1,
   1.149 +              scheduler_ui->day_temp);
   1.150  
   1.151 -	gtk_button_set_label(GTK_BUTTON(scheduler_ui->date_button), sched_date);
   1.152 +    gtk_button_set_label(GTK_BUTTON(scheduler_ui->date_button),
   1.153 +                         sched_date);
   1.154  
   1.155 -	gtk_widget_destroy(scheduler_ui->calendar_dialog);
   1.156 -	scheduler_ui->calendar_dialog = NULL;
   1.157 -	scheduler_ui->calendar = NULL;
   1.158 +    gtk_widget_destroy(scheduler_ui->calendar_dialog);
   1.159 +    scheduler_ui->calendar_dialog = NULL;
   1.160 +    scheduler_ui->calendar = NULL;
   1.161  }
   1.162  
   1.163 -//calendar
   1.164 +// calendar
   1.165  static void
   1.166 -run_calendar_dialog (GtkButton *button, gpointer data)
   1.167 +run_calendar_dialog(GtkButton * button, gpointer data)
   1.168  {
   1.169  
   1.170 -	GtkWidget *dialog_vbox;
   1.171 -	MMythSchedulerUI *scheduler_ui = (MMythSchedulerUI*) data;
   1.172 +    GtkWidget      *dialog_vbox;
   1.173 +    MMythSchedulerUI *scheduler_ui = (MMythSchedulerUI *) data;
   1.174  
   1.175 -	// calendar_dialog and calendar are been released at set_date_from_calendar ()
   1.176 -	scheduler_ui->calendar_dialog = gtk_dialog_new ();
   1.177 -	gtk_container_set_border_width (GTK_CONTAINER (scheduler_ui->calendar_dialog), 1);
   1.178 -  	gtk_window_set_title (GTK_WINDOW (scheduler_ui->calendar_dialog), "Select starting date");
   1.179 -  	gtk_window_set_position (GTK_WINDOW (scheduler_ui->calendar_dialog), GTK_WIN_POS_CENTER);
   1.180 -	gtk_window_set_decorated (GTK_WINDOW (scheduler_ui->calendar_dialog), FALSE);
   1.181 +    // calendar_dialog and calendar are been released at
   1.182 +    // set_date_from_calendar ()
   1.183 +    scheduler_ui->calendar_dialog = gtk_dialog_new();
   1.184 +    gtk_container_set_border_width(GTK_CONTAINER
   1.185 +                                   (scheduler_ui->calendar_dialog), 1);
   1.186 +    gtk_window_set_title(GTK_WINDOW(scheduler_ui->calendar_dialog),
   1.187 +                         "Select starting date");
   1.188 +    gtk_window_set_position(GTK_WINDOW(scheduler_ui->calendar_dialog),
   1.189 +                            GTK_WIN_POS_CENTER);
   1.190 +    gtk_window_set_decorated(GTK_WINDOW(scheduler_ui->calendar_dialog),
   1.191 +                             FALSE);
   1.192  
   1.193 -	dialog_vbox = GTK_DIALOG (scheduler_ui->calendar_dialog)->vbox;
   1.194 +    dialog_vbox = GTK_DIALOG(scheduler_ui->calendar_dialog)->vbox;
   1.195  
   1.196 -	scheduler_ui->calendar = gtk_calendar_new ();
   1.197 +    scheduler_ui->calendar = gtk_calendar_new();
   1.198  
   1.199 -	gtk_box_pack_start (GTK_BOX (dialog_vbox), scheduler_ui->calendar, TRUE, TRUE, 0);
   1.200 -	gtk_calendar_display_options (GTK_CALENDAR (scheduler_ui->calendar),
   1.201 -        GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES);
   1.202 +    gtk_box_pack_start(GTK_BOX(dialog_vbox), scheduler_ui->calendar, TRUE,
   1.203 +                       TRUE, 0);
   1.204 +    gtk_calendar_display_options(GTK_CALENDAR(scheduler_ui->calendar),
   1.205 +                                 GTK_CALENDAR_SHOW_HEADING |
   1.206 +                                 GTK_CALENDAR_SHOW_DAY_NAMES);
   1.207  
   1.208 -	gtk_widget_show_all (scheduler_ui->calendar_dialog);
   1.209 +    gtk_widget_show_all(scheduler_ui->calendar_dialog);
   1.210  
   1.211 -	g_signal_connect (G_OBJECT (scheduler_ui->calendar), "day-selected-double-click",
   1.212 -                      G_CALLBACK (set_date_from_calendar), data);
   1.213 +    g_signal_connect(G_OBJECT(scheduler_ui->calendar),
   1.214 +                     "day-selected-double-click",
   1.215 +                     G_CALLBACK(set_date_from_calendar), data);
   1.216  }
   1.217  
   1.218  
   1.219  gboolean
   1.220 -mmyth_schedulerui_save (MMythSchedulerUI *scheduler_ui)
   1.221 +mmyth_schedulerui_save(MMythSchedulerUI * scheduler_ui)
   1.222  {
   1.223 -	GMythScheduler *scheduler;
   1.224 -	ScheduleInfo *schedule_info;
   1.225 -	GMythChannelInfo *channel_info;
   1.226 +    GMythScheduler *scheduler;
   1.227 +    ScheduleInfo   *schedule_info;
   1.228 +    GMythChannelInfo *channel_info;
   1.229  
   1.230 -	GList *clist;
   1.231 -	gint index, duration;
   1.232 -	gint frequency;
   1.233 -	struct tm start_tm;
   1.234 +    GList          *clist;
   1.235 +    gint            index,
   1.236 +                    duration;
   1.237 +    gint            frequency;
   1.238 +    struct tm       start_tm;
   1.239  
   1.240 -	schedule_info = g_new0(ScheduleInfo, 1);
   1.241 -	if(schedule_info == NULL) {
   1.242 -		g_warning ("Error allocating memory");
   1.243 -		return FALSE;
   1.244 -	}
   1.245 +    schedule_info = g_new0(ScheduleInfo, 1);
   1.246 +    if (schedule_info == NULL) {
   1.247 +        g_warning("Error allocating memory");
   1.248 +        return FALSE;
   1.249 +    }
   1.250  
   1.251 -	clist = scheduler_ui->channel_list;
   1.252 +    clist = scheduler_ui->channel_list;
   1.253  
   1.254 -	index = gtk_combo_box_get_active(GTK_COMBO_BOX(scheduler_ui->channel_combobox));
   1.255 +    index =
   1.256 +        gtk_combo_box_get_active(GTK_COMBO_BOX
   1.257 +                                 (scheduler_ui->channel_combobox));
   1.258  
   1.259 -	if (clist != NULL)
   1.260 -		clist = g_list_nth(clist, index);
   1.261 +    if (clist != NULL)
   1.262 +        clist = g_list_nth(clist, index);
   1.263  
   1.264 -	if (clist) {
   1.265 -		g_debug ("[%s] New schedule: %d", __FUNCTION__, index);
   1.266 -	} else {
   1.267 -		g_warning ("[%s] Error when adding new schedule", __FUNCTION__);
   1.268 -		return FALSE;
   1.269 -	}
   1.270 +    if (clist) {
   1.271 +        g_debug("[%s] New schedule: %d", __FUNCTION__, index);
   1.272 +    } else {
   1.273 +        g_warning("[%s] Error when adding new schedule", __FUNCTION__);
   1.274 +        return FALSE;
   1.275 +    }
   1.276  
   1.277 -	channel_info = clist->data;
   1.278 +    channel_info = clist->data;
   1.279  
   1.280 -	/* initialize schedule_info */
   1.281 -	schedule_info->channel_id = channel_info->channel_ID;
   1.282 +    /*
   1.283 +     * initialize schedule_info 
   1.284 +     */
   1.285 +    schedule_info->channel_id = channel_info->channel_ID;
   1.286  
   1.287 -	start_tm.tm_hour = 
   1.288 -		(int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(scheduler_ui->hour_spinbutton));
   1.289 -	start_tm.tm_min = 
   1.290 -		(int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(scheduler_ui->min_spinbutton));
   1.291 -	start_tm.tm_sec = 0;
   1.292 +    start_tm.tm_hour =
   1.293 +        (int)
   1.294 +        gtk_spin_button_get_value(GTK_SPIN_BUTTON
   1.295 +                                  (scheduler_ui->hour_spinbutton));
   1.296 +    start_tm.tm_min =
   1.297 +        (int)
   1.298 +        gtk_spin_button_get_value(GTK_SPIN_BUTTON
   1.299 +                                  (scheduler_ui->min_spinbutton));
   1.300 +    start_tm.tm_sec = 0;
   1.301  
   1.302 -	start_tm.tm_mday = (gint)scheduler_ui->day_temp;
   1.303 -	start_tm.tm_mon =  (gint)scheduler_ui->month_temp;
   1.304 -	start_tm.tm_year = (gint)scheduler_ui->year_temp - 1900; //years since 1900
   1.305 -	GTimeVal* time_val_local = g_new0( GTimeVal, 1 );
   1.306 -	time_val_local->tv_sec = timelocal(&start_tm);
   1.307 +    start_tm.tm_mday = (gint) scheduler_ui->day_temp;
   1.308 +    start_tm.tm_mon = (gint) scheduler_ui->month_temp;
   1.309 +    start_tm.tm_year = (gint) scheduler_ui->year_temp - 1900;   // years
   1.310 +                                                                // since
   1.311 +                                                                // 1900
   1.312 +    GTimeVal       *time_val_local = g_new0(GTimeVal, 1);
   1.313 +    time_val_local->tv_sec = timelocal(&start_tm);
   1.314  
   1.315 -	schedule_info->start_time = time_val_local;
   1.316 -	if ( NULL == schedule_info->start_time ) {
   1.317 -		g_warning ("timelocal error!\n");
   1.318 -		return FALSE;
   1.319 -	}
   1.320 +    schedule_info->start_time = time_val_local;
   1.321 +    if (NULL == schedule_info->start_time) {
   1.322 +        g_warning("timelocal error!\n");
   1.323 +        return FALSE;
   1.324 +    }
   1.325  
   1.326 -	duration = (gint) gtk_spin_button_get_value(
   1.327 -			GTK_SPIN_BUTTON(scheduler_ui->duration_spinbutton));
   1.328 -	schedule_info->end_time = schedule_info->start_time + (duration*60);
   1.329 +    duration =
   1.330 +        (gint)
   1.331 +        gtk_spin_button_get_value(GTK_SPIN_BUTTON
   1.332 +                                  (scheduler_ui->duration_spinbutton));
   1.333 +    schedule_info->end_time = schedule_info->start_time + (duration * 60);
   1.334  
   1.335 -	/* TODO: frequency is not implemented yet */
   1.336 -	frequency = gtk_combo_box_get_active(GTK_COMBO_BOX(scheduler_ui->freq_combobox));
   1.337 +    /*
   1.338 +     * TODO: frequency is not implemented yet 
   1.339 +     */
   1.340 +    frequency =
   1.341 +        gtk_combo_box_get_active(GTK_COMBO_BOX
   1.342 +                                 (scheduler_ui->freq_combobox));
   1.343  
   1.344 -	schedule_info->title = g_string_new("");
   1.345 -	g_string_printf(schedule_info->title, "%s", 
   1.346 -			gtk_entry_get_text(GTK_ENTRY(scheduler_ui->title_entry)));
   1.347 +    schedule_info->title = g_string_new("");
   1.348 +    g_string_printf(schedule_info->title, "%s",
   1.349 +                    gtk_entry_get_text(GTK_ENTRY
   1.350 +                                       (scheduler_ui->title_entry)));
   1.351  
   1.352 -	/* FIXME: Architecture change to reuse the scheduler created in the recordui! */
   1.353 -	scheduler = gmyth_scheduler_new ();
   1.354 +    /*
   1.355 +     * FIXME: Architecture change to reuse the scheduler created in the
   1.356 +     * recordui! 
   1.357 +     */
   1.358 +    scheduler = gmyth_scheduler_new();
   1.359  
   1.360 -	gmyth_scheduler_connect(scheduler, scheduler->backend_info);
   1.361 +    gmyth_scheduler_connect(scheduler, scheduler->backend_info);
   1.362  
   1.363 -	/* FIXME: set record_id = -1 to add a new schedule */
   1.364 -	schedule_info->record_id = -1;
   1.365 -	gmyth_scheduler_add_schedule (scheduler, schedule_info);
   1.366 +    /*
   1.367 +     * FIXME: set record_id = -1 to add a new schedule 
   1.368 +     */
   1.369 +    schedule_info->record_id = -1;
   1.370 +    gmyth_scheduler_add_schedule(scheduler, schedule_info);
   1.371  
   1.372 -	gmyth_scheduler_disconnect(scheduler);
   1.373 +    gmyth_scheduler_disconnect(scheduler);
   1.374  
   1.375 -	/* free allocated memory */
   1.376 -	g_object_unref (scheduler);
   1.377 -	g_free (schedule_info);
   1.378 +    /*
   1.379 +     * free allocated memory 
   1.380 +     */
   1.381 +    g_object_unref(scheduler);
   1.382 +    g_free(schedule_info);
   1.383  
   1.384 -	return TRUE;
   1.385 -} 
   1.386 +    return TRUE;
   1.387 +}
   1.388  
   1.389 -static GtkWidget*
   1.390 -add_line (GtkWidget *vbox, const gchar *str)
   1.391 +static GtkWidget *
   1.392 +add_line(GtkWidget * vbox, const gchar * str)
   1.393  {
   1.394 -	GtkWidget *label;
   1.395 -	GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
   1.396 +    GtkWidget      *label;
   1.397 +    GtkWidget      *hbox = gtk_hbox_new(FALSE, 0);
   1.398  
   1.399 -	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
   1.400 -	gtk_container_set_border_width (GTK_CONTAINER (hbox), 3);
   1.401 -	
   1.402 -	label = gtk_label_new (str);
   1.403 -	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
   1.404 -	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);	
   1.405 +    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
   1.406 +    gtk_container_set_border_width(GTK_CONTAINER(hbox), 3);
   1.407  
   1.408 -	return hbox;
   1.409 +    label = gtk_label_new(str);
   1.410 +    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
   1.411 +    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
   1.412 +
   1.413 +    return hbox;
   1.414  }
   1.415  
   1.416  static void
   1.417 -add_channel_field (MMythSchedulerUI *scheduler_ui, GtkWidget *vbox)
   1.418 +add_channel_field(MMythSchedulerUI * scheduler_ui, GtkWidget * vbox)
   1.419  {
   1.420 -	GtkWidget *combobox;
   1.421 -	
   1.422 -	GtkWidget *hbox = add_line (vbox, "Channel:    ");
   1.423 -	
   1.424 -	combobox = gtk_combo_box_new_text ();
   1.425 +    GtkWidget      *combobox;
   1.426  
   1.427 -	scheduler_ui->channel_combobox = combobox;
   1.428 -	gtk_box_pack_start (GTK_BOX (hbox), combobox, FALSE, FALSE, 0);
   1.429 -			
   1.430 -	GMythEPG *mmyth_epg = gmyth_epg_new ();
   1.431 -	if (!gmyth_epg_connect (mmyth_epg, scheduler_ui->backend_info)) {
   1.432 -		// FIXME: Without this list the scheduler UI should not be shown!
   1.433 -		g_warning ("[%s] Error when getting list of channels", __FUNCTION__);
   1.434 -	}
   1.435 -  	
   1.436 -	if (gmyth_epg_get_channel_list (mmyth_epg, &(scheduler_ui->channel_list)) < 0) {
   1.437 -		g_debug ("[%s] Error while trying to retrieve channel list", __FUNCTION__);
   1.438 -	} else {
   1.439 - 		GList *clist =  scheduler_ui->channel_list;
   1.440 -		GMythChannelInfo *channel_info;
   1.441 +    GtkWidget      *hbox = add_line(vbox, "Channel:    ");
   1.442  
   1.443 -		while (clist != NULL) {
   1.444 -  	  		channel_info = clist->data;
   1.445 -  	  		clist = clist->next;
   1.446 -  	  		gtk_combo_box_append_text (GTK_COMBO_BOX (scheduler_ui->channel_combobox), 
   1.447 -                                       (channel_info->channel_name->str));
   1.448 -  		}
   1.449 +    combobox = gtk_combo_box_new_text();
   1.450  
   1.451 -       gtk_combo_box_set_active(GTK_COMBO_BOX (scheduler_ui->channel_combobox), 0);
   1.452 -  	}
   1.453 +    scheduler_ui->channel_combobox = combobox;
   1.454 +    gtk_box_pack_start(GTK_BOX(hbox), combobox, FALSE, FALSE, 0);
   1.455 +
   1.456 +    GMythEPG       *mmyth_epg = gmyth_epg_new();
   1.457 +    if (!gmyth_epg_connect(mmyth_epg, scheduler_ui->backend_info)) {
   1.458 +        // FIXME: Without this list the scheduler UI should not be shown!
   1.459 +        g_warning("[%s] Error when getting list of channels",
   1.460 +                  __FUNCTION__);
   1.461 +    }
   1.462 +
   1.463 +    if (gmyth_epg_get_channel_list
   1.464 +        (mmyth_epg, &(scheduler_ui->channel_list)) < 0) {
   1.465 +        g_debug("[%s] Error while trying to retrieve channel list",
   1.466 +                __FUNCTION__);
   1.467 +    } else {
   1.468 +        GList          *clist = scheduler_ui->channel_list;
   1.469 +        GMythChannelInfo *channel_info;
   1.470 +
   1.471 +        while (clist != NULL) {
   1.472 +            channel_info = clist->data;
   1.473 +            clist = clist->next;
   1.474 +            gtk_combo_box_append_text(GTK_COMBO_BOX
   1.475 +                                      (scheduler_ui->channel_combobox),
   1.476 +                                      (channel_info->channel_name->str));
   1.477 +        }
   1.478 +
   1.479 +        gtk_combo_box_set_active(GTK_COMBO_BOX
   1.480 +                                 (scheduler_ui->channel_combobox), 0);
   1.481 +    }
   1.482  }
   1.483  
   1.484  static void
   1.485 -add_time_field (MMythSchedulerUI *scheduler_ui, GtkWidget *vbox)
   1.486 +add_time_field(MMythSchedulerUI * scheduler_ui, GtkWidget * vbox)
   1.487  {
   1.488 -	GtkWidget *label;
   1.489 -	GtkObject *spinbutton_adj;
   1.490 -	GtkWidget *hbox = add_line (vbox, "Time:         ");
   1.491 +    GtkWidget      *label;
   1.492 +    GtkObject      *spinbutton_adj;
   1.493 +    GtkWidget      *hbox = add_line(vbox, "Time:         ");
   1.494  
   1.495 -	time_t real_time;
   1.496 -	struct tm sched_time;
   1.497 +    time_t          real_time;
   1.498 +    struct tm       sched_time;
   1.499  
   1.500 -	time(&real_time);
   1.501 +    time(&real_time);
   1.502  
   1.503 -    if (localtime_r((time_t *)&real_time, &sched_time) == NULL) {
   1.504 -        g_warning ("localtime_r error in mmyth_epg_grid_view!\n");
   1.505 +    if (localtime_r((time_t *) & real_time, &sched_time) == NULL) {
   1.506 +        g_warning("localtime_r error in mmyth_epg_grid_view!\n");
   1.507          return;
   1.508      }
   1.509 - 
   1.510 -	if (sched_time.tm_min>30){
   1.511 -  		sched_time.tm_hour = sched_time.tm_hour+1;
   1.512 -  		sched_time.tm_min = 0;
   1.513 -	} else if (sched_time.tm_min>0) {
   1.514 -  		sched_time.tm_min = 30;
   1.515 -	}
   1.516  
   1.517 -  	scheduler_ui->year_temp = (guint)sched_time.tm_year + 1900;
   1.518 -  	scheduler_ui->month_temp = (guint)sched_time.tm_mon;
   1.519 -  	scheduler_ui->day_temp = (guint)sched_time.tm_mday;
   1.520 -   
   1.521 -	//hour entry
   1.522 -	spinbutton_adj = gtk_adjustment_new (sched_time.tm_hour, 00, 23, 1, 10, 10);
   1.523 -	scheduler_ui->hour_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_adj), 1, 0);
   1.524 -	gtk_box_pack_start (GTK_BOX (hbox), scheduler_ui->hour_spinbutton, FALSE, FALSE, 0);
   1.525 +    if (sched_time.tm_min > 30) {
   1.526 +        sched_time.tm_hour = sched_time.tm_hour + 1;
   1.527 +        sched_time.tm_min = 0;
   1.528 +    } else if (sched_time.tm_min > 0) {
   1.529 +        sched_time.tm_min = 30;
   1.530 +    }
   1.531  
   1.532 -	label = gtk_label_new ((" : "));
   1.533 -	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
   1.534 -	gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);
   1.535 -	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
   1.536 +    scheduler_ui->year_temp = (guint) sched_time.tm_year + 1900;
   1.537 +    scheduler_ui->month_temp = (guint) sched_time.tm_mon;
   1.538 +    scheduler_ui->day_temp = (guint) sched_time.tm_mday;
   1.539  
   1.540 -	//minute entry
   1.541 -	spinbutton_adj = gtk_adjustment_new (sched_time.tm_min, 0, 59, 1, 10, 10);
   1.542 -	scheduler_ui->min_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_adj), 1, 0);
   1.543 -	gtk_box_pack_start (GTK_BOX (hbox), scheduler_ui->min_spinbutton, FALSE, FALSE, 0);
   1.544 +    // hour entry
   1.545 +    spinbutton_adj =
   1.546 +        gtk_adjustment_new(sched_time.tm_hour, 00, 23, 1, 10, 10);
   1.547 +    scheduler_ui->hour_spinbutton =
   1.548 +        gtk_spin_button_new(GTK_ADJUSTMENT(spinbutton_adj), 1, 0);
   1.549 +    gtk_box_pack_start(GTK_BOX(hbox), scheduler_ui->hour_spinbutton, FALSE,
   1.550 +                       FALSE, 0);
   1.551  
   1.552 -	label = gtk_label_new ((" (hh:mm)"));
   1.553 +    label = gtk_label_new((" : "));
   1.554 +    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
   1.555 +    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
   1.556 +    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
   1.557  
   1.558 -	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
   1.559 +    // minute entry
   1.560 +    spinbutton_adj =
   1.561 +        gtk_adjustment_new(sched_time.tm_min, 0, 59, 1, 10, 10);
   1.562 +    scheduler_ui->min_spinbutton =
   1.563 +        gtk_spin_button_new(GTK_ADJUSTMENT(spinbutton_adj), 1, 0);
   1.564 +    gtk_box_pack_start(GTK_BOX(hbox), scheduler_ui->min_spinbutton, FALSE,
   1.565 +                       FALSE, 0);
   1.566  
   1.567 -}	
   1.568 +    label = gtk_label_new((" (hh:mm)"));
   1.569  
   1.570 -static void
   1.571 -add_date_field (MMythSchedulerUI *scheduler_ui, GtkWidget *vbox)
   1.572 -{
   1.573 -	char sched_date[24];
   1.574 -	GtkWidget *hbox = add_line (vbox, "Date:        ");
   1.575 -		
   1.576 -	//sched_date = ctime(&real_time);
   1.577 -  	g_sprintf (sched_date, "%04d %02d %02d (yyyy mm dd)", scheduler_ui->year_temp, scheduler_ui->month_temp+1, scheduler_ui->day_temp);
   1.578 -  	sched_date[23]='\0';
   1.579 -  
   1.580 -  	scheduler_ui->date_button = gtk_button_new_with_label (sched_date);
   1.581 -  	gtk_box_pack_start (GTK_BOX (hbox), scheduler_ui->date_button, FALSE, FALSE, 0);
   1.582 -  	gtk_button_set_relief (GTK_BUTTON (scheduler_ui->date_button), GTK_RELIEF_NONE);
   1.583 -
   1.584 -	g_signal_connect (G_OBJECT (scheduler_ui->date_button), "clicked",
   1.585 -                      G_CALLBACK (run_calendar_dialog), scheduler_ui);
   1.586 +    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
   1.587  
   1.588  }
   1.589  
   1.590  static void
   1.591 -add_duration_field (MMythSchedulerUI *scheduler_ui, GtkWidget *vbox)
   1.592 +add_date_field(MMythSchedulerUI * scheduler_ui, GtkWidget * vbox)
   1.593  {
   1.594 -	GtkWidget *hbox = add_line (vbox, "Duration:   ");
   1.595 -	GtkWidget *label;
   1.596 -	GtkObject *spinbutton_adj;
   1.597 -	
   1.598 -	spinbutton_adj = gtk_adjustment_new (60, 5, 360, 5, 60, 60);
   1.599 -  	scheduler_ui->duration_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_adj), 1, 0);
   1.600 -  	gtk_box_pack_start (GTK_BOX (hbox), scheduler_ui->duration_spinbutton, FALSE, TRUE, 0);
   1.601 -  	gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (scheduler_ui->duration_spinbutton), TRUE);
   1.602 +    char            sched_date[24];
   1.603 +    GtkWidget      *hbox = add_line(vbox, "Date:        ");
   1.604  
   1.605 -	label = gtk_label_new ((" (minutes)     "));
   1.606 -  	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
   1.607 -}
   1.608 +    // sched_date = ctime(&real_time);
   1.609 +    g_sprintf(sched_date, "%04d %02d %02d (yyyy mm dd)",
   1.610 +              scheduler_ui->year_temp, scheduler_ui->month_temp + 1,
   1.611 +              scheduler_ui->day_temp);
   1.612 +    sched_date[23] = '\0';
   1.613  
   1.614 -static void
   1.615 -add_frequency_field (MMythSchedulerUI *scheduler_ui, GtkWidget *vbox)
   1.616 -{
   1.617 -	
   1.618 -	GtkWidget *hbox = add_line (vbox, "Frequency: ");	
   1.619 -	
   1.620 -	scheduler_ui->freq_combobox = gtk_combo_box_new_text ();
   1.621 -	gtk_box_pack_start (GTK_BOX (hbox), scheduler_ui->freq_combobox, FALSE, FALSE, 0);
   1.622 -	gtk_combo_box_append_text (GTK_COMBO_BOX (scheduler_ui->freq_combobox), ("Only this day               "));
   1.623 -	gtk_combo_box_append_text (GTK_COMBO_BOX (scheduler_ui->freq_combobox), ("Daily                            "));
   1.624 -	gtk_combo_box_append_text (GTK_COMBO_BOX (scheduler_ui->freq_combobox), ("Weekly                         "));
   1.625 -	gtk_combo_box_set_active(GTK_COMBO_BOX (scheduler_ui->freq_combobox), 0);
   1.626 +    scheduler_ui->date_button = gtk_button_new_with_label(sched_date);
   1.627 +    gtk_box_pack_start(GTK_BOX(hbox), scheduler_ui->date_button, FALSE,
   1.628 +                       FALSE, 0);
   1.629 +    gtk_button_set_relief(GTK_BUTTON(scheduler_ui->date_button),
   1.630 +                          GTK_RELIEF_NONE);
   1.631 +
   1.632 +    g_signal_connect(G_OBJECT(scheduler_ui->date_button), "clicked",
   1.633 +                     G_CALLBACK(run_calendar_dialog), scheduler_ui);
   1.634  
   1.635  }
   1.636  
   1.637  static void
   1.638 -add_title_field (MMythSchedulerUI *scheduler_ui, GtkWidget *vbox)
   1.639 +add_duration_field(MMythSchedulerUI * scheduler_ui, GtkWidget * vbox)
   1.640  {
   1.641 -	GtkWidget *hbox = add_line (vbox, "Title:           ");
   1.642 -	
   1.643 -  	scheduler_ui->title_entry = gtk_entry_new ();
   1.644 -  	gtk_box_pack_start (GTK_BOX (hbox), scheduler_ui->title_entry, FALSE, FALSE, 0);
   1.645 -  	gtk_entry_set_text (GTK_ENTRY (scheduler_ui->title_entry), "(Optional)");
   1.646 -	
   1.647 +    GtkWidget      *hbox = add_line(vbox, "Duration:   ");
   1.648 +    GtkWidget      *label;
   1.649 +    GtkObject      *spinbutton_adj;
   1.650 +
   1.651 +    spinbutton_adj = gtk_adjustment_new(60, 5, 360, 5, 60, 60);
   1.652 +    scheduler_ui->duration_spinbutton =
   1.653 +        gtk_spin_button_new(GTK_ADJUSTMENT(spinbutton_adj), 1, 0);
   1.654 +    gtk_box_pack_start(GTK_BOX(hbox), scheduler_ui->duration_spinbutton,
   1.655 +                       FALSE, TRUE, 0);
   1.656 +    gtk_spin_button_set_numeric(GTK_SPIN_BUTTON
   1.657 +                                (scheduler_ui->duration_spinbutton), TRUE);
   1.658 +
   1.659 +    label = gtk_label_new((" (minutes)     "));
   1.660 +    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
   1.661  }
   1.662 +
   1.663 +static void
   1.664 +add_frequency_field(MMythSchedulerUI * scheduler_ui, GtkWidget * vbox)
   1.665 +{
   1.666 +
   1.667 +    GtkWidget      *hbox = add_line(vbox, "Frequency: ");
   1.668 +
   1.669 +    scheduler_ui->freq_combobox = gtk_combo_box_new_text();
   1.670 +    gtk_box_pack_start(GTK_BOX(hbox), scheduler_ui->freq_combobox, FALSE,
   1.671 +                       FALSE, 0);
   1.672 +    gtk_combo_box_append_text(GTK_COMBO_BOX(scheduler_ui->freq_combobox),
   1.673 +                              ("Only this day               "));
   1.674 +    gtk_combo_box_append_text(GTK_COMBO_BOX(scheduler_ui->freq_combobox),
   1.675 +                              ("Daily                            "));
   1.676 +    gtk_combo_box_append_text(GTK_COMBO_BOX(scheduler_ui->freq_combobox),
   1.677 +                              ("Weekly                         "));
   1.678 +    gtk_combo_box_set_active(GTK_COMBO_BOX(scheduler_ui->freq_combobox),
   1.679 +                             0);
   1.680 +
   1.681 +}
   1.682 +
   1.683 +static void
   1.684 +add_title_field(MMythSchedulerUI * scheduler_ui, GtkWidget * vbox)
   1.685 +{
   1.686 +    GtkWidget      *hbox = add_line(vbox, "Title:           ");
   1.687 +
   1.688 +    scheduler_ui->title_entry = gtk_entry_new();
   1.689 +    gtk_box_pack_start(GTK_BOX(hbox), scheduler_ui->title_entry, FALSE,
   1.690 +                       FALSE, 0);
   1.691 +    gtk_entry_set_text(GTK_ENTRY(scheduler_ui->title_entry), "(Optional)");
   1.692 +
   1.693 +}