/**
 * File:	installation/general/inst_congratulate.ycp
 * Module:	Installation
 * Summary:	Display congratulation
 * Authors:	Arvin Schnell <arvin@suse.de>
 *
 * Display a nice congratulation message for the user.
 *
 * $Id: inst_congratulate.ycp 22387 2005-03-09 15:18:31Z sh $
 */

{
    textdomain "installation";

    import "Mode";
    import "Wizard";
    import "Popup";
    import "Label";
    import "ProductFeatures";
    import "GetInstArgs";

    map argmap = GetInstArgs::argmap();

    // show button "start control center"?
    boolean show_y2cc_checkbox = true;
    if (argmap["show_y2cc_checkbox"]:"yes" == "no" 
            && haskey(argmap, "show_y2cc_checkbox"))
        show_y2cc_checkbox = false;



    map display = UI::GetDisplayInfo();
    if (!display["TextMode"]:true)
    {
	if (!Pkg::IsProvided ("yast2-control-center"))
	{
	    show_y2cc_checkbox = false;
	}
    }

    integer space = display["TextMode"]:true ? 1 : 3;
    string vendor_url_tmp = (string)ProductFeatures::GetFeatureProperties("globals/vendor_url");
    
    string vendor_url = "http://www.novell.com/linux/";

    if (vendor_url_tmp != nil && vendor_url != "")
        vendor_url = vendor_url_tmp;

    term check_box_start_y2cc = `Empty();
    
    if (show_y2cc_checkbox)
    {
        check_box_start_y2cc = `CheckBox (`id(`start_y2cc),
        // Check box: Should the YaST2 control center automatically
        // be started after this part of the installation is done?
        // Translators: About 40 characters max,
        // use newlines for longer translations.
                                           _("&Start YaST Control Center"), false);
    }


    // caption for dialog "Congratulation Dialog"
    string caption = _("Installation Completed");

    // congratulation text 1/4
    string text = _("<p><b>Congratulations!</b></p>") +

    // congratulation text 2/4
	_("<p>The installation of &product; on your machine is complete.
After clicking <b>Finish</b>, you can log in to the system.</p>
") +

    // congratulation text 3/4
        sformat(_("<p>Visit us at %1.</p>"), vendor_url ) +

    // congratulation text 4/4
	_("<p>Have a lot of fun!<br>Your SUSE Development Team</p>");

    term contents = `VBox (
			   `VSpacing (space),
			   `HBox (
				  `HSpacing (2*space),
				  `RichText (`id (`text), text),
				  `HSpacing (2*space)
				  ),
			   `VSpacing (space),
			   check_box_start_y2cc,
			   `VSpacing (2)
			   );

    string help_file = "";
    // help 1/4 for dialog "Congratulation Dialog"
    string help = _("<p>Your system is ready for use.</p>") +

    // help 2/4 for dialog "Congratulation Dialog"
	_("<p><b>Finish</b> will close the YaST installation and continue
to the login screen.</p>
") +

    // help 3/4 for dialog "Congratulation Dialog"
	_("<p>If you choose the default graphical desktop KDE, you can
adjust some KDE settings to your hardware. Also notice
our SUSE Welcome Dialog.</p>
") +

    // help 4/4 for dialog "Congratulation Dialog"
	_("<p>If desired, experts can use the full range of SUSE's configuration
modules at this time. Check <b>Start YaST Control Center</b> and it starts
after <b>Finish</b> is pressed. Note: The Control Center does not have a back button to
return to this installation sequence.</p>
");

    Wizard::SetContents (caption, contents, help, 
            GetInstArgs::enable_back(), GetInstArgs::enable_next());
    Wizard::SetTitleIcon ("SuSEmenu");

    Wizard::SetNextButton(`next, Label::FinishButton() );
    Wizard::SetFocusToNextButton();

    // FIXME: richtext eats return key
    // UI::SetFocus (`id (`text));

    any ret = nil;

    repeat {

	ret = Wizard::UserInput();

	if (ret == `abort)
	{
	    if (Popup::ConfirmAbort (`incomplete))
		break;
	}
	else if ( ret == `help )
	{
	    Wizard::ShowHelp (help);
	}

    } until ( ret == `next || ret == `back );

    //Wizard::RestoreNextButton ();

    if (!UI::WidgetExists(`id(`start_y2cc)))
    {
        return ret;
    }
    else if (ret == `next && (boolean)UI::QueryWidget (`id(`start_y2cc), `Value))
    {
	// Create empty /var/lib/YaST2/start_y2cc file to signal the calling script
	// that the YaST2 control center should be started after the installation
	SCR::Write (.target.string, "/var/lib/YaST2/start_y2cc", "");
	y2milestone( "Going to start YaST2 control center after the installation workflow" );
    }

    return ret;
}
