ACC SHELL

Path : /usr/share/YaST2/clients/
File Upload :
Current File : //usr/share/YaST2/clients/inst_desktop.ycp

/**
 * File:	clients/inst_desktop.ycp
 * Package:	Installation
 * Summary:	Desktop Selection
 * Authors:	Jiri Srain <jsrain@suse.cz>
 *
 * $Id: inst_desktop.ycp 45758 2008-03-26 15:48:38Z lslezak $
 *
 */

{

textdomain "packager";

import "Directory";
import "GetInstArgs";
import "Label";
import "Packages";
import "Popup";
import "ProductFeatures";
import "Stage";
import "Wizard";
import "DefaultDesktop";

// do not offer the dialog if base selection is fixed
if (ProductFeatures::GetFeature ("software", "selection_type") == `fixed)
    return `auto;

string alt_desktop = DefaultDesktop::Desktop ();
string other_desktop = nil;

if (alt_desktop == nil)
{
    DefaultDesktop::Init ();
    alt_desktop = DefaultDesktop::Desktop ();
}
if (alt_desktop != nil)
{
    if (alt_desktop != "kde" && alt_desktop != "gnome")
    {
	alt_desktop = "other";
    }
}

map display = UI::GetDisplayInfo();
integer space = display["TextMode"]:true ? 1 : 3;

// all the arguments
map argmap = GetInstArgs::argmap();



string gnome_blurb =
// explanation text for GNOME
_("GNOME is a powerful and intuitive desktop
environment that uses Evolution as its mailer,
Firefox as its browser, and Nautilus as its
file manager.");

string kde_blurb =
// explanation text for KDE
_("KDE is a powerful and intuitive desktop
environment that uses Kontact as its mailer,
Konqueror as its file manager, and offers
both, Firefox and Konqueror as its Web browser.
");

// help text 1/3
string help = _("<p>Both <b>KDE</b> and <b>GNOME</b> are powerful and intuitive
desktop environments. They combine ease of use
and attractive graphical interfaces with their
own sets of perfectly integrated applications.</p>")
+
// help text 2/3
_("<p>Choosing the default <b>GNOME</b> or <b>KDE</b> desktop
environment installs a broad set of the
most important desktop applications on your
system.</p>")
+
// help text 3/3
_("<p>Choose <b>Other</b> then select from
an alternative, such as a text-only system or a minimal graphical
system with a basic window manager.</p>");

term kde = `VBox (
	    `Left (`RadioButton (`id ("kde"), `opt(`notify, `boldFont),
		// radio button
		_("&KDE"),
		alt_desktop == "kde")),
	    `Left (`HBox (
		`HSpacing (3),
		`Top (`Label (kde_blurb)),
		`HSpacing (1),
		`Right (`Top (`Image (
		    Directory::icondir + "/48x48/apps/yast-kde.png",
			"")))
	    ))
	);

term gnome = `VBox (
	    `Left (`RadioButton (`id ("gnome"), `opt (`notify, `boldFont),
		// radio button
		_("&GNOME"),
		alt_desktop == "gnome")),
	    `HBox (
		`HSpacing (3),
		`Top (`Label (gnome_blurb)),
		`HSpacing (1),
		`Right (`Top ( `Image (
		    Directory::icondir + "/48x48/apps/yast-gnome.png",
			"")))
	    )
	);

term contents = `RadioButtonGroup (`id (`desktop), `HBox (
    `HWeight(1, `Empty()),	// Distribute excess space 1:2 (left:right)
    `VBox (
	`VStretch (),
	// label (in bold font)
	`VWeight (10, gnome),
	`VSpacing (0.4),
	`VWeight (10, kde),
	`VSpacing (0.4),

	`VWeight (10, `HBox (
	    `Left (`RadioButton (`id ("other"), `opt(`notify, `boldFont),
		// radio button
		_("&Other"),
		alt_desktop != "gnome" && alt_desktop != "kde"
		    && alt_desktop != nil)),
	    `HBox (
		`HSpacing (2),
		// push button
		`RadioButtonGroup (`id(`other_rb), `ReplacePoint (`id(`other_options), `VBox(`VSpacing(4))))
	    )
	)),
	`VStretch ()
    ),
    `HWeight (2, `Empty ())
));

void EnableOtherOptions () {
    UI::ReplaceWidget (`id (`other_options), `VBox (
	`VSpacing (2),
	`Left (`RadioButton (`id ("min_x11"), `opt(`notify),
	    // radio button
	    _("&Minimal Graphical System"), (other_desktop == "min_x11"))),
	`Left (`RadioButton (`id ("text"), `opt(`notify),
	    // radio button
	    _("&Text Mode"), (other_desktop == "text")))
    ));
}

void DisableOtherOptions () {
    UI::ReplaceWidget (`id(`other_options), `VBox(`VSpacing(4)));
}

// dialog caption
Wizard::SetContents (_("Desktop Selection"), contents, help,
    GetInstArgs::enable_back(), GetInstArgs::enable_next());
Wizard::SetTitleIcon ("yast-desktop-select");
Wizard::SetFocusToNextButton();

// initialize other desktop when going back
if (alt_desktop == "other")
{
    other_desktop = DefaultDesktop::Desktop();
    EnableOtherOptions();
}

any ret = nil;

repeat {
    map event = UI::WaitForEvent();
    ret = event["ID"]:nil;

    // by default, nothing is selected, enabling next
    // handling [Next] button
    if (ret == "gnome" || ret == "kde" || ret == "min_x11" || ret == "text") {
	Wizard::EnableNextButton();
    } else if (ret == "other" && (other_desktop == "min_x11" || other_desktop == "text")) {
	Wizard::EnableNextButton();
    } else {
	Wizard::DisableNextButton();
    }

    if (ret == `next) {
	if (alt_desktop == nil || alt_desktop == "") {
	    Popup::Message (_("No desktop was selected. Select the
desktop to install."));
	    ret = nil;
	// alt_desktop is also neither 'nil' nor ""
	} else if (alt_desktop == "other") {
	    alt_desktop = other_desktop;
	}
    } else if (ret == `abort) {
	if (Popup::ConfirmAbort (Stage::initial () ? `painless : `incomplete))
	    return `abort;
	continue;
    } else if (ret == "other") {
	EnableOtherOptions();
    } else if (ret == "gnome" || ret == "kde") {
	alt_desktop = tostring (ret);
	DisableOtherOptions();
    } else if (ret == "min_x11" || ret == "text") {
	alt_desktop = "other";
	other_desktop = tostring (ret);
    }

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

Wizard::EnableNextButton ();

if (ret == `accept)
    ret = `next;

if (ret == `next)
{
    if (DefaultDesktop::Desktop () != alt_desktop)
    {
	y2milestone ("Setting default desktop to %1", alt_desktop);
	DefaultDesktop::SetDesktop (alt_desktop);
	Packages::ForceFullRepropose ();
	Packages::Reset ([`product]);
    }
}

return (symbol)ret;



/* EOF */
}

ACC SHELL 2018