xref: /haiku/src/add-ons/disk_systems/intel/PrimaryParameterEditor.cpp (revision 7d6915b4d08ffe728cd38af02843d5e98ddfe0db)
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")) {
48 		fActiveCheckBox->SetEnabled(strcmp(variant.ToString(),
49 			kPartitionTypeIntelExtended) != 0);
50 	}
51 	return B_OK;
52 }
53 
54 
55 status_t
56 PrimaryPartitionEditor::GetParameters(BString& parameters)
57 {
58 	if (fActiveCheckBox->IsEnabled()) {
59 		if (fActiveCheckBox->Value() == B_CONTROL_ON)
60 			parameters.SetTo("active true ;");
61 		else
62 			parameters.SetTo("active false ;");
63 	} else
64 		parameters.SetTo("");
65 
66 	return B_OK;
67 }
68