Ticket #9982: 0001-installer-eula-fix-goes-to-next-window.2.patch

File 0001-installer-eula-fix-goes-to-next-window.2.patch, 17.4 KB (added by Freeman, 11 years ago)
  • new file src/apps/installer/EULAWindow.cpp

    From 30c91ca189ef4489932bea9434c9d6239d35212a Mon Sep 17 00:00:00 2001
    From: Freeman Lou <freemanlou2430@Yahoo.com>
    Date: Tue, 17 Dec 2013 22:18:08 +0000
    Subject: [PATCH] installer eula fix goes to next window
    
    ---
     src/apps/installer/EULAWindow.cpp   | 200 ++++++++++++++++++++++++++++++++++++
     src/apps/installer/EULAWindow.h     |  21 ++++
     src/apps/installer/InstallerApp.cpp | 173 +------------------------------
     src/apps/installer/InstallerApp.h   |   4 +-
     src/apps/installer/Jamfile          |   2 +
     5 files changed, 229 insertions(+), 171 deletions(-)
     create mode 100644 src/apps/installer/EULAWindow.cpp
     create mode 100644 src/apps/installer/EULAWindow.h
    
    diff --git a/src/apps/installer/EULAWindow.cpp b/src/apps/installer/EULAWindow.cpp
    new file mode 100644
    index 0000000..e5ca7ef
    - +  
     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
     21static const uint32 kMsgAgree = 'agre';
     22static const uint32 kMsgNext = 'next';
     23
     24
     25#define B_TRANSLATION_CONTEXT "InstallerApp"
     26
     27
     28EULAWindow::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", textView, B_WILL_DRAW, false,
     168        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
     195bool
     196EULAWindow::QuitRequested()
     197{
     198    be_app->PostMessage(kMsgNext);
     199    return true;   
     200}
  • new file src/apps/installer/EULAWindow.h

    diff --git a/src/apps/installer/EULAWindow.h b/src/apps/installer/EULAWindow.h
    new file mode 100644
    index 0000000..748fe1a
    - +  
     1/*
     2 * Copyright 2013,  Jérôme DUVAL.
     3 * All rights reserved. Distributed under the terms of the MIT license.
     4 */
     5#ifndef EULA_WINDOW_H
     6#define EULA_WINDOW_H
     7
     8
     9#include <Window.h>
     10
     11
     12class EULAWindow : public BWindow {
     13public:
     14                                EULAWindow();
     15    virtual bool                QuitRequested();
     16   
     17private:
     18
     19};
     20
     21#endif // EULA_WINDOW_H
  • src/apps/installer/InstallerApp.cpp

    diff --git a/src/apps/installer/InstallerApp.cpp b/src/apps/installer/InstallerApp.cpp
    index 8f16d34..b13ed46 100644
    a b  
    77#include "InstallerApp.h"
    88
    99#include <Alert.h>
    10 #include <Button.h>
    11 #include <LayoutBuilder.h>
    12 #include <Locale.h>
    13 #include <Roster.h>
    14 #include <ScrollView.h>
    1510#include <TextView.h>
    1611
    1712#include "tracker_private.h"
    1813
    1914
    2015static const uint32 kMsgAgree = 'agre';
     16static const uint32 kMsgNext = 'next';
    2117
    2218//static const char* kEULAText =
    2319//"NOTICE: READ THIS BEFORE INSTALLING OR USING HAIKU\n\n"
    InstallerApp::MessageReceived(BMessage* message)  
    6864{
    6965    switch (message->what) {
    7066        case kMsgAgree:
     67        case kMsgNext:
    7168            fEULAWindow->Lock();
    7269            fEULAWindow->Quit();
    7370            new InstallerWindow();
    InstallerApp::AboutRequested()  
    103100void
    104101InstallerApp::ReadyToRun()
    105102{
    106     BString infoText;
    107     infoText << B_TRANSLATE(
    108         "Welcome to the Haiku Installer!\n\n");
    109     infoText << B_TRANSLATE(
    110         "IMPORTANT INFORMATION BEFORE INSTALLING HAIKU\n\n");
    111     infoText << B_TRANSLATE(
    112         "This is alpha-quality software! It means there is a high risk of "
    113         "losing important data. Make frequent backups! You have been "
    114         "warned.\n\n\n");
    115     infoText << B_TRANSLATE(
    116         "1)   If you are installing Haiku onto real hardware (not inside an "
    117         "emulator) it is recommended that you have already prepared a hard "
    118         "disk partition. The Installer and the DriveSetup tool offer to "
    119         "initialize existing partitions with the Haiku native file system, "
    120         "but the options to change the actual partition layout may not have "
    121         "been tested on a sufficiently great variety of computer "
    122         "configurations so we do not recommend using it.\n");
    123     infoText << B_TRANSLATE(
    124         "If you have not created a partition yet, simply reboot, create the "
    125         "partition using whatever tool you feel most comfortable with, and "
    126         "reboot into Haiku to continue with the installation. You could for "
    127         "example use the GParted Live-CD, it can also resize existing "
    128         "partitions to make room.\n\n\n");
    129     infoText << B_TRANSLATE(
    130         "2)   The Installer will make the Haiku partition itself bootable, "
    131         "but takes no steps to integrate Haiku into an existing boot menu. "
    132         "If you have GRUB already installed, you can add Haiku to its boot "
    133         "menu. Depending on what version of GRUB you use, this is done "
    134         "differently.\n\n\n");
    135     infoText << B_TRANSLATE(
    136         "2.1) GRUB (since os-prober v1.44)\n");
    137     infoText << B_TRANSLATE(
    138         "Starting with os-prober v1.44 (e.g. in Ubuntu 11.04 or later), Haiku "
    139         "should be recognized out of the box. To add Haiku to the GRUB menu, "
    140         "open a Terminal and enter:\n\n");
    141     infoText << B_TRANSLATE(
    142         "\tsudo update-grub\n\n\n");
    143     infoText << B_TRANSLATE(
    144         "2.2) GRUB 1\n");
    145     infoText << B_TRANSLATE(
    146         "Configure your /boot/grub/menu.lst by launching your favorite "
    147         "editor from a Terminal like this:\n\n");
    148     infoText << B_TRANSLATE(
    149         "\tsudo <your favorite text editor> /boot/grub/menu.lst\n\n");
    150     infoText << B_TRANSLATE(
    151         "You'll note that GRUB uses a different naming strategy for hard "
    152         "drives than Linux.\n\n");
    153     infoText << B_TRANSLATE(
    154         "With GRUB it's: (hdN,n)\n\n");
    155     infoText << B_TRANSLATE(
    156         "All hard disks start with \"hd\".\n");
    157     infoText << B_TRANSLATE(
    158         "\"N\" is the hard disk number, starting with \"0\".\n");
    159     infoText << B_TRANSLATE(
    160         "\"n\" is the partition number, also starting with \"0\".\n");
    161     infoText << B_TRANSLATE(
    162         "The first logical partition always has the number \"4\", regardless "
    163         "of the number of primary partitions.\n\n");
    164     infoText << B_TRANSLATE(
    165         "So behind the other menu entries towards the bottom of the file, add "
    166         "something similar to these lines:\n\n");
    167     infoText << B_TRANSLATE(
    168         "\t# Haiku on /dev/sda7\n");
    169     infoText << B_TRANSLATE(
    170         "\ttitle\t\t\t\tHaiku\n");
    171     infoText << B_TRANSLATE(
    172         "\trootnoverify\t\t(hd0,6)\n");
    173     infoText << B_TRANSLATE(
    174         "\tchainloader\t\t+1\n\n");
    175     infoText << B_TRANSLATE(
    176         "You can see the correct partition in GParted for example.\n\n\n");
    177     infoText << B_TRANSLATE(
    178         "2.3) GRUB 2\n");
    179     infoText << B_TRANSLATE(
    180         "Newer versions of GRUB use an extra configuration file to add "
    181         "custom entries to the boot menu. To add them to the top, you have "
    182         "to create/edit a file by launching your favorite editor from a "
    183         "Terminal like this:\n\n");
    184     infoText << B_TRANSLATE(
    185         "\tsudo <your favorite text editor> /etc/grub.d/40_custom\n\n");
    186     infoText << B_TRANSLATE(
    187         "NOTE: While the naming strategy for hard disks is still as described "
    188         "under 2.1) the naming scheme for partitions has changed.\n\n");
    189     infoText << B_TRANSLATE(
    190         "GRUB's naming scheme is still: (hdN,n)\n\n");
    191     infoText << B_TRANSLATE(
    192         "All hard disks start with \"hd\".\n");
    193     infoText << B_TRANSLATE(
    194         "\"N\" is the hard disk number, starting with \"0\".\n");
    195     infoText << B_TRANSLATE(
    196         "\"n\" is the partition number, which for GRUB 2 starts with \"1\"\n");
    197     infoText << B_TRANSLATE(
    198         "With GRUB 2 the first logical partition always has the number \"5\", "
    199         "regardless of the number of primary partitions.\n\n");
    200     infoText << B_TRANSLATE(
    201         "So below the heading that must not be edited, add something similar "
    202         "to these lines:\n\n");
    203     infoText << B_TRANSLATE(
    204         "\t# Haiku on /dev/sda7\n");
    205     infoText << B_TRANSLATE(
    206         "\tmenuentry \"Haiku Alpha\" {\n");
    207     infoText << B_TRANSLATE(
    208         "\t\tset root=(hd0,7)\n");
    209     infoText << B_TRANSLATE(
    210         "\t\tchainloader +1\n");
    211     infoText << B_TRANSLATE(
    212         "\t}\n\n");
    213     infoText << B_TRANSLATE(
    214         "Additionally you have to edit another file to actually display the "
    215         "boot menu:\n\n");
    216     infoText << B_TRANSLATE(
    217         "\tsudo <your favorite text editor> /etc/default/grub\n\n");
    218     infoText << B_TRANSLATE(
    219         "Here you have to comment out the line \"GRUB_HIDDEN_TIMEOUT=0\" by "
    220         "putting a \"#\" in front of it in order to actually display the "
    221         "boot menu.\n\n");
    222     infoText << B_TRANSLATE(
    223         "Finally, you have to update the boot menu by entering:\n\n");
    224     infoText << B_TRANSLATE(
    225         "\tsudo update-grub\n\n\n");
    226     infoText << B_TRANSLATE(
    227         "3)   When you successfully boot into Haiku for the first time, make "
    228         "sure to read our \"Welcome\" and \"Userguide\" documentation. There "
    229         "are links on the Desktop and in WebPositive's bookmarks.\n\n");
    230     infoText << B_TRANSLATE(
    231         "Have fun and thanks a lot for trying out Haiku! We hope you like it!");
    232 
    233103#if 1
    234104    // Show the EULA first.
    235     BTextView* textView = new BTextView("eula", be_plain_font, NULL,
    236         B_WILL_DRAW);
    237     textView->SetInsets(10, 10, 10, 10);
    238     textView->MakeEditable(false);
    239     textView->MakeSelectable(false);
    240     textView->SetText(infoText);
    241 
    242     BScrollView* scrollView = new BScrollView("eulaScroll",
    243         textView, B_WILL_DRAW, false, true);
    244 
    245     BButton* cancelButton = new BButton(B_TRANSLATE("Quit"),
    246         new BMessage(B_QUIT_REQUESTED));
    247     cancelButton->SetTarget(this);
    248 
    249     BButton* continueButton = new BButton(B_TRANSLATE("Continue"),
    250         new BMessage(kMsgAgree));
    251     continueButton->SetTarget(this);
    252     continueButton->MakeDefault(true);
    253 
    254     BRect eulaFrame = BRect(0, 0, 600, 450);
    255     fEULAWindow = new BWindow(eulaFrame, B_TRANSLATE("README"),
    256         B_MODAL_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE
    257             | B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS);
    258 
    259     if (!be_roster->IsRunning(kTrackerSignature))
    260         fEULAWindow->SetWorkspaces(B_ALL_WORKSPACES);
    261 
    262     BLayoutBuilder::Group<>(fEULAWindow, B_VERTICAL, 10)
    263         .SetInsets(10)
    264         .Add(scrollView)
    265         .AddGroup(B_HORIZONTAL, 10)
    266             .AddGlue()
    267             .Add(cancelButton)
    268             .Add(continueButton);
    269 
    270     fEULAWindow->CenterOnScreen();
    271     fEULAWindow->Show();
     105    fEULAWindow = new EULAWindow();
    272106#else
    273107    // Show the installer window without EULA.
    274108    new InstallerWindow();
    275109#endif
    276110}
    277 
  • src/apps/installer/InstallerApp.h

    diff --git a/src/apps/installer/InstallerApp.h b/src/apps/installer/InstallerApp.h
    index de068ab..49aa72a 100644
    a b  
    55#ifndef INSTALLER_APP_H
    66#define INSTALLER_APP_H
    77
     8
    89#include <Application.h>
    910#include <Catalog.h>
    1011
     12#include "EULAWindow.h"
    1113#include "InstallerWindow.h"
    1214
    1315
    public:  
    2022    virtual void                ReadyToRun();
    2123
    2224private:
    23             BWindow*            fEULAWindow;
     25            EULAWindow*         fEULAWindow;
    2426};
    2527
    2628#endif // INSTALLER_APP_H
  • src/apps/installer/Jamfile

    diff --git a/src/apps/installer/Jamfile b/src/apps/installer/Jamfile
    index b5843f2..9d9b4d19 100644
    a b SubDirHdrs [ FDirName $(HAIKU_TOP) src kits tracker ] ;  
    55
    66Application Installer :
    77    CopyEngine.cpp
     8    EULAWindow.cpp
    89    InstallerApp.cpp
    910    InstallerDefs.cpp
    1011    InstallerWindow.cpp
    Application Installer :  
    2122DoCatalogs Installer :
    2223    x-vnd.Haiku-Installer
    2324    :
     25    EULAWindow.cpp
    2426    InstallerApp.cpp
    2527    InstallerWindow.cpp
    2628    PackageViews.cpp