[svn r247] Fixes problem when searching for MySQL libraries.
11 #include "mmyth_recordui.h"
13 /* GMyth library includes */
14 #include <gmyth/gmyth_scheduler.h>
15 #include <gmyth/gmyth_util.h>
18 START_DATE_COLUMN = 0,
28 mmyth_recordui_reload_all (MMythRecordUI *recordui)
32 res = mmyth_recordui_reload_schedule (recordui);
34 res = res & mmyth_recordui_reload_record (recordui);
38 g_warning ("[%s] Error while reloading schedule and recording content", __FUNCTION__);
44 mmyth_recordui_reload_schedule (MMythRecordUI *recordui)
47 ScheduleInfo *schedule_info;
50 gchar *start_date_time = NULL;
51 gchar *end_date_time = NULL;
52 GString *str_aux = g_string_new("");
55 gtk_tree_store_clear(recordui->sch_tree_store);
57 res = gmyth_scheduler_get_schedule_list(recordui->scheduler, &(schedule_list));
59 g_warning ("[%s] Retrieved NULL list of scheduled data from database",
64 for ( ; schedule_list; schedule_list = schedule_list->next) {
65 schedule_info = (ScheduleInfo*) schedule_list->data;
67 gtk_tree_store_insert(recordui->sch_tree_store, &iter, NULL, new_row++);
69 start_date_time = gmyth_util_time_to_string_from_time_val(schedule_info->start_time);
70 end_date_time = gmyth_util_time_to_string_from_time_val(schedule_info->end_time);
72 g_string_printf(str_aux, "%d", schedule_info->channel_id);
74 gtk_tree_store_set(recordui->sch_tree_store, &iter,
75 START_DATE_COLUMN, start_date_time,
76 TITLE_COLUMN, schedule_info->title->str,
77 CHAN_ID_COLUMN, str_aux->str,
78 END_TIME_COLUMN, end_date_time, //It doesn't appear
79 RECORD_ID_COLUMN, schedule_info->record_id,
80 -1); //the last line is a hidden item to be used in searching tasks
83 g_debug ("[%s] %d lines added to schedule list UI", __FUNCTION__, new_row);
85 /* free allocated memory */
87 g_free(start_date_time);
89 g_free(end_date_time);
90 g_string_free(str_aux, FALSE);
96 mmyth_recordui_reload_record (MMythRecordUI *recordui)
99 RecordedInfo *recorded_info;
100 GList *record_list = NULL;
102 gchar *start_date_time = NULL;
103 gchar *end_date_time = NULL;
104 GString *str_aux = g_string_new("");
107 gtk_tree_store_clear(recordui->rec_tree_store);
109 res = gmyth_scheduler_get_recorded_list(recordui->scheduler, &record_list);
111 g_warning ("[%s] Retrieved NULL list of recorded data from database", __FUNCTION__);
115 for (; record_list; record_list = record_list->next) {
116 recorded_info = (RecordedInfo*) record_list->data;
118 gtk_tree_store_insert(recordui->rec_tree_store, &iter, NULL, new_row++);
120 start_date_time = gmyth_util_time_to_string_from_time_val(recorded_info->start_time);
121 end_date_time = gmyth_util_time_to_string_from_time_val(recorded_info->end_time);
123 g_string_printf(str_aux, "%d", recorded_info->channel_id);
125 gtk_tree_store_set(recordui->rec_tree_store, &iter,
126 START_DATE_COLUMN, start_date_time,
127 TITLE_COLUMN, recorded_info->title->str,
128 CHAN_ID_COLUMN, str_aux->str,
129 END_TIME_COLUMN, end_date_time, //It doesn't appear
130 RECORD_ID_COLUMN, recorded_info->record_id,
131 BASENAME_COLUMN, recorded_info->basename->str, -1);
132 //the last line is a hidden item to be used in searching tasks
135 g_debug ("[%s] %d lines added to record list UI", __FUNCTION__, new_row);
137 /* free allocated memory */
138 if( NULL != start_date_time)
139 g_free(start_date_time);
140 if( NULL != end_date_time)
141 g_free(end_date_time);
142 g_string_free(str_aux, FALSE);
149 mmyth_recordui_new( GMythBackendInfo* backend_info )
151 MMythRecordUI *recordui = g_new0 (MMythRecordUI, 1);
153 g_return_val_if_fail( backend_info != NULL, NULL );
155 recordui->backend_info = backend_info;
157 recordui->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
158 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (recordui->scrolled_window),
159 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
161 recordui->viewport = gtk_viewport_new (NULL, NULL);
162 gtk_container_add (GTK_CONTAINER (recordui->scrolled_window), recordui->viewport);
164 recordui->notebook = gtk_notebook_new ();
165 gtk_container_set_border_width (GTK_CONTAINER (recordui->notebook), 1);
166 gtk_notebook_set_scrollable (GTK_NOTEBOOK (recordui->notebook), TRUE);
167 gtk_notebook_popup_enable (GTK_NOTEBOOK (recordui->notebook));
168 gtk_container_add (GTK_CONTAINER (recordui->viewport), recordui->notebook);
169 gtk_notebook_popup_disable(GTK_NOTEBOOK (recordui->notebook));
172 recordui->sch_scrolled_window = gtk_scrolled_window_new (NULL, NULL);
173 gtk_container_add (GTK_CONTAINER (recordui->notebook), recordui->sch_scrolled_window);
174 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (recordui->sch_scrolled_window),
175 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
176 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (recordui->sch_scrolled_window),
179 /* The basename column in the sched_tree_store is not being used*/
180 recordui->sch_tree_store =
181 gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING,
182 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING );
184 recordui->sch_treeview =
185 gtk_tree_view_new_with_model(GTK_TREE_MODEL(recordui->sch_tree_store));
186 gtk_container_add (GTK_CONTAINER (recordui->sch_scrolled_window),
187 recordui->sch_treeview);
188 recordui->sch_renderer = gtk_cell_renderer_text_new();
189 //g_object_set(G_OBJECT(renderer1), "foreground", "green", "background", "black", NULL);
190 recordui->sch_column1 =
191 gtk_tree_view_column_new_with_attributes("Start time", recordui->sch_renderer,
192 "text", START_DATE_COLUMN, NULL);
193 gtk_tree_view_append_column(GTK_TREE_VIEW(recordui->sch_treeview),
194 recordui->sch_column1);
195 recordui->sch_column2 =
196 gtk_tree_view_column_new_with_attributes("Title", recordui->sch_renderer,
197 "text", TITLE_COLUMN, NULL);
198 gtk_tree_view_append_column(GTK_TREE_VIEW(recordui->sch_treeview),
199 recordui->sch_column2);
200 recordui->sch_column3 =
201 gtk_tree_view_column_new_with_attributes("Channel", recordui->sch_renderer,
202 "text", CHAN_ID_COLUMN, NULL);
203 gtk_tree_view_append_column(GTK_TREE_VIEW(recordui->sch_treeview),
204 recordui->sch_column3);
205 gtk_tree_view_column_set_resizable(recordui->sch_column1, TRUE);
206 gtk_tree_view_column_set_resizable(recordui->sch_column2, TRUE);
207 gtk_tree_view_column_set_resizable(recordui->sch_column3, TRUE);
208 gtk_tree_view_column_set_reorderable(recordui->sch_column1, TRUE);
209 gtk_tree_view_column_set_reorderable(recordui->sch_column2, TRUE);
210 gtk_tree_view_column_set_reorderable(recordui->sch_column3, TRUE);
211 // recordui->sch_column4 =
212 // gtk_tree_view_column_new_with_attributes("", recordui->sch_renderer, "text", END_TIME_COLUMN, NULL);
213 // gtk_tree_view_append_column(GTK_TREE_VIEW(recordui->sch_treeview),
214 // recordui->sch_column4);
216 recordui->sch_label = gtk_label_new (("Schedule"));
217 gtk_notebook_set_tab_label (GTK_NOTEBOOK (recordui->notebook),
218 gtk_notebook_get_nth_page (
219 GTK_NOTEBOOK (recordui->notebook), 0),
220 recordui->sch_label);
223 // g_object_set(G_OBJECT(renderer2), "foreground", "blue", NULL);
224 recordui->rec_scrolled_window = gtk_scrolled_window_new (NULL, NULL);
225 gtk_container_add (GTK_CONTAINER (recordui->notebook),
226 recordui->rec_scrolled_window);
227 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (recordui->rec_scrolled_window),
228 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
229 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (recordui->rec_scrolled_window),
232 recordui->rec_tree_store =
233 gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING,
234 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING);
235 recordui->rec_treeview =
236 gtk_tree_view_new_with_model(GTK_TREE_MODEL(recordui->rec_tree_store));
237 gtk_container_add (GTK_CONTAINER (recordui->rec_scrolled_window),
238 recordui->rec_treeview);
239 recordui->rec_renderer = gtk_cell_renderer_text_new();
240 //g_object_set(G_OBJECT(renderer1), "foreground", "green", "background", "black", NULL);
242 recordui->rec_column1 =
243 gtk_tree_view_column_new_with_attributes("Start time", recordui->rec_renderer,
244 "text", START_DATE_COLUMN, NULL);
245 gtk_tree_view_append_column(GTK_TREE_VIEW(recordui->rec_treeview),
246 recordui->rec_column1);
247 recordui->rec_column2 =
248 gtk_tree_view_column_new_with_attributes("Title", recordui->rec_renderer,
249 "text", TITLE_COLUMN, NULL);
250 gtk_tree_view_append_column(GTK_TREE_VIEW(recordui->rec_treeview),
251 recordui->rec_column2);
252 recordui->rec_column3 =
253 gtk_tree_view_column_new_with_attributes("Channel", recordui->rec_renderer,
254 "text", CHAN_ID_COLUMN, NULL);
255 gtk_tree_view_append_column(GTK_TREE_VIEW(recordui->rec_treeview),
256 recordui->rec_column3);
257 gtk_tree_view_column_set_resizable(recordui->rec_column1, TRUE);
258 gtk_tree_view_column_set_resizable(recordui->rec_column2, TRUE);
259 gtk_tree_view_column_set_resizable(recordui->rec_column3, TRUE);
260 gtk_tree_view_column_set_reorderable(recordui->rec_column1, TRUE);
261 gtk_tree_view_column_set_reorderable(recordui->rec_column2, TRUE);
262 gtk_tree_view_column_set_reorderable(recordui->rec_column3, TRUE);
263 // recordui->rec_column4 = gtk_tree_view_column_new_with_attributes("", recordui->rec_renderer, "text", END_TIME_COLUMN, NULL);
264 // gtk_tree_view_append_column(GTK_TREE_VIEW(recordui->rec_treeview), recordui->rec_column4);
266 recordui->rec_label = gtk_label_new (("Recorded"));
267 gtk_notebook_set_tab_label (GTK_NOTEBOOK (recordui->notebook),
268 gtk_notebook_get_nth_page (
269 GTK_NOTEBOOK (recordui->notebook), 1),
270 recordui->rec_label);
272 // Gets the mmyth scheduler manager
273 recordui->scheduler = gmyth_scheduler_new ( backend_info );
275 /* init connection to the backend */
276 gmyth_scheduler_connect (recordui->scheduler, recordui->scheduler->backend_info);
282 mmyth_recordui_free (MMythRecordUI *recordui)
284 // FIXME: Release memory here!
285 /* close connection to the backend */
286 gmyth_scheduler_disconnect (recordui->scheduler);
290 mmyth_recordui_delete_selected (GtkButton *button, MMythRecordUI *recordui)
292 GtkTreeSelection *selection;
293 GtkTreeModel *list_store;
298 curr_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(recordui->notebook));
300 if ( curr_page == 0) {
301 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(recordui->sch_treeview));
302 if (selection != NULL) {
303 gtk_tree_selection_get_selected(selection, &list_store, &iter);
304 gtk_tree_model_get(list_store, &iter, RECORD_ID_COLUMN, &index, -1);
305 gmyth_scheduler_delete_schedule(recordui->scheduler, index);
306 mmyth_recordui_reload_schedule (recordui);
310 } else if (curr_page == 1) {
311 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(recordui->rec_treeview));
312 if (selection != NULL) {
313 gtk_tree_selection_get_selected(selection, &list_store, &iter);
314 gtk_tree_model_get(list_store, &iter, RECORD_ID_COLUMN, &index, -1);
315 gmyth_scheduler_delete_recorded(recordui->scheduler, index);
316 mmyth_recordui_reload_record (recordui);
321 g_warning ("[%s] None element was removed from the list", __FUNCTION__);
324 /* FIXME: change this function name, it is returning the
325 * basename_column that represents the nuv filename of
326 * the recorded content */
328 mmyth_recordui_get_selected_recorded (MMythRecordUI *recordui)
330 GtkTreeSelection *selection = NULL;
331 GtkTreeModel *list_store = NULL;
335 /* returning nuv filename, basename_column */
336 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(recordui->rec_treeview));
337 if (gtk_tree_selection_get_selected (selection, &list_store, &iter)) {
338 gtk_tree_model_get(list_store, &iter, BASENAME_COLUMN, &path, -1);
341 // FIXME: MOVE THIS TO OTHER PLACE