22
22
#include "scheduled_recording_dialog.h"
23
23
#include "application.h"
25
ScheduledRecordingsDialog* ScheduledRecordingsDialog::create(Glib::RefPtr<Gnome::Glade::Xml> glade)
25
ScheduledRecordingsDialog& ScheduledRecordingsDialog::create(Glib::RefPtr<Gtk::Builder> builder)
27
27
ScheduledRecordingsDialog* scheduled_recordings_dialog = NULL;
28
glade->get_widget_derived("dialog_scheduled_recordings", scheduled_recordings_dialog);
29
return scheduled_recordings_dialog;
28
builder->get_widget_derived("dialog_scheduled_recordings", scheduled_recordings_dialog);
29
return *scheduled_recordings_dialog;
32
ScheduledRecordingsDialog::ScheduledRecordingsDialog(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& glade_xml) :
33
Gtk::Dialog(cobject), glade(glade_xml)
32
ScheduledRecordingsDialog::ScheduledRecordingsDialog(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder) :
33
Gtk::Dialog(cobject), builder(builder)
35
glade->connect_clicked("button_scheduled_recordings_add", sigc::mem_fun(*this, &ScheduledRecordingsDialog::on_button_scheduled_recordings_add_clicked));
36
glade->connect_clicked("button_scheduled_recordings_delete", sigc::mem_fun(*this, &ScheduledRecordingsDialog::on_button_scheduled_recordings_delete_clicked));
37
tree_view_scheduled_recordings = dynamic_cast<Gtk::TreeView*>(glade->get_widget("tree_view_scheduled_recordings"));
35
Gtk::Button* button = NULL;
36
builder->get_widget("button_scheduled_recordings_add", button);
37
button->signal_clicked().connect(sigc::mem_fun(*this, &ScheduledRecordingsDialog::on_button_scheduled_recordings_add_clicked));
39
builder->get_widget("button_scheduled_recordings_delete", button);
40
button->signal_clicked().connect(sigc::mem_fun(*this, &ScheduledRecordingsDialog::on_button_scheduled_recordings_delete_clicked));
42
builder->get_widget("tree_view_scheduled_recordings", tree_view_scheduled_recordings);
38
43
tree_view_scheduled_recordings->signal_row_activated().connect(sigc::mem_fun(*this, &ScheduledRecordingsDialog::on_row_activated));
39
44
list_store = Gtk::ListStore::create(columns);
40
45
tree_view_scheduled_recordings->set_model(list_store);
42
47
tree_view_scheduled_recordings->append_column(_("Channel"), columns.column_channel);
43
48
tree_view_scheduled_recordings->append_column(_("Start Time"), columns.column_start_time);
44
49
tree_view_scheduled_recordings->append_column(_("Duration"), columns.column_duration);
50
tree_view_scheduled_recordings->append_column(_("Device"), columns.column_device);
52
list_store->set_sort_column(columns.column_sort, Gtk::SORT_ASCENDING);
47
55
void ScheduledRecordingsDialog::on_button_scheduled_recordings_add_clicked()
50
ScheduledRecordingDialog* scheduled_recordings_dialog = ScheduledRecordingDialog::create(glade);
51
scheduled_recordings_dialog->run(this);
52
scheduled_recordings_dialog->hide();
58
ScheduledRecordingDialog& scheduled_recordings_dialog = ScheduledRecordingDialog::create(builder);
59
scheduled_recordings_dialog.run(this);
60
scheduled_recordings_dialog.hide();
60
68
Glib::RefPtr<Gtk::TreeSelection> selection = tree_view_scheduled_recordings->get_selection();
61
if (selection->count_selected_rows() > 0)
69
if (selection->count_selected_rows() == 0)
63
Gtk::TreeModel::Row row = *(selection->get_selected());
66
guint scheduled_recording_id = row[columns.column_scheduled_recording_id];
67
data.delete_scheduled_recording(scheduled_recording_id);
69
get_application().check_scheduled_recordings(data);
71
throw Exception(_("No scheduled recording selected"));
74
Gtk::TreeModel::Row row = *(selection->get_selected());
76
guint scheduled_recording_id = row[columns.column_scheduled_recording_id];
77
get_application().scheduled_recording_manager.remove_scheduled_recording(scheduled_recording_id);
74
82
void ScheduledRecordingsDialog::update()
80
void ScheduledRecordingsDialog::update(Data& data)
82
Profile& current_profile = get_application().get_profile_manager().get_current_profile();
84
ChannelManager& channel_manager = get_application().channel_manager;
83
85
list_store->clear();
84
ScheduledRecordingList recordings = data.get_scheduled_recordings();
85
for (ScheduledRecordingList::iterator i = recordings.begin(); i != recordings.end(); i++)
86
ScheduledRecordingList& scheduled_recordings = get_application().scheduled_recording_manager.scheduled_recordings;
87
for (ScheduledRecordingList::iterator i = scheduled_recordings.begin(); i != scheduled_recordings.end(); i++)
87
89
ScheduledRecording& scheduled_recording = *i;
88
90
Gtk::TreeModel::Row row = *(list_store->append());
91
row[columns.column_sort] = scheduled_recording.start_time;
89
92
row[columns.column_scheduled_recording_id] = scheduled_recording.scheduled_recording_id;
90
93
row[columns.column_description] = scheduled_recording.description;
91
row[columns.column_channel] = current_profile.get_channel(scheduled_recording.channel_id).name;
94
row[columns.column_channel] = channel_manager.get_channel(scheduled_recording.channel_id).name;
92
95
row[columns.column_start_time] = scheduled_recording.get_start_time_text();
93
96
row[columns.column_duration] = scheduled_recording.get_duration_text();
97
row[columns.column_device] = scheduled_recording.device;
100
104
Glib::RefPtr<Gtk::TreeSelection> selection = tree_view_scheduled_recordings->get_selection();
101
105
Gtk::TreeModel::Row row = *(selection->get_selected());
103
106
guint scheduled_recording_id = row[columns.column_scheduled_recording_id];
104
ScheduledRecording scheduled_recording;
105
if (!data.get_scheduled_recording(scheduled_recording_id, scheduled_recording))
107
throw Exception(_("Failed to get scheduled recording"));
109
ScheduledRecordingDialog* scheduled_recording_dialog = ScheduledRecordingDialog::create(glade);
110
scheduled_recording_dialog->run(this, scheduled_recording);
111
scheduled_recording_dialog->hide();
108
ScheduledRecording scheduled_recording = get_application().scheduled_recording_manager.get_scheduled_recording(scheduled_recording_id);
110
ScheduledRecordingDialog& scheduled_recording_dialog = ScheduledRecordingDialog::create(builder);
111
scheduled_recording_dialog.run(this, scheduled_recording);
112
scheduled_recording_dialog.hide();