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

« back to all changes in this revision

Viewing changes to src/scheduled_recordings_dialog.cc

  • Committer: Bazaar Package Importer
  • Author(s): Scott Evans
  • Date: 2009-06-27 00:46:22 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20090627004622-q0zvsie6ioa60vh3
Tags: 0.9.4-0ubuntu1
* New upstream release (LP: #379706)
  - Fix to stop EPG update crashing the application
    after faulty save (LP: #72872)
  - Fixed spin buttons from GtkBuilder conversion (LP: #382197) 
  - Fixed icon on application popup menu (LP: #379685)
  - Fixed compiling of me-tv-0.8.12 fails on Fedora 11 (LP: #377020)
  - Fixed Failed to lock to channel at boot (LP: #377050)
  - Increased timeout to 5 seconds again (LP: #371165)
  - Fixed me-tv unusually slow, often freezes (LP: #351510)
  - Fixed channel persistence (LP: #361514)
  - Fix for forward slashes in description (LP: #359710)
  - Fixed Must create .me-tv directory manually (LP: #353796)
  - Fixed audio stream can't be changed (LP: #350402)
* debian/control:
  - Removed dependency libxine1-ffmpeg, libxine1-x
  - Removed libglademm-2.4-dev Build-Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include "scheduled_recording_dialog.h"
23
23
#include "application.h"
24
24
 
25
 
ScheduledRecordingsDialog* ScheduledRecordingsDialog::create(Glib::RefPtr<Gnome::Glade::Xml> glade)
 
25
ScheduledRecordingsDialog& ScheduledRecordingsDialog::create(Glib::RefPtr<Gtk::Builder> builder)
26
26
{
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;
30
30
}
31
31
 
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)
34
34
{
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));
 
38
 
 
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));
 
41
 
 
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);
 
51
        
 
52
        list_store->set_sort_column(columns.column_sort, Gtk::SORT_ASCENDING);
45
53
}
46
54
 
47
55
void ScheduledRecordingsDialog::on_button_scheduled_recordings_add_clicked()
48
56
{
49
57
        TRY
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();
53
61
        update();
54
62
        CATCH
55
63
}
58
66
{
59
67
        TRY
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)
62
70
        {
63
 
                Gtk::TreeModel::Row row = *(selection->get_selected());
64
 
 
65
 
                Data data;
66
 
                guint scheduled_recording_id = row[columns.column_scheduled_recording_id];
67
 
                data.delete_scheduled_recording(scheduled_recording_id);
68
 
                update(data);
69
 
                get_application().check_scheduled_recordings(data);
 
71
                throw Exception(_("No scheduled recording selected"));
70
72
        }
 
73
        
 
74
        Gtk::TreeModel::Row row = *(selection->get_selected());
 
75
 
 
76
        guint scheduled_recording_id = row[columns.column_scheduled_recording_id];
 
77
        get_application().scheduled_recording_manager.remove_scheduled_recording(scheduled_recording_id);
 
78
        update();
71
79
        CATCH
72
80
}
73
81
 
74
82
void ScheduledRecordingsDialog::update()
75
83
{
76
 
        Data data;
77
 
        update(data);
78
 
}
79
 
 
80
 
void ScheduledRecordingsDialog::update(Data& data)
81
 
{
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++)
86
88
        {
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;
94
98
        }
95
99
}
96
100
 
99
103
        TRY
100
104
        Glib::RefPtr<Gtk::TreeSelection> selection = tree_view_scheduled_recordings->get_selection();
101
105
        Gtk::TreeModel::Row row = *(selection->get_selected());
102
 
        Data data;
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))
106
 
        {
107
 
                throw Exception(_("Failed to get scheduled recording"));
108
 
        }
109
 
        ScheduledRecordingDialog* scheduled_recording_dialog = ScheduledRecordingDialog::create(glade);
110
 
        scheduled_recording_dialog->run(this, scheduled_recording);
111
 
        scheduled_recording_dialog->hide();
112
 
        update(data);
 
107
 
 
108
        ScheduledRecording scheduled_recording = get_application().scheduled_recording_manager.get_scheduled_recording(scheduled_recording_id);
 
109
 
 
110
        ScheduledRecordingDialog& scheduled_recording_dialog = ScheduledRecordingDialog::create(builder);
 
111
        scheduled_recording_dialog.run(this, scheduled_recording);
 
112
        scheduled_recording_dialog.hide();
 
113
 
 
114
        update();
113
115
        CATCH
114
116
}
115
117