Ticket #4425: InstallerExhance.diff

File InstallerExhance.diff, 7.0 KB (added by BeSman, 14 years ago)

This patch add Installer features asked by stippi

  • InstallerWindow.cpp

     
    4848#define TR_CONTEXT "InstallerWindow"
    4949
    5050#define DRIVESETUP_SIG "application/x-vnd.Haiku-DriveSetup"
     51#define BOOTMAN_SIG "application/x-vnd.Haiku-Bootman"
    5152
    5253const uint32 BEGIN_MESSAGE = 'iBGN';
    5354const uint32 SHOW_BOTTOM_MESSAGE = 'iSBT';
     
    213214        TR("Write boot sector"), new BMessage(MSG_WRITE_BOOT_SECTOR));
    214215    fMakeBootableButton->SetEnabled(false);
    215216
     217    fBootmanButton = new BButton("bootman_button",
     218        TR("Setup Boot Menu"), new BMessage(MSG_WRITE_BOOTMAN));
     219    fBootmanButton->SetEnabled(false);
     220
    216221    SetLayout(new BGroupLayout(B_HORIZONTAL));
    217222    AddChild(BGroupLayoutBuilder(B_VERTICAL)
    218223        .Add(BGroupLayoutBuilder(B_HORIZONTAL)
     
    238243            .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
    239244                .Add(fSetupButton)
    240245                .Add(fMakeBootableButton)
     246                .Add(fBootmanButton)
    241247                .AddGlue()
    242248                .Add(fBeginButton)
    243249            )
     
    268274        "the installation, but you can manually make a\n"
    269275        "partition bootable in case you do not need to\n"
    270276        "perform an installation."));
    271 
     277    fBootmanButton->SetToolTip(
     278        TR("Install/Uninstall our Boot Menu, which allow you to choose\n"
     279        "operating system to boot when computer starts up\n"
     280        "If you have another Boot manager such as LILO or GRUB\n"
     281        "You do not need to perform this one\n"));
    272282    // finish creating window
    273283    if (!be_roster->IsRunning(kDeskbarSignature))
    274284        SetFlags(Flags() | B_NOT_MINIMIZABLE);
     
    276286    CenterOnScreen();
    277287    Show();
    278288
    279     fDriveSetupLaunched = be_roster->IsRunning(DRIVESETUP_SIG);
    280289 
    281290    if (Lock()) {
    282         fSetupButton->SetEnabled(!fDriveSetupLaunched);
     291        fSetupButton->SetEnabled(!fDriveSetupLaunched || !fDriveSetupLaunched);
    283292        Unlock();
    284293    }
    285294
     
    466475        case B_SOME_APP_LAUNCHED:
    467476        case B_SOME_APP_QUIT:
    468477        {
    469             const char *signature;
    470             if (msg->FindString("be:signature", &signature) == B_OK
    471                 && strcasecmp(signature, DRIVESETUP_SIG) == 0) {
    472                 fDriveSetupLaunched = msg->what == B_SOME_APP_LAUNCHED;
    473                 fBeginButton->SetEnabled(!fDriveSetupLaunched);
    474                 _DisableInterface(fDriveSetupLaunched);
    475                 if (fDriveSetupLaunched)
    476                     _SetStatusMessage(TR("Running DriveSetup" B_UTF8_ELLIPSIS
     478
     479            if (fDriveSetupLaunched) {
     480            fDriveSetupLaunched = msg->what == B_SOME_APP_LAUNCHED;
     481            fBeginButton->SetEnabled(!fDriveSetupLaunched);
     482            _DisableInterface(fDriveSetupLaunched);
     483            _SetStatusMessage(TR("Running DriveSetup" B_UTF8_ELLIPSIS
    477484                        "\n\nClose DriveSetup to continue with the "
    478485                        "installation."));
    479                 else
     486                } else
    480487                    _ScanPartitions();
     488
     489            if (fBootmanLaunched) {
     490            fBootmanLaunched = msg->what == B_SOME_APP_LAUNCHED;
     491            fBeginButton->SetEnabled(!fBootmanLaunched);
     492            _DisableInterface(fBootmanLaunched);
     493            _SetStatusMessage(TR("Running Boot Manager" B_UTF8_ELLIPSIS
     494                        "\n\nClose Boot Manager to continue with the "
     495                        "installation."));
     496                }
    481497            }
    482498            break;
    483         }
     499           
    484500        case MSG_WRITE_BOOT_SECTOR:
    485501            fWorkerThread->WriteBootSector(fDestMenu);
    486502            break;
    487503
     504        case MSG_WRITE_BOOTMAN:
     505        {
     506            _LaunchBootman();
     507        }
     508            break;
    488509        default:
    489510            BWindow::MessageReceived(msg);
    490511            break;
     
    502523        return false;
    503524    }
    504525
     526    if (fBootmanLaunched) {
     527        (new BAlert("bootman",
     528            TR("Please close the Boot Manager window before closing the "
     529            "Installer window."), TR("OK")))->Go();
     530        return false;
     531    }
     532   
    505533    if (fInstallStatus != kFinished && (Flags() & B_NOT_MINIMIZABLE) != 0) {
    506534        // This means Deskbar is not running, i.e. Installer is the only
    507535        // thing on the screen and we will reboot the machine once it quits.
     
    536564void
    537565InstallerWindow::_LaunchDriveSetup()
    538566{
    539     if (be_roster->Launch(DRIVESETUP_SIG) != B_OK) {
     567    if (be_roster->Launch(DRIVESETUP_SIG) == B_OK) {
     568
     569        fDriveSetupLaunched = be_roster->IsRunning(DRIVESETUP_SIG);
     570
     571    } else {
     572
    540573        // Try really hard to launch it. It's very likely that this fails,
    541574        // when we run from the CD and there is only an incomplete mime
    542575        // database for example...
     
    552585                "application to configure disk partitions, could not be "
    553586                "launched."), TR("OK"));
    554587            alert->Go();
     588            }
     589        fDriveSetupLaunched = be_roster->IsRunning(&ref);
     590    }
     591}
     592
     593void
     594InstallerWindow::_LaunchBootman()
     595{
     596    if (be_roster->Launch(BOOTMAN_SIG) == B_OK) {
     597
     598        fBootmanLaunched = be_roster->IsRunning(BOOTMAN_SIG);
     599
     600        } else {
     601        // Try really hard to launch it. It's very likely that this fails,
     602        // when we run from the CD and there is only an incomplete mime
     603        // database for example...
     604        BPath path;
     605        if (find_directory(B_BEOS_SYSTEM_DIRECTORY, &path) != B_OK
     606            || path.Append("bin/bootman") != B_OK) {
     607            path.SetTo("/boot/system/bin/bootman");
    555608        }
     609        BEntry entry(path.Path());
     610        entry_ref ref;
     611        if (entry.GetRef(&ref) != B_OK || be_roster->Launch(&ref) != B_OK) {
     612            BAlert* alert = new BAlert("error", TR("Boot Manager, the "
     613                "application to Setup Boot Menu, could not be "
     614                "launched."), TR("OK"));
     615            alert->Go();
     616            }
     617        fBootmanLaunched = be_roster->IsRunning(&ref);
    556618    }
    557619}
    558620
    559 
    560621void
    561622InstallerWindow::_DisableInterface(bool disable)
    562623{
    563624    fSetupButton->SetEnabled(!disable);
    564625    fMakeBootableButton->SetEnabled(!disable);
     626    fBootmanButton->SetEnabled(!disable);
    565627    fSrcMenuField->SetEnabled(!disable);
    566628    fDestMenuField->SetEnabled(!disable);
    567629}
     
    651713    fBeginButton->SetLabel(TR("Begin"));
    652714    fBeginButton->SetEnabled(srcItem && dstItem);
    653715
    654     // adjust "Write Boot Sector" button
     716    // adjust "Write Boot Sector and Setup Boot Menu" button
    655717    if (dstItem) {
    656718        char buffer[256];
    657719        snprintf(buffer, sizeof(buffer), TR("Write boot sector to '%s'"),
     
    661723        label = TR("Write boot sector");
    662724    fMakeBootableButton->SetEnabled(dstItem);
    663725    fMakeBootableButton->SetLabel(label.String());
    664 
     726    fBootmanButton->SetEnabled(dstItem);
     727   
    665728    if (!fEncouragedToSetupPartitions && !foundOneSuitableTarget) {
    666729        // Focus the users attention on the DriveSetup button
    667730        fEncouragedToSetupPartitions = true;
  • InstallerWindow.h

     
    3535const uint32 MSG_INSTALL_FINISHED = 'iIFN';
    3636const uint32 MSG_RESET = 'iRSI';
    3737const uint32 MSG_WRITE_BOOT_SECTOR = 'iWBS';
     38const uint32 MSG_WRITE_BOOTMAN = 'iWBM';
    3839
    3940const char PACKAGES_DIRECTORY[] = "_packages_";
    4041const char VAR_DIRECTORY[] = "var";
     
    5354private:
    5455            void                _ShowOptionalPackages();
    5556            void                _LaunchDriveSetup();
     57            void                _LaunchBootman();
    5658            void                _DisableInterface(bool disable);
    5759            void                _ScanPartitions();
    5860            void                _UpdateControls();
     
    8688            BButton*            fBeginButton;
    8789            BButton*            fSetupButton;
    8890            BButton*            fMakeBootableButton;
    89 
     91            BButton*            fBootmanButton;
    9092            bool                fEncouragedToSetupPartitions;
    9193
    9294            bool                fDriveSetupLaunched;
     95            bool                fBootmanLaunched;
     96           
    9397            InstallStatus       fInstallStatus;
    9498
    9599            WorkerThread*       fWorkerThread;