1 /* 2 * Copyright 2013, Axel Dörfler, axeld@pinc-software.de. 3 * Copyright 2009, Bryce Groff, brycegroff@gmail.com. 4 * Distributed under the terms of the MIT License. 5 */ 6 7 8 #include "PrimaryParameterEditor.h" 9 10 #include <Catalog.h> 11 #include <DiskDeviceTypes.h> 12 #include <GroupView.h> 13 #include <PartitionParameterEditor.h> 14 #include <Variant.h> 15 #include <View.h> 16 17 18 #undef B_TRANSLATION_CONTEXT 19 #define B_TRANSLATION_CONTEXT "PrimaryPartitionEditor" 20 21 22 PrimaryPartitionEditor::PrimaryPartitionEditor() 23 { 24 fActiveCheckBox = new BCheckBox("active", B_TRANSLATE("Active partition"), 25 NULL); 26 fView = new BGroupView(B_VERTICAL); 27 fView->AddChild(fActiveCheckBox); 28 } 29 30 31 PrimaryPartitionEditor::~PrimaryPartitionEditor() 32 { 33 } 34 35 36 BView* 37 PrimaryPartitionEditor::View() 38 { 39 return fView; 40 } 41 42 43 status_t 44 PrimaryPartitionEditor::ParameterChanged(const char* name, 45 const BVariant& variant) 46 { 47 if (strcmp(name, "type") == 0) { 48 fActiveCheckBox->SetEnabled(strcmp(variant.ToString(), 49 kPartitionTypeIntelExtended) != 0); 50 fActiveCheckBox->SetValue(false); 51 } 52 53 if (strcmp(name, "active") == 0) 54 fActiveCheckBox->SetValue(variant.ToBool()); 55 56 return B_OK; 57 } 58 59 60 status_t 61 PrimaryPartitionEditor::GetParameters(BString& parameters) 62 { 63 if (fActiveCheckBox->IsEnabled()) { 64 if (fActiveCheckBox->Value() == B_CONTROL_ON) 65 parameters.SetTo("active true ;"); 66 else 67 parameters.SetTo("active false ;"); 68 } else 69 parameters.SetTo(""); 70 71 return B_OK; 72 } 73