~ubuntu-branches/ubuntu/precise/me-tv/precise-proposed

« back to all changes in this revision

Viewing changes to src/main_window.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Lamothe
  • Date: 2008-02-12 21:56:59 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080212215659-g3u4v9iz8wzxu2cd
Tags: 0.5.17-1
New upstream release (Closes: #464922)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2007 Michael Lamothe
 
2
 * Copyright (C) 2008 Michael Lamothe
 
3
 *
 
4
 * This file is part of Me TV
3
5
 *
4
6
 * This program is free software; you can redistribute it and/or modify
5
7
 * it under the terms of the GNU General Public License as published by
16
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
17
19
 */
18
20
 
19
 
#include "html_epg_widget.h"
20
21
#include "main_window.h"
21
22
#include "application.h"
22
23
#include "exception_handler.h"
36
37
 
37
38
        Application& application = Application::get_current();
38
39
        Configuration& configuration = application.get_configuration();
39
 
        GeneralConfigurationSection& general_section = configuration.get_general_section();
40
40
        Glade& glade = application.get_glade();
41
41
        
 
42
        audio_stream_group                      = NULL;
 
43
        subtitle_stream_group           = NULL;
 
44
        
42
45
        window_main                                     = glade.get_widget("window_main");
 
46
        vpaned_main                                     = glade.get_widget("vpaned_main");
43
47
        statusbar                                       = glade.get_widget("statusbar");
44
 
        vpaned_main                                     = glade.get_widget("vpaned_main");
45
48
        toolbar                                         = glade.get_widget("handlebox_toolbar");
46
49
        menubar                                         = glade.get_widget("menubar");
47
 
        event_dialog                            = glade.get_widget("event_dialog");
48
 
        preferences_dialog                      = glade.get_widget("preferences_dialog");
49
 
        scheduled_recording_dialog      = glade.get_widget("scheduled_recording_dialog");
50
 
        eventbox_video                          = glade.get_widget("eventbox_video");
51
 
        scrolled_window_epg                     = glade.get_widget("scrolledwindow_epg");
 
50
        dialog_program_details          = glade.get_widget("dialog_program_details");
 
51
        event_box_video                         = glade.get_widget("event_box_video");
52
52
        
53
 
        epg_widget = new HtmlEpgWidget();
 
53
        epg_widget = new GtkEpgWidget();
 
54
        preferences_dialog = new PreferencesDialog();
 
55
        scheduled_recording_dialog      = new ScheduledRecordingDialog();
54
56
        scheduled_recordings_dialog     = new ScheduledRecordingsDialog();
55
57
        
 
58
        search_bar = new SearchBar();
 
59
        
56
60
        is_fullscreen = false;
57
 
 
 
61
        
58
62
        gtk_window_set_title(GTK_WINDOW(window_main), APPLICATION_NAME);
59
63
        
60
64
        g_signal_connect( G_OBJECT ( window_main ), "motion-notify-event", G_CALLBACK( on_window_main_motion_notify ), this );
61
65
        g_signal_connect( G_OBJECT ( window_main ), "delete-event", G_CALLBACK ( on_window_main_delete ), this );
62
 
        g_signal_connect( G_OBJECT ( glade.get_widget("toolbutton_mute") ), "toggled", G_CALLBACK ( on_toolbutton_mute_toggled ), this );       
63
 
        g_signal_connect( G_OBJECT ( glade.get_widget("toolbutton_record") ), "toggled", G_CALLBACK ( on_toolbutton_record_toggled ), this );   
64
 
        g_signal_connect( G_OBJECT ( glade.get_widget("toolbutton_auto_surf") ), "toggled", G_CALLBACK ( on_toolbutton_auto_surf_toggled ), this );     
65
 
        g_signal_connect( G_OBJECT ( glade.get_widget("toolbutton_broadcast") ), "toggled", G_CALLBACK ( on_toolbutton_broadcast_toggled ), this );     
66
 
        g_signal_connect( G_OBJECT ( glade.get_widget("toolbutton_scheduled_recordings") ), "clicked", G_CALLBACK ( on_toolbutton_scheduled_recordings_clicked ), this );
67
 
        g_signal_connect( G_OBJECT ( glade.get_widget("toolbutton_hide_controls") ), "clicked", G_CALLBACK ( on_toolbutton_hide_controls_clicked ), this );     
68
 
        g_signal_connect( G_OBJECT ( glade.get_widget("imagemenuitem_file_quit") ), "activate", G_CALLBACK ( on_menu_item_file_quit_activate ), this ); 
69
 
        g_signal_connect( G_OBJECT ( glade.get_widget("imagemenuitem_view_fullscreen") ), "activate", G_CALLBACK ( on_menu_item_view_fullscreen_activate ), this );     
70
 
        g_signal_connect( G_OBJECT ( glade.get_widget("imagemenuitem_view_preferences") ), "activate", G_CALLBACK ( on_menu_item_view_preferences_activate ), this );   
71
 
        g_signal_connect( G_OBJECT ( glade.get_widget("imagemenuitem_view_video_controls") ), "activate", G_CALLBACK ( on_menu_item_view_video_controls_activate ), this );     
72
 
        g_signal_connect( G_OBJECT ( glade.get_widget("imagemenuitem_help_contents") ), "activate", G_CALLBACK ( on_menu_item_help_contents_activate ), this ); 
73
 
        g_signal_connect( G_OBJECT ( glade.get_widget("imagemenuitem_help_about") ), "activate", G_CALLBACK ( on_menu_item_help_about_activate ), this );       
74
 
        g_signal_connect( G_OBJECT ( eventbox_video ), "button_press_event",    G_CALLBACK ( on_button_press ), this );
 
66
        g_signal_connect( G_OBJECT ( window_main ), "key-press-event", G_CALLBACK( on_window_main_key_press_event ), this );
 
67
        g_signal_connect( G_OBJECT ( glade.get_widget("tool_button_mute") ), "toggled", G_CALLBACK ( on_tool_button_mute_toggled ), this );     
 
68
        g_signal_connect( G_OBJECT ( glade.get_widget("tool_button_record") ), "toggled", G_CALLBACK ( on_tool_button_record_toggled ), this ); 
 
69
        g_signal_connect( G_OBJECT ( glade.get_widget("tool_button_auto_surf") ), "toggled", G_CALLBACK ( on_tool_button_auto_surf_toggled ), this );   
 
70
        g_signal_connect( G_OBJECT ( glade.get_widget("tool_button_broadcast") ), "toggled", G_CALLBACK ( on_tool_button_broadcast_toggled ), this );   
 
71
        g_signal_connect( G_OBJECT ( glade.get_widget("tool_button_scheduled_recordings") ), "clicked", G_CALLBACK ( on_tool_button_scheduled_recordings_clicked ), this );
 
72
        g_signal_connect( G_OBJECT ( glade.get_widget("tool_button_hide_controls") ), "clicked", G_CALLBACK ( on_tool_button_hide_controls_clicked ), this );   
 
73
        g_signal_connect( G_OBJECT ( glade.get_widget("menu_item_file_quit") ), "activate", G_CALLBACK ( on_menu_item_file_quit_activate ), this );     
 
74
        g_signal_connect( G_OBJECT ( glade.get_widget("menu_item_view_fullscreen") ), "activate", G_CALLBACK ( on_menu_item_view_fullscreen_activate ), this ); 
 
75
        g_signal_connect( G_OBJECT ( glade.get_widget("menu_item_view_preferences") ), "activate", G_CALLBACK ( on_menu_item_view_preferences_activate ), this );       
 
76
        g_signal_connect( G_OBJECT ( glade.get_widget("menu_item_view_epg") ), "activate", G_CALLBACK ( on_menu_item_view_epg_activate ), this );       
 
77
        g_signal_connect( G_OBJECT ( glade.get_widget("menu_item_view_program_search") ), "activate", G_CALLBACK ( on_menu_item_view_program_search_activate ), this ); 
 
78
        g_signal_connect( G_OBJECT ( glade.get_widget("menu_item_audio_mute") ), "toggled", G_CALLBACK ( on_menu_item_audio_mute_toggled ), this );     
 
79
        g_signal_connect( G_OBJECT ( glade.get_widget("menu_item_help_contents") ), "activate", G_CALLBACK ( on_menu_item_help_contents_activate ), this );     
 
80
        g_signal_connect( G_OBJECT ( glade.get_widget("menu_item_help_about") ), "activate", G_CALLBACK ( on_menu_item_help_about_activate ), this );   
 
81
        g_signal_connect( G_OBJECT ( event_box_video ), "button_press_event",   G_CALLBACK ( on_window_main_button_press ), this );
75
82
        
76
83
        g_signal_connect( G_OBJECT ( glade.get_widget("combo_box_record_type") ), "changed", G_CALLBACK ( on_combo_box_record_type_changed ), this );   
77
84
        g_signal_connect( G_OBJECT ( glade.get_widget("spinbutton_duration") ), "value-changed", G_CALLBACK ( on_spinbutton_duration_value_changed ), this );   
 
85
 
 
86
        g_signal_connect( G_OBJECT ( glade.get_widget("menu_item_audio_dual_language_disable") ), "toggled", G_CALLBACK ( on_menu_item_audio_dual_language_changed ), this );
 
87
        g_signal_connect( G_OBJECT ( glade.get_widget("menu_item_audio_dual_language_left") ), "toggled", G_CALLBACK ( on_menu_item_audio_dual_language_changed ), this );
 
88
        g_signal_connect( G_OBJECT ( glade.get_widget("menu_item_audio_dual_language_right") ), "toggled", G_CALLBACK ( on_menu_item_audio_dual_language_changed ), this );
78
89
        
79
 
        Glib::ustring engine_type = general_section.get_value("engine_type");
80
 
        Log::write(N_("Using '%s' engine"), engine_type.c_str());
 
90
        GtkWidget* menu_item_subtitles_disabled = glade.get_widget("menu_item_subtitles_disabled");
 
91
        g_signal_connect( G_OBJECT ( menu_item_subtitles_disabled ), "toggled", G_CALLBACK ( on_menu_item_subtitle_stream_toggled ), NULL );
 
92
 
 
93
        String engine_type = configuration.get_string_value("engine_type");
 
94
        Log::write(_("Using '%s' engine"), engine_type.c_str());
81
95
        if (engine_type == "xine")
82
96
        {
83
97
                engine = new XineEngine();
88
102
        }
89
103
        else
90
104
        {
91
 
                throw Exception(N_("Unknown engine type '%s'"), engine_type.c_str());
 
105
                throw Exception(_("Unknown engine type '%s'"), engine_type.c_str());
92
106
        }
93
107
        
94
 
        int x           = general_section.get_int_value("x");
95
 
        int y           = general_section.get_int_value("y");
96
 
        int width       = general_section.get_int_value("width");
97
 
        int height      = general_section.get_int_value("height");
 
108
        gint x          = configuration.get_int_value("x");
 
109
        gint y          = configuration.get_int_value("y");
 
110
        gint width      = configuration.get_int_value("width");
 
111
        gint height     = configuration.get_int_value("height");
98
112
 
99
113
        if (x != -1)
100
114
        {
104
118
 
105
119
        gtk_paned_set_position(
106
120
                GTK_PANED(glade.get_widget("vpaned_main")),
107
 
                general_section.get_int_value("video_position"));
108
 
 
109
 
        gtk_window_set_keep_above(GTK_WINDOW(window_main), general_section.get_boolean_value("always_on_top"));
110
 
 
111
 
        show_controls(general_section.get_boolean_value("show_controls"));
112
 
        show_epg(general_section.get_boolean_value("show_epg"));
 
121
                configuration.get_int_value("video_position"));
 
122
 
 
123
        gtk_window_set_keep_above(GTK_WINDOW(window_main), configuration.get_boolean_value("always_on_top"));
 
124
 
 
125
        show_controls(configuration.get_boolean_value("show_controls"));
 
126
        show_epg(configuration.get_boolean_value("show_epg"));
113
127
 
114
128
        GtkComboBox* combo_box_channel = GTK_COMBO_BOX(glade.get_widget("combo_box_channel"));
115
129
        GSList* iterator = application.get_channel_manager().get_channels();
136
150
 
137
151
MainWindow::~MainWindow()
138
152
{
 
153
        Application& application = Application::get_current();
 
154
        Configuration& configuration = application.get_configuration();
 
155
        
 
156
        configuration.set_int_value("video_position", gtk_paned_get_position(GTK_PANED(vpaned_main)));
 
157
        configuration.set_boolean_value("fullscreen", is_fullscreen);
 
158
        configuration.set_boolean_value("show_controls", get_controls_visible());
 
159
        configuration.set_boolean_value("show_epg", get_epg_visible());
 
160
 
 
161
        if (!is_fullscreen)
 
162
        {
 
163
                gint x, y, width, height;
 
164
                
 
165
                gtk_window_get_position(GTK_WINDOW(window_main), &x, &y);
 
166
                gtk_window_get_size(GTK_WINDOW(window_main), &width, &height);
 
167
        
 
168
                configuration.set_int_value("x", x);
 
169
                configuration.set_int_value("y", y);
 
170
                configuration.set_int_value("width", width);
 
171
                configuration.set_int_value("height", height);
 
172
        }
 
173
 
139
174
        if (engine != NULL)
140
175
        {
141
176
                delete engine;
147
182
                gdk_cursor_unref(hidden_cursor);
148
183
                hidden_cursor = NULL;
149
184
        }
150
 
 
151
 
        Application& application = Application::get_current();
152
 
        NameValueConfigurationSection& general_section = application.get_configuration().get_general_section();
153
185
        
154
 
        general_section.set_int_value("video_position", gtk_paned_get_position(GTK_PANED(vpaned_main)));
155
 
        general_section.set_boolean_value("fullscreen", is_fullscreen);
156
 
        general_section.set_boolean_value("show_controls", get_controls_visible());
157
 
        general_section.set_boolean_value("show_epg", get_epg_visible());
158
 
 
159
 
        if (!is_fullscreen)
 
186
        if (search_bar != NULL)
160
187
        {
161
 
                gint x, y, width, height;
162
 
                
163
 
                gtk_window_get_position(GTK_WINDOW(window_main), &x, &y);
164
 
                gtk_window_get_size(GTK_WINDOW(window_main), &width, &height);
165
 
        
166
 
                general_section.set_int_value("x", x);
167
 
                general_section.set_int_value("y", y);
168
 
                general_section.set_int_value("width", width);
169
 
                general_section.set_int_value("height", height);
 
188
                delete search_bar;
 
189
                search_bar = NULL;
170
190
        }
171
191
}
172
192
 
173
193
gboolean MainWindow::on_window_main_delete (GtkWindow* window_main, GdkEvent* event, MainWindow* main_window)
174
194
{
175
195
        Application& application = Application::get_current();
176
 
        NameValueConfigurationSection& general_section = application.get_configuration().get_general_section();
177
 
        if (general_section.get_boolean_value("quit_on_close"))
 
196
        Configuration& configuration = application.get_configuration();
 
197
        
 
198
        gboolean quit_on_close = configuration.get_boolean_value("quit_on_close");
 
199
        gboolean has_scheduled_recordings = application.get_recording_manager().has_scheduled_recordings();
 
200
        
 
201
        if (quit_on_close && !has_scheduled_recordings)
178
202
        {
179
203
                application.quit();
180
204
        }
210
234
void MainWindow::show_epg(gboolean show)
211
235
{
212
236
        if (show)
213
 
        {       
214
 
                gtk_widget_show(scrolled_window_epg);
 
237
        {
 
238
                epg_widget->show();
215
239
        }
216
240
        else
217
241
        {
218
 
                gtk_widget_hide(scrolled_window_epg);
 
242
                epg_widget->hide();
 
243
                search_bar->hide();
 
244
        }
 
245
 
 
246
        Glade& glade = Application::get_current().get_glade();
 
247
        GtkCheckMenuItem* menu_item_program_guide = GTK_CHECK_MENU_ITEM(glade.get_widget("menu_item_view_epg"));
 
248
        gboolean active = gtk_check_menu_item_get_active(menu_item_program_guide);
 
249
        if (active != show)
 
250
        {
 
251
                gtk_check_menu_item_set_active(menu_item_program_guide, show);
219
252
        }
220
253
}
221
254
 
224
257
        if (show)
225
258
        {
226
259
                gtk_window_fullscreen(GTK_WINDOW(window_main));
227
 
                is_fullscreen = true;
228
 
                show_epg(false);
229
 
                show_controls(false);
230
260
        }
231
261
        else
232
262
        {
233
263
                gtk_window_unfullscreen(GTK_WINDOW(window_main));
234
 
                is_fullscreen = false;
235
 
                show_controls(true);
236
264
        }
 
265
 
 
266
        is_fullscreen = show;
237
267
}
238
268
 
239
269
void MainWindow::toggle_controls()
272
302
 
273
303
void MainWindow::toggle_fullscreen()
274
304
{
275
 
        show_fullscreen(!is_fullscreen);
 
305
        if (!is_fullscreen)
 
306
        {
 
307
                was_maximised = gdk_window_get_state(window_main->window) & GDK_WINDOW_STATE_MAXIMIZED;
 
308
                show_fullscreen(true);
 
309
                show_controls(false);
 
310
                show_epg(false);
 
311
        }
 
312
        else            
 
313
        {
 
314
                show_fullscreen(false);
 
315
                show_controls(true);
 
316
 
 
317
                if (!was_maximised)
 
318
                {
 
319
                        gtk_window_unmaximize(GTK_WINDOW(window_main));                 
 
320
                }
 
321
        }
276
322
}
277
323
 
278
 
void MainWindow::on_toolbutton_mute_toggled (GtkToggleToolButton *widget, MainWindow* main_window)
 
324
void MainWindow::on_tool_button_mute_toggled (GtkToggleToolButton *widget, MainWindow* main_window)
279
325
{
 
326
        TRY
280
327
        Application::get_current().mute(gtk_toggle_tool_button_get_active(widget));
281
 
}
282
 
 
283
 
void MainWindow::on_toolbutton_record_toggled (GtkToggleToolButton* widget, MainWindow* main_window)
284
 
{
285
 
        Application::get_current().record(gtk_toggle_tool_button_get_active(widget));
286
 
}
287
 
 
288
 
void MainWindow::on_toolbutton_auto_surf_toggled (GtkToggleToolButton* widget, MainWindow* main_window)
289
 
{
 
328
        CATCH
 
329
}
 
330
 
 
331
void MainWindow::on_tool_button_record_toggled (GtkToggleToolButton* widget, MainWindow* main_window)
 
332
{
 
333
        TRY
 
334
        gboolean active = gtk_toggle_tool_button_get_active(widget);
 
335
        Application& application = Application::get_current();
 
336
 
 
337
        if (!active && application.is_scheduled_recording() && !application.is_shutting_down())
 
338
        {
 
339
                gint result = application.show_message_dialog(
 
340
                        _("You have stopped a scheduled recording.  "\
 
341
                           "If you do not delete the scheduled recording then it will start again automatically.  "\
 
342
                           "Would you like to delete this scheduled recording?"),
 
343
                        GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO);
 
344
                
 
345
                if (result == GTK_RESPONSE_YES)
 
346
                {
 
347
                        application.remove_current_scheduled_recording();
 
348
                }
 
349
        }
 
350
        
 
351
        Application::get_current().record(active);
 
352
        CATCH
 
353
}
 
354
 
 
355
void MainWindow::on_tool_button_auto_surf_toggled (GtkToggleToolButton* widget, MainWindow* main_window)
 
356
{
 
357
        TRY
290
358
        Application::get_current().auto_surf(gtk_toggle_tool_button_get_active(widget));
 
359
        CATCH
291
360
}
292
361
 
293
 
void MainWindow::on_toolbutton_broadcast_toggled (GtkToggleToolButton *widget, MainWindow* main_window)
 
362
void MainWindow::on_tool_button_broadcast_toggled (GtkToggleToolButton *widget, MainWindow* main_window)
294
363
{
 
364
        TRY
295
365
        Application::get_current().broadcast(gtk_toggle_tool_button_get_active(widget));
 
366
        CATCH
296
367
}
297
368
 
298
 
void MainWindow::on_toolbutton_scheduled_recordings_clicked(GtkToolButton *widget, MainWindow* main_window)
 
369
void MainWindow::on_tool_button_scheduled_recordings_clicked(GtkToolButton *widget, MainWindow* main_window)
299
370
{
 
371
        TRY
300
372
        main_window->show_scheduled_recordings_dialog();
 
373
        CATCH
301
374
}
302
375
 
303
 
void MainWindow::on_toolbutton_hide_controls_clicked(GtkToolButton *widget, MainWindow* main_window)
 
376
void MainWindow::on_tool_button_hide_controls_clicked(GtkToolButton *widget, MainWindow* main_window)
304
377
{
 
378
        TRY
305
379
        Application::get_current().hide_controls();
306
 
}
307
 
 
308
 
void MainWindow::on_audio_channel_value_changed (GtkSpinButton *widget, MainWindow* main_window)
309
 
{
310
 
        Application::get_current().audio_channel(gtk_spin_button_get_value_as_int(widget));
311
 
}
312
 
 
313
 
void MainWindow::on_subtitle_channel_value_changed (GtkSpinButton *widget, MainWindow* main_window)
314
 
{
315
 
        Application::get_current().subtitle_channel(gtk_spin_button_get_value_as_int(widget));
 
380
        CATCH
316
381
}
317
382
 
318
383
void MainWindow::on_menu_item_file_quit_activate (GtkMenuItem *widget, MainWindow* main_window)
319
384
{
 
385
        TRY
320
386
        Application::get_current().quit();
 
387
        CATCH
321
388
}
322
389
 
323
390
void MainWindow::on_menu_item_view_preferences_activate (GtkMenuItem* widget, MainWindow* main_window)
324
391
{
 
392
        TRY
325
393
        main_window->show_preferences_dialog();
 
394
        CATCH
326
395
}
327
396
 
328
397
void MainWindow::on_menu_item_view_fullscreen_activate (GtkMenuItem* widget, MainWindow* main_window)
329
398
{
 
399
        TRY
330
400
        main_window->toggle_fullscreen();
331
 
}
332
 
 
333
 
void MainWindow::on_menu_item_view_video_controls_activate (GtkMenuItem* widget, MainWindow* main_window)
334
 
{
335
 
        main_window->toggle_controls();
 
401
        CATCH
 
402
}
 
403
 
 
404
void MainWindow::on_menu_item_view_epg_activate (GtkCheckMenuItem* widget, MainWindow* main_window)
 
405
{
 
406
        TRY
 
407
        main_window->show_epg(gtk_check_menu_item_get_active(widget));
 
408
        CATCH
 
409
}
 
410
 
 
411
void MainWindow::on_menu_item_view_program_search_activate (GtkMenuItem* widget, MainWindow* main_window)
 
412
{
 
413
        TRY
 
414
        main_window->show_search();
 
415
        CATCH
 
416
}
 
417
 
 
418
void MainWindow::on_menu_item_audio_stream_toggled(GtkCheckMenuItem *checkmenuitem, gpointer data)
 
419
{
 
420
        TRY
 
421
        if (gtk_check_menu_item_get_active(checkmenuitem))
 
422
        {
 
423
                gint audio_pid = *((gint *)data);
 
424
                Log::write(_("Setting audio PID to %d"), audio_pid);
 
425
                Application& application = Application::get_current();
 
426
                application.get_video_channel().default_audio_pid = audio_pid;
 
427
                application.restart_stream();
 
428
        }
 
429
        CATCH
 
430
}
 
431
 
 
432
void MainWindow::on_menu_item_subtitle_stream_toggled(GtkCheckMenuItem *checkmenuitem, gpointer data)
 
433
{
 
434
        TRY
 
435
        if (gtk_check_menu_item_get_active(checkmenuitem))
 
436
        {
 
437
                gint subtitle_pid = 0;
 
438
                
 
439
                if (data != NULL)
 
440
                {
 
441
                        subtitle_pid = *((gint *)data);
 
442
                }
 
443
                
 
444
                Log::write(_("Setting subtitle PID to %d"), subtitle_pid);
 
445
                Application& application = Application::get_current();
 
446
                application.get_video_channel().default_subtitle_pid = subtitle_pid;
 
447
                application.restart_stream();
 
448
        }
 
449
        CATCH
 
450
}
 
451
 
 
452
void MainWindow::on_menu_item_audio_mute_toggled(GtkCheckMenuItem *checkmenuitem, MainWindow* main_window)
 
453
{
 
454
        TRY
 
455
        Application::get_current().mute(gtk_check_menu_item_get_active(checkmenuitem));
 
456
        CATCH
336
457
}
337
458
 
338
459
void MainWindow::on_menu_item_help_contents_activate (GtkMenuItem* widget, MainWindow* main_window)
339
460
{
 
461
        TRY
340
462
        Application::get_current().show_help();
 
463
        CATCH
341
464
}
342
465
 
343
466
void MainWindow::on_menu_item_help_about_activate (GtkMenuItem* widget, MainWindow* main_window)
344
467
{
 
468
        TRY
345
469
        Application::get_current().show_about();
346
 
}
347
 
 
348
 
gboolean MainWindow::on_button_press(GtkWindow* widget, GdkEventButton *event, MainWindow* main_window)
349
 
{
 
470
        CATCH
 
471
}
 
472
 
 
473
gboolean MainWindow::on_window_main_key_press_event(GtkWidget* window_main, GdkEventKey* event, MainWindow* main_window)
 
474
{
 
475
        TRY
 
476
        if (main_window->search_bar->is_visible())
 
477
        {
 
478
                return FALSE;
 
479
        }
 
480
        
 
481
        switch(event->keyval)
 
482
        {
 
483
                case GDK_a:
 
484
                case GDK_A:
 
485
                        Application::get_current().toggle_auto_surf();
 
486
                        break;
 
487
                case GDK_b:
 
488
                case GDK_B:
 
489
                        Application::get_current().toggle_broadcast();
 
490
                        break;
 
491
                case GDK_e:
 
492
                case GDK_E:
 
493
                        Application::get_current().toggle_controls();
 
494
                        break;
 
495
                case GDK_f:
 
496
                case GDK_F:
 
497
                        if ((event->state & GDK_CONTROL_MASK) != 0)
 
498
                        {
 
499
                                main_window->show_search();
 
500
                        }
 
501
                        else
 
502
                        {
 
503
                                Application::get_current().toggle_fullscreen();
 
504
                        }
 
505
                        break;
 
506
                case GDK_r:
 
507
                case GDK_R:
 
508
                        Application::get_current().toggle_record();
 
509
                        break;
 
510
                case GDK_m:
 
511
                case GDK_M:
 
512
                        Application::get_current().toggle_mute();
 
513
                        break;
 
514
                case GDK_h:
 
515
                case GDK_H:
 
516
                        Application::get_current().hide_controls();
 
517
                        break;
 
518
        }
 
519
        CATCH
 
520
        
 
521
        return FALSE;
 
522
}
 
523
 
 
524
gboolean MainWindow::on_window_main_button_press(GtkWindow* widget, GdkEventButton *event, MainWindow* main_window)
 
525
{
 
526
        TRY
350
527
        Application& application = Application::get_current();
351
528
        if (event->button == 1)
352
529
        {                               
359
536
        {
360
537
                application.toggle_controls();
361
538
        }
 
539
        CATCH
362
540
 
363
541
        return FALSE;
364
542
}
365
543
 
366
544
void MainWindow::on_combo_box_record_type_changed (GtkComboBox* widget, MainWindow* main_window)
367
545
{
 
546
        TRY
368
547
        Application& application = Application::get_current();
369
548
        Glade& glade = application.get_glade();
370
549
        
391
570
                gtk_widget_hide(glade.get_widget("label_start_day"));
392
571
                gtk_widget_hide(glade.get_widget("combo_box_start_day"));
393
572
        }
 
573
        CATCH
394
574
}
395
575
 
396
576
void MainWindow::on_spinbutton_duration_value_changed (GtkSpinButton* widget, MainWindow* main_window)
397
577
{
 
578
        TRY
398
579
        Application& application = Application::get_current();
399
580
        Glade& glade = application.get_glade();
400
581
        
401
582
        int duration = (int)gtk_spin_button_get_value(widget);
402
 
        Glib::ustring text = " minutes";
 
583
        String text = " minutes";
403
584
        if (duration >= 60)
404
585
        {
405
586
                text += " (";
407
588
                text += ")";
408
589
        }
409
590
        gtk_label_set_text(GTK_LABEL(glade.get_widget("label_duration_text")), text.c_str());
410
 
}
411
 
 
412
 
void MainWindow::change_channel(Channel& channel)
 
591
        CATCH
 
592
}
 
593
 
 
594
void MainWindow::on_menu_item_audio_dual_language_changed(GtkCheckMenuItem* widget, MainWindow* main_window)
 
595
{
 
596
        TRY
 
597
        if (gtk_check_menu_item_get_active(widget))
 
598
        {
 
599
                GtkWidget* w = GTK_WIDGET(widget);
 
600
                gint state = ENGINE_DUAL_LANGUAGE_DISABLE;
 
601
                Glade& glade = Application::get_current().get_glade();
 
602
                if (w == glade.get_widget("menu_item_audio_dual_language_left"))
 
603
                {
 
604
                        state = ENGINE_DUAL_LANGUAGE_LEFT;
 
605
                }
 
606
                else if (w == glade.get_widget("menu_item_audio_dual_language_right"))
 
607
                {
 
608
                        state = ENGINE_DUAL_LANGUAGE_RIGHT;
 
609
                }
 
610
                
 
611
                main_window->engine->set_dual_language_state(state);
 
612
        }
 
613
        CATCH
 
614
}
 
615
 
 
616
void MainWindow::show_search()
 
617
{
 
618
        show_epg(true);
 
619
        search_bar->show();
 
620
}
 
621
 
 
622
void MainWindow::update_audio_stream_menu()
 
623
{
 
624
        Application& application = Application::get_current();
 
625
        Glade& glade = application.get_glade();
 
626
        Channel& channel = application.get_video_channel();
 
627
        
 
628
        GtkWidget* menuitem_audio_streams = glade.get_widget("menu_item_audio_streams");
 
629
        GtkWidget* menu_widget = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menuitem_audio_streams));
 
630
        if (menu_widget != NULL)
 
631
        {
 
632
                audio_stream_group = NULL;
 
633
                gtk_widget_destroy(menu_widget);
 
634
        }
 
635
 
 
636
        guint audio_pid_size = channel.audio_pids.size();
 
637
        if (audio_pid_size > 0)
 
638
        {
 
639
                if (audio_pid_size > MAX_AUDIO_PIDS)
 
640
                {
 
641
                        audio_pid_size = MAX_AUDIO_PIDS;
 
642
                }
 
643
                
 
644
                menu_widget = gtk_menu_new();
 
645
                for (guint i = 0; i < audio_pid_size; i++)
 
646
                {
 
647
                        guint audio_pid = channel.audio_pids[i];
 
648
                        audio_pids[i] = audio_pid;
 
649
                        String label = String::format(_("Audio Stream %d (PID %d)"), i + 1, audio_pid);
 
650
                        GtkWidget* menu_item = gtk_radio_menu_item_new_with_label(audio_stream_group, label.c_str());
 
651
                        audio_stream_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
 
652
                        gtk_menu_shell_append(GTK_MENU_SHELL(menu_widget), menu_item);
 
653
                        
 
654
                        if (channel.default_audio_pid == audio_pid)
 
655
                        {
 
656
                                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), true);
 
657
                        }
 
658
                        
 
659
                        g_signal_connect( G_OBJECT ( menu_item ), "toggled", G_CALLBACK ( on_menu_item_audio_stream_toggled ), &(audio_pids[i]) );
 
660
                        gtk_widget_show(menu_item);
 
661
                }
 
662
                gtk_widget_show(menu_widget);
 
663
                
 
664
                gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem_audio_streams), menu_widget);
 
665
        }
 
666
}
 
667
 
 
668
void MainWindow::update_view_subtitle_menu()
 
669
{
 
670
        Application& application = Application::get_current();
 
671
        Glade& glade = application.get_glade();
 
672
        Channel& channel = application.get_video_channel();
 
673
        
 
674
        GtkWidget* menu_item_view_subtitles = glade.get_widget("menu_item_view_subtitles");
 
675
        GtkWidget* menu_widget = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu_item_view_subtitles));
 
676
                
 
677
        guint subtitle_pid_size = channel.subtitle_pids.size();
 
678
        if (subtitle_pid_size > 0)
 
679
        {
 
680
                if (subtitle_pid_size > MAX_AUDIO_PIDS)
 
681
                {
 
682
                        subtitle_pid_size = MAX_AUDIO_PIDS;
 
683
                }
 
684
                
 
685
                menu_widget = gtk_menu_new();
 
686
                for (guint i = 0; i < subtitle_pid_size; i++)
 
687
                {
 
688
                        guint subtitle_pid = channel.subtitle_pids[i];
 
689
                        subtitle_pids[i] = subtitle_pid;
 
690
                        String label = String::format(_("Subtitle Stream %d (PID %d)"), i + 1, subtitle_pid);
 
691
                        GtkWidget* menu_item = gtk_radio_menu_item_new_with_label(subtitle_stream_group, label.c_str());
 
692
                        subtitle_stream_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
 
693
                        gtk_menu_shell_append(GTK_MENU_SHELL(menu_widget), menu_item);
 
694
                        
 
695
                        if (channel.default_subtitle_pid == subtitle_pid)
 
696
                        {
 
697
                                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), true);
 
698
                        }
 
699
                        
 
700
                        g_signal_connect( G_OBJECT ( menu_item ), "toggled", G_CALLBACK ( on_menu_item_subtitle_stream_toggled ), &(subtitle_pids[i]) );
 
701
                        gtk_widget_show(menu_item);
 
702
                }
 
703
                gtk_widget_show(menu_widget);
 
704
        }
 
705
}
 
706
 
 
707
void MainWindow::channel_change_complete()
 
708
{
 
709
        update_audio_stream_menu();
 
710
        update_view_subtitle_menu();
 
711
}
 
712
 
 
713
void MainWindow::change_channel_start()
413
714
{
414
715
        update_epg();
415
716
}
420
721
        Application& application = Application::get_current();
421
722
        if (state)
422
723
        {
423
 
                Glib::ustring message = N_("Recording to ");
 
724
                String message = _("Recording to ");
424
725
                message += application.get_recording_file_name();
425
726
                gtk_statusbar_push(GTK_STATUSBAR(statusbar), context_id, message.c_str());
426
727
        }
430
731
        }
431
732
        
432
733
        gtk_toggle_tool_button_set_active(
433
 
                GTK_TOGGLE_TOOL_BUTTON(application.get_glade().get_widget("toolbutton_record")),
 
734
                GTK_TOGGLE_TOOL_BUTTON(application.get_glade().get_widget("tool_button_record")),
434
735
                state);
435
736
}
436
737
 
441
742
                engine->mute(state);
442
743
        }
443
744
        
444
 
        GtkToggleToolButton* item = GTK_TOGGLE_TOOL_BUTTON(
445
 
                Application::get_current().get_glade().get_widget("toolbutton_mute"));
446
 
        if (gtk_toggle_tool_button_get_active(item) != state)
447
 
        {
448
 
                gtk_toggle_tool_button_set_active(item, state);
 
745
        Glade& glade = Application::get_current().get_glade();
 
746
        
 
747
        GtkToggleToolButton* tool_button_mute = GTK_TOGGLE_TOOL_BUTTON(glade.get_widget("tool_button_mute"));
 
748
        if (gtk_toggle_tool_button_get_active(tool_button_mute) != state)
 
749
        {
 
750
                gtk_toggle_tool_button_set_active(tool_button_mute, state);
 
751
        }
 
752
        
 
753
        GtkCheckMenuItem* menu_item_audio_mute = GTK_CHECK_MENU_ITEM(glade.get_widget("menu_item_audio_mute"));
 
754
        if (gtk_check_menu_item_get_active(menu_item_audio_mute) != state)
 
755
        {
 
756
                gtk_check_menu_item_set_active(menu_item_audio_mute, state);
449
757
        }
450
758
}
451
759
 
452
760
void MainWindow::auto_surf(gboolean state)
453
761
{
454
 
        GtkToggleToolButton* toolbutton_auto_surf = GTK_TOGGLE_TOOL_BUTTON(
455
 
                Application::get_current().get_glade().get_widget("toolbutton_auto_surf"));
456
 
        if (gtk_toggle_tool_button_get_active(toolbutton_auto_surf) != state)
 
762
        GtkToggleToolButton* tool_button_auto_surf = GTK_TOGGLE_TOOL_BUTTON(
 
763
                Application::get_current().get_glade().get_widget("tool_button_auto_surf"));
 
764
        if (gtk_toggle_tool_button_get_active(tool_button_auto_surf) != state)
457
765
        {
458
 
                gtk_toggle_tool_button_set_active(toolbutton_auto_surf, state);
 
766
                gtk_toggle_tool_button_set_active(tool_button_auto_surf, state);
459
767
        }
460
768
}
461
769
 
462
770
void MainWindow::broadcast(gboolean state)
463
771
{
464
772
        GtkToggleToolButton* item = GTK_TOGGLE_TOOL_BUTTON(
465
 
                Application::get_current().get_glade().get_widget("toolbutton_broadcast"));
 
773
                Application::get_current().get_glade().get_widget("tool_button_broadcast"));
466
774
        if (gtk_toggle_tool_button_get_active(item) != state)
467
775
        {
468
776
                gtk_toggle_tool_button_set_active(item, state);
487
795
 
488
796
void MainWindow::update_epg()
489
797
{
490
 
        GtkAdjustment* hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scrolled_window_epg));
491
 
        GtkAdjustment* vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrolled_window_epg));
492
 
 
493
 
        gdouble hvalue = gtk_adjustment_get_value(hadjustment);
494
 
        gdouble vvalue = gtk_adjustment_get_value(vadjustment);
495
 
        
496
798
        epg_widget->update();
497
799
        
498
 
        gtk_adjustment_set_value(hadjustment, hvalue);
499
 
        gtk_adjustment_set_value(vadjustment, vvalue);
500
 
 
501
800
        Application& application = Application::get_current();
502
 
        Glib::ustring message = application.get_status_message();
 
801
        String message = application.get_status_message();
503
802
        static int context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), "Current channel - event");      
504
803
        gtk_statusbar_pop(GTK_STATUSBAR(statusbar), context_id);
505
804
        gtk_statusbar_push(GTK_STATUSBAR(statusbar), context_id, message.c_str());
525
824
 
526
825
gboolean MainWindow::get_epg_visible()
527
826
{
528
 
        return GTK_WIDGET_VISIBLE(scrolled_window_epg);
 
827
        return epg_widget->is_visible();
529
828
}
530
829
 
531
830
void MainWindow::show()
532
831
{
533
832
        gtk_widget_show(GTK_WIDGET(window_main));
 
833
 
 
834
        Configuration& configuration = Application::get_current().get_configuration();
 
835
        
 
836
        gint x = configuration.get_int_value("x");
 
837
        gint y = configuration.get_int_value("y");
 
838
 
 
839
        gtk_window_move(GTK_WINDOW(window_main), x, y);
534
840
}
535
841
 
536
842
void MainWindow::hide()
537
843
{
 
844
        gint x = 0;
 
845
        gint y = 0;
 
846
 
538
847
        mute(true);
 
848
        Configuration& configuration = Application::get_current().get_configuration();
 
849
        gtk_window_get_position(GTK_WINDOW(window_main), &x, &y);
 
850
        configuration.set_int_value("x", x);
 
851
        configuration.set_int_value("y", y);
539
852
        gtk_widget_hide(GTK_WIDGET(window_main));
540
853
}
541
854
 
557
870
 
558
871
void MainWindow::show_scheduled_recordings_dialog()
559
872
{
 
873
        gboolean fullscreen_workaround = Application::get_current().get_configuration().get_boolean_value("fullscreen_workaround");
 
874
        gboolean was_fullscreen = get_is_fullscreen();
 
875
 
 
876
        if (fullscreen_workaround && was_fullscreen)
 
877
        {
 
878
                maximise();
 
879
                show_fullscreen(false);
 
880
        }
 
881
        
560
882
        scheduled_recordings_dialog->show();
 
883
        
 
884
        if (fullscreen_workaround && was_fullscreen)
 
885
        {
 
886
                show_fullscreen(true);
 
887
        }
 
888
}
 
889
 
 
890
void MainWindow::show_scheduled_recording_dialog()
 
891
{
 
892
        gboolean fullscreen_workaround = Application::get_current().get_configuration().get_boolean_value("fullscreen_workaround");
 
893
        gboolean was_fullscreen = get_is_fullscreen();
 
894
 
 
895
        if (fullscreen_workaround && was_fullscreen)
 
896
        {
 
897
                maximise();
 
898
                show_fullscreen(false);
 
899
        }
 
900
        
 
901
        scheduled_recording_dialog->show();     
 
902
        
 
903
        if (fullscreen_workaround && was_fullscreen)
 
904
        {
 
905
                show_fullscreen(true);
 
906
        }
 
907
        
 
908
        update_epg();
561
909
}
562
910
 
563
911
void MainWindow::show_scheduled_recording_dialog(ScheduledRecording& scheduled_recording)
564
912
{
565
 
        int response = 0;
566
 
        Application& application = Application::get_current();
567
 
        Glade& glade = application.get_glade();
568
 
        
569
 
        GtkEntry*               entry_description                               = GTK_ENTRY(glade.get_widget("entry_description"));     
570
 
        GtkComboBox*    combo_box_channel                               = GTK_COMBO_BOX(glade.get_widget("combo_box_channel"));
571
 
        GtkComboBox*    combo_box_record_type                   = GTK_COMBO_BOX(glade.get_widget("combo_box_record_type"));
572
 
        GtkComboBox*    combo_box_start_day                             = GTK_COMBO_BOX(glade.get_widget("combo_box_start_day"));
573
 
        GnomeDateEdit*  date_edit_start_date                    = (GnomeDateEdit*)glade.get_widget("date_edit_start_date");
574
 
        GtkSpinButton*  spinbutton_start_time_hour              = GTK_SPIN_BUTTON(glade.get_widget("spinbutton_start_time_hour"));
575
 
        GtkSpinButton*  spinbutton_start_time_minute    = GTK_SPIN_BUTTON(glade.get_widget("spinbutton_start_time_minute"));
576
 
        GtkSpinButton*  spinbutton_duration                             = GTK_SPIN_BUTTON(glade.get_widget("spinbutton_duration"));
 
913
        gboolean fullscreen_workaround = Application::get_current().get_configuration().get_boolean_value("fullscreen_workaround");
 
914
        gboolean was_fullscreen = get_is_fullscreen();
577
915
 
578
 
        int index = 0;
579
 
        GSList* iterator = application.get_channel_manager().get_channels();
580
 
        while (iterator != NULL)
 
916
        if (fullscreen_workaround && was_fullscreen)
581
917
        {
582
 
                Channel& channel = *(Channel*)iterator->data;
583
 
                if (scheduled_recording.channel_name == channel.name)
584
 
                {
585
 
                        gtk_combo_box_set_active(combo_box_channel, index);
586
 
                }
587
 
                index++;
588
 
                iterator = g_slist_next(iterator);
 
918
                maximise();
 
919
                show_fullscreen(false);
589
920
        }
590
 
 
591
 
        gtk_entry_set_text(entry_description, scheduled_recording.description.c_str());
592
 
        gtk_combo_box_set_active(combo_box_record_type, scheduled_recording.type);
593
 
        DateTime start_time(scheduled_recording.start_time, true);
594
 
 
595
 
        gnome_date_edit_set_time(
596
 
                date_edit_start_date,
597
 
                scheduled_recording.type == RECORDING_TYPE_ONCE_OFF ? scheduled_recording.start_time : 0);
598
 
        gtk_combo_box_set_active(combo_box_start_day, scheduled_recording.day_of_week);
599
 
        
600
 
        gtk_spin_button_set_value(spinbutton_start_time_hour, start_time.get_hour());
601
 
        gtk_spin_button_set_value(spinbutton_start_time_minute, start_time.get_minute());
602
 
        gtk_spin_button_set_value(spinbutton_duration, scheduled_recording.duration / 60);
603
 
        
604
 
        response = gtk_dialog_run(GTK_DIALOG(scheduled_recording_dialog));
605
 
        
606
 
        gtk_widget_hide(GTK_WIDGET(scheduled_recording_dialog));
607
 
 
608
 
        if (response == 1)
 
921
        
 
922
        scheduled_recording_dialog->show(scheduled_recording);  
 
923
        
 
924
        if (fullscreen_workaround && was_fullscreen)
609
925
        {
610
 
                int start_time = 0;
611
 
                int day_of_week = 0;
612
 
 
613
 
                scheduled_recording.type = gtk_combo_box_get_active(combo_box_record_type);
614
 
                int start_time_date = gnome_date_edit_get_time(date_edit_start_date) - (daylight * 60 * 60) + timezone;
615
 
        
616
 
                start_time = start_time_date +
617
 
                        (int)(gtk_spin_button_get_value(spinbutton_start_time_hour) * 60 * 60 +
618
 
                                gtk_spin_button_get_value(spinbutton_start_time_minute) * 60);
619
 
 
620
 
                day_of_week = gtk_combo_box_get_active(combo_box_start_day);
621
 
                
622
 
                if (scheduled_recording.type == RECORDING_TYPE_NONE)
623
 
                {
624
 
                        application.get_recording_manager().remove_scheduled_recording(scheduled_recording.description);
625
 
                }
626
 
                else
627
 
                {
628
 
                        scheduled_recording.description = gtk_entry_get_text(entry_description);
629
 
                        scheduled_recording.channel_name = gtk_combo_box_get_active_text(combo_box_channel);
630
 
                        scheduled_recording.start_time = start_time;
631
 
                        scheduled_recording.day_of_week = day_of_week;
632
 
                        scheduled_recording.duration = (int)gtk_spin_button_get_value(spinbutton_duration) * 60;
633
 
                        application.get_recording_manager().save_scheduled_recording(scheduled_recording);
634
 
                }
 
926
                show_fullscreen(true);
635
927
        }
636
928
        
637
929
        update_epg();
638
930
}
639
931
 
640
 
void MainWindow::show_event_dialog (const EpgEvent& event)
 
932
void MainWindow::show_program_details_dialog (const EpgEvent& event)
641
933
{
642
934
        int response = 0;
643
935
        Application& application = Application::get_current();
644
936
        Glade& glade = application.get_glade();
645
937
 
646
 
        GeneralConfigurationSection& general_section = application.get_configuration().get_general_section();
647
 
        
648
 
        Glib::ustring start_time = event.get_start_time_text();
649
 
        Glib::ustring duration = event.get_duration_text();
650
 
        
651
 
        gtk_label_set_text(GTK_LABEL(glade.get_widget("label_event_title")), event.get_title().c_str());
652
 
        gtk_label_set_text(GTK_LABEL(glade.get_widget("label_event_description")), event.get_description().c_str());
653
 
        gtk_label_set_text(GTK_LABEL(glade.get_widget("label_event_start_time")), start_time.c_str());
654
 
        gtk_label_set_text(GTK_LABEL(glade.get_widget("label_event_duration")), duration.c_str());
655
 
        
656
 
        response = gtk_dialog_run(GTK_DIALOG(event_dialog));
657
 
        gtk_widget_hide(GTK_WIDGET(event_dialog));
 
938
        Configuration& configuration = application.get_configuration();
 
939
        
 
940
        String start_time = event.get_start_time_text();
 
941
        String duration = event.get_duration_text();
 
942
        
 
943
        gtk_label_set_text(GTK_LABEL(glade.get_widget("label_program_title")), event.get_title().c_str());
 
944
        gtk_label_set_text(GTK_LABEL(glade.get_widget("label_program_description")), event.get_description().c_str());
 
945
        gtk_label_set_text(GTK_LABEL(glade.get_widget("label_program_start_time")), start_time.c_str());
 
946
        gtk_label_set_text(GTK_LABEL(glade.get_widget("label_program_duration")), duration.c_str());
 
947
        
 
948
        gboolean fullscreen_workaround = configuration.get_boolean_value("fullscreen_workaround");
 
949
        gboolean was_fullscreen = get_is_fullscreen();
658
950
 
 
951
        if (fullscreen_workaround && was_fullscreen)
 
952
        {
 
953
                maximise();
 
954
                show_fullscreen(false);
 
955
        }
 
956
        
 
957
        response = gtk_dialog_run(GTK_DIALOG(dialog_program_details));
 
958
        gtk_widget_hide(GTK_WIDGET(dialog_program_details));
 
959
        
 
960
        if (fullscreen_workaround && was_fullscreen)
 
961
        {
 
962
                show_fullscreen(true);
 
963
        }
 
964
        
659
965
        if (response == 1)
660
966
        {       
661
967
                ScheduledRecording scheduled_recording;
662
 
                DateTime now;
663
968
                
664
 
                int record_extra_before_seconds = general_section.get_int_value("record_extra_before") * 60;
665
 
                int record_extra_after_seconds = general_section.get_int_value("record_extra_after") * 60;
 
969
                int record_extra_before_seconds = configuration.get_int_value("record_extra_before") * 60;
 
970
                int record_extra_after_seconds = configuration.get_int_value("record_extra_after") * 60;
666
971
 
667
972
                scheduled_recording.description         = event.get_title();
668
973
                scheduled_recording.channel_name        = event.get_channel().name;
669
974
                scheduled_recording.type                        = RECORDING_TYPE_ONCE_OFF;
670
 
                scheduled_recording.day_of_week         = now.get_day_of_week();
671
975
                scheduled_recording.start_time          = event.get_start_time() - record_extra_before_seconds;
672
976
                scheduled_recording.duration            = event.get_duration() + record_extra_before_seconds + record_extra_after_seconds;
673
977
                
677
981
 
678
982
void MainWindow::show_preferences_dialog ()
679
983
{
680
 
        int response = 0;
681
 
        Application& application = Application::get_current();
682
 
        Glade& glade = application.get_glade();
683
 
 
684
 
        GeneralConfigurationSection& general_section = application.get_configuration().get_general_section();
685
 
 
686
 
        GtkFileChooser* filechooserbutton_recording_directory = GTK_FILE_CHOOSER(glade.get_widget("filechooserbutton_recording_directory"));
687
 
        
688
 
        Glib::ustring recording_directory = general_section.get_value("recording_directory");
689
 
        gtk_file_chooser_set_current_folder(filechooserbutton_recording_directory, recording_directory.c_str());
690
 
 
691
 
        response = gtk_dialog_run(GTK_DIALOG(preferences_dialog));
692
 
        gtk_widget_hide(GTK_WIDGET(preferences_dialog));
693
 
                                                                                
694
 
        if (response == 1)
695
 
        {
696
 
                recording_directory = gtk_file_chooser_get_current_folder(filechooserbutton_recording_directory);
697
 
                general_section.set_value("recording_directory", recording_directory);
698
 
        }
 
984
        preferences_dialog->show();
 
985
        update_epg();
699
986
}
700
987
 
701
988
void MainWindow::show_cursor()
703
990
        if (is_cursor_visible == false)
704
991
        {
705
992
                last_motion_time = time(NULL);
706
 
                gdk_window_set_cursor(eventbox_video->window, NULL);
 
993
                gdk_window_set_cursor(event_box_video->window, NULL);
707
994
                is_cursor_visible = true;
708
995
        }
709
996
}
710
997
 
711
998
void MainWindow::hide_cursor()
712
999
{
713
 
        gdk_window_set_cursor(eventbox_video->window, hidden_cursor);
 
1000
        gdk_window_set_cursor(event_box_video->window, hidden_cursor);
714
1001
        is_cursor_visible = false;
715
1002
}
 
1003
 
 
1004
void MainWindow::set_selected_event(xmlNodePtr event)
 
1005
{
 
1006
        epg_widget->set_selected_event(event);
 
1007
}
 
1008
 
 
1009
void MainWindow::maximise()
 
1010
{
 
1011
        gtk_window_maximize(GTK_WINDOW(window_main));
 
1012
}
 
1013
 
 
1014
gboolean MainWindow::is_minimised()             
 
1015
{               
 
1016
        GdkWindowState state = gdk_window_get_state(GTK_WIDGET(window_main)->window);           
 
1017
        return state & GDK_WINDOW_STATE_ICONIFIED;
 
1018
        return false;
 
1019
}