~ubuntu-branches/ubuntu/wily/bombono-dvd/wily

« back to all changes in this revision

Viewing changes to src/mgui/author/burn.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-03-12 08:42:05 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100312084205-kugmzrqqv7zm3k7n
Tags: upstream-0.5.5
Import upstream version 0.5.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "burn.h"
25
25
#include "execute.h"
26
26
 
 
27
#include <mgui/sdk/treemodel.h>
27
28
#include <mgui/timer.h>
28
29
#include <mgui/dialog.h>
 
30
#include <mgui/gettext.h>
29
31
 
30
32
#include <boost/regex.hpp>
31
33
#include <boost/lexical_cast.hpp>
38
40
void devices_add_device(const gchar *device_name, const gchar * /*device_id*/,
39
41
                        const gchar *device_node, const gint capabilities)
40
42
{
41
 
    // нам нужны резаки DVD
42
 
    if( capabilities & DC_WRITE_DVDR )
 
43
    // требования:
 
44
    // - информация доступна об устройстве
 
45
    // - резаки DVD
 
46
    if( device_name && (capabilities & DC_WRITE_DVDR) )
43
47
    {
44
48
        //io::cout << "model = " << device_name << ", dev = " << device_node
45
49
        //         << ", capabilities = " << capabilities << ", device_id = " << device_id << io::endl;
87
91
boost::regex WriteSpeed_RE("Write Speed #"RG_NUM":"RG_SPS RG_NUM"\\."RG_NUM "x1385"); 
88
92
 
89
93
RefPtr<Gtk::ListStore> sp_store;
90
 
Gtk::TreeModelColumn<double>      dbl_cln;
91
 
Gtk::TreeModelColumn<std::string> str_cln;
92
 
const char* UpdateSpeedsEntry = "Update speeds ...";
 
94
 
 
95
enum SpeedEntryType
 
96
{
 
97
    setNONE   = 0, // по умолчанию
 
98
    setUPDATE = 1, // "Update speeds ..."
 
99
};
 
100
 
 
101
struct SpeedFields
 
102
{
 
103
    Gtk::TreeModelColumn<double>         dbl_cln;
 
104
    Gtk::TreeModelColumn<std::string>    str_cln;
 
105
    Gtk::TreeModelColumn<SpeedEntryType> type_cln;
 
106
 
 
107
 
 
108
    SpeedFields(Gtk::TreeModelColumnRecord& rec)
 
109
    {
 
110
        rec.add(dbl_cln);
 
111
        rec.add(str_cln);
 
112
        rec.add(type_cln);
 
113
    }
 
114
};
 
115
 
 
116
static SpeedFields& SF()
 
117
{
 
118
    return GetColumnFields<SpeedFields>();
 
119
}
93
120
 
94
121
bool SeparatorFunc(const RefPtr<Gtk::TreeModel>&, const Gtk::TreeIter& itr)
95
122
{
96
 
    return itr->get_value(str_cln) == "separator";
 
123
    return itr->get_value(SF().str_cln) == "separator";
97
124
}
98
125
 
99
126
static void SetupSpeeds(Gtk::ComboBox& speed_btn)
100
127
{
101
128
    if( !sp_store )
102
 
    {
103
 
        Gtk::TreeModelColumnRecord columns;
104
 
        Gtk::TreeModelColumn<double>      dbl_cln_;
105
 
        dbl_cln = dbl_cln_;
106
 
        Gtk::TreeModelColumn<std::string> str_cln_;
107
 
        str_cln = str_cln_;
108
 
        columns.add(dbl_cln);
109
 
        columns.add(str_cln);
 
129
        sp_store = Gtk::ListStore::create(GetColumnRecord<SpeedFields>());
110
130
 
111
 
        sp_store = Gtk::ListStore::create(columns);
112
 
    }
113
131
    speed_btn.set_model(sp_store);
114
132
    speed_btn.set_row_separator_func(&SeparatorFunc);
115
133
 
116
134
    // * внешний вид
117
 
    speed_btn.pack_start(str_cln);
 
135
    speed_btn.pack_start(SF().str_cln);
118
136
}
119
137
 
120
138
bool IsBurnerSetup(std::string& dev_path)
132
150
{
133
151
    Gtk::TreeIter itr = GetBD().SpeedBtn().get_active();
134
152
    ASSERT( itr );
135
 
    return itr->get_value(dbl_cln);
 
153
    return itr->get_value(SF().dbl_cln);
136
154
}
137
155
 
138
156
bool TestDvdDisc(const std::string& dev_path, std::string& str)
173
191
        ASSERT( sp_store );
174
192
 
175
193
        sp_store->clear();
 
194
        SpeedFields& sf = SF();
176
195
        // * заполняем
177
196
        Gtk::TreeRow row = *sp_store->append();
178
 
        row[str_cln] = "Auto";
 
197
        row[sf.str_cln] = _("Auto");
179
198
        speed_btn.set_active(row);
180
199
 
181
200
        for( SpeedsArray::iterator itr = speeds.begin(), end = speeds.end(); itr != end; ++itr )
182
201
        {
183
202
            Gtk::TreeRow row = *sp_store->append();
184
 
            row[dbl_cln] = *itr;
185
 
            row[str_cln] = boost::lexical_cast<std::string>(*itr) + "\303\227";
 
203
            row[sf.dbl_cln] = *itr;
 
204
            row[sf.str_cln] = boost::lexical_cast<std::string>(*itr) + "\303\227";
186
205
        }
187
206
        row = *sp_store->append();
188
 
        row[str_cln] = "separator";
 
207
        row[sf.str_cln]  = "separator";
189
208
        row = *sp_store->append();
190
 
        row[str_cln] = UpdateSpeedsEntry;
 
209
        row[sf.str_cln]  = _("Update speeds ..."); 
 
210
        row[sf.type_cln] = setUPDATE;
191
211
    }
192
212
}
193
213
 
208
228
{
209
229
    BurnData& bd = GetBD();
210
230
    Gtk::TreeIter itr = bd.SpeedBtn().get_active();
211
 
    if( itr->get_value(str_cln) == UpdateSpeedsEntry )
 
231
    if( itr && (itr->get_value(SF().type_cln) == setUPDATE) )
212
232
    {
213
233
        UpdateSpeeds();
214
234
 
316
336
        std::string str;
317
337
        bool is_good = false;
318
338
        {
319
 
            WaitProgress wp("Checking Disc ..."); 
 
339
            WaitProgress wp(_("Checking Disc ...")); 
320
340
            is_good = TestDvdDisc(dvd_drive, str);
321
341
        }
322
342
 
330
350
            break;
331
351
        case dvdCD_DRIVE_ONLY:
332
352
            try_again = Gtk::RESPONSE_OK == 
333
 
                MessageBox("Selected burn drive is for CD discs only. Change to another burn drive.", 
 
353
                MessageBox(_("Selected burn drive is for CD discs only. Change to another burn drive."), 
334
354
                           Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK_CANCEL, "", true);
335
355
            break;
336
356
        case dvdCD_DISC:
337
357
            try_again = Gtk::RESPONSE_OK == 
338
 
                MessageBox("CD disc is found in the drive, not DVD. Change to DVD disc.", 
 
358
                MessageBox(_("CD disc is found in the drive, not DVD. Change to DVD disc."), 
339
359
                           Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK_CANCEL, "", true);
340
360
            break;
341
361
        case dvdEMPTY_DRIVE:
342
362
            try_again = Gtk::RESPONSE_OK == 
343
 
                MessageBox("No DVD disc in the drive. Load a clear one and press OK.", 
 
363
                MessageBox(_("No DVD disc in the drive. Load a clear one and press OK."), 
344
364
                           Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK_CANCEL, "", true);
345
365
            break;
346
366
        case dvdOTHER:
347
367
            try_again = Gtk::RESPONSE_OK == 
348
 
                MessageBox("Disc with type \"" + inf.name + "\" is found in the drive but "
 
368
                MessageBox(BF_("Disc with type \"%1%\" is found in the drive but "
349
369
                           "for DVD-Video disc type should be one from: DVD-R, DVD+R, DVD-RW, DVD+RW. "
350
 
                           "Load a clear one with right type and press OK.", 
 
370
                           "Load a clear one with right type and press OK.") % inf.name % bf::stop, 
351
371
                           Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK_CANCEL, "", true);
352
372
            break;
353
373
        default:
354
374
            ASSERT( (inf.typ == dvdR) || (inf.typ == dvdRW) );
355
375
            if( inf.typ == dvdR && !inf.isBlank )
356
376
                try_again = Gtk::RESPONSE_OK == 
357
 
                    MessageBox("Disc with type \"" + inf.name + "\" in the drive is not clear. Only clear recordable "
358
 
                               "discs can be used for burning DVD-Video. Load a clear one and press OK.", 
 
377
                    MessageBox(BF_("Disc with type \"%1%\" in the drive is not clear. Only clear recordable "
 
378
                               "discs can be used for burning DVD-Video. Load a clear one and press OK.") % inf.name % bf::stop, 
359
379
                               Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK_CANCEL, "", true);
360
380
            else
361
381
            {
362
382
                if( inf.typ == dvdRW && !inf.isBlank )
363
383
                {
364
 
                    std::string title = "Disc with type \"" + inf.name + "\" in the drive is not clear." 
365
 
                                        " We need to remove its contents before writing new one. Continue?";
 
384
                    std::string title = BF_("Disc with type \"%1%\" in the drive is not clear." 
 
385
                                        " We need to remove its contents before writing new one. Continue?") % inf.name % bf::stop;
366
386
                    Gtk::MessageDialog dlg(MakeMessageBoxTitle(title), true, Gtk::MESSAGE_INFO, Gtk::BUTTONS_NONE);
367
387
 
368
 
                    dlg.add_button("_Cancel",    Gtk::RESPONSE_CANCEL);
369
 
                    dlg.add_button("_Try again", Gtk::RESPONSE_REJECT);
 
388
                    dlg.add_button(_("_Cancel"),    Gtk::RESPONSE_CANCEL);
 
389
                    dlg.add_button(_("_Try again"), Gtk::RESPONSE_REJECT);
370
390
                    dlg.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
371
391
                    dlg.set_default_response(Gtk::RESPONSE_OK);
372
392