btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / installer / EULAWindow.cpp
blobca7abd19eae0c2e76eb7da46cb7b32a60ed10172
1 /*
2 * Copyright 2013, Jérôme DUVAL.
3 * All rights reserved. Distributed under the terms of the MIT license.
4 */
7 #include "EULAWindow.h"
9 #include <Application.h>
10 #include <Box.h>
11 #include <Button.h>
12 #include <Catalog.h>
13 #include <LayoutBuilder.h>
14 #include <LayoutUtils.h>
15 #include <Roster.h>
16 #include <ScrollView.h>
17 #include <SpaceLayoutItem.h>
19 #include "tracker_private.h"
21 static const uint32 kMsgAgree = 'agre';
22 static const uint32 kMsgNext = 'next';
24 #undef B_TRANSLATION_CONTEXT
25 #define B_TRANSLATION_CONTEXT "InstallerApp"
28 EULAWindow::EULAWindow()
30 BWindow(BRect(0, 0, 600, 450), B_TRANSLATE("README"),
31 B_MODAL_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE
32 | B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS)
34 BString infoText;
35 infoText << B_TRANSLATE(
36 "Welcome to the Haiku Installer!\n\n");
37 infoText << B_TRANSLATE(
38 "IMPORTANT INFORMATION BEFORE INSTALLING HAIKU\n\n");
39 infoText << B_TRANSLATE(
40 "This is alpha-quality software! It means there is a high risk of "
41 "losing important data. Make frequent backups! You have been "
42 "warned.\n\n\n");
43 infoText << B_TRANSLATE(
44 "1) If you are installing Haiku onto real hardware (not inside an "
45 "emulator) it is recommended that you have already prepared a hard "
46 "disk partition. The Installer and the DriveSetup tool offer to "
47 "initialize existing partitions with the Haiku native file system, "
48 "but the options to change the actual partition layout may not have "
49 "been tested on a sufficiently great variety of computer "
50 "configurations so we do not recommend using it.\n");
51 infoText << B_TRANSLATE(
52 "If you have not created a partition yet, simply reboot, create the "
53 "partition using whatever tool you feel most comfortable with, and "
54 "reboot into Haiku to continue with the installation. You could for "
55 "example use the GParted Live-CD, it can also resize existing "
56 "partitions to make room.\n\n\n");
57 infoText << B_TRANSLATE(
58 "2) The Installer will make the Haiku partition itself bootable, "
59 "but takes no steps to integrate Haiku into an existing boot menu. "
60 "If you have GRUB already installed, you can add Haiku to its boot "
61 "menu. Depending on what version of GRUB you use, this is done "
62 "differently.\n\n\n");
63 infoText << B_TRANSLATE(
64 "2.1) GRUB (since os-prober v1.44)\n");
65 infoText << B_TRANSLATE(
66 "Starting with os-prober v1.44 (e.g. in Ubuntu 11.04 or later), Haiku "
67 "should be recognized out of the box. To add Haiku to the GRUB menu, "
68 "open a Terminal and enter:\n\n");
69 infoText << B_TRANSLATE(
70 "\tsudo update-grub\n\n\n");
71 infoText << B_TRANSLATE(
72 "2.2) GRUB 2\n");
73 infoText << B_TRANSLATE(
74 "If the os-prober approach doesn't work for you, GRUB 2 uses an extra "
75 "configuration file to add custom entries to the boot menu. To add "
76 "them to the top, you have to create/edit a file by launching your "
77 "favorite editor from a Terminal like this:\n\n");
78 infoText << B_TRANSLATE(
79 "\tsudo <your favorite text editor> /etc/grub.d/40_custom\n\n");
80 infoText << B_TRANSLATE(
81 "GRUB's naming scheme for partitions is: (hdN,n)\n\n");
82 infoText << B_TRANSLATE(
83 "All hard disks start with \"hd\".\n");
84 infoText << B_TRANSLATE(
85 "\"N\" is the hard disk number, starting with \"0\".\n");
86 infoText << B_TRANSLATE(
87 "\"n\" is the partition number, which for GRUB 2 starts with \"1\"\n");
88 infoText << B_TRANSLATE(
89 "With GRUB 2 the first logical partition always has the number \"5\", "
90 "regardless of the number of primary partitions.\n\n");
91 infoText << B_TRANSLATE(
92 "So below the heading that must not be edited, add something similar "
93 "to these lines:\n\n");
94 infoText << B_TRANSLATE(
95 "\t# Haiku on /dev/sda7\n");
96 infoText << B_TRANSLATE(
97 "\tmenuentry \"Haiku Alpha\" {\n");
98 infoText << B_TRANSLATE(
99 "\t\tset root=(hd0,7)\n");
100 infoText << B_TRANSLATE(
101 "\t\tchainloader +1\n");
102 infoText << B_TRANSLATE(
103 "\t}\n\n");
104 infoText << B_TRANSLATE(
105 "Additionally you have to edit another file to actually display the "
106 "boot menu:\n\n");
107 infoText << B_TRANSLATE(
108 "\tsudo <your favorite text editor> /etc/default/grub\n\n");
109 infoText << B_TRANSLATE(
110 "Here you have to comment out the line \"GRUB_HIDDEN_TIMEOUT=0\" by "
111 "putting a \"#\" in front of it in order to actually display the "
112 "boot menu.\n\n");
113 infoText << B_TRANSLATE(
114 "Finally, you have to update the boot menu by entering:\n\n");
115 infoText << B_TRANSLATE(
116 "\tsudo update-grub\n\n\n");
117 infoText << B_TRANSLATE(
118 "3) When you successfully boot into Haiku for the first time, make "
119 "sure to read our \"Welcome\" and \"Userguide\" documentation. There "
120 "are links on the Desktop and in WebPositive's bookmarks.\n\n");
121 infoText << B_TRANSLATE(
122 "Have fun and thanks a lot for trying out Haiku! We hope you like it!");
124 BTextView* textView = new BTextView("eula", be_plain_font, NULL, B_WILL_DRAW);
125 textView->SetInsets(10, 10, 10, 10);
126 textView->MakeEditable(false);
127 textView->MakeSelectable(false);
128 textView->SetText(infoText);
130 BScrollView* scrollView = new BScrollView("eulaScroll",
131 textView, B_WILL_DRAW, false, true);
133 BButton* cancelButton = new BButton(B_TRANSLATE("Quit"),
134 new BMessage(B_QUIT_REQUESTED));
135 cancelButton->SetTarget(be_app);
137 BButton* continueButton = new BButton(B_TRANSLATE("Continue"),
138 new BMessage(kMsgAgree));
139 continueButton->SetTarget(be_app);
140 continueButton->MakeDefault(true);
142 if (!be_roster->IsRunning(kTrackerSignature))
143 SetWorkspaces(B_ALL_WORKSPACES);
145 BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING)
146 .SetInsets(B_USE_WINDOW_SPACING)
147 .Add(scrollView)
148 .AddGroup(B_HORIZONTAL, B_USE_ITEM_SPACING)
149 .AddGlue()
150 .Add(cancelButton)
151 .Add(continueButton);
153 CenterOnScreen();
154 Show();
158 bool
159 EULAWindow::QuitRequested()
161 be_app->PostMessage(kMsgNext);
162 return true;