maemo-ui/src/mmyth_epg_grid_view.c
branchtrunk
changeset 789 f9cd59844f78
parent 244 c88244670b08
     1.1 --- a/maemo-ui/src/mmyth_epg_grid_view.c	Fri Jan 05 19:27:27 2007 +0000
     1.2 +++ b/maemo-ui/src/mmyth_epg_grid_view.c	Wed Aug 01 14:22:14 2007 +0100
     1.3 @@ -7,7 +7,9 @@
     1.4  #include "mmyth_epg_grid_view.h"
     1.5  #include "mmyth_epg_grid_widget.h"
     1.6  
     1.7 -/* Service genre */
     1.8 +/*
     1.9 + * Service genre 
    1.10 + */
    1.11  #define GENRE_MIN               0
    1.12  #define GENRE_MAX               10
    1.13  #define GENRE_UNDEFINED         0
    1.14 @@ -24,190 +26,218 @@
    1.15  
    1.16  #define NRO_HOURS 3
    1.17  
    1.18 -/* Function prototypes*/
    1.19 -static void update_service_details(MMythEpgGridWidget *object, 
    1.20 -                                   gpointer arg1, gpointer user_data);
    1.21 -static gboolean key_press_epg_grid_view(GtkWidget * widget, 
    1.22 -                                        GdkEventKey * event, 
    1.23 +/*
    1.24 + * Function prototypes
    1.25 + */
    1.26 +static void     update_service_details(MMythEpgGridWidget * object,
    1.27 +                                       gpointer arg1, gpointer user_data);
    1.28 +static gboolean key_press_epg_grid_view(GtkWidget * widget,
    1.29 +                                        GdkEventKey * event,
    1.30                                          gpointer user_data);
    1.31  
    1.32  static GtkWidget *mmyth_epg_grid_widget = NULL;
    1.33  
    1.34 -/* is a GtkEventBox */
    1.35 +/*
    1.36 + * is a GtkEventBox 
    1.37 + */
    1.38  static GtkWidget *program_details_area = NULL;
    1.39  static GtkWidget *details_main_hbox = NULL;
    1.40  static GtkWidget *details_vbox = NULL;
    1.41  static GtkWidget *details_logo_vbox = NULL;
    1.42  
    1.43 -/* update signal callback from MMythEpgGridWidget */
    1.44 +/*
    1.45 + * update signal callback from MMythEpgGridWidget 
    1.46 + */
    1.47  static void
    1.48 -update_service_details(MMythEpgGridWidget *object, gpointer arg1, gpointer user_data) 
    1.49 +update_service_details(MMythEpgGridWidget * object, gpointer arg1,
    1.50 +                       gpointer user_data)
    1.51  {
    1.52 -	g_return_if_fail(arg1 != NULL);
    1.53 +    g_return_if_fail(arg1 != NULL);
    1.54  
    1.55 -	EpgGridItem *epg_grid_item = (EpgGridItem *) arg1;
    1.56 -	
    1.57 -	gchar sel_prog_desc[100] = "<big><b>";
    1.58 -	gchar time_buffer[50];
    1.59 +    EpgGridItem    *epg_grid_item = (EpgGridItem *) arg1;
    1.60  
    1.61 -    /* FIXME: get first content from content_list*/
    1.62 -    GMythProgramInfo *proginfo = (GMythProgramInfo *) epg_grid_item->proginfo;
    1.63 +    gchar           sel_prog_desc[100] = "<big><b>";
    1.64 +    gchar           time_buffer[50];
    1.65  
    1.66 -    if(proginfo) {
    1.67 -        GString *prog_name = proginfo->title;    
    1.68 -        GString *service_name = proginfo->chanid;
    1.69 -           
    1.70 -    	if(details_vbox != NULL)
    1.71 -  	        gtk_container_remove (GTK_CONTAINER (details_main_hbox), details_vbox);	
    1.72 -    
    1.73 -        /* update service description */
    1.74 +    /*
    1.75 +     * FIXME: get first content from content_list
    1.76 +     */
    1.77 +    GMythProgramInfo *proginfo =
    1.78 +        (GMythProgramInfo *) epg_grid_item->proginfo;
    1.79 +
    1.80 +    if (proginfo) {
    1.81 +        GString        *prog_name = proginfo->title;
    1.82 +        GString        *service_name = proginfo->chanid;
    1.83 +
    1.84 +        if (details_vbox != NULL)
    1.85 +            gtk_container_remove(GTK_CONTAINER(details_main_hbox),
    1.86 +                                 details_vbox);
    1.87 +
    1.88 +        /*
    1.89 +         * update service description 
    1.90 +         */
    1.91          strcat(sel_prog_desc, service_name->str);
    1.92          strcat(sel_prog_desc, "</b></big>");
    1.93 -    
    1.94 -        GtkWidget *fst_line_lbl = gtk_label_new(NULL);
    1.95 -        gtk_misc_set_alignment (GTK_MISC(fst_line_lbl), 0.0, 0.0); 
    1.96 -        gtk_label_set_markup(GTK_LABEL(fst_line_lbl), sel_prog_desc);     
    1.97  
    1.98 -        /* freeing char[] */
    1.99 +        GtkWidget      *fst_line_lbl = gtk_label_new(NULL);
   1.100 +        gtk_misc_set_alignment(GTK_MISC(fst_line_lbl), 0.0, 0.0);
   1.101 +        gtk_label_set_markup(GTK_LABEL(fst_line_lbl), sel_prog_desc);
   1.102 +
   1.103 +        /*
   1.104 +         * freeing char[] 
   1.105 +         */
   1.106          sel_prog_desc[0] = 0;
   1.107          strcat(sel_prog_desc, "\t");
   1.108 -        strcat(sel_prog_desc, prog_name->str);    
   1.109 -            	        		
   1.110 -        struct tm loctime_start, loctime_end;
   1.111 -    
   1.112 +        strcat(sel_prog_desc, prog_name->str);
   1.113 +
   1.114 +        struct tm       loctime_start,
   1.115 +                        loctime_end;
   1.116 +
   1.117          // Convert it to local time representation. 
   1.118 -        /* FIXME: conversion from time to localtime is different
   1.119 -        in different machines */
   1.120 -        long int schedule_start_time = proginfo->startts->tv_sec;
   1.121 -        long int schedule_end_time   = proginfo->endts->tv_sec;
   1.122 -    
   1.123 +        /*
   1.124 +         * FIXME: conversion from time to localtime is different in
   1.125 +         * different machines 
   1.126 +         */
   1.127 +        long int        schedule_start_time = proginfo->startts->tv_sec;
   1.128 +        long int        schedule_end_time = proginfo->endts->tv_sec;
   1.129 +
   1.130          if (localtime_r(&schedule_start_time, &loctime_start) == NULL) {
   1.131 -            g_warning ("localtime_r error in mmyth_epg_grid_view!\n");
   1.132 +            g_warning("localtime_r error in mmyth_epg_grid_view!\n");
   1.133          }
   1.134 -    
   1.135 -        #if 0 
   1.136 -            fprintf (stderr, asctime (loctime_start)); 
   1.137 -        #endif
   1.138 -    
   1.139 -        strftime (time_buffer, 100, "  %H:%M - ", &loctime_start);
   1.140 -        strcat(sel_prog_desc, time_buffer );
   1.141 -    
   1.142 +#if 0
   1.143 +        fprintf(stderr, asctime(loctime_start));
   1.144 +#endif
   1.145 +
   1.146 +        strftime(time_buffer, 100, "  %H:%M - ", &loctime_start);
   1.147 +        strcat(sel_prog_desc, time_buffer);
   1.148 +
   1.149          if (localtime_r(&schedule_end_time, &loctime_end) == NULL) {
   1.150 -            g_warning ("localtime_r error in mmyth_epg_grid_view!\n");
   1.151 +            g_warning("localtime_r error in mmyth_epg_grid_view!\n");
   1.152          }
   1.153 +#if 0
   1.154 +        fprintf(stderr, asctime(loctime_end));
   1.155 +#endif
   1.156  
   1.157 -        #if 0
   1.158 -            fprintf (stderr, asctime (loctime_end));     		    
   1.159 -        #endif
   1.160 -    
   1.161 -        strftime (time_buffer, 100, "%H:%M\n", &loctime_end);
   1.162 -        strcat(sel_prog_desc, time_buffer );
   1.163 -    
   1.164 -        GtkWidget *snd_line_lbl = gtk_label_new(NULL);
   1.165 -        gtk_misc_set_alignment (GTK_MISC(snd_line_lbl), 0.0, 0.0); 
   1.166 -        gtk_label_set_markup(GTK_LABEL(snd_line_lbl), sel_prog_desc);     
   1.167 -    
   1.168 +        strftime(time_buffer, 100, "%H:%M\n", &loctime_end);
   1.169 +        strcat(sel_prog_desc, time_buffer);
   1.170 +
   1.171 +        GtkWidget      *snd_line_lbl = gtk_label_new(NULL);
   1.172 +        gtk_misc_set_alignment(GTK_MISC(snd_line_lbl), 0.0, 0.0);
   1.173 +        gtk_label_set_markup(GTK_LABEL(snd_line_lbl), sel_prog_desc);
   1.174 +
   1.175          // add the current selected program description to the label
   1.176          details_vbox = gtk_vbox_new(FALSE, 0);
   1.177 -        GtkWidget *fst_line_hbox = gtk_hbox_new(FALSE, 0);        
   1.178 -        
   1.179 -        gtk_box_pack_start (GTK_BOX (fst_line_hbox),
   1.180 -                            fst_line_lbl, FALSE, FALSE, 6);
   1.181 -        gtk_box_pack_start (GTK_BOX (details_vbox),
   1.182 -                            fst_line_hbox, FALSE, FALSE, 0);
   1.183 -        gtk_box_pack_start (GTK_BOX (details_vbox),
   1.184 -                            snd_line_lbl, FALSE, FALSE, 0);
   1.185 -        gtk_box_pack_start (GTK_BOX (details_main_hbox),
   1.186 -                            details_vbox, FALSE, FALSE, 0);
   1.187 -        
   1.188 +        GtkWidget      *fst_line_hbox = gtk_hbox_new(FALSE, 0);
   1.189 +
   1.190 +        gtk_box_pack_start(GTK_BOX(fst_line_hbox),
   1.191 +                           fst_line_lbl, FALSE, FALSE, 6);
   1.192 +        gtk_box_pack_start(GTK_BOX(details_vbox),
   1.193 +                           fst_line_hbox, FALSE, FALSE, 0);
   1.194 +        gtk_box_pack_start(GTK_BOX(details_vbox),
   1.195 +                           snd_line_lbl, FALSE, FALSE, 0);
   1.196 +        gtk_box_pack_start(GTK_BOX(details_main_hbox),
   1.197 +                           details_vbox, FALSE, FALSE, 0);
   1.198 +
   1.199          gtk_widget_show_all(details_main_hbox);
   1.200 -    }        
   1.201 +    }
   1.202  }
   1.203  
   1.204 -/* Callback for hardware keys */
   1.205 -static gboolean
   1.206 -key_press_epg_grid_view(GtkWidget * widget, 
   1.207 +/*
   1.208 + * Callback for hardware keys 
   1.209 + */
   1.210 +static          gboolean
   1.211 +key_press_epg_grid_view(GtkWidget * widget,
   1.212                          GdkEventKey * event, gpointer user_data)
   1.213  {
   1.214 -    MMythEpgGridWidget *mmyth_epg_grid_widget = (MMythEpgGridWidget *) user_data;
   1.215 +    MMythEpgGridWidget *mmyth_epg_grid_widget =
   1.216 +        (MMythEpgGridWidget *) user_data;
   1.217  
   1.218 -    return mmyth_epg_grid_widget_key_press(mmyth_epg_grid_widget, widget, event); 
   1.219 +    return mmyth_epg_grid_widget_key_press(mmyth_epg_grid_widget, widget,
   1.220 +                                           event);
   1.221  }
   1.222  
   1.223 -GtkWidget *
   1.224 -epg_grid_view_new (MMythUi* mmyth_ui) 
   1.225 +GtkWidget      *
   1.226 +epg_grid_view_new(MMythUi * mmyth_ui)
   1.227  {
   1.228 -    GtkWidget *scrolled_window;
   1.229 -    scrolled_window = gtk_scrolled_window_new (NULL, NULL);
   1.230 -    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
   1.231 -                                    GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);                   
   1.232 -    
   1.233 -    gtk_widget_modify_bg(scrolled_window, GTK_STATE_NORMAL, &main_bg_color);  
   1.234 -    
   1.235 -    GtkWidget *main_vbox = gtk_vbox_new (FALSE, 0);      
   1.236 -    //gtk_container_set_border_width(main_vbox, 4);        
   1.237 -    
   1.238 -    GtkWidget *details_event_box = gtk_event_box_new();               
   1.239 -    gtk_widget_modify_bg(details_event_box, GTK_STATE_NORMAL, &main_bg_color);  
   1.240 -    
   1.241 -    program_details_area = gtk_vbox_new (FALSE, 0);
   1.242 -    gtk_container_add (GTK_CONTAINER (details_event_box),
   1.243 -                       program_details_area);   
   1.244 -    gtk_container_set_border_width(GTK_CONTAINER (program_details_area), 4);        
   1.245 +    GtkWidget      *scrolled_window;
   1.246 +    scrolled_window = gtk_scrolled_window_new(NULL, NULL);
   1.247 +    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
   1.248 +                                   GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
   1.249  
   1.250 -	details_main_hbox = gtk_hbox_new (FALSE, 10);    
   1.251 +    gtk_widget_modify_bg(scrolled_window, GTK_STATE_NORMAL,
   1.252 +                         &main_bg_color);
   1.253  
   1.254 -	gtk_box_pack_start (GTK_BOX (program_details_area),
   1.255 -	                    details_main_hbox, FALSE, FALSE, 0);                    
   1.256 -	                    
   1.257 -	details_logo_vbox = gtk_vbox_new (FALSE, 0);      	 
   1.258 -    
   1.259 -	GtkWidget *details_desc_vbox = gtk_vbox_new (FALSE, 0);      
   1.260 +    GtkWidget      *main_vbox = gtk_vbox_new(FALSE, 0);
   1.261 +    // gtk_container_set_border_width(main_vbox, 4); 
   1.262  
   1.263 -    gtk_box_pack_start (GTK_BOX (details_main_hbox),
   1.264 -	                    details_desc_vbox, FALSE, FALSE, 0);                    
   1.265 -    gtk_box_pack_start (GTK_BOX (details_main_hbox),
   1.266 -	                    details_logo_vbox, FALSE, FALSE, 0);                    	
   1.267 -	
   1.268 -    gtk_widget_set_size_request (program_details_area, -1, 120);          
   1.269 -    
   1.270 +    GtkWidget      *details_event_box = gtk_event_box_new();
   1.271 +    gtk_widget_modify_bg(details_event_box, GTK_STATE_NORMAL,
   1.272 +                         &main_bg_color);
   1.273 +
   1.274 +    program_details_area = gtk_vbox_new(FALSE, 0);
   1.275 +    gtk_container_add(GTK_CONTAINER(details_event_box),
   1.276 +                      program_details_area);
   1.277 +    gtk_container_set_border_width(GTK_CONTAINER(program_details_area), 4);
   1.278 +
   1.279 +    details_main_hbox = gtk_hbox_new(FALSE, 10);
   1.280 +
   1.281 +    gtk_box_pack_start(GTK_BOX(program_details_area),
   1.282 +                       details_main_hbox, FALSE, FALSE, 0);
   1.283 +
   1.284 +    details_logo_vbox = gtk_vbox_new(FALSE, 0);
   1.285 +
   1.286 +    GtkWidget      *details_desc_vbox = gtk_vbox_new(FALSE, 0);
   1.287 +
   1.288 +    gtk_box_pack_start(GTK_BOX(details_main_hbox),
   1.289 +                       details_desc_vbox, FALSE, FALSE, 0);
   1.290 +    gtk_box_pack_start(GTK_BOX(details_main_hbox),
   1.291 +                       details_logo_vbox, FALSE, FALSE, 0);
   1.292 +
   1.293 +    gtk_widget_set_size_request(program_details_area, -1, 120);
   1.294 +
   1.295      mmyth_epg_grid_widget = mmyth_epg_grid_widget_new();
   1.296 -    g_signal_connect(mmyth_epg_grid_widget, "selection_updated", 
   1.297 -                     G_CALLBACK (update_service_details), NULL);    
   1.298 +    g_signal_connect(mmyth_epg_grid_widget, "selection_updated",
   1.299 +                     G_CALLBACK(update_service_details), NULL);
   1.300  
   1.301 -    /* select by default the first service */
   1.302 -    /* depends on mount services */
   1.303 +    /*
   1.304 +     * select by default the first service 
   1.305 +     */
   1.306 +    /*
   1.307 +     * depends on mount services 
   1.308 +     */
   1.309      if (MMYTH_EPG_GRID_WIDGET(mmyth_epg_grid_widget)->epg_view_model) {
   1.310 -	    GList *fst_service = (GList *) 
   1.311 -	    	MMYTH_EPG_GRID_WIDGET(mmyth_epg_grid_widget)->epg_view_model->data;
   1.312 -    	mmyth_epg_grid_widget_update_service(MMYTH_EPG_GRID_WIDGET(mmyth_epg_grid_widget),
   1.313 -                                         fst_service);
   1.314 +        GList          *fst_service = (GList *)
   1.315 +            MMYTH_EPG_GRID_WIDGET(mmyth_epg_grid_widget)->epg_view_model->
   1.316 +            data;
   1.317 +        mmyth_epg_grid_widget_update_service(MMYTH_EPG_GRID_WIDGET
   1.318 +                                             (mmyth_epg_grid_widget),
   1.319 +                                             fst_service);
   1.320      }
   1.321 -    
   1.322 -    gtk_box_pack_start (GTK_BOX (main_vbox),
   1.323 -                        details_event_box, FALSE, FALSE, 0); 
   1.324 -    gtk_box_pack_start (GTK_BOX (main_vbox),
   1.325 -                        gtk_hseparator_new(), FALSE, FALSE, 0);         
   1.326 -    gtk_box_pack_start (GTK_BOX (main_vbox),
   1.327 -                        mmyth_epg_grid_widget, FALSE, FALSE, 0);                    
   1.328  
   1.329 -    gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window),
   1.330 -                                           main_vbox);    
   1.331 -    
   1.332 -    /* Add hardware button listener to application */
   1.333 -    g_signal_connect(mmyth_ui->main_window, "key_press_event", 
   1.334 -                     G_CALLBACK (key_press_epg_grid_view), mmyth_epg_grid_widget);    
   1.335 +    gtk_box_pack_start(GTK_BOX(main_vbox),
   1.336 +                       details_event_box, FALSE, FALSE, 0);
   1.337 +    gtk_box_pack_start(GTK_BOX(main_vbox),
   1.338 +                       gtk_hseparator_new(), FALSE, FALSE, 0);
   1.339 +    gtk_box_pack_start(GTK_BOX(main_vbox),
   1.340 +                       mmyth_epg_grid_widget, FALSE, FALSE, 0);
   1.341  
   1.342 -    gtk_widget_show_all (scrolled_window);
   1.343 -    
   1.344 +    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW
   1.345 +                                          (scrolled_window), main_vbox);
   1.346 +
   1.347 +    /*
   1.348 +     * Add hardware button listener to application 
   1.349 +     */
   1.350 +    g_signal_connect(mmyth_ui->main_window, "key_press_event",
   1.351 +                     G_CALLBACK(key_press_epg_grid_view),
   1.352 +                     mmyth_epg_grid_widget);
   1.353 +
   1.354 +    gtk_widget_show_all(scrolled_window);
   1.355 +
   1.356      return scrolled_window;
   1.357  }
   1.358  
   1.359  /*
   1.360 -DVBHScheduleEvent * 
   1.361 -mmyth_epg_grid_view_get_selected_schedule()
   1.362 -{
   1.363 -    return mmyth_epg_grid_get_selected_schedule
   1.364 -            (MMYTH_EPG_GRID_WIDGET(mmyth_epg_grid_widget));
   1.365 -}
   1.366 -*/
   1.367 + * DVBHScheduleEvent * mmyth_epg_grid_view_get_selected_schedule() {
   1.368 + * return mmyth_epg_grid_get_selected_schedule
   1.369 + * (MMYTH_EPG_GRID_WIDGET(mmyth_epg_grid_widget)); } 
   1.370 + */