[svn r877] gmyth-dbus configure.ac: package renamed from myth-dbus to gmyth-dbus
4 #include <gdk/gdkkeysyms.h>
7 #include "mmyth_epg_grid_view.h"
8 #include "mmyth_epg_grid_widget.h"
15 #define GENRE_UNDEFINED 0
19 #define GENRE_SPORTS 4
20 #define GENRE_CHILDREN 5
22 #define GENRE_CULTURE 7
23 #define GENRE_SOCIAL 8
24 #define GENRE_EDUCATION 9
25 #define GENRE_LEISURE 10
32 static void update_service_details(MMythEpgGridWidget * object,
33 gpointer arg1, gpointer user_data);
34 static gboolean key_press_epg_grid_view(GtkWidget * widget,
38 static GtkWidget *mmyth_epg_grid_widget = NULL;
43 static GtkWidget *program_details_area = NULL;
44 static GtkWidget *details_main_hbox = NULL;
45 static GtkWidget *details_vbox = NULL;
46 static GtkWidget *details_logo_vbox = NULL;
49 * update signal callback from MMythEpgGridWidget
52 update_service_details(MMythEpgGridWidget * object, gpointer arg1,
55 g_return_if_fail(arg1 != NULL);
57 EpgGridItem *epg_grid_item = (EpgGridItem *) arg1;
59 gchar sel_prog_desc[100] = "<big><b>";
60 gchar time_buffer[50];
63 * FIXME: get first content from content_list
65 GMythProgramInfo *proginfo =
66 (GMythProgramInfo *) epg_grid_item->proginfo;
69 GString *prog_name = proginfo->title;
70 GString *service_name = proginfo->chanid;
72 if (details_vbox != NULL)
73 gtk_container_remove(GTK_CONTAINER(details_main_hbox),
77 * update service description
79 strcat(sel_prog_desc, service_name->str);
80 strcat(sel_prog_desc, "</b></big>");
82 GtkWidget *fst_line_lbl = gtk_label_new(NULL);
83 gtk_misc_set_alignment(GTK_MISC(fst_line_lbl), 0.0, 0.0);
84 gtk_label_set_markup(GTK_LABEL(fst_line_lbl), sel_prog_desc);
90 strcat(sel_prog_desc, "\t");
91 strcat(sel_prog_desc, prog_name->str);
93 struct tm loctime_start,
96 // Convert it to local time representation.
98 * FIXME: conversion from time to localtime is different in
101 long int schedule_start_time = proginfo->startts->tv_sec;
102 long int schedule_end_time = proginfo->endts->tv_sec;
104 if (localtime_r(&schedule_start_time, &loctime_start) == NULL) {
105 g_warning("localtime_r error in mmyth_epg_grid_view!\n");
108 fprintf(stderr, asctime(loctime_start));
111 strftime(time_buffer, 100, " %H:%M - ", &loctime_start);
112 strcat(sel_prog_desc, time_buffer);
114 if (localtime_r(&schedule_end_time, &loctime_end) == NULL) {
115 g_warning("localtime_r error in mmyth_epg_grid_view!\n");
118 fprintf(stderr, asctime(loctime_end));
121 strftime(time_buffer, 100, "%H:%M\n", &loctime_end);
122 strcat(sel_prog_desc, time_buffer);
124 GtkWidget *snd_line_lbl = gtk_label_new(NULL);
125 gtk_misc_set_alignment(GTK_MISC(snd_line_lbl), 0.0, 0.0);
126 gtk_label_set_markup(GTK_LABEL(snd_line_lbl), sel_prog_desc);
128 // add the current selected program description to the label
129 details_vbox = gtk_vbox_new(FALSE, 0);
130 GtkWidget *fst_line_hbox = gtk_hbox_new(FALSE, 0);
132 gtk_box_pack_start(GTK_BOX(fst_line_hbox),
133 fst_line_lbl, FALSE, FALSE, 6);
134 gtk_box_pack_start(GTK_BOX(details_vbox),
135 fst_line_hbox, FALSE, FALSE, 0);
136 gtk_box_pack_start(GTK_BOX(details_vbox),
137 snd_line_lbl, FALSE, FALSE, 0);
138 gtk_box_pack_start(GTK_BOX(details_main_hbox),
139 details_vbox, FALSE, FALSE, 0);
141 gtk_widget_show_all(details_main_hbox);
146 * Callback for hardware keys
149 key_press_epg_grid_view(GtkWidget * widget,
150 GdkEventKey * event, gpointer user_data)
152 MMythEpgGridWidget *mmyth_epg_grid_widget =
153 (MMythEpgGridWidget *) user_data;
155 return mmyth_epg_grid_widget_key_press(mmyth_epg_grid_widget, widget,
160 epg_grid_view_new(MMythUi * mmyth_ui)
162 GtkWidget *scrolled_window;
163 scrolled_window = gtk_scrolled_window_new(NULL, NULL);
164 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
165 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
167 gtk_widget_modify_bg(scrolled_window, GTK_STATE_NORMAL,
170 GtkWidget *main_vbox = gtk_vbox_new(FALSE, 0);
171 // gtk_container_set_border_width(main_vbox, 4);
173 GtkWidget *details_event_box = gtk_event_box_new();
174 gtk_widget_modify_bg(details_event_box, GTK_STATE_NORMAL,
177 program_details_area = gtk_vbox_new(FALSE, 0);
178 gtk_container_add(GTK_CONTAINER(details_event_box),
179 program_details_area);
180 gtk_container_set_border_width(GTK_CONTAINER(program_details_area), 4);
182 details_main_hbox = gtk_hbox_new(FALSE, 10);
184 gtk_box_pack_start(GTK_BOX(program_details_area),
185 details_main_hbox, FALSE, FALSE, 0);
187 details_logo_vbox = gtk_vbox_new(FALSE, 0);
189 GtkWidget *details_desc_vbox = gtk_vbox_new(FALSE, 0);
191 gtk_box_pack_start(GTK_BOX(details_main_hbox),
192 details_desc_vbox, FALSE, FALSE, 0);
193 gtk_box_pack_start(GTK_BOX(details_main_hbox),
194 details_logo_vbox, FALSE, FALSE, 0);
196 gtk_widget_set_size_request(program_details_area, -1, 120);
198 mmyth_epg_grid_widget = mmyth_epg_grid_widget_new();
199 g_signal_connect(mmyth_epg_grid_widget, "selection_updated",
200 G_CALLBACK(update_service_details), NULL);
203 * select by default the first service
206 * depends on mount services
208 if (MMYTH_EPG_GRID_WIDGET(mmyth_epg_grid_widget)->epg_view_model) {
209 GList *fst_service = (GList *)
210 MMYTH_EPG_GRID_WIDGET(mmyth_epg_grid_widget)->epg_view_model->
212 mmyth_epg_grid_widget_update_service(MMYTH_EPG_GRID_WIDGET
213 (mmyth_epg_grid_widget),
217 gtk_box_pack_start(GTK_BOX(main_vbox),
218 details_event_box, FALSE, FALSE, 0);
219 gtk_box_pack_start(GTK_BOX(main_vbox),
220 gtk_hseparator_new(), FALSE, FALSE, 0);
221 gtk_box_pack_start(GTK_BOX(main_vbox),
222 mmyth_epg_grid_widget, FALSE, FALSE, 0);
224 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW
225 (scrolled_window), main_vbox);
228 * Add hardware button listener to application
230 g_signal_connect(mmyth_ui->main_window, "key_press_event",
231 G_CALLBACK(key_press_epg_grid_view),
232 mmyth_epg_grid_widget);
234 gtk_widget_show_all(scrolled_window);
236 return scrolled_window;
240 * DVBHScheduleEvent * mmyth_epg_grid_view_get_selected_schedule() {
241 * return mmyth_epg_grid_get_selected_schedule
242 * (MMYTH_EPG_GRID_WIDGET(mmyth_epg_grid_widget)); }