home *** CD-ROM | disk | FTP | other *** search
- /**
- * Module: auto_part_ui.ycp
- *
- * Authors: Andreas Schwab (schwab@suse.de)
- * Klaus KΣmpf (kkaempf@suse.de)
- *
- * Purpose: This module contains the user interface
- * definitions for the automatic partitioner
- *
- *
- *
- * $Id: auto_part_ui.ycp 33868 2006-10-30 15:35:53Z fehr $
- *
- * used globals:
- *
- * defined functions
- global define display_error_box (string reason) ``{
- global define warn_not_bootable () ``{
- global define partition_text (integer nr, map pentry) ``{
- global define ask_free_space ()
- global define construct_partition_dialog ()
- global define open_auto_dialog (string targetname, term targetbox) ``{
- global define create_resize_dialog (list partitions) ``{
- */
- {
- textdomain "storage";
-
- import "Wizard";
- import "Partitions";
- import "Report";
-
- include "partitioning/partition_defines.ycp";
- import "Popup";
- import "Product";
-
- // --------------------------------------------------------------
- // warning and pop-ups
-
- define void display_error_box (string reason) ``{
- // There is a consistency check for the selection. Next is the message, that
- // is displayed. The reason is determined within this consistency check and
- // then the message is passed through this interface transparently
- string text = sformat(_("The current selection is invalid:\n%1"), reason);
- Popup::Message(text);
- };
-
- define void warn_not_bootable () ``{
- // This is a warning message that pops up when the selection does not
- // include a bootable disk region (< 1024 cylinders).
- Report::Warning(sformat(_("With the current partitioning, your %2 installation
- cannot be booted directly, because your /boot partition
- is above cylinder %1.
- "), Partitions::BootCyl(), Product::name) );
- };
-
-
- // Return a text that describes a partition
-
- define string partition_text (integer nr, map pentry, integer bps)
- ``{
- string size_str = ByteToHumanString(size_of_region( pentry["region"]:[], bps));
- if( pentry["type"]:`unknown == `free)
- // list of partition checkboxes: show partition as unassigned
- // e.g. "1: 2 GB, unassigned"
- return sformat( _("&%1: %2, unassigned"), nr, size_str );
- else
- // list of partition checkboxes: show partition as assigned
- return sformat( "&%1: %2, %3 (%4)", nr, size_str,
- pentry["fstype"]:"", pentry["device"]:"" );
- };
-
- define boolean ask_free_space () ``{
- // we found an unassigned partition which is large enough for a minimal installation
- return Popup::YesNo(sformat(_("There is free space on the selected disk.
- Use this for %1?
- "),Product::name));
- };
-
- define map construct_partition_dialog( list<map> partitions, string ptype,
- integer bps )
- ``{
- term vbox_contents =
- `VBox( // Message between the full name of the hard disk to use
- // and the "Use entire hard disk" button
- // - please avoid excessively long lines - rather, include a newline
- `Left( `Label (sformat(_("Disk Areas to Use
- to Install %1
- "),Product::name))),
- `VSpacing(0.3)
- );
-
- // Add option to select the entire disk at once
- vbox_contents =
- add( vbox_contents,
- // pushbutton to choose the entire disk, erasing all data on
- // the disk this is an easy way to select all partitions on
- // the target disk
- `Left(`PushButton (`id (`full), _("Use &entire hard disk"))));
-
- vbox_contents = add (vbox_contents, `VSpacing(0.5) );
-
- integer i = 0;
- integer ui_id = 0;
- foreach( map pentry, partitions,
- ``{
- symbol ptype = pentry["type"]:`unknown;
- if (ptype != `extended)
- {
- // skip #3 on AlphaBSD and SparcBSD
- if( pentry["fsid"]:0 != Partitions::fsid_mac_hidden &&
- ((ptype!=`bsd && ptype!=`sun) || pentry["nr"]:0 != 3) &&
- !pentry["create"]:false)
- {
- ui_id = pentry["ui_id"]:0;
- i = i + 1;
- boolean sel = pentry["delete"]:false || ptype==`free;
- vbox_contents = add (vbox_contents,
- `Left(`CheckBox (`id (ui_id),
- partition_text(i, pentry, bps),
- sel)));
- }
- }
- });
- return $[ "term": vbox_contents, "high_id": ui_id ];
- };
-
- define term create_whole_disk_dialog () ``{
- // There were no prior partitions on this disk.
- // No partitions to choose from will be displayed.
- return (`VBox(`Left(`Label( sformat(_("There are no partitions on this disk yet.
- The entire disk will be used for %1."),Product::name)))));
- };
-
- define term create_resize_dialog (list<map> partitions, integer bps)
- ``{
- // popup text
- string explanation = _("This disk appears to be used by Windows.
- There is not enough space to install Linux.");
-
- return (`VBox(
- `RadioButtonGroup (
- `HBox(
- `HSpacing(1.5),
- `VBox (
- `Left(`Label( explanation )),
- `VSpacing(0.5),
- `Left (`RadioButton (`id (`part_id),
- // Radio button for using an entire (Windows) partition for Linux
- _("&Delete Windows completely") ) ),
- `VSpacing(0.5),
- `Left (`RadioButton (`id (`resize),
- // Radio button for resizing a (Windows) partition
- _("&Shrink Windows partition"), true ) )
- )
- )
- )
- )
- );
- };
-
- // --------------------------------------------------------------
-
-
- // normal case
- //
- define void open_auto_dialog (string targetname, term targetbox) ``{
-
- // helptext for semi-automatic partitioning
- // part 1 of 4
- string helptext = _("<p>
- Select where on your hard disk to install &product;.
- </p>
- ");
- // helptext, part 2 of 4
- helptext = helptext + _("<p>
- You can either use the <b>entire hard disk</b> or one or more of the
- partitions or free regions shown.
- </p>");
- // helptext, part 3 of 4
- helptext = helptext + _("<p>
- Notice: If you select a region that is not shown as <i>free</i>, you
- might loose existing data on your hard disk. This could also affect
- other operating systems.
- </p>");
- // helptext, part 4 of 4
- helptext = helptext + _("<p>
- <b><i>The marked regions will be deleted. All data there will be
- lost. </i></b> There will be no way to recover this data.
- </p>
- ");
-
- // Information what to do, background information
- Wizard::SetContents( _("Preparing Hard Disk -- Step 2"),
- `HCenter(
- `HSquash(
- `Frame(
- // Frame title for installation target hard disk / partition(s)
- _("Installing on:"),
- `HBox(
- `HSpacing(),
- `VBox(
- `VSpacing(0.5),
- `HBox(
- `HSpacing(2),
- `Left( `Label(`opt(`outputField), targetname) )
- ),
- `VSpacing(0.5),
-
- // All partitions are listed that are found on the target (hard disk).
- `VSquash( targetbox ),
- `VSpacing(0.5)
- ),
- `HSpacing()
- )
- )
- )
- ), helptext, (boolean)WFM::Args (0), (boolean)WFM::Args (1));
- };
-
-
- // resize case
- //
- define void open_auto_dialog_resize (string targetname, term targetbox)
- ``{
- // helptext for semi-automatic partitioning
- // part 1 of 2
- string helptext = _("<p>
- The selected hard disk is probably used by Windows. There is not enough
- space for &product;. You can either <b>delete Windows completely</b> or
- <b>shrink</b> it to get enough free space.
- </p>");
- // helptext, part 2 of 2
- helptext = helptext + _("<p>
- If you delete Windows, all data on this partition will be <b>irreversibly
- lost</b> in the installation. When shrinking Windows, we <b>strongly
- recommend a data backup</b>, because the data must be reorganized.
- This may fail under rare circumstances.
- </p>
- ");
-
- // Information what to do, background information
- Wizard::SetContents( _("Preparing Hard Disk -- Step 2"),
- `HCenter(
- `Frame(
- // Frame title for installation target hard disk / partition(s)
- _("Installing on:"),
- `HBox(
- `HSpacing(),
- `VBox(
- `VSpacing(0.5),
- `HBox(
- `HSpacing(2),
- `Left( `Label(`opt(`outputField), targetname) )
- ),
- `VSpacing(0.5),
-
- // All partitions are listed that are found on the target (hard disk).
- `VSquash(targetbox),
- `VSpacing(0.5)
- ),
- `HSpacing()
- )
- )
- ), helptext, (boolean)WFM::Args(0), (boolean)WFM::Args (1));
- };
-
- term add_common_widgets( term vbox )
- {
- map cfg = Storage::GetControlCfg();
- term vb = `VBox();
- vb = add (vb,
- `Left(`HBox(`HSpacing(3), `CheckBox( `id(`home),
- // Label text
- _("Propose Separate &Home Partition" ),
- cfg["home"]:false ))));
- vb = add (vb, `VSpacing(1) );
- vb = add( vb,
- `Left(`HBox(`HSpacing(3), `CheckBox(`id(`lvm), `opt(`notify),
- // Label text
- _("Create &LVM Based Proposal"), cfg["prop_lvm"]:false ))));
- if( cfg["evms_config"]:false )
- vb = add( vb,
- `Left(`HBox(`HSpacing(3), `CheckBox(`id(`evms), `opt(`notify),
- // Label text
- _("Create &EVMS Based Proposal"),
- cfg["prop_evms"]:false ))));
- vbox = add (vbox, `VSpacing(1.5) );
- term frame = `HVCenter(`Frame( _( "Proposal type" ), `HVCenter(vb) ));
- vbox = add (vbox, frame );
- return( vbox );
- }
- }
-