ACC SHELL

Path : /usr/share/YaST2/modules/
File Upload :
Current File : //usr/share/YaST2/modules/InstShowInfo.ycp

/**
 * Module:	InstShowInfo.ycp
 *
 * Author:	Stefan Hundhammer <sh@suse.de>
 *
 * Purpose:	Show /info.txt (if present) in a popup
 */
{
    module "InstShowInfo";

    // IMPORTANT: maintainer of yast2-add-on is responsible for this module

    textdomain "packager";

    import "Report";
    import "Label";

    /*
     * @param string info_file (/info.txt" - Copied from inst media to inst-sys by linuxrc)
     */
    global void show_info_txt(string info_file)
    {
       map display_info = UI::GetDisplayInfo();
       integer size_x = tointeger(display_info["Width"]:800);
       integer size_y = tointeger(display_info["Height"]:600);
       if (size_x >= 800 && size_y >= 600) {
		size_x = 78;
		size_y = 18;
	} else {
		size_x = 54;
		size_y = 15;
	}

	if ( SCR::Read(.target.size, info_file ) <= 0 )
	{
	    y2milestone( "No %1", info_file );
	    return;
	}

	string info_text = (string) SCR::Read( .target.string, info_file );

	map report_settings	= Report::Export();
	map message_settings	= report_settings[ "messages" ]:$[];
	integer timeout_seconds	= message_settings["timeout"]:0;
	// timeout_seconds = 12;
	boolean use_timeout = timeout_seconds > 0;
	term button_box =
	    `HBox(
		  `HStretch(),
		  `HWeight(1, `PushButton(`id(`ok), Label::OKButton() ) ),
		  `HStretch()
		  );

	if ( use_timeout )
	{
	    button_box = add( button_box, `HWeight(1, `PushButton(`id(`stop), Label::StopButton() ) ) );
	    button_box = add( button_box, `HStretch() );

	}

	UI::OpenDialog(
		       `VBox(
			     `MinSize(size_x, size_y, `RichText(`opt(`plainText), info_text ) ),
			     use_timeout ? 
			     `Label(`id(`timeout), sformat( "   %1   ", timeout_seconds ) )
			     : `VSpacing( 0.2 ),
			     button_box,
			     `VSpacing( 0.2 )
			     )
		       );

	UI::SetFocus(`ok);
	symbol button = `nothing;

	do
	{
	    button = (symbol) ( use_timeout ?
				UI::TimeoutUserInput( 1000 ) :
				UI::UserInput() );

	    if ( button == `timeout )
	    {
		timeout_seconds = timeout_seconds - 1;
		UI::ChangeWidget(`timeout, `Value, sformat( "%1", timeout_seconds ) );
	    }
	    else if ( button == `stop )
	    {
		use_timeout = false;
		UI::ChangeWidget(`stop, `Enabled, false );
		UI::ChangeWidget(`timeout, `Value, "" );
	    }
	} while ( button != `ok && timeout_seconds > 0 );

	UI::CloseDialog();
    }

    // show_info_txt();	// for debugging
}

ACC SHELL 2018