ACC SHELL
/**
* File: clients/inst_software_selection.ycp
* Package: Installation
* Summary: New Desktop Selection (bnc #379157)
* Authors: Lukas Ocilka <locilka@suse.cz>
* Stephan Kulow <coolo@suse.de>
*
* $Id: inst_new_desktop.ycp 58814 2009-09-29 14:30:54Z kmachalkova $
*
*/
{
textdomain "installation";
import "ProductFeatures";
import "InstData";
import "GetInstArgs";
import "DefaultDesktop";
import "Wizard";
import "Packages";
import "Popup";
import "Stage";
import "Directory";
import "ProductControl";
// do not offer the dialog if base selection is fixed
if (ProductFeatures::GetFeature ("software", "selection_type") == `fixed)
return `auto;
boolean text_mode = UI::GetDisplayInfo()["TextMode"]:false;
// TRANSLATORS: help text, part 1
string help = _("<p>At Linux <b>choice</b> is a top priority. <i>openSUSE</i> offers a number
of different desktop environments. Below you see a list of the 2 major ones
<b>GNOME</b> and <b>KDE</b>.</p>") +
// TRANSLATORS: help text, part 3
_("<p>You may select alternative desktop environments (or one of minimal installation patterns)
that could fit your needs better using the <b>Other</b> option . Later in the software
selection or after installation, you can change your selection or add additional desktop
environments. This screen allows you to set the default.</p>");
if (DefaultDesktop::Desktop() == nil || DefaultDesktop::Desktop() == "") {
DefaultDesktop::Init();
}
map <string, map> all_desktops = DefaultDesktop::GetAllDesktopsMap();
string packages_proposal_ID = "inst_new_desktop";
void SelectSoftwareNow () {
Packages::ForceFullRepropose();
y2milestone ("Selected desktop: %1", DefaultDesktop::Desktop());
// Sets PackagesProposal - packages to install
DefaultDesktop::SetDesktop (DefaultDesktop::Desktop());
}
string GetDesktopRadioButtonId (string desktop_name) {
if (desktop_name == nil || desktop_name == "") {
y2warning ("Wrong desktop name: %1", desktop_name);
return "";
}
return sformat ("selected_desktop_%1", desktop_name);
}
string GetDesktopDescriptionId (string desktop_name) {
if (desktop_name == nil || desktop_name == "") {
y2warning ("Wrong desktop name: %1", desktop_name);
return "";
}
return sformat ("desktop_description_%1", desktop_name);
}
list <string> other_desktops = [];
term GetDesktops (string desktops, boolean show_descr) {
list <string> sort_order = maplist (string desktop_name, map one_desktop, all_desktops, {
return desktop_name;
});
sort_order = sort (string x, string y, sort_order, ``(all_desktops[x,"order"]:99 < all_desktops[y,"order"]:99));
if (desktops == "major") {
sort_order = filter (string desktop_name, sort_order, {
return (all_desktops[desktop_name,"order"]:99 == 1);
});
} else if (desktops == "minor") {
sort_order = filter (string desktop_name, sort_order, {
return (all_desktops[desktop_name,"order"]:99 > 1);
});
other_desktops = sort_order;
}
term ret = `VBox ();
integer counter = -1;
integer last_desktop_order = -1;
foreach (string desktop_name, sort_order, {
counter = counter + 1;
if (counter != 0 && desktops == "major") {
ret[counter] = `VSpacing (1);
counter = counter + 1;
}
integer desktop_order = all_desktops[desktop_name,"order"]:99;
term radio_opt = `opt (`notify, `boldFont);
if (desktops == "minor")
radio_opt = `opt (`notify);
ret[counter] =
`Left (`HBox (
`HSpacing ((desktops == "major" ? 2:8)),
`VBox (
`Left (`RadioButton (
`id (GetDesktopRadioButtonId (desktop_name)),
radio_opt,
// BNC #449818
ProductControl::GetTranslatedText (all_desktops[desktop_name,"label_id"]:"")
)),
(desktops == "major" && show_descr ?
`ReplacePoint (`id (GetDesktopDescriptionId (desktop_name)), `HBox (
`HSpacing ((text_mode ? 4:2)),
// BNC #449818
`Left (`Label (ProductControl::GetTranslatedText (all_desktops[desktop_name,"description_id"]:""))),
`HSpacing (1)
))
:
`Empty()
)
),
(desktops == "major" ?
`Image (Directory::themedir + "/current/icons/64x64/apps/" + all_desktops[desktop_name,"icon"]:"yast" + ".png")
:
`Empty()
)
));
last_desktop_order = desktop_order;
});
if (desktops == "major") {
counter = counter + 1;
if (counter != 0) {
ret[counter] = `VSpacing (1);
counter = counter + 1;
}
ret[counter] =
`Left (`HBox (
`HSpacing (2),
`VBox (
`Left (`RadioButton (
`id ("__other__"),
`opt (`notify, `boldFont),
_("Other")
))
)
));
}
return ret;
}
term major_desktops = GetDesktops ("major", true);
term major_no_descr = GetDesktops ("major", false);
term minor_desktops = GetDesktops ("minor", true);
boolean current_minor_d_status = false;
void ShowHideOther (boolean show) {
string currently_selected = (string) UI::QueryWidget (`id ("selected_desktop"), `Value);
if (show == true && current_minor_d_status == false) {
if (text_mode) UI::ReplaceWidget (`id ("major_options"), major_no_descr);
UI::ReplaceWidget (`id ("other_options"), minor_desktops);
current_minor_d_status = true;
} else if (show == false && current_minor_d_status == true) {
if (text_mode) UI::ReplaceWidget (`id ("major_options"), major_desktops);
UI::ReplaceWidget (`id ("other_options"), `Empty());
current_minor_d_status = false;
}
UI::ChangeWidget (`id ("selected_desktop"), `Value, currently_selected);
UI::SetFocus (`id (currently_selected));
}
term default_ui_minor = `Empty();
string default_desktop = DefaultDesktop::Desktop();
if (default_desktop != nil && default_desktop != "" && contains (other_desktops, default_desktop)) {
default_ui_minor = minor_desktops;
current_minor_d_status = true;
}
term contents = `Left (`HBox (
`HSquash (
`VBox (
`Label (ProductControl::GetTranslatedText ("desktop_dialog")),
`VWeight (3, `VStretch()),
`RadioButtonGroup (
`id ("selected_desktop"),
`opt (`hstretch),
`VBox (
`ReplacePoint (`id ("major_options"), major_desktops),
`ReplacePoint (`id ("other_options"), default_ui_minor)
)
),
`VWeight (5, `VStretch())
)
)
));
// TRANSLATORS: dialog caption
string caption = _("Desktop Selection");
// Set UI
Wizard::SetContents (caption, contents, help,
Stage::initial() ? GetInstArgs::enable_back():true,
Stage::initial() ? GetInstArgs::enable_next():true
);
Wizard::SetTitleIcon ("yast-desktop-select");
// Adjust default values
if (! UI::WidgetExists (`id ("selected_desktop"))) {
y2error (-1, "Widget selected_desktop does not exist");
} else if (default_desktop != nil && default_desktop != "") {
y2milestone ("Already selected desktop: %1", DefaultDesktop::Desktop());
UI::ChangeWidget (`id ("selected_desktop"), `Value, GetDesktopRadioButtonId (DefaultDesktop::Desktop()));
}
// UI wait loop
any ret = nil;
while (true) {
ret = UI::UserInput();
if (is (ret, string) && regexpmatch (tostring (ret), "^selected_desktop_.*")) {
string currently_selected = regexpsub (tostring (ret), "^selected_desktop_(.*)", "\\1");
if (! contains (other_desktops, currently_selected)) {
ShowHideOther (false);
}
} else if (ret == `next) {
string currently_selected = (string) UI::QueryWidget (`id ("selected_desktop"), `Value);
if (currently_selected == "__other__") {
Popup::Message (_("No system type was selected.
Select the default type."));
continue;
}
if (currently_selected != nil && currently_selected != "") {
DefaultDesktop::SetDesktop (regexpsub (tostring (currently_selected), "^selected_desktop_(.*)", "\\1"));
Packages::ForceFullRepropose();
if (DefaultDesktop::Desktop() != nil && haskey (all_desktops, DefaultDesktop::Desktop())) {
SelectSoftwareNow ();
break;
}
}
Popup::Message (_("No system type was selected.
Select the default type."));
continue;
} else if (ret == `abort || ret == `cancel) {
if (Popup::ConfirmAbort (Stage::initial () ? `painless : `incomplete)) {
ret = `abort;
break;
}
continue;
} else if (ret == `back) {
break;
} else if (ret == "__other__") {
ShowHideOther (true);
} else {
y2error ("Input %1 not handled", ret);
}
}
return (symbol) ret;
/* EOF */
}
ACC SHELL 2018