// Advanced example of using the Wizard widget.
//
// Note: YCP applications are discouraged from using the Wizard widget directly.
// Use the Wizard module instead.

{

    list<map> base_installation_steps =
	[
	  $[ "id": "language",		"label": "Language"			],
	  $[ "id": "proposal",		"label": "Installation Settings"	],
	  $[ "id": "do_resize",		"label": "Perform Installation"		],
	  $[ "id": "prepdisk",		"label": "Perform Installation"		],
	  $[ "id": "kickoff",		"label": "Perform Installation"		],
	  $[ "id": "rpmcopy",		"label": "Perform Installation"		],
	  $[ "id": "finish",		"label": "Perform Installation"		]
	];

    list<map> config_steps =
	[
	  $[ "id": "root",		"label": "Root Password"		],
	  $[ "id": "proposal_net",	"label": "Network"			],
          $[ "id": "ask_net_test",	"label": "Network"			],
	  $[ "id": "do_net_test",	"label": "Network"			],
	  $[ "id": "you",		"label": "Online Update"		],
	  $[ "id": "auth",		"label": "Users"			],
	  $[ "id": "user",		"label": "Users"			],
	  $[ "id": "suseconfig",	"label": "Clean Up"			],
	  $[ "id": "release_notes",	"label": "Release Notes"		],
	  $[ "id": "proposal_hw",	"label": "Device Configuration"		]
	];

    list<map> steps = flatten( [ base_installation_steps, config_steps ] );

    if ( ! UI::HasSpecialWidget(`Wizard) )
    {
	y2error( "This works only with UIs that provide the wizard widget!" );
	return;
    }

    string help_text =
	"<p>This is a help text.</p>"
	+ "<p>It should be helpful.</p>"
	+ "<p>If it isn't helpful, it should rather not be called a <i>help text</i>.</p>";

    UI::OpenDialog(`opt(`defaultsize ),
		   `Wizard(`opt(`stepsEnabled),
			   `back,  "&Back",
			   `abort, "Ab&ort",
			   `next,  "&Next" ) );
    
    // UI::DumpWidgetTree();

    UI::WizardCommand(`SetDialogIcon( "/usr/share/YaST2/theme/SuSELinux/icons/22x22/apps/user_add.png" ) );
    UI::WizardCommand(`SetDialogHeading( "Welcome to openSUSE" ) );
    UI::WizardCommand(`SetHelpText( help_text ) );
    UI::WizardCommand(`ShowReleaseNotesButton( "&Release Notes", "release_notes" ) );

    UI::WizardCommand(`AddStepHeading( "Base Installation" ) );
    
    foreach ( map step, base_installation_steps, ``{
	UI::WizardCommand(`AddStep( step["label"]:"", step["id"]:"" ) );
    });
    

    UI::WizardCommand(`AddStepHeading( "Configuration" ) );
    
    foreach ( map step, config_steps, ``{
	UI::WizardCommand(`AddStep( step["label"]:"", step["id"]:"" ) );
    });

    UI::WizardCommand(`SetCurrentStep( "language" ) );

    list language_list =
        [
         "English - English",
         "German - Deutsch",
         "French - Francais",
         "Chinese - ???"
         ];
      
    term detailsPage =
        `VBox(`id(`detailsPage ),
              `Left(`Label("Please answer some basic question to finish the openSUSE installation in very little time.")),
              `VWeight(80, `VSpacing(0.4)),
	      `Label("Please select your language:"),
              `ComboBox(`id(`language_combo), "", language_list),
              `VWeight(80, `VSpacing(0.4)),
	      `RichText("<p>We need you to acknowledge our License Agreement due to legal requirements in several countries. You can read the full text <a href='/license'>here</a>.</p>"),
              `Left(`CheckBox("&Yes, I accept the License Agreement")),
              `VWeight(80, `VSpacing(0.4)),
              `RichText("<p>If you want to know what new features or possible problems are in this release, we suggest you read the <a href='/release_notes'>Release&nbsp;Notes</a>.</p>"),
              `VWeight(80, `VSpacing(0.4))
               );

    term contents =
        `VBox(
              `VSpacing( 0.4 ),
              `VWeight( 1,      // lower layout priority
                        `HBox(
                              `HSpacing( 1 ),
                              detailsPage,
                              `HSpacing( 0.5 )
                              )
                        ),
              `VSpacing( 0.4 )
              );

    UI::ReplaceWidget(`id(`contents), contents);

    while( true )
    {
	any button = (any) UI::UserInput();

	if ( button == `abort || button == `cancel )
	    break;

	if ( button == `next || button == `back )
	    break;

        if ( button == "/license")
        {
            UI::OpenDialog(
		   `VBox(`RichText(`opt(`plainText), "openSUSE 11.0
Novell Pre-Release Software License Agreement

PLEASE READ THIS AGREEMENT CAREFULLY. BY INSTALLING OR OTHERWISE USING
THE SOFTWARE (INCLUDING ITS COMPONENTS), YOU AGREE TO THE TERMS OF
THIS AGREEMENT. IF YOU DO NOT AGREE WITH THESE TERMS, DO NOT DOWNLOAD,
INSTALL OR USE THE SOFTWARE AND, IF APPLICABLE, RETURN THE ENTIRE
UNUSED PACKAGE TO THE RESELLER WITH YOUR RECEIPT FOR A REFUND. THE
SOFTWARE MAY NOT BE SOLD, TRANSFERRED, OR FURTHER DISTRIBUTED WITHOUT
PRIOR WRITTEN AUTHORIZATION FROM NOVELL."),
                    `PushButton("Close")));
;
           UI::UserInput();
           UI::CloseDialog();
        }

        if ( button == "/release_notes")
        {
            UI::OpenDialog(
		   `VBox(`RichText(
" <h1>openSUSE 10.3 Release Notes</h1>

 <p>Copyright ?? 2007 Novell, Inc.</p>
 <p>Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included as the file <tt>fdl.txt</tt>.</p>


 <p>The release notes are under constant development. Download the newest version as part of the Internet test or refer to <tt>http://www.suse.com/relnotes/i386/openSUSE/10.3/RELEASE-NOTES.en.html</tt>. </p>

"),
                    `PushButton("Close")));
;
           UI::UserInput();
           UI::CloseDialog();
        }
    }

    UI::CloseDialog();

}
