1 /* 2 * Copyright 2013, Jérôme DUVAL. 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 6 7 #include "EULAWindow.h" 8 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> 18 19 #include "tracker_private.h" 20 21 static const uint32 kMsgAgree = 'agre'; 22 static const uint32 kMsgNext = 'next'; 23 24 #undef B_TRANSLATION_CONTEXT 25 #define B_TRANSLATION_CONTEXT "InstallerApp" 26 27 28 EULAWindow::EULAWindow() 29 : 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) 33 { 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 1\n"); 73 infoText << B_TRANSLATE( 74 "Configure your /boot/grub/menu.lst by launching your favorite " 75 "editor from a Terminal like this:\n\n"); 76 infoText << B_TRANSLATE( 77 "\tsudo <your favorite text editor> /boot/grub/menu.lst\n\n"); 78 infoText << B_TRANSLATE( 79 "You'll note that GRUB uses a different naming strategy for hard " 80 "drives than Linux.\n\n"); 81 infoText << B_TRANSLATE( 82 "With GRUB it's: (hdN,n)\n\n"); 83 infoText << B_TRANSLATE( 84 "All hard disks start with \"hd\".\n"); 85 infoText << B_TRANSLATE( 86 "\"N\" is the hard disk number, starting with \"0\".\n"); 87 infoText << B_TRANSLATE( 88 "\"n\" is the partition number, also starting with \"0\".\n"); 89 infoText << B_TRANSLATE( 90 "The first logical partition always has the number \"4\", regardless " 91 "of the number of primary partitions.\n\n"); 92 infoText << B_TRANSLATE( 93 "So behind the other menu entries towards the bottom of the file, add " 94 "something similar to these lines:\n\n"); 95 infoText << B_TRANSLATE( 96 "\t# Haiku on /dev/sda7\n"); 97 infoText << B_TRANSLATE( 98 "\ttitle\t\t\t\tHaiku\n"); 99 infoText << B_TRANSLATE( 100 "\trootnoverify\t\t(hd0,6)\n"); 101 infoText << B_TRANSLATE( 102 "\tchainloader\t\t+1\n\n"); 103 infoText << B_TRANSLATE( 104 "You can see the correct partition in GParted for example.\n\n\n"); 105 infoText << B_TRANSLATE( 106 "2.3) GRUB 2\n"); 107 infoText << B_TRANSLATE( 108 "Newer versions of GRUB use an extra configuration file to add " 109 "custom entries to the boot menu. To add them to the top, you have " 110 "to create/edit a file by launching your favorite editor from a " 111 "Terminal like this:\n\n"); 112 infoText << B_TRANSLATE( 113 "\tsudo <your favorite text editor> /etc/grub.d/40_custom\n\n"); 114 infoText << B_TRANSLATE( 115 "NOTE: While the naming strategy for hard disks is still as described " 116 "under 2.1) the naming scheme for partitions has changed.\n\n"); 117 infoText << B_TRANSLATE( 118 "GRUB's naming scheme is still: (hdN,n)\n\n"); 119 infoText << B_TRANSLATE( 120 "All hard disks start with \"hd\".\n"); 121 infoText << B_TRANSLATE( 122 "\"N\" is the hard disk number, starting with \"0\".\n"); 123 infoText << B_TRANSLATE( 124 "\"n\" is the partition number, which for GRUB 2 starts with \"1\"\n"); 125 infoText << B_TRANSLATE( 126 "With GRUB 2 the first logical partition always has the number \"5\", " 127 "regardless of the number of primary partitions.\n\n"); 128 infoText << B_TRANSLATE( 129 "So below the heading that must not be edited, add something similar " 130 "to these lines:\n\n"); 131 infoText << B_TRANSLATE( 132 "\t# Haiku on /dev/sda7\n"); 133 infoText << B_TRANSLATE( 134 "\tmenuentry \"Haiku Alpha\" {\n"); 135 infoText << B_TRANSLATE( 136 "\t\tset root=(hd0,7)\n"); 137 infoText << B_TRANSLATE( 138 "\t\tchainloader +1\n"); 139 infoText << B_TRANSLATE( 140 "\t}\n\n"); 141 infoText << B_TRANSLATE( 142 "Additionally you have to edit another file to actually display the " 143 "boot menu:\n\n"); 144 infoText << B_TRANSLATE( 145 "\tsudo <your favorite text editor> /etc/default/grub\n\n"); 146 infoText << B_TRANSLATE( 147 "Here you have to comment out the line \"GRUB_HIDDEN_TIMEOUT=0\" by " 148 "putting a \"#\" in front of it in order to actually display the " 149 "boot menu.\n\n"); 150 infoText << B_TRANSLATE( 151 "Finally, you have to update the boot menu by entering:\n\n"); 152 infoText << B_TRANSLATE( 153 "\tsudo update-grub\n\n\n"); 154 infoText << B_TRANSLATE( 155 "3) When you successfully boot into Haiku for the first time, make " 156 "sure to read our \"Welcome\" and \"Userguide\" documentation. There " 157 "are links on the Desktop and in WebPositive's bookmarks.\n\n"); 158 infoText << B_TRANSLATE( 159 "Have fun and thanks a lot for trying out Haiku! We hope you like it!"); 160 161 BTextView* textView = new BTextView("eula", be_plain_font, NULL, B_WILL_DRAW); 162 textView->SetInsets(10, 10, 10, 10); 163 textView->MakeEditable(false); 164 textView->MakeSelectable(false); 165 textView->SetText(infoText); 166 167 BScrollView* scrollView = new BScrollView("eulaScroll", 168 textView, B_WILL_DRAW, false, true); 169 170 BButton* cancelButton = new BButton(B_TRANSLATE("Quit"), 171 new BMessage(B_QUIT_REQUESTED)); 172 cancelButton->SetTarget(be_app); 173 174 BButton* continueButton = new BButton(B_TRANSLATE("Continue"), 175 new BMessage(kMsgAgree)); 176 continueButton->SetTarget(be_app); 177 continueButton->MakeDefault(true); 178 179 if (!be_roster->IsRunning(kTrackerSignature)) 180 SetWorkspaces(B_ALL_WORKSPACES); 181 182 BLayoutBuilder::Group<>(this, B_VERTICAL, 10) 183 .SetInsets(10) 184 .Add(scrollView) 185 .AddGroup(B_HORIZONTAL, 10) 186 .AddGlue() 187 .Add(cancelButton) 188 .Add(continueButton); 189 190 CenterOnScreen(); 191 Show(); 192 } 193 194 195 bool 196 EULAWindow::QuitRequested() 197 { 198 be_app->PostMessage(kMsgNext); 199 return true; 200 } 201