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

« back to all changes in this revision

Viewing changes to src/mgui/author/output.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:
32
32
#include <mgui/sdk/packing.h>
33
33
#include <mgui/sdk/widget.h>
34
34
#include <mgui/timer.h>
 
35
#include <mgui/gettext.h>
35
36
 
36
37
#include <mbase/resources.h>
37
38
#include <mlib/filesystem.h>
49
50
namespace Project 
50
51
{
51
52
 
52
 
const std::string DVDOperation = "DVD-Video Building";
 
53
const std::string DVDOperation = N_("DVD-Video Building");
53
54
 
54
55
Gtk::Button& FillBuildButton(Gtk::Button& btn, bool not_started, 
55
56
                             const std::string& op_name)
59
60
 
60
61
    const char* pix_fname = "button/still.ico";
61
62
    const char* tooltip   = not_started ? "Build DVD-Video of the project." : 0 ;
62
 
    std::string cancel_name = "_Cancel " + op_name;
63
 
    std::string label     = not_started ? std::string("_Build DVD-Video") : cancel_name.c_str() ;
 
63
    std::string cancel_name = BF_("_Cancel %1%") % op_name % bf::stop;
 
64
    std::string label     = not_started ? std::string(_("_Build DVD-Video")) : cancel_name.c_str() ;
64
65
 
65
66
    ASSERT( btn.has_screen() ); // ради image-spacing
66
67
    int image_spacing = 0;
160
161
        {
161
162
            Gtk::VBox& box = PackStart(vbox, NewManaged<Gtk::VBox>());
162
163
 
163
 
            Gtk::Label& lbl = PackStart(box, MakeAuthorLabel("Select Output _Folder:", true));
 
164
            Gtk::Label& lbl = PackStart(box, MakeAuthorLabel(_("Select Output _Folder:"), true));
164
165
            lbl.set_mnemonic_widget(ch_btn);
165
166
            // по умолчанию будет директория проекта
166
167
            if( !prj_fname.empty() )
174
175
            Gtk::Alignment& out_alg = PackStart(vbox, MakeNullAlg());
175
176
            Gtk::Alignment& alg = MakeNullAlg();
176
177
            alg.set_padding(0, 0, 5, 5);
177
 
            out_alg.add(PackWidgetInFrame(alg, Gtk::SHADOW_ETCHED_IN, " Choose Author Mode: "));
 
178
            out_alg.add(PackWidgetInFrame(alg, Gtk::SHADOW_ETCHED_IN, _(" Choose Author Mode: ")));
178
179
 
179
180
            Gtk::VBox& mode_box = Add(alg, NewManaged<Gtk::VBox>(false, 2));
180
181
 
181
182
            Gtk::RadioButtonGroup grp;
182
183
            // цель по умолчанию
183
 
            AddAuthoringMode(mode_box, grp, "_Write DVD Folder", Author::modFOLDER, true);
184
 
            AddAuthoringMode(mode_box, grp, "Write Disk _Image", Author::modDISK_IMAGE);
 
184
            AddAuthoringMode(mode_box, grp, _("_Write DVD Folder"), Author::modFOLDER, true);
 
185
            AddAuthoringMode(mode_box, grp, _("Write Disk _Image"), Author::modDISK_IMAGE);
185
186
 
186
187
            RefPtr<Gtk::SizeGroup> labels_sg = Gtk::SizeGroup::create(Gtk::SIZE_GROUP_HORIZONTAL);
187
188
            RefPtr<Gtk::SizeGroup> wdg_sg    = Gtk::SizeGroup::create(Gtk::SIZE_GROUP_HORIZONTAL);
190
191
                Gtk::Alignment& alg = PackStart(mode_box, MakeSubOptionsAlg());
191
192
 
192
193
                Gtk::HBox& box = Add(alg, NewManaged<Gtk::HBox>(false));
193
 
                labels_sg->add_widget(PackStart(box, MakeAuthorLabel("Disc Label: ", false)));
 
194
                labels_sg->add_widget(PackStart(box, MakeAuthorLabel(_("Disc Label: "), false)));
194
195
                Gtk::Entry& ent = PackStart(box, bd.Label());
195
196
                wdg_sg->add_widget(ent);
196
197
            }
197
198
 
198
 
            Gtk::RadioButton& burn_rb = AddAuthoringMode(mode_box, grp, "Burn to _DVD", Author::modBURN);
 
199
            Gtk::RadioButton& burn_rb = AddAuthoringMode(mode_box, grp, _("Burn to _DVD"), Author::modBURN);
199
200
            {
200
201
                Gtk::Alignment& alg = PackStart(mode_box, MakeSubOptionsAlg());
201
202
                Gtk::Table& tbl = Add(alg, NewManaged<Gtk::Table>(2, 2, false));
203
204
                Gtk::ComboBoxText& dvd_btn = bd.DVDDevices();
204
205
                Gtk::ComboBox& speed_btn   = bd.SpeedBtn();
205
206
    
206
 
                Gtk::Label& drv_lbl = MakeAuthorLabel("DVD Drive: ", false);
 
207
                Gtk::Label& drv_lbl = MakeAuthorLabel(_("DVD Drive: "), false);
207
208
                labels_sg->add_widget(drv_lbl);
208
209
                tbl.attach(drv_lbl, 0, 1, 0, 1, Gtk::SHRINK);
209
210
                wdg_sg->add_widget(dvd_btn);
210
211
                tbl.attach(dvd_btn, 1, 2, 0, 1, Gtk::SHRINK);
211
212
 
212
 
                Gtk::Label& speed_lbl = MakeAuthorLabel("Writing Speed: ", false);
 
213
                Gtk::Label& speed_lbl = MakeAuthorLabel(_("Writing Speed: "), false);
213
214
                labels_sg->add_widget(speed_lbl);
214
215
                tbl.attach(speed_lbl, 0, 1, 1, 2, Gtk::SHRINK);
215
216
                wdg_sg->add_widget(speed_btn);
220
221
            }
221
222
 
222
223
            PackHSeparator(mode_box);
223
 
            AddAuthoringMode(mode_box, grp, "_Rendering only (for experts)", Author::modRENDERING);
 
224
            AddAuthoringMode(mode_box, grp, _("_Rendering only"), Author::modRENDERING);
224
225
        }
225
226
 
226
227
        // *
228
229
            Gtk::VBox& box = PackStart(vbox, NewManaged<Gtk::VBox>());
229
230
            PackProgressBar(box, es);
230
231
 
231
 
            Gtk::Expander& expdr = PackStart(box, NewManaged<Gtk::Expander>("Show/_Hide Details", true));
 
232
            Gtk::Expander& expdr = PackStart(box, NewManaged<Gtk::Expander>(_("Show/_Hide Details"), true));
232
233
            Gtk::TextView& txt_view = es.detailsView;
233
234
            txt_view.set_size_request(0, 200);
234
235
            expdr.add(Author::PackDetails(txt_view));
274
275
 
275
276
void SetExecState(ExecState& es, bool is_exec)
276
277
{
277
 
    std::string op = (es.mode == modRENDERING) ? std::string("Rendering") : Project::DVDOperation;
 
278
    std::string op = (es.mode == modRENDERING) ? _("Rendering") : gettext(Project::DVDOperation.c_str());
278
279
    SetExecState(es, is_exec, op);
279
280
    if( is_exec )
280
281
        InitStageMap(es.mode);
351
352
        { SetExecState(es, false); }
352
353
};
353
354
 
354
 
const std::string BurnOperation = "DVD Burning";
 
355
const char* BurnOperation = N_("DVD Burning");
355
356
 
356
357
static void SetBurningState(ExecState& es, bool is_exec)
357
358
{
358
 
    SetExecState(es, is_exec, BurnOperation);
 
359
    SetExecState(es, is_exec, gettext(BurnOperation));
359
360
}
360
361
 
361
362
class BurningStateSetter: public CommonStateSetter
395
396
    str::stream dsc_strm;
396
397
    if( mode != modBURN )
397
398
    {
398
 
        dsc_strm << "The result is here: <span style=\"italic\">" << TargetPath(mode, dir).string() << "</span>.";
 
399
        dsc_strm << _("The result is here") << ": <span style=\"italic\">" << TargetPath(mode, dir).string() << "</span>.";
399
400
        if( mode == modRENDERING )
400
 
            dsc_strm << "\n\nYou can run authoring manually by executing command \"scons\" at " 
401
 
                        "the specified folder. Also, see README file for other options over there.";
 
401
            dsc_strm << "\n\n" << _("You can run authoring manually by executing command \"scons\" at " 
 
402
                        "the specified folder. Also, see README file for other options over there.");
402
403
    }
403
404
    return dsc_strm.str();
404
405
}
420
421
static bool CanUseForAuthoring(const std::string& dir_str)
421
422
{
422
423
    bool res = true;
423
 
    std::string abort_str(". Authoring is cancelled.");
 
424
    // Translators: impossible to go on!
 
425
    std::string abort_str(_("Authoring is cancelled."));
 
426
    abort_str = ". " + abort_str;
424
427
    if( !fs::exists(dir_str) )
425
428
    {
426
429
        try { fs::create_directories(dir_str); } 
427
430
        catch( const std::exception& )
428
431
        {
429
 
            MessageBox("Cant create directory " + dir_str + " (check permissions)" + abort_str,
430
 
                       Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK);
 
432
            MessageBox(BF_("Cant create folder %1% (check permissions)") % dir_str
 
433
                       % bf::stop + abort_str, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK);
431
434
            res = false;
432
435
        }
433
436
    }
434
437
    else if( !fs::is_directory(dir_str) )
435
438
    {
436
 
        MessageBox(dir_str + " is not a directory" + abort_str,
 
439
        MessageBox(BF_("%1% is not a folder") % dir_str % bf::stop + abort_str,
437
440
                   Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK);
438
441
        res = false;
439
442
    }
444
447
    ASSERT( fs::is_directory(dir_path) );
445
448
    if( !Project::HaveFullAccess(dir_path) )
446
449
    {
447
 
        MessageBox("Cant have full access to directory " + dir_str + " (read, write)" + abort_str,
 
450
        MessageBox(BF_("Cant have full access to folder %1% (read, write)") % dir_str % bf::stop + abort_str,
448
451
                   Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK);
449
452
        res = false;
450
453
    }
452
455
    {
453
456
        bool is_empty = false;
454
457
        if( Gtk::RESPONSE_YES == 
455
 
            MessageBox(dir_str + " is not empty. We need to remove all files in it for authoring process.\n"
456
 
                       "Continue?", Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO) )
 
458
            MessageBox(BF_("Folder %1% is not empty. We need to remove all files in it before authoring.\n"
 
459
                       "Continue?") % dir_str % bf::stop, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO) )
457
460
        {
458
461
            std::string err_str;
459
462
            is_empty = Project::ClearAllFiles(dir_path, err_str);
460
463
            if( !is_empty )
461
 
                MessageBox("Error during removing files: " + err_str + abort_str,
 
464
                MessageBox(BF_("Error during removing files: %1%") % err_str % bf::stop + abort_str,
462
465
                           Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK);
463
466
        }
464
467
        res = is_empty;
620
623
    return res;
621
624
}
622
625
 
 
626
static std::string MakeOperStatus(boost::format tmpl, ExecState& es)
 
627
{
 
628
    return (tmpl % es.operationName).str();
 
629
}
 
630
 
623
631
static void FailureMessageBox(ExecState& es, const std::string& reason)
624
632
{
625
633
    if( es.userAbort )
626
 
        FinalMessageBox(es.operationName + " cancelled.", false, Gtk::MESSAGE_INFO, "");
 
634
        FinalMessageBox(MakeOperStatus(BF_("%1% cancelled."), es), false, Gtk::MESSAGE_INFO, "");
627
635
    else
628
 
        FinalMessageBox(es.operationName + " broken.", false, Gtk::MESSAGE_ERROR,
629
 
                        "The reason is \"" + reason + "\" (see Details)");
 
636
        FinalMessageBox(MakeOperStatus(BF_("%1% broken."), es), false, Gtk::MESSAGE_ERROR,
 
637
                        BF_("The reason is \"%1%\" (see Details)") % reason % bf::stop);
630
638
}
631
639
 
632
640
static std::string OperationCompleted(ExecState& es)
633
641
{
634
 
    return es.operationName + " successfully completed.";
 
642
    // Translators: can be tranlated as "Operation "%1%" ..."
 
643
    return MakeOperStatus(BF_("%1% successfully completed."), es);
635
644
}
636
645
 
637
646
bool CheckDVDBlank();
661
670
                                   Gtk::MESSAGE_INFO, Gtk::BUTTONS_NONE);
662
671
            dlg.set_secondary_text(desc_str, true);
663
672
 
664
 
            dlg.add_button("_Play in Totem", RESPONSE_TOTEM);
665
 
            dlg.add_button("_Burn to DVD",   RESPONSE_BURN);
 
673
            dlg.add_button(_("_Play in Totem"), RESPONSE_TOTEM);
 
674
            dlg.add_button(_("_Burn to DVD"),   RESPONSE_BURN);
666
675
            std::string dvd_drive;
667
676
            if( /*(es.mode == modBURN) ||*/ !Author::IsBurnerSetup(dvd_drive) )
668
677
                dlg.set_response_sensitive(RESPONSE_BURN, false);
727
736
    {
728
737
        // COPY_N_PASTE - тупо сделал содержимое сообщений как у "TSNAMI-MPEG DVD Author"
729
738
        // А что делать - нафига свои придумывать, если смысл один и тот же
730
 
        if( Gtk::RESPONSE_YES == MessageBox("You are about to cancel " + es.operationName + 
731
 
                                            ". Are you sure?", Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO) )
 
739
        if( Gtk::RESPONSE_YES == MessageBox(BF_("You are about to cancel %1%. Are you sure?") % es.operationName 
 
740
                                                % bf::stop, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO) )
732
741
        {
733
742
            es.userAbort = true;
734
743
            if( es.pid != NO_HNDL ) // во время выполнения внешней команды