1.1 --- a/maemo-ui/src/mmyth_epg_grid_widget.c Fri Jan 12 21:26:30 2007 +0000
1.2 +++ b/maemo-ui/src/mmyth_epg_grid_widget.c Sat Jun 30 00:27:43 2007 +0100
1.3 @@ -12,498 +12,611 @@
1.4 #define PROGRAM_SEPARATION 2
1.5
1.6 enum {
1.7 - SELECTION_UPDATED_SIGNAL,
1.8 - LAST_SIGNAL
1.9 + SELECTION_UPDATED_SIGNAL,
1.10 + LAST_SIGNAL
1.11 };
1.12
1.13 struct _MMythEpgGridWidgetPrivate {
1.14 - /* private widget components */
1.15 - GtkWidget *epg_channels_vbox;
1.16 - GtkWidget *epg_programs_vbox;
1.17 -
1.18 - GHashTable *service_model_hash;
1.19 -
1.20 - /* guidegrid attributes */
1.21 - gboolean show_favorites;
1.22 - gint current_start_channel_id;
1.23 -
1.24 - GTimeVal* current_start_time;
1.25 - GTimeVal* current_end_time;
1.26 + /*
1.27 + * private widget components
1.28 + */
1.29 + GtkWidget *epg_channels_vbox;
1.30 + GtkWidget *epg_programs_vbox;
1.31
1.32 - guint selected_channel_index;
1.33 -
1.34 - /* GList of ProgramInfo for each Channel */
1.35 - GList * program_list[MAX_DISPLAY_CHANS];
1.36 - GList * channel_list;
1.37 -
1.38 - GMythEPG *mmyth_epg;
1.39 + GHashTable *service_model_hash;
1.40 +
1.41 + /*
1.42 + * guidegrid attributes
1.43 + */
1.44 + gboolean show_favorites;
1.45 + gint current_start_channel_id;
1.46 +
1.47 + GTimeVal *current_start_time;
1.48 + GTimeVal *current_end_time;
1.49 +
1.50 + guint selected_channel_index;
1.51 +
1.52 + /*
1.53 + * GList of ProgramInfo for each Channel
1.54 + */
1.55 + GList *program_list[MAX_DISPLAY_CHANS];
1.56 + GList *channel_list;
1.57 +
1.58 + GMythEPG *mmyth_epg;
1.59
1.60 GMythBackendInfo *backend_info;
1.61 -
1.62 - gint DISPLAY_CHANS;
1.63 +
1.64 + gint DISPLAY_CHANS;
1.65 };
1.66
1.67 -static void mmyth_epg_grid_widget_class_init (MMythEpgGridWidgetClass *klass);
1.68 -static void mmyth_epg_grid_widget_init (MMythEpgGridWidget *object);
1.69 -static void mmyth_epg_grid_widget_private_init (MMythEpgGridWidgetPrivate *private);
1.70 -static void mmyth_epg_grid_widget_mount_services (MMythEpgGridWidget *object,
1.71 - GTimeVal* start_time, GTimeVal* end_time);
1.72 -static void mmyth_epg_grid_widget_mount_header (MMythEpgGridWidget *object);
1.73 -static void mmyth_epg_grid_widget_clicked (GtkWidget* widget,
1.74 - GdkEventExpose *event,
1.75 - gpointer data);
1.76 -static GtkWidget *create_event_box_lbl (gchar *str, int width,
1.77 - const GdkColor *bg_color,
1.78 - const GdkColor *fg_color);
1.79 +static void mmyth_epg_grid_widget_class_init(MMythEpgGridWidgetClass *
1.80 + klass);
1.81 +static void mmyth_epg_grid_widget_init(MMythEpgGridWidget * object);
1.82 +static void
1.83 +mmyth_epg_grid_widget_private_init(MMythEpgGridWidgetPrivate * private);
1.84 +static void mmyth_epg_grid_widget_mount_services(MMythEpgGridWidget *
1.85 + object,
1.86 + GTimeVal * start_time,
1.87 + GTimeVal * end_time);
1.88 +static void mmyth_epg_grid_widget_mount_header(MMythEpgGridWidget *
1.89 + object);
1.90 +static void mmyth_epg_grid_widget_clicked(GtkWidget * widget,
1.91 + GdkEventExpose * event,
1.92 + gpointer data);
1.93 +static GtkWidget *create_event_box_lbl(gchar * str, int width,
1.94 + const GdkColor * bg_color,
1.95 + const GdkColor * fg_color);
1.96
1.97 -static void mmyth_epg_grid_widget_fill_programinfos(MMythEpgGridWidgetPrivate *private);
1.98 -static void mmyth_epg_grid_widget_fill_program_row_infos(
1.99 - MMythEpgGridWidgetPrivate *private,
1.100 - unsigned int chanNum, unsigned int row);
1.101 +static void
1.102 +mmyth_epg_grid_widget_fill_programinfos(MMythEpgGridWidgetPrivate *
1.103 + private);
1.104 +static void
1.105 +mmyth_epg_grid_widget_fill_program_row_infos(MMythEpgGridWidgetPrivate *
1.106 + private, unsigned int chanNum,
1.107 + unsigned int row);
1.108
1.109 -static gint mmyth_epg_grid_widget_signals[LAST_SIGNAL] = { 0 };
1.110 +static gint mmyth_epg_grid_widget_signals[LAST_SIGNAL] = { 0 };
1.111
1.112 -G_DEFINE_TYPE(MMythEpgGridWidget, mmyth_epg_grid_widget, GTK_TYPE_EVENT_BOX)
1.113 -
1.114 -static void
1.115 -mmyth_epg_grid_widget_class_init (MMythEpgGridWidgetClass *klass)
1.116 +G_DEFINE_TYPE(MMythEpgGridWidget, mmyth_epg_grid_widget,
1.117 + GTK_TYPE_EVENT_BOX)
1.118 +
1.119 + static void
1.120 +
1.121 +
1.122 +
1.123 +
1.124 +
1.125 +
1.126 +
1.127 +
1.128 +
1.129 +
1.130 +
1.131 +
1.132 +
1.133 + mmyth_epg_grid_widget_class_init(MMythEpgGridWidgetClass * klass)
1.134 {
1.135 - g_type_class_add_private (klass, sizeof (MMythEpgGridWidgetPrivate));
1.136 -
1.137 - mmyth_epg_grid_widget_signals[SELECTION_UPDATED_SIGNAL] = g_signal_new (
1.138 - "selection_updated",
1.139 - G_TYPE_FROM_CLASS(klass),
1.140 - G_SIGNAL_RUN_FIRST,
1.141 - 0,
1.142 - NULL,
1.143 - NULL,
1.144 - g_cclosure_marshal_VOID__POINTER,
1.145 - G_TYPE_NONE,
1.146 - 1,
1.147 + g_type_class_add_private(klass, sizeof(MMythEpgGridWidgetPrivate));
1.148 +
1.149 + mmyth_epg_grid_widget_signals[SELECTION_UPDATED_SIGNAL] =
1.150 + g_signal_new("selection_updated", G_TYPE_FROM_CLASS(klass),
1.151 + G_SIGNAL_RUN_FIRST, 0, NULL, NULL,
1.152 + g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
1.153 G_TYPE_POINTER);
1.154 }
1.155
1.156 -static void
1.157 -mmyth_epg_grid_widget_private_init (MMythEpgGridWidgetPrivate *private)
1.158 +static void
1.159 +mmyth_epg_grid_widget_private_init(MMythEpgGridWidgetPrivate * private)
1.160 {
1.161 - time_t cur_time;
1.162 -
1.163 - g_return_if_fail(private != NULL);
1.164 + time_t cur_time;
1.165
1.166 - private->epg_channels_vbox = NULL;
1.167 - private->epg_programs_vbox = NULL;
1.168 - private->service_model_hash = NULL;
1.169 + g_return_if_fail(private != NULL);
1.170 +
1.171 + private->epg_channels_vbox = NULL;
1.172 + private->epg_programs_vbox = NULL;
1.173 + private->service_model_hash = NULL;
1.174
1.175 private->show_favorites = FALSE;
1.176 private->current_start_channel_id = -1;
1.177
1.178 - /* Selected the first diplayable channel initially */
1.179 + /*
1.180 + * Selected the first diplayable channel initially
1.181 + */
1.182 private->selected_channel_index = 0;
1.183 -
1.184 - /* TODO fix the current start/end time */
1.185 - private->current_start_time = g_new0( GTimeVal, 1 );
1.186 +
1.187 + /*
1.188 + * TODO fix the current start/end time
1.189 + */
1.190 + private->current_start_time = g_new0(GTimeVal, 1);
1.191 private->current_start_time->tv_sec = time(&cur_time);
1.192
1.193 - private->current_end_time = g_new0( GTimeVal, 1 );
1.194 + private->current_end_time = g_new0(GTimeVal, 1);
1.195 private->current_end_time->tv_sec = time(&cur_time) + 10800;
1.196 -
1.197 +
1.198 private->DISPLAY_CHANS = MAX_DISPLAY_CHANS;
1.199
1.200 - private->backend_info = gmyth_backend_info_new_full ( "localhost", "mythtv",
1.201 - "mythtv", "mythconverg", 6543 );
1.202 + private->backend_info =
1.203 + gmyth_backend_info_new_full("localhost", "mythtv", "mythtv",
1.204 + "mythconverg", 6543);
1.205
1.206 // TODO: Close the epg and unref it in dispose call
1.207 - private->mmyth_epg = gmyth_epg_new ();
1.208 - if (!gmyth_epg_connect (private->mmyth_epg, private->backend_info)) {
1.209 - g_warning ("[%s] Could not connect mysql handler to db", __FUNCTION__);
1.210 - g_object_unref (private->mmyth_epg);
1.211 - private->mmyth_epg = NULL;
1.212 + private->mmyth_epg = gmyth_epg_new();
1.213 + if (!gmyth_epg_connect(private->mmyth_epg, private->backend_info)) {
1.214 + g_warning("[%s] Could not connect mysql handler to db",
1.215 + __FUNCTION__);
1.216 + g_object_unref(private->mmyth_epg);
1.217 + private->mmyth_epg = NULL;
1.218 }
1.219 }
1.220
1.221 static void
1.222 -mmyth_epg_grid_widget_init (MMythEpgGridWidget *mmyth_epg_grid_widget)
1.223 +mmyth_epg_grid_widget_init(MMythEpgGridWidget * mmyth_epg_grid_widget)
1.224 {
1.225 - MMythEpgGridWidgetPrivate *private =
1.226 + MMythEpgGridWidgetPrivate *private =
1.227 MMYTH_EPG_GRID_WIDGET_GET_PRIVATE(mmyth_epg_grid_widget);
1.228 -
1.229 - /* init private fields */
1.230 +
1.231 + /*
1.232 + * init private fields
1.233 + */
1.234 mmyth_epg_grid_widget_private_init(private);
1.235
1.236 - mmyth_epg_grid_widget->epg_view_model = NULL;
1.237 - mmyth_epg_grid_widget->selected_grid_item = NULL;
1.238 + mmyth_epg_grid_widget->epg_view_model = NULL;
1.239 + mmyth_epg_grid_widget->selected_grid_item = NULL;
1.240
1.241 - GtkWidget *epg_event_box = GTK_WIDGET(mmyth_epg_grid_widget);
1.242 + GtkWidget *epg_event_box = GTK_WIDGET(mmyth_epg_grid_widget);
1.243 gtk_widget_modify_bg(epg_event_box, GTK_STATE_NORMAL, &main_bg_color);
1.244 - gtk_widget_set_size_request (epg_event_box, 0, 125);
1.245 -
1.246 - GtkWidget *epg_main_hbox = gtk_hbox_new (FALSE, 10);
1.247 - gtk_container_set_border_width(GTK_CONTAINER (epg_main_hbox), 10);
1.248 -
1.249 - gtk_container_add (GTK_CONTAINER (epg_event_box),
1.250 - epg_main_hbox);
1.251 -
1.252 - /* channels vbox */
1.253 - GtkWidget *epg_channels_vbox = gtk_vbox_new (FALSE, 3);
1.254 - private->epg_channels_vbox = epg_channels_vbox;
1.255 + gtk_widget_set_size_request(epg_event_box, 0, 125);
1.256
1.257 - /* programs vbox */
1.258 - GtkWidget *epg_programs_vbox = gtk_vbox_new (FALSE, 3);
1.259 + GtkWidget *epg_main_hbox = gtk_hbox_new(FALSE, 10);
1.260 + gtk_container_set_border_width(GTK_CONTAINER(epg_main_hbox), 10);
1.261 +
1.262 + gtk_container_add(GTK_CONTAINER(epg_event_box), epg_main_hbox);
1.263 +
1.264 + /*
1.265 + * channels vbox
1.266 + */
1.267 + GtkWidget *epg_channels_vbox = gtk_vbox_new(FALSE, 3);
1.268 + private->epg_channels_vbox = epg_channels_vbox;
1.269 +
1.270 + /*
1.271 + * programs vbox
1.272 + */
1.273 + GtkWidget *epg_programs_vbox = gtk_vbox_new(FALSE, 3);
1.274 private->epg_programs_vbox = epg_programs_vbox;
1.275 -
1.276 - /* packing start */
1.277 - gtk_box_pack_start (GTK_BOX (epg_main_hbox),
1.278 - epg_channels_vbox, FALSE, FALSE, 0);
1.279 - gtk_box_pack_start (GTK_BOX (epg_main_hbox),
1.280 - epg_programs_vbox, FALSE, FALSE, 0);
1.281
1.282 - /* table header (first line) */
1.283 - mmyth_epg_grid_widget_mount_header(mmyth_epg_grid_widget);
1.284 -
1.285 - /* service programs */
1.286 - /* mount service programs with current time */
1.287 - mmyth_epg_grid_widget_mount_services(mmyth_epg_grid_widget,
1.288 + /*
1.289 + * packing start
1.290 + */
1.291 + gtk_box_pack_start(GTK_BOX(epg_main_hbox),
1.292 + epg_channels_vbox, FALSE, FALSE, 0);
1.293 + gtk_box_pack_start(GTK_BOX(epg_main_hbox),
1.294 + epg_programs_vbox, FALSE, FALSE, 0);
1.295 +
1.296 + /*
1.297 + * table header (first line)
1.298 + */
1.299 + mmyth_epg_grid_widget_mount_header(mmyth_epg_grid_widget);
1.300 +
1.301 + /*
1.302 + * service programs
1.303 + */
1.304 + /*
1.305 + * mount service programs with current time
1.306 + */
1.307 + mmyth_epg_grid_widget_mount_services(mmyth_epg_grid_widget,
1.308 private->current_start_time,
1.309 - private->current_end_time);
1.310 + private->current_end_time);
1.311 }
1.312
1.313 -GtkWidget*
1.314 -mmyth_epg_grid_widget_new ()
1.315 +GtkWidget *
1.316 +mmyth_epg_grid_widget_new()
1.317 {
1.318 - return GTK_WIDGET ( gtk_type_new (mmyth_epg_grid_widget_get_type ()));
1.319 + return GTK_WIDGET(gtk_type_new(mmyth_epg_grid_widget_get_type()));
1.320 }
1.321
1.322 static void
1.323 -mmyth_epg_grid_widget_mount_services( MMythEpgGridWidget *mmyth_epg_grid_widget,
1.324 - GTimeVal* start_time, GTimeVal* end_time )
1.325 +mmyth_epg_grid_widget_mount_services(MMythEpgGridWidget *
1.326 + mmyth_epg_grid_widget,
1.327 + GTimeVal * start_time,
1.328 + GTimeVal * end_time)
1.329 {
1.330 - GList *proglist;
1.331 - GList *channel_list = NULL;
1.332 + GList *proglist;
1.333 + GList *channel_list = NULL;
1.334 GMythChannelInfo *channel_info;
1.335
1.336 - int chanid;
1.337 - MMythEpgGridWidgetPrivate *private =
1.338 + int chanid;
1.339 + MMythEpgGridWidgetPrivate *private =
1.340 MMYTH_EPG_GRID_WIDGET_GET_PRIVATE(mmyth_epg_grid_widget);
1.341 -
1.342 - // update view_model
1.343 - /* FIXME shallow free or recursive? */
1.344 - if(mmyth_epg_grid_widget->epg_view_model != NULL) {
1.345 - g_list_free(mmyth_epg_grid_widget->epg_view_model);
1.346 - mmyth_epg_grid_widget->epg_view_model = NULL;
1.347 - }
1.348 -
1.349 - if(private->service_model_hash != NULL) {
1.350 - g_hash_table_destroy(private->service_model_hash);
1.351 - }
1.352
1.353 - private->service_model_hash = g_hash_table_new(NULL, NULL);
1.354 + // update view_model
1.355 + /*
1.356 + * FIXME shallow free or recursive?
1.357 + */
1.358 + if (mmyth_epg_grid_widget->epg_view_model != NULL) {
1.359 + g_list_free(mmyth_epg_grid_widget->epg_view_model);
1.360 + mmyth_epg_grid_widget->epg_view_model = NULL;
1.361 + }
1.362
1.363 - /* fill program infos from db */
1.364 + if (private->service_model_hash != NULL) {
1.365 + g_hash_table_destroy(private->service_model_hash);
1.366 + }
1.367 +
1.368 + private->service_model_hash = g_hash_table_new(NULL, NULL);
1.369 +
1.370 + /*
1.371 + * fill program infos from db
1.372 + */
1.373 mmyth_epg_grid_widget_fill_programinfos(private);
1.374 -
1.375 +
1.376 channel_list = private->channel_list;
1.377 -
1.378 - /* for each channel get_programs() */
1.379 - for (chanid=0; channel_list &&
1.380 - chanid < private->DISPLAY_CHANS; chanid++) {
1.381 - proglist = (GList *) private->program_list[chanid];
1.382 -
1.383 +
1.384 + /*
1.385 + * for each channel get_programs()
1.386 + */
1.387 + for (chanid = 0; channel_list &&
1.388 + chanid < private->DISPLAY_CHANS; chanid++) {
1.389 + proglist = (GList *) private->program_list[chanid];
1.390 +
1.391 channel_info = (GMythChannelInfo *) channel_list->data;
1.392 - channel_list = g_list_next(channel_list);
1.393 + channel_list = g_list_next(channel_list);
1.394
1.395 - /* Service Title*/
1.396 - GString *name = NULL;
1.397 + /*
1.398 + * Service Title
1.399 + */
1.400 + GString *name = NULL;
1.401 if (channel_info->channel_name)
1.402 - name = g_string_new (channel_info->channel_name->str);
1.403 -
1.404 - GdkColor title_bg_color;
1.405 - title_bg_color.red = 5000;
1.406 - title_bg_color.green = 9000;
1.407 - title_bg_color.blue = 40000;
1.408 -
1.409 - GdkColor title_fg_color;
1.410 - title_fg_color.red = 60000;
1.411 - title_fg_color.green = 60000;
1.412 - title_fg_color.blue = 60000;
1.413 -
1.414 - GtkWidget *event_box_channel = create_event_box_lbl(
1.415 - name->str, 90,
1.416 - &title_bg_color,
1.417 - &title_fg_color);
1.418 + name = g_string_new(channel_info->channel_name->str);
1.419
1.420 - gtk_box_pack_start (GTK_BOX (private->epg_channels_vbox),
1.421 - event_box_channel, FALSE, FALSE, 0);
1.422 + GdkColor title_bg_color;
1.423 + title_bg_color.red = 5000;
1.424 + title_bg_color.green = 9000;
1.425 + title_bg_color.blue = 40000;
1.426
1.427 - GtkWidget *epg_line_hbox = gtk_hbox_new (FALSE, 0);
1.428 + GdkColor title_fg_color;
1.429 + title_fg_color.red = 60000;
1.430 + title_fg_color.green = 60000;
1.431 + title_fg_color.blue = 60000;
1.432
1.433 - GdkColor bg_color;
1.434 - bg_color.red = 5000;
1.435 - bg_color.green = 30000;
1.436 - bg_color.blue = 60000;
1.437 -
1.438 - GdkColor fg_color;
1.439 - fg_color.red = 60000;
1.440 - fg_color.green = 60000;
1.441 - fg_color.blue = 60000;
1.442 -
1.443 - /* Content parsing */
1.444 - GList *epg_grid_list = NULL;
1.445 + GtkWidget *event_box_channel =
1.446 + create_event_box_lbl(name->str, 90,
1.447 + &title_bg_color,
1.448 + &title_fg_color);
1.449 +
1.450 + gtk_box_pack_start(GTK_BOX(private->epg_channels_vbox),
1.451 + event_box_channel, FALSE, FALSE, 0);
1.452 +
1.453 + GtkWidget *epg_line_hbox = gtk_hbox_new(FALSE, 0);
1.454 +
1.455 + GdkColor bg_color;
1.456 + bg_color.red = 5000;
1.457 + bg_color.green = 30000;
1.458 + bg_color.blue = 60000;
1.459 +
1.460 + GdkColor fg_color;
1.461 + fg_color.red = 60000;
1.462 + fg_color.green = 60000;
1.463 + fg_color.blue = 60000;
1.464 +
1.465 + /*
1.466 + * Content parsing
1.467 + */
1.468 + GList *epg_grid_list = NULL;
1.469
1.470 GMythProgramInfo *proginfo;
1.471 - int pixel_count = 0;
1.472 + int pixel_count = 0;
1.473 for (; proglist; proglist = proglist->next) {
1.474 proginfo = (GMythProgramInfo *) proglist->data;
1.475 -
1.476 - GString *content_name = proginfo->title;
1.477 -
1.478 - GTimeVal* initial_time = g_new0( GTimeVal, 1 );
1.479 - GTimeVal* last_time = g_new0( GTimeVal, 1 );
1.480 - GTimeVal* duration = g_new0( GTimeVal, 1 );
1.481
1.482 - GTimeVal* schedule_start_time = proginfo->startts;
1.483 - GTimeVal* schedule_end_time = proginfo->endts;
1.484 + GString *content_name = proginfo->title;
1.485
1.486 - initial_time->tv_sec =
1.487 - (schedule_start_time->tv_sec < start_time->tv_sec) ? start_time->tv_sec : schedule_start_time->tv_sec;
1.488 - last_time->tv_sec = (schedule_end_time->tv_sec > end_time->tv_sec) ? end_time->tv_sec : schedule_end_time->tv_sec;
1.489 - duration->tv_sec = last_time->tv_sec - initial_time->tv_sec;
1.490 -
1.491 + GTimeVal *initial_time = g_new0(GTimeVal, 1);
1.492 + GTimeVal *last_time = g_new0(GTimeVal, 1);
1.493 + GTimeVal *duration = g_new0(GTimeVal, 1);
1.494 +
1.495 + GTimeVal *schedule_start_time = proginfo->startts;
1.496 + GTimeVal *schedule_end_time = proginfo->endts;
1.497 +
1.498 + initial_time->tv_sec =
1.499 + (schedule_start_time->tv_sec <
1.500 + start_time->tv_sec) ? start_time->
1.501 + tv_sec : schedule_start_time->tv_sec;
1.502 + last_time->tv_sec =
1.503 + (schedule_end_time->tv_sec >
1.504 + end_time->tv_sec) ? end_time->tv_sec : schedule_end_time->
1.505 + tv_sec;
1.506 + duration->tv_sec = last_time->tv_sec - initial_time->tv_sec;
1.507 +
1.508 // Verify program time
1.509 - #if 0
1.510 - g_debug ("ServiceID: %d, ScheduleID: %d\n", service->id, schedule->id);
1.511 - fprintf (stderr, "program time\nfrom = %d, to = %d\n",
1.512 - schedule->validFrom, schedule->validTo);
1.513 -
1.514 - struct tm loctime;
1.515 -
1.516 - /* Convert it to local time representation. */
1.517 - if (localtime_r((time_t *)&schedule->validFrom, &loctime) == NULL) {
1.518 - g_warning ("localtime_r error in mmyth_epg_grid_widget!\n");
1.519 - return NULL;
1.520 - }
1.521 - fprintf (stderr, asctime (&loctime));
1.522 -
1.523 - if (localtime_r((time_t *)&schedule->validTo, &loctime) == NULL) {
1.524 - g_warning ("localtime_r error in mmyth_epg_grid_widget!\n");
1.525 - return NULL;
1.526 - }
1.527 - fprintf (stderr, asctime (&loctime));
1.528 - #endif
1.529 -
1.530 - /* fprintf(stderr, "duration = %d\n", duration); */
1.531 - double duration_hour = duration->tv_sec / (double) 3600.0;
1.532 - /* fprintf(stderr, "duration_hour = %lf\n", duration_hour); */
1.533 -
1.534 - int size = PIXELS_HOUR * duration_hour;
1.535 -
1.536 - /* complete hour */
1.537 - /* FIXME: UGLY WRONG HACK TO ALIGN PROGRAM TIME!!!*/
1.538 - if( last_time->tv_sec % 3600 != 0 ) {
1.539 - size -= PROGRAM_SEPARATION;
1.540 +#if 0
1.541 + g_debug("ServiceID: %d, ScheduleID: %d\n", service->id,
1.542 + schedule->id);
1.543 + fprintf(stderr, "program time\nfrom = %d, to = %d\n",
1.544 + schedule->validFrom, schedule->validTo);
1.545 +
1.546 + struct tm loctime;
1.547 +
1.548 + /*
1.549 + * Convert it to local time representation.
1.550 + */
1.551 + if (localtime_r((time_t *) & schedule->validFrom, &loctime) ==
1.552 + NULL) {
1.553 + g_warning("localtime_r error in mmyth_epg_grid_widget!\n");
1.554 + return NULL;
1.555 }
1.556 - if ( initial_time->tv_sec % 3600 != 0 ) {
1.557 - size -= PROGRAM_SEPARATION;
1.558 + fprintf(stderr, asctime(&loctime));
1.559 +
1.560 + if (localtime_r((time_t *) & schedule->validTo, &loctime) ==
1.561 + NULL) {
1.562 + g_warning("localtime_r error in mmyth_epg_grid_widget!\n");
1.563 + return NULL;
1.564 + }
1.565 + fprintf(stderr, asctime(&loctime));
1.566 +#endif
1.567 +
1.568 + /*
1.569 + * fprintf(stderr, "duration = %d\n", duration);
1.570 + */
1.571 + double duration_hour =
1.572 + duration->tv_sec / (double) 3600.0;
1.573 + /*
1.574 + * fprintf(stderr, "duration_hour = %lf\n", duration_hour);
1.575 + */
1.576 +
1.577 + int size = PIXELS_HOUR * duration_hour;
1.578 +
1.579 + /*
1.580 + * complete hour
1.581 + */
1.582 + /*
1.583 + * FIXME: UGLY WRONG HACK TO ALIGN PROGRAM TIME!!!
1.584 + */
1.585 + if (last_time->tv_sec % 3600 != 0) {
1.586 + size -= PROGRAM_SEPARATION;
1.587 + }
1.588 + if (initial_time->tv_sec % 3600 != 0) {
1.589 + size -= PROGRAM_SEPARATION;
1.590 }
1.591
1.592 pixel_count += size + PROGRAM_SEPARATION;
1.593 - GtkWidget *event_box = create_event_box_lbl(content_name->str,
1.594 - size, &bg_color,
1.595 - &fg_color);
1.596 - gtk_widget_add_events(event_box,
1.597 - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
1.598 -
1.599 - /* create EpgGridItem */
1.600 - EpgGridItem *epg_grid_item = g_new0(EpgGridItem, 1);
1.601 - epg_grid_item->proginfo = proginfo;
1.602 + GtkWidget *event_box =
1.603 + create_event_box_lbl(content_name->str,
1.604 + size, &bg_color,
1.605 + &fg_color);
1.606 + gtk_widget_add_events(event_box,
1.607 + GDK_BUTTON_PRESS_MASK |
1.608 + GDK_BUTTON_RELEASE_MASK);
1.609 +
1.610 + /*
1.611 + * create EpgGridItem
1.612 + */
1.613 + EpgGridItem *epg_grid_item = g_new0(EpgGridItem, 1);
1.614 + epg_grid_item->proginfo = proginfo;
1.615 epg_grid_item->event_box = event_box;
1.616 - epg_grid_item->object = mmyth_epg_grid_widget;
1.617 -
1.618 - epg_grid_list = g_list_prepend(epg_grid_list, (gpointer) epg_grid_item);
1.619 + epg_grid_item->object = mmyth_epg_grid_widget;
1.620
1.621 - gtk_box_pack_start (GTK_BOX (epg_line_hbox),
1.622 - event_box, FALSE, FALSE, PROGRAM_SEPARATION);
1.623 -
1.624 - g_signal_connect (G_OBJECT (event_box), "button-press-event",
1.625 - G_CALLBACK (mmyth_epg_grid_widget_clicked),
1.626 - (gpointer*) epg_grid_list);
1.627 + epg_grid_list =
1.628 + g_list_prepend(epg_grid_list, (gpointer) epg_grid_item);
1.629 +
1.630 + gtk_box_pack_start(GTK_BOX(epg_line_hbox),
1.631 + event_box, FALSE, FALSE,
1.632 + PROGRAM_SEPARATION);
1.633 +
1.634 + g_signal_connect(G_OBJECT(event_box), "button-press-event",
1.635 + G_CALLBACK(mmyth_epg_grid_widget_clicked),
1.636 + (gpointer *) epg_grid_list);
1.637 }
1.638 #if 0
1.639 - printf("chaind = %d!!!!" chanid);fflush(stdout);
1.640 -#endif
1.641 + printf("chaind = %d!!!!" chanid);
1.642 + fflush(stdout);
1.643 +#endif
1.644
1.645 - if(!epg_grid_list) {
1.646 - /* No programs for current channel */
1.647 - /* FIXME: size HARDCODED */
1.648 - GtkWidget *event_box = create_event_box_lbl("No program list available",
1.649 - PIXELS_HOUR * 3, &bg_color,
1.650 - &fg_color);
1.651 - gtk_widget_add_events(event_box,
1.652 - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
1.653 + if (!epg_grid_list) {
1.654 + /*
1.655 + * No programs for current channel
1.656 + */
1.657 + /*
1.658 + * FIXME: size HARDCODED
1.659 + */
1.660 + GtkWidget *event_box =
1.661 + create_event_box_lbl("No program list available",
1.662 + PIXELS_HOUR * 3, &bg_color,
1.663 + &fg_color);
1.664 + gtk_widget_add_events(event_box,
1.665 + GDK_BUTTON_PRESS_MASK |
1.666 + GDK_BUTTON_RELEASE_MASK);
1.667
1.668 - /* create EpgGridItem */
1.669 - EpgGridItem *epg_grid_item = g_new0(EpgGridItem, 1);
1.670 - epg_grid_item->proginfo = NULL;
1.671 + /*
1.672 + * create EpgGridItem
1.673 + */
1.674 + EpgGridItem *epg_grid_item = g_new0(EpgGridItem, 1);
1.675 + epg_grid_item->proginfo = NULL;
1.676 epg_grid_item->event_box = event_box;
1.677 - epg_grid_item->object = mmyth_epg_grid_widget;
1.678 + epg_grid_item->object = mmyth_epg_grid_widget;
1.679
1.680 - epg_grid_list = g_list_prepend(epg_grid_list, (gpointer) epg_grid_item);
1.681 -
1.682 - gtk_box_pack_start (GTK_BOX (epg_line_hbox),
1.683 - event_box, FALSE, FALSE, PROGRAM_SEPARATION);
1.684 -
1.685 - g_signal_connect (G_OBJECT (event_box), "button-press-event",
1.686 - G_CALLBACK (mmyth_epg_grid_widget_clicked),
1.687 - (gpointer*) epg_grid_list);
1.688 + epg_grid_list =
1.689 + g_list_prepend(epg_grid_list, (gpointer) epg_grid_item);
1.690 +
1.691 + gtk_box_pack_start(GTK_BOX(epg_line_hbox),
1.692 + event_box, FALSE, FALSE,
1.693 + PROGRAM_SEPARATION);
1.694 +
1.695 + g_signal_connect(G_OBJECT(event_box), "button-press-event",
1.696 + G_CALLBACK(mmyth_epg_grid_widget_clicked),
1.697 + (gpointer *) epg_grid_list);
1.698 }
1.699
1.700 epg_grid_list = g_list_reverse(epg_grid_list);
1.701 - mmyth_epg_grid_widget->epg_view_model =
1.702 - g_list_append(mmyth_epg_grid_widget->epg_view_model, epg_grid_list);
1.703 -
1.704 - gtk_box_pack_start (GTK_BOX (private->epg_programs_vbox),
1.705 - epg_line_hbox, FALSE, FALSE, 0);
1.706 + mmyth_epg_grid_widget->epg_view_model =
1.707 + g_list_append(mmyth_epg_grid_widget->epg_view_model,
1.708 + epg_grid_list);
1.709 +
1.710 + gtk_box_pack_start(GTK_BOX(private->epg_programs_vbox),
1.711 + epg_line_hbox, FALSE, FALSE, 0);
1.712 }
1.713 }
1.714
1.715 static void
1.716 -mmyth_epg_grid_widget_mount_header(MMythEpgGridWidget *mmyth_epg_grid_widget)
1.717 -{
1.718 - MMythEpgGridWidgetPrivate *private =
1.719 +mmyth_epg_grid_widget_mount_header(MMythEpgGridWidget *
1.720 + mmyth_epg_grid_widget)
1.721 +{
1.722 + MMythEpgGridWidgetPrivate *private =
1.723 MMYTH_EPG_GRID_WIDGET_GET_PRIVATE(mmyth_epg_grid_widget);
1.724 -
1.725 - struct tm hour_tm;
1.726 - const gchar name_title[] = "Today";
1.727 - GtkWidget * lbl_title = gtk_label_new(name_title);
1.728
1.729 - gtk_misc_set_alignment (GTK_MISC(lbl_title), 0.0, 0.5);
1.730 -
1.731 - gtk_box_pack_start (GTK_BOX (private->epg_channels_vbox),
1.732 - lbl_title, FALSE, FALSE, 0);
1.733 + struct tm hour_tm;
1.734 + const gchar name_title[] = "Today";
1.735 + GtkWidget *lbl_title = gtk_label_new(name_title);
1.736
1.737 - /* hours title line */
1.738 - GtkWidget *epg_programs_hours_hbox = gtk_hbox_new (TRUE, 0);
1.739 + gtk_misc_set_alignment(GTK_MISC(lbl_title), 0.0, 0.5);
1.740
1.741 - if (localtime_r((time_t *)&private->current_start_time->tv_sec, &hour_tm) == NULL) {
1.742 - g_warning ("localtime_r error in mmyth_epg_grid_widget!\n");
1.743 + gtk_box_pack_start(GTK_BOX(private->epg_channels_vbox),
1.744 + lbl_title, FALSE, FALSE, 0);
1.745 +
1.746 + /*
1.747 + * hours title line
1.748 + */
1.749 + GtkWidget *epg_programs_hours_hbox = gtk_hbox_new(TRUE, 0);
1.750 +
1.751 + if (localtime_r
1.752 + ((time_t *) & private->current_start_time->tv_sec,
1.753 + &hour_tm) == NULL) {
1.754 + g_warning("localtime_r error in mmyth_epg_grid_widget!\n");
1.755 return;
1.756 - }
1.757 + }
1.758
1.759 - if (hour_tm.tm_min>30) {
1.760 + if (hour_tm.tm_min > 30) {
1.761 hour_tm.tm_min = 30;
1.762 - } else if (hour_tm.tm_min>0) {
1.763 + } else if (hour_tm.tm_min > 0) {
1.764 hour_tm.tm_min = 0;
1.765 }
1.766 -
1.767 - gchar hour1_str[10];
1.768 +
1.769 + gchar hour1_str[10];
1.770 strftime(hour1_str, 8, "%H:%M", &hour_tm);
1.771 - GtkWidget * lbl_hour1 = gtk_label_new(hour1_str);
1.772 - gtk_misc_set_alignment (GTK_MISC(lbl_hour1), 0.0, 0.5);
1.773 -
1.774 - hour_tm.tm_hour++;
1.775 - gchar hour2_str[10];
1.776 - strftime(hour2_str, 8, "%H:%M", &hour_tm);
1.777 - GtkWidget * lbl_hour2 = gtk_label_new(hour2_str);
1.778 - gtk_misc_set_alignment (GTK_MISC(lbl_hour2), 0.0, 0.5);
1.779 + GtkWidget *lbl_hour1 = gtk_label_new(hour1_str);
1.780 + gtk_misc_set_alignment(GTK_MISC(lbl_hour1), 0.0, 0.5);
1.781
1.782 hour_tm.tm_hour++;
1.783 - gchar hour3_str[10];
1.784 + gchar hour2_str[10];
1.785 + strftime(hour2_str, 8, "%H:%M", &hour_tm);
1.786 + GtkWidget *lbl_hour2 = gtk_label_new(hour2_str);
1.787 + gtk_misc_set_alignment(GTK_MISC(lbl_hour2), 0.0, 0.5);
1.788 +
1.789 + hour_tm.tm_hour++;
1.790 + gchar hour3_str[10];
1.791 strftime(hour3_str, 8, "%H:%M", &hour_tm);
1.792 - GtkWidget * lbl_hour3 = gtk_label_new(hour3_str);
1.793 - gtk_misc_set_alignment (GTK_MISC(lbl_hour3), 0.0, 0.5);
1.794 -
1.795 - gtk_box_pack_start (GTK_BOX (epg_programs_hours_hbox),
1.796 - lbl_hour1, TRUE, TRUE, 0);
1.797 - gtk_box_pack_start (GTK_BOX (epg_programs_hours_hbox),
1.798 - lbl_hour2, TRUE, TRUE, 0);
1.799 - gtk_box_pack_start (GTK_BOX (epg_programs_hours_hbox),
1.800 - lbl_hour3, TRUE, TRUE, 0);
1.801 -
1.802 - gtk_box_pack_start (GTK_BOX (private->epg_programs_vbox),
1.803 - epg_programs_hours_hbox, FALSE, FALSE, 0);
1.804 + GtkWidget *lbl_hour3 = gtk_label_new(hour3_str);
1.805 + gtk_misc_set_alignment(GTK_MISC(lbl_hour3), 0.0, 0.5);
1.806 +
1.807 + gtk_box_pack_start(GTK_BOX(epg_programs_hours_hbox),
1.808 + lbl_hour1, TRUE, TRUE, 0);
1.809 + gtk_box_pack_start(GTK_BOX(epg_programs_hours_hbox),
1.810 + lbl_hour2, TRUE, TRUE, 0);
1.811 + gtk_box_pack_start(GTK_BOX(epg_programs_hours_hbox),
1.812 + lbl_hour3, TRUE, TRUE, 0);
1.813 +
1.814 + gtk_box_pack_start(GTK_BOX(private->epg_programs_vbox),
1.815 + epg_programs_hours_hbox, FALSE, FALSE, 0);
1.816 }
1.817
1.818 /******************************************************************************
1.819 * INTERNAL CALLBACKS FOR STATE CHANGE *
1.820 *****************************************************************************/
1.821 -static void
1.822 -mmyth_epg_grid_widget_deselect_service(MMythEpgGridWidget *mmyth_epg_grid_widget)
1.823 +static void
1.824 +mmyth_epg_grid_widget_deselect_service(MMythEpgGridWidget *
1.825 + mmyth_epg_grid_widget)
1.826 {
1.827 - EpgGridItem *epg_grid_item;
1.828 -
1.829 - /* deselect*/
1.830 - if(mmyth_epg_grid_widget->selected_grid_item != NULL) {
1.831 - epg_grid_item =
1.832 - (EpgGridItem*) mmyth_epg_grid_widget->selected_grid_item->data;
1.833 - gtk_widget_set_state(GTK_WIDGET(epg_grid_item->event_box), GTK_STATE_NORMAL);
1.834 - }
1.835 + EpgGridItem *epg_grid_item;
1.836 +
1.837 + /*
1.838 + * deselect
1.839 + */
1.840 + if (mmyth_epg_grid_widget->selected_grid_item != NULL) {
1.841 + epg_grid_item =
1.842 + (EpgGridItem *) mmyth_epg_grid_widget->selected_grid_item->
1.843 + data;
1.844 + gtk_widget_set_state(GTK_WIDGET(epg_grid_item->event_box),
1.845 + GTK_STATE_NORMAL);
1.846 + }
1.847 }
1.848
1.849 -static void
1.850 -mmyth_epg_grid_widget_clicked (GtkWidget* widget,
1.851 - GdkEventExpose *event, gpointer data)
1.852 -{
1.853 +static void
1.854 +mmyth_epg_grid_widget_clicked(GtkWidget * widget,
1.855 + GdkEventExpose * event, gpointer data)
1.856 +{
1.857 g_return_if_fail(data != NULL);
1.858
1.859 - GList *epg_grid_item_list = (GList *) data;
1.860 - EpgGridItem *epg_grid_item = (EpgGridItem *) epg_grid_item_list->data;
1.861 + GList *epg_grid_item_list = (GList *) data;
1.862 + EpgGridItem *epg_grid_item =
1.863 + (EpgGridItem *) epg_grid_item_list->data;
1.864
1.865 - /* update the selected service */
1.866 - mmyth_epg_grid_widget_update_service( epg_grid_item->object, (GList*) data );
1.867 + /*
1.868 + * update the selected service
1.869 + */
1.870 + mmyth_epg_grid_widget_update_service(epg_grid_item->object,
1.871 + (GList *) data);
1.872 }
1.873
1.874 void
1.875 mmyth_epg_grid_widget_update_service(MMythEpgGridWidget * object,
1.876 - GList *selected_grid_list)
1.877 + GList * selected_grid_list)
1.878 {
1.879 g_return_if_fail(object != NULL);
1.880 g_return_if_fail(selected_grid_list != NULL);
1.881 -
1.882 - EpgGridItem *epg_grid_item = (EpgGridItem *) selected_grid_list->data;
1.883 +
1.884 + EpgGridItem *epg_grid_item =
1.885 + (EpgGridItem *) selected_grid_list->data;
1.886
1.887 mmyth_epg_grid_widget_deselect_service(epg_grid_item->object);
1.888
1.889 - /* updating current selected schedule_item and schedule_list*/
1.890 + /*
1.891 + * updating current selected schedule_item and schedule_list
1.892 + */
1.893 object->selected_grid_item = selected_grid_list;
1.894 -
1.895 - /* set state of the event box */
1.896 - gtk_widget_set_state(GTK_WIDGET(epg_grid_item->event_box), GTK_STATE_SELECTED);
1.897 - /* emit update signal for listeners */
1.898 - g_signal_emit(object,
1.899 +
1.900 + /*
1.901 + * set state of the event box
1.902 + */
1.903 + gtk_widget_set_state(GTK_WIDGET(epg_grid_item->event_box),
1.904 + GTK_STATE_SELECTED);
1.905 + /*
1.906 + * emit update signal for listeners
1.907 + */
1.908 + g_signal_emit(object,
1.909 mmyth_epg_grid_widget_signals[SELECTION_UPDATED_SIGNAL],
1.910 - 0,
1.911 - (gpointer) epg_grid_item);
1.912 + 0, (gpointer) epg_grid_item);
1.913 }
1.914
1.915 -static GtkWidget *
1.916 -create_event_box_lbl(gchar *str, int width, const GdkColor *bg_color,
1.917 - const GdkColor *fg_color)
1.918 +static GtkWidget *
1.919 +create_event_box_lbl(gchar * str, int width, const GdkColor * bg_color,
1.920 + const GdkColor * fg_color)
1.921 {
1.922 - GtkWidget *event_box = gtk_event_box_new();
1.923 - GtkWidget *lbl = gtk_label_new(str);
1.924 + GtkWidget *event_box = gtk_event_box_new();
1.925 + GtkWidget *lbl = gtk_label_new(str);
1.926 gtk_label_set_ellipsize(GTK_LABEL(lbl), PANGO_ELLIPSIZE_END);
1.927
1.928 - gtk_widget_modify_bg(event_box, GTK_STATE_NORMAL, bg_color);
1.929 - gtk_widget_modify_fg(lbl, GTK_STATE_NORMAL, fg_color);
1.930 -
1.931 - /* selected colors are const*/
1.932 - GdkColor selected_bg_color;
1.933 + gtk_widget_modify_bg(event_box, GTK_STATE_NORMAL, bg_color);
1.934 + gtk_widget_modify_fg(lbl, GTK_STATE_NORMAL, fg_color);
1.935 +
1.936 + /*
1.937 + * selected colors are const
1.938 + */
1.939 + GdkColor selected_bg_color;
1.940 selected_bg_color.red = 100;
1.941 selected_bg_color.green = 40000;
1.942 - selected_bg_color.blue = 100;
1.943 + selected_bg_color.blue = 100;
1.944
1.945 - GdkColor selected_fg_color;
1.946 + GdkColor selected_fg_color;
1.947 selected_fg_color.red = 100;
1.948 selected_fg_color.green = 100;
1.949 - selected_fg_color.blue = 100;
1.950 -
1.951 - gtk_widget_modify_bg(event_box, GTK_STATE_SELECTED, &selected_bg_color);
1.952 - gtk_widget_modify_fg(lbl, GTK_STATE_SELECTED, &selected_fg_color);
1.953 -
1.954 - gtk_misc_set_alignment (GTK_MISC(lbl), 0.0, 0.5);
1.955 - gtk_container_add (GTK_CONTAINER (event_box),
1.956 - lbl);
1.957 - gtk_widget_set_size_request(event_box, width, -1);
1.958 -
1.959 + selected_fg_color.blue = 100;
1.960 +
1.961 + gtk_widget_modify_bg(event_box, GTK_STATE_SELECTED,
1.962 + &selected_bg_color);
1.963 + gtk_widget_modify_fg(lbl, GTK_STATE_SELECTED, &selected_fg_color);
1.964 +
1.965 + gtk_misc_set_alignment(GTK_MISC(lbl), 0.0, 0.5);
1.966 + gtk_container_add(GTK_CONTAINER(event_box), lbl);
1.967 + gtk_widget_set_size_request(event_box, width, -1);
1.968 +
1.969 return event_box;
1.970 }
1.971
1.972 @@ -511,122 +624,153 @@
1.973 * METHODS *
1.974 *****************************************************************************/
1.975
1.976 -/* Callback for hardware keys */
1.977 +/*
1.978 + * Callback for hardware keys
1.979 + */
1.980 gboolean
1.981 -mmyth_epg_grid_widget_key_press (MMythEpgGridWidget * object,
1.982 - GtkWidget * widget, GdkEventKey * event)
1.983 +mmyth_epg_grid_widget_key_press(MMythEpgGridWidget * object,
1.984 + GtkWidget * widget, GdkEventKey * event)
1.985 {
1.986 - MMythEpgGridWidgetPrivate *private =
1.987 + MMythEpgGridWidgetPrivate *private =
1.988 MMYTH_EPG_GRID_WIDGET_GET_PRIVATE(object);
1.989 -
1.990 - EpgGridItem *epg_grid_item;
1.991 - GList *tmp;
1.992 -
1.993 - /* List of selected_grid_item */
1.994 - GList *selected_view_model;
1.995 -
1.996 - gint channel_index;
1.997 -
1.998 - if(object->selected_grid_item == NULL) {
1.999 - g_warning ("No program selected");
1.1000 - return FALSE;
1.1001 - }
1.1002 -
1.1003 - epg_grid_item = (EpgGridItem*) object->selected_grid_item->data;
1.1004 -
1.1005 +
1.1006 + EpgGridItem *epg_grid_item;
1.1007 + GList *tmp;
1.1008 +
1.1009 + /*
1.1010 + * List of selected_grid_item
1.1011 + */
1.1012 + GList *selected_view_model;
1.1013 +
1.1014 + gint channel_index;
1.1015 +
1.1016 + if (object->selected_grid_item == NULL) {
1.1017 + g_warning("No program selected");
1.1018 + return FALSE;
1.1019 + }
1.1020 +
1.1021 + epg_grid_item = (EpgGridItem *) object->selected_grid_item->data;
1.1022 +
1.1023 channel_index = private->selected_channel_index;
1.1024 -
1.1025 +
1.1026 switch (event->keyval) {
1.1027 - case GDK_Up:
1.1028 - selected_view_model = g_list_nth( object->epg_view_model, channel_index - 1 );
1.1029 - if(selected_view_model != NULL) {
1.1030 - private->selected_channel_index = channel_index - 1;
1.1031 - tmp = (GList *) selected_view_model->data;
1.1032 - /* TODO: select a better centralized item
1.1033 - currently is picking the 1st or last item */
1.1034 - if(g_list_next(object->selected_grid_item) == NULL &&
1.1035 - g_list_previous(object->selected_grid_item) != NULL) {
1.1036 - /* in this case the new selected will be the last */
1.1037 - tmp = g_list_last(tmp);
1.1038 - }
1.1039 + case GDK_Up:
1.1040 + selected_view_model =
1.1041 + g_list_nth(object->epg_view_model, channel_index - 1);
1.1042 + if (selected_view_model != NULL) {
1.1043 + private->selected_channel_index = channel_index - 1;
1.1044 + tmp = (GList *) selected_view_model->data;
1.1045 + /*
1.1046 + * TODO: select a better centralized item currently is
1.1047 + * picking the 1st or last item
1.1048 + */
1.1049 + if (g_list_next(object->selected_grid_item) == NULL &&
1.1050 + g_list_previous(object->selected_grid_item) != NULL) {
1.1051 + /*
1.1052 + * in this case the new selected will be the last
1.1053 + */
1.1054 + tmp = g_list_last(tmp);
1.1055 + }
1.1056
1.1057 - /* update the selected service */
1.1058 - mmyth_epg_grid_widget_update_service( object, tmp );
1.1059 - }
1.1060 - return TRUE;
1.1061 - case GDK_Down:
1.1062 - selected_view_model = g_list_nth( object->epg_view_model, channel_index + 1 );
1.1063 - if(selected_view_model != NULL) {
1.1064 - private->selected_channel_index = channel_index + 1;
1.1065 - tmp = (GList *) selected_view_model->data;
1.1066 - /* TODO: select a better centralized item
1.1067 - currently is picking the 1st or last item */
1.1068 - if(g_list_next(object->selected_grid_item) == NULL &&
1.1069 - g_list_previous(object->selected_grid_item) != NULL) {
1.1070 - /* in this case the new selected will be the last */
1.1071 - tmp = g_list_last(tmp);
1.1072 - }
1.1073 + /*
1.1074 + * update the selected service
1.1075 + */
1.1076 + mmyth_epg_grid_widget_update_service(object, tmp);
1.1077 + }
1.1078 + return TRUE;
1.1079 + case GDK_Down:
1.1080 + selected_view_model =
1.1081 + g_list_nth(object->epg_view_model, channel_index + 1);
1.1082 + if (selected_view_model != NULL) {
1.1083 + private->selected_channel_index = channel_index + 1;
1.1084 + tmp = (GList *) selected_view_model->data;
1.1085 + /*
1.1086 + * TODO: select a better centralized item currently is
1.1087 + * picking the 1st or last item
1.1088 + */
1.1089 + if (g_list_next(object->selected_grid_item) == NULL &&
1.1090 + g_list_previous(object->selected_grid_item) != NULL) {
1.1091 + /*
1.1092 + * in this case the new selected will be the last
1.1093 + */
1.1094 + tmp = g_list_last(tmp);
1.1095 + }
1.1096
1.1097 - /* update the selected service */
1.1098 - mmyth_epg_grid_widget_update_service( object, tmp );
1.1099 - }
1.1100 - return TRUE;
1.1101 - case GDK_Left:
1.1102 - tmp = g_list_previous( object->selected_grid_item );
1.1103 - if(tmp != NULL) {
1.1104 - /* update the selected service */
1.1105 - mmyth_epg_grid_widget_update_service( object, tmp );
1.1106 - }
1.1107 - return TRUE;
1.1108 - case GDK_Right:
1.1109 - tmp = g_list_next( object->selected_grid_item );
1.1110 - if(tmp != NULL) {
1.1111 - /* update the selected service */
1.1112 - mmyth_epg_grid_widget_update_service( object, tmp );
1.1113 - }
1.1114 - return TRUE;
1.1115 - default:
1.1116 - return TRUE;
1.1117 + /*
1.1118 + * update the selected service
1.1119 + */
1.1120 + mmyth_epg_grid_widget_update_service(object, tmp);
1.1121 + }
1.1122 + return TRUE;
1.1123 + case GDK_Left:
1.1124 + tmp = g_list_previous(object->selected_grid_item);
1.1125 + if (tmp != NULL) {
1.1126 + /*
1.1127 + * update the selected service
1.1128 + */
1.1129 + mmyth_epg_grid_widget_update_service(object, tmp);
1.1130 + }
1.1131 + return TRUE;
1.1132 + case GDK_Right:
1.1133 + tmp = g_list_next(object->selected_grid_item);
1.1134 + if (tmp != NULL) {
1.1135 + /*
1.1136 + * update the selected service
1.1137 + */
1.1138 + mmyth_epg_grid_widget_update_service(object, tmp);
1.1139 + }
1.1140 + return TRUE;
1.1141 + default:
1.1142 + return TRUE;
1.1143 }
1.1144 -
1.1145 +
1.1146 return FALSE;
1.1147 }
1.1148
1.1149 -static void
1.1150 -mmyth_epg_grid_widget_fill_programinfos (MMythEpgGridWidgetPrivate *private)
1.1151 +static void
1.1152 +mmyth_epg_grid_widget_fill_programinfos(MMythEpgGridWidgetPrivate *
1.1153 + private)
1.1154 {
1.1155 - GList *channels_list = NULL;
1.1156 - int y;
1.1157 + GList *channels_list = NULL;
1.1158 + int y;
1.1159
1.1160 if ((private->mmyth_epg != NULL) &&
1.1161 - (gmyth_epg_get_channel_list (private->mmyth_epg, &channels_list) < 0 )) {
1.1162 - private->channel_list = NULL;
1.1163 - return;
1.1164 + (gmyth_epg_get_channel_list(private->mmyth_epg, &channels_list) <
1.1165 + 0)) {
1.1166 + private->channel_list = NULL;
1.1167 + return;
1.1168 }
1.1169 -
1.1170 +
1.1171 private->channel_list = channels_list;
1.1172 -
1.1173 +
1.1174 for (y = 0; y < private->DISPLAY_CHANS && channels_list; y++) {
1.1175 - GMythChannelInfo *channel_info = (GMythChannelInfo *) channels_list->data;
1.1176 + GMythChannelInfo *channel_info =
1.1177 + (GMythChannelInfo *) channels_list->data;
1.1178
1.1179 - mmyth_epg_grid_widget_fill_program_row_infos(
1.1180 - private, channel_info->channel_ID, y);
1.1181 + mmyth_epg_grid_widget_fill_program_row_infos(private,
1.1182 + channel_info->
1.1183 + channel_ID, y);
1.1184
1.1185 - channels_list = g_list_next (channels_list);
1.1186 + channels_list = g_list_next(channels_list);
1.1187 }
1.1188 }
1.1189
1.1190 -static void
1.1191 -mmyth_epg_grid_widget_fill_program_row_infos(MMythEpgGridWidgetPrivate *private,
1.1192 - guint chanNum, guint row)
1.1193 -{
1.1194 - gint res = gmyth_epg_get_program_list (private->mmyth_epg,
1.1195 - &(private->program_list[row]),
1.1196 - chanNum, private->current_start_time,
1.1197 - private->current_end_time);
1.1198 -
1.1199 +static void
1.1200 +mmyth_epg_grid_widget_fill_program_row_infos(MMythEpgGridWidgetPrivate *
1.1201 + private, guint chanNum,
1.1202 + guint row)
1.1203 +{
1.1204 + gint res = gmyth_epg_get_program_list(private->mmyth_epg,
1.1205 + &(private->
1.1206 + program_list[row]),
1.1207 + chanNum,
1.1208 + private->
1.1209 + current_start_time,
1.1210 + private->
1.1211 + current_end_time);
1.1212 +
1.1213 if (res < 0) {
1.1214 - g_warning ("[%s] Error while retrieving epg programs", __FUNCTION__);
1.1215 + g_warning("[%s] Error while retrieving epg programs",
1.1216 + __FUNCTION__);
1.1217 }
1.1218 }
1.1219 -