/**
 * Module: 		inst_packages.ycp
 * Authors:		Gabriele Strattner <gs@suse.de>
 * Purpose:             Show the package installation dialogue.
 *
 * $Id: inst_packages.ycp 21679 2005-02-17 20:32:05Z nashif $
 */

{
    import "StorageDevices";
    import "Mode";
    import "Stage";

    symbol mode = `searchMode;

    y2milestone("inst_packages called with: %1" , WFM::Args() );
    if (size(WFM::Args()) > 0 && is(WFM::Args(0), symbol))
    {
        mode = (symbol)WFM::Args(0);
        y2milestone("mode: %1", mode);
    }

    string floppyDevice = StorageDevices::FloppyDevice;

    if ( Mode::normal () )
    {
	UI::OpenDialog(`opt(`defaultsize),
		       `PackageSelector( `id(`selector), `opt(mode), floppyDevice ) );
    }
    else
    {
	
        if (size(WFM::Args()) > 0 && ! Stage::initial() )
            UI::OpenDialog(`opt(`defaultsize),
                    `PackageSelector( `id(`selector), `opt(mode), floppyDevice ) );
        else
            UI::OpenDialog(`opt(`defaultsize),
                    `PackageSelector( `id(`selector), floppyDevice ) );
    }

    Pkg::SaveState();

    // returns `accept or `cancel
    symbol result = (symbol) UI::RunPkgSelection(`id(`selector) );

    if (result == `accept)
	Pkg::ClearSaveState();
    else
	Pkg::RestoreState(false);

    UI::CloseDialog();
    return result;
}
