leo_sobral@1
|
1 |
#include <string.h>
|
leo_sobral@1
|
2 |
#include <stdlib.h>
|
leo_sobral@1
|
3 |
#include <gtk/gtk.h>
|
leo_sobral@1
|
4 |
#include <gdk/gdkkeysyms.h>
|
leo_sobral@1
|
5 |
#include <time.h>
|
leo_sobral@1
|
6 |
|
leo_sobral@1
|
7 |
#include "mmyth_epg_grid_view.h"
|
leo_sobral@1
|
8 |
#include "mmyth_epg_grid_widget.h"
|
leo_sobral@1
|
9 |
|
leo_sobral@1
|
10 |
/* Service genre */
|
leo_sobral@1
|
11 |
#define GENRE_MIN 0
|
leo_sobral@1
|
12 |
#define GENRE_MAX 10
|
leo_sobral@1
|
13 |
#define GENRE_UNDEFINED 0
|
leo_sobral@1
|
14 |
#define GENRE_MOVIE 1
|
leo_sobral@1
|
15 |
#define GENRE_NEWS 2
|
leo_sobral@1
|
16 |
#define GENRE_SHOW 3
|
leo_sobral@1
|
17 |
#define GENRE_SPORTS 4
|
leo_sobral@1
|
18 |
#define GENRE_CHILDREN 5
|
leo_sobral@1
|
19 |
#define GENRE_MUSIC 6
|
leo_sobral@1
|
20 |
#define GENRE_CULTURE 7
|
leo_sobral@1
|
21 |
#define GENRE_SOCIAL 8
|
leo_sobral@1
|
22 |
#define GENRE_EDUCATION 9
|
leo_sobral@1
|
23 |
#define GENRE_LEISURE 10
|
leo_sobral@1
|
24 |
|
leo_sobral@1
|
25 |
#define NRO_HOURS 3
|
leo_sobral@1
|
26 |
|
leo_sobral@1
|
27 |
/* Function prototypes*/
|
leo_sobral@1
|
28 |
static void update_service_details(MMythEpgGridWidget *object,
|
leo_sobral@1
|
29 |
gpointer arg1, gpointer user_data);
|
leo_sobral@1
|
30 |
static gboolean key_press_epg_grid_view(GtkWidget * widget,
|
leo_sobral@1
|
31 |
GdkEventKey * event,
|
leo_sobral@1
|
32 |
gpointer user_data);
|
leo_sobral@1
|
33 |
|
leo_sobral@1
|
34 |
static GtkWidget *mmyth_epg_grid_widget = NULL;
|
leo_sobral@1
|
35 |
|
leo_sobral@1
|
36 |
/* is a GtkEventBox */
|
leo_sobral@1
|
37 |
static GtkWidget *program_details_area = NULL;
|
leo_sobral@1
|
38 |
static GtkWidget *details_main_hbox = NULL;
|
leo_sobral@1
|
39 |
static GtkWidget *details_vbox = NULL;
|
leo_sobral@1
|
40 |
static GtkWidget *details_logo_vbox = NULL;
|
leo_sobral@1
|
41 |
|
leo_sobral@1
|
42 |
/* update signal callback from MMythEpgGridWidget */
|
leo_sobral@1
|
43 |
static void
|
leo_sobral@1
|
44 |
update_service_details(MMythEpgGridWidget *object, gpointer arg1, gpointer user_data)
|
leo_sobral@1
|
45 |
{
|
leo_sobral@1
|
46 |
g_return_if_fail(arg1 != NULL);
|
leo_sobral@1
|
47 |
|
leo_sobral@1
|
48 |
EpgGridItem *epg_grid_item = (EpgGridItem *) arg1;
|
leo_sobral@1
|
49 |
|
leo_sobral@1
|
50 |
gchar sel_prog_desc[100] = "<big><b>";
|
leo_sobral@1
|
51 |
gchar time_buffer[50];
|
leo_sobral@1
|
52 |
|
leo_sobral@1
|
53 |
/* FIXME: get first content from content_list*/
|
leo_sobral@1
|
54 |
GMythProgramInfo *proginfo = (GMythProgramInfo *) epg_grid_item->proginfo;
|
leo_sobral@1
|
55 |
|
leo_sobral@1
|
56 |
if(proginfo) {
|
leo_sobral@1
|
57 |
GString *prog_name = proginfo->title;
|
leo_sobral@1
|
58 |
GString *service_name = proginfo->chanid;
|
leo_sobral@1
|
59 |
|
leo_sobral@1
|
60 |
if(details_vbox != NULL)
|
leo_sobral@1
|
61 |
gtk_container_remove (GTK_CONTAINER (details_main_hbox), details_vbox);
|
leo_sobral@1
|
62 |
|
leo_sobral@1
|
63 |
/* update service description */
|
leo_sobral@1
|
64 |
strcat(sel_prog_desc, service_name->str);
|
leo_sobral@1
|
65 |
strcat(sel_prog_desc, "</b></big>");
|
leo_sobral@1
|
66 |
|
leo_sobral@1
|
67 |
GtkWidget *fst_line_lbl = gtk_label_new(NULL);
|
leo_sobral@1
|
68 |
gtk_misc_set_alignment (GTK_MISC(fst_line_lbl), 0.0, 0.0);
|
leo_sobral@1
|
69 |
gtk_label_set_markup(GTK_LABEL(fst_line_lbl), sel_prog_desc);
|
leo_sobral@1
|
70 |
|
leo_sobral@1
|
71 |
/* freeing char[] */
|
leo_sobral@1
|
72 |
sel_prog_desc[0] = 0;
|
leo_sobral@1
|
73 |
strcat(sel_prog_desc, "\t");
|
leo_sobral@1
|
74 |
strcat(sel_prog_desc, prog_name->str);
|
leo_sobral@1
|
75 |
|
leo_sobral@1
|
76 |
struct tm loctime_start, loctime_end;
|
leo_sobral@1
|
77 |
|
leo_sobral@1
|
78 |
// Convert it to local time representation.
|
leo_sobral@1
|
79 |
/* FIXME: conversion from time to localtime is different
|
leo_sobral@1
|
80 |
in different machines */
|
leo_sobral@1
|
81 |
long int schedule_start_time = proginfo->startts;
|
leo_sobral@1
|
82 |
long int schedule_end_time = proginfo->endts;
|
leo_sobral@1
|
83 |
|
leo_sobral@1
|
84 |
if (localtime_r(&schedule_start_time, &loctime_start) == NULL) {
|
leo_sobral@1
|
85 |
g_warning ("localtime_r error in mmyth_epg_grid_view!\n");
|
leo_sobral@1
|
86 |
}
|
leo_sobral@1
|
87 |
|
leo_sobral@1
|
88 |
#if 0
|
leo_sobral@1
|
89 |
fprintf (stderr, asctime (loctime_start));
|
leo_sobral@1
|
90 |
#endif
|
leo_sobral@1
|
91 |
|
leo_sobral@1
|
92 |
strftime (time_buffer, 100, " %H:%M - ", &loctime_start);
|
leo_sobral@1
|
93 |
strcat(sel_prog_desc, time_buffer );
|
leo_sobral@1
|
94 |
|
leo_sobral@1
|
95 |
if (localtime_r(&schedule_end_time, &loctime_end) == NULL) {
|
leo_sobral@1
|
96 |
g_warning ("localtime_r error in mmyth_epg_grid_view!\n");
|
leo_sobral@1
|
97 |
}
|
leo_sobral@1
|
98 |
|
leo_sobral@1
|
99 |
#if 0
|
leo_sobral@1
|
100 |
fprintf (stderr, asctime (loctime_end));
|
leo_sobral@1
|
101 |
#endif
|
leo_sobral@1
|
102 |
|
leo_sobral@1
|
103 |
strftime (time_buffer, 100, "%H:%M\n", &loctime_end);
|
leo_sobral@1
|
104 |
strcat(sel_prog_desc, time_buffer );
|
leo_sobral@1
|
105 |
|
leo_sobral@1
|
106 |
GtkWidget *snd_line_lbl = gtk_label_new(NULL);
|
leo_sobral@1
|
107 |
gtk_misc_set_alignment (GTK_MISC(snd_line_lbl), 0.0, 0.0);
|
leo_sobral@1
|
108 |
gtk_label_set_markup(GTK_LABEL(snd_line_lbl), sel_prog_desc);
|
leo_sobral@1
|
109 |
|
leo_sobral@1
|
110 |
// add the current selected program description to the label
|
leo_sobral@1
|
111 |
details_vbox = gtk_vbox_new(FALSE, 0);
|
leo_sobral@1
|
112 |
GtkWidget *fst_line_hbox = gtk_hbox_new(FALSE, 0);
|
leo_sobral@1
|
113 |
|
leo_sobral@1
|
114 |
gtk_box_pack_start (GTK_BOX (fst_line_hbox),
|
leo_sobral@1
|
115 |
fst_line_lbl, FALSE, FALSE, 6);
|
leo_sobral@1
|
116 |
gtk_box_pack_start (GTK_BOX (details_vbox),
|
leo_sobral@1
|
117 |
fst_line_hbox, FALSE, FALSE, 0);
|
leo_sobral@1
|
118 |
gtk_box_pack_start (GTK_BOX (details_vbox),
|
leo_sobral@1
|
119 |
snd_line_lbl, FALSE, FALSE, 0);
|
leo_sobral@1
|
120 |
gtk_box_pack_start (GTK_BOX (details_main_hbox),
|
leo_sobral@1
|
121 |
details_vbox, FALSE, FALSE, 0);
|
leo_sobral@1
|
122 |
|
leo_sobral@1
|
123 |
gtk_widget_show_all(details_main_hbox);
|
leo_sobral@1
|
124 |
}
|
leo_sobral@1
|
125 |
}
|
leo_sobral@1
|
126 |
|
leo_sobral@1
|
127 |
/* Callback for hardware keys */
|
leo_sobral@1
|
128 |
static gboolean
|
leo_sobral@1
|
129 |
key_press_epg_grid_view(GtkWidget * widget,
|
leo_sobral@1
|
130 |
GdkEventKey * event, gpointer user_data)
|
leo_sobral@1
|
131 |
{
|
leo_sobral@1
|
132 |
MMythEpgGridWidget *mmyth_epg_grid_widget = (MMythEpgGridWidget *) user_data;
|
leo_sobral@1
|
133 |
|
leo_sobral@1
|
134 |
return mmyth_epg_grid_widget_key_press(mmyth_epg_grid_widget, widget, event);
|
leo_sobral@1
|
135 |
}
|
leo_sobral@1
|
136 |
|
leo_sobral@1
|
137 |
GtkWidget *
|
leo_sobral@1
|
138 |
epg_grid_view_new (MMythUi* mmyth_ui)
|
leo_sobral@1
|
139 |
{
|
leo_sobral@1
|
140 |
GtkWidget *scrolled_window;
|
leo_sobral@1
|
141 |
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
leo_sobral@1
|
142 |
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
leo_sobral@1
|
143 |
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
leo_sobral@1
|
144 |
|
leo_sobral@1
|
145 |
gtk_widget_modify_bg(scrolled_window, GTK_STATE_NORMAL, &main_bg_color);
|
leo_sobral@1
|
146 |
|
leo_sobral@1
|
147 |
GtkWidget *main_vbox = gtk_vbox_new (FALSE, 0);
|
leo_sobral@1
|
148 |
//gtk_container_set_border_width(main_vbox, 4);
|
leo_sobral@1
|
149 |
|
leo_sobral@1
|
150 |
GtkWidget *details_event_box = gtk_event_box_new();
|
leo_sobral@1
|
151 |
gtk_widget_modify_bg(details_event_box, GTK_STATE_NORMAL, &main_bg_color);
|
leo_sobral@1
|
152 |
|
leo_sobral@1
|
153 |
program_details_area = gtk_vbox_new (FALSE, 0);
|
leo_sobral@1
|
154 |
gtk_container_add (GTK_CONTAINER (details_event_box),
|
leo_sobral@1
|
155 |
program_details_area);
|
leo_sobral@1
|
156 |
gtk_container_set_border_width(GTK_CONTAINER (program_details_area), 4);
|
leo_sobral@1
|
157 |
|
leo_sobral@1
|
158 |
details_main_hbox = gtk_hbox_new (FALSE, 10);
|
leo_sobral@1
|
159 |
|
leo_sobral@1
|
160 |
gtk_box_pack_start (GTK_BOX (program_details_area),
|
leo_sobral@1
|
161 |
details_main_hbox, FALSE, FALSE, 0);
|
leo_sobral@1
|
162 |
|
leo_sobral@1
|
163 |
details_logo_vbox = gtk_vbox_new (FALSE, 0);
|
leo_sobral@1
|
164 |
|
leo_sobral@1
|
165 |
GtkWidget *details_desc_vbox = gtk_vbox_new (FALSE, 0);
|
leo_sobral@1
|
166 |
|
leo_sobral@1
|
167 |
gtk_box_pack_start (GTK_BOX (details_main_hbox),
|
leo_sobral@1
|
168 |
details_desc_vbox, FALSE, FALSE, 0);
|
leo_sobral@1
|
169 |
gtk_box_pack_start (GTK_BOX (details_main_hbox),
|
leo_sobral@1
|
170 |
details_logo_vbox, FALSE, FALSE, 0);
|
leo_sobral@1
|
171 |
|
leo_sobral@1
|
172 |
gtk_widget_set_size_request (program_details_area, -1, 120);
|
leo_sobral@1
|
173 |
|
leo_sobral@1
|
174 |
mmyth_epg_grid_widget = mmyth_epg_grid_widget_new();
|
leo_sobral@1
|
175 |
g_signal_connect(mmyth_epg_grid_widget, "selection_updated",
|
leo_sobral@1
|
176 |
G_CALLBACK (update_service_details), NULL);
|
leo_sobral@1
|
177 |
|
leo_sobral@1
|
178 |
/* select by default the first service */
|
leo_sobral@1
|
179 |
/* depends on mount services */
|
leo_sobral@1
|
180 |
if (MMYTH_EPG_GRID_WIDGET(mmyth_epg_grid_widget)->epg_view_model) {
|
leo_sobral@1
|
181 |
GList *fst_service = (GList *)
|
leo_sobral@1
|
182 |
MMYTH_EPG_GRID_WIDGET(mmyth_epg_grid_widget)->epg_view_model->data;
|
leo_sobral@1
|
183 |
mmyth_epg_grid_widget_update_service(MMYTH_EPG_GRID_WIDGET(mmyth_epg_grid_widget),
|
leo_sobral@1
|
184 |
fst_service);
|
leo_sobral@1
|
185 |
}
|
leo_sobral@1
|
186 |
|
leo_sobral@1
|
187 |
gtk_box_pack_start (GTK_BOX (main_vbox),
|
leo_sobral@1
|
188 |
details_event_box, FALSE, FALSE, 0);
|
leo_sobral@1
|
189 |
gtk_box_pack_start (GTK_BOX (main_vbox),
|
leo_sobral@1
|
190 |
gtk_hseparator_new(), FALSE, FALSE, 0);
|
leo_sobral@1
|
191 |
gtk_box_pack_start (GTK_BOX (main_vbox),
|
leo_sobral@1
|
192 |
mmyth_epg_grid_widget, FALSE, FALSE, 0);
|
leo_sobral@1
|
193 |
|
leo_sobral@1
|
194 |
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window),
|
leo_sobral@1
|
195 |
main_vbox);
|
leo_sobral@1
|
196 |
|
leo_sobral@1
|
197 |
/* Add hardware button listener to application */
|
leo_sobral@1
|
198 |
g_signal_connect(mmyth_ui->main_window, "key_press_event",
|
leo_sobral@1
|
199 |
G_CALLBACK (key_press_epg_grid_view), mmyth_epg_grid_widget);
|
leo_sobral@1
|
200 |
|
leo_sobral@1
|
201 |
gtk_widget_show_all (scrolled_window);
|
leo_sobral@1
|
202 |
|
leo_sobral@1
|
203 |
return scrolled_window;
|
leo_sobral@1
|
204 |
}
|
leo_sobral@1
|
205 |
|
leo_sobral@1
|
206 |
/*
|
leo_sobral@1
|
207 |
DVBHScheduleEvent *
|
leo_sobral@1
|
208 |
mmyth_epg_grid_view_get_selected_schedule()
|
leo_sobral@1
|
209 |
{
|
leo_sobral@1
|
210 |
return mmyth_epg_grid_get_selected_schedule
|
leo_sobral@1
|
211 |
(MMYTH_EPG_GRID_WIDGET(mmyth_epg_grid_widget));
|
leo_sobral@1
|
212 |
}
|
leo_sobral@1
|
213 |
*/
|