Ticket #4123: drivesetupdisablebutton-v2.patch

File drivesetupdisablebutton-v2.patch, 2.9 KB (added by idefix, 10 years ago)

Updated patch to prevent DriveSetup initialise volumes without a name by disabling the Initialize button (updated to account for the recent changes in DriveSetup)

  • src/add-ons/disk_systems/bfs/InitializeParameterEditor.cpp

     
    2424
    2525
    2626static uint32 MSG_BLOCK_SIZE = 'blsz';
     27static uint32 MSG_NAME_CHANGED = 'nmch';
    2728
    2829
    2930InitializeBFSEditor::InitializeBFSEditor()
     
    9596InitializeBFSEditor::_CreateViewControls()
    9697{
    9798    fNameTC = new BTextControl("Name:", "Haiku", NULL);
     99    fNameTC->SetModificationMessage(new BMessage(MSG_NAME_CHANGED));
    98100    // TODO find out what is the max length for this specific FS partition name
    99101    fNameTC->TextView()->SetMaxBytes(31);
    100102
  • src/apps/drivesetup/InitParamsPanel.cpp

     
    2020#include <Message.h>
    2121#include <MessageFilter.h>
    2222#include <String.h>
     23#include <TextControl.h>
    2324
    2425
    2526#define TR_CONTEXT "InitParamsPanel"
     
    7071enum {
    7172    MSG_OK                      = 'okok',
    7273    MSG_CANCEL                  = 'cncl',
    73     MSG_BLOCK_SIZE              = 'blsz'
     74    MSG_NAME_CHANGED            = 'nmch'
    7475};
    7576
    7677
     
    8788{
    8889    AddCommonFilter(fEscapeFilter);
    8990
    90     BButton* okButton = new BButton(TR("Initialize"), new BMessage(MSG_OK));
     91    fOkButton = new BButton(TR("Initialize"), new BMessage(MSG_OK));
    9192
    9293    partition->GetInitializationParameterEditor(diskSystem.String(),
    9394        &fEditor);
     
    99100        .AddGroup(B_HORIZONTAL, spacing)
    100101            .AddGlue()
    101102            .Add(new BButton(TR("Cancel"), new BMessage(MSG_CANCEL)))
    102             .Add(okButton)
     103            .Add(fOkButton)
    103104        .End()
    104105        .SetInsets(spacing, spacing, spacing, spacing)
    105106    );
    106107
    107     SetDefaultButton(okButton);
     108    SetDefaultButton(fOkButton);
    108109
    109110    // If the partition had a previous name, set to that name.
    110111    BString name = partition->ContentName();
     
    145146            release_sem(fExitSemaphore);
    146147            break;
    147148
     149        case MSG_NAME_CHANGED:
     150            // message comes from fEditor's BTextControl
     151            BTextControl* control;
     152            if (message->FindPointer("source", (void**)&control) != B_OK)
     153                break;
     154            if (control->TextView()->TextLength() == 0
     155                && fOkButton->IsEnabled())
     156                fOkButton->SetEnabled(false);
     157            else if (control->TextView()->TextLength() > 0
     158                && !fOkButton->IsEnabled())
     159                fOkButton->SetEnabled(true);
     160            break;
     161
    148162        default:
    149163            BWindow::MessageReceived(message);
    150164    }
  • src/apps/drivesetup/InitParamsPanel.h

     
    3636            EscapeFilter*       fEscapeFilter;
    3737            sem_id              fExitSemaphore;
    3838            BWindow*            fWindow;
     39            BButton*            fOkButton;
    3940            int32               fReturnValue;
    4041
    4142            BPartitionParameterEditor*  fEditor;