home *** CD-ROM | disk | FTP | other *** search
- /**
- * File:
- * include/bootloader/routines/ui.ycp
- *
- * Module:
- * Bootloader installation and configuration
- *
- * Summary:
- * User interface for bootloader installation/configuration
- *
- * Authors:
- * Jiri Srain <jsrain@suse.cz>
- *
- * $Id: dialogs.ycp 31102 2006-05-22 16:54:46Z jplack $
- *
- */
-
-
- {
- textdomain "bootloader";
-
- import "BootCommon";
- import "CWM";
- import "Label";
- import "Mode";
- import "Popup";
- import "Wizard";
- import "Bootloader";
- import "Stage";
-
- include "bootloader/routines/popups.ycp";
- include "bootloader/routines/section_widgets.ycp";
- include "bootloader/routines/global_widgets.ycp";
-
- /**
- * Test for abort.
- * @return true if abort was pressed
- */
- boolean testAbort () {
- if (Mode::commandline ())
- return false;
- if (`abort == UI::PollInput ())
- {
- if (! Stage::initial ())
- UI::CloseDialog ();
- return true;
- }
- return false;
- }
-
- /**
- * Read settings dialog
- * @return `abort if aborted and `next otherwise
- */
- symbol ReadDialog() {
- Bootloader::test_abort = testAbort;
- Wizard::RestoreHelp (getInitProgressHelp ());
- boolean ret = Bootloader::Read();
- return ret ? `next : `abort;
- }
-
- /**
- * Write settings dialog
- * @return `abort if aborted and `next otherwise
- */
- symbol WriteDialog() {
- if (! Stage::initial ())
- Bootloader::test_abort = testAbort;
- Wizard::RestoreHelp (getSaveProgressHelp ());
- boolean ret = Bootloader::Write();
- return ret ? `next : `abort;
- }
-
-
- string return_tab = "sections";
-
- /**
- * Run dialog for kernel section editation
- * @return symbol for wizard sequencer
- */
- symbol MainDialog () {
- y2milestone ("Running Main Dialog");
-
- term contents = `VBox (
- "tab",
- `Right ("adv_button")
- );
-
- list<string> widget_names = ["tab", "adv_button"];
- map<string,map<string,any> > widget_descr = (map<string,map<string,any> >)
- union (CommonGlobalWidgets (), Bootloader::blWidgetMaps ());
- widget_descr["tab"] = CWMTab::CreateWidget($[
- "tab_order": ["sections", "installation"],
- "tabs": TabsDescr (),
- "widget_descr": widget_descr,
- "initial_tab" : return_tab,
- ]);
- widget_descr["tab", "no_help"] = "";
-
- // dialog caption
- string caption = _("Boot Loader Settings");
- symbol ret = CWM::ShowAndRun ($[
- "widget_descr" : widget_descr,
- "widget_names" : widget_names,
- "contents" : contents,
- "caption" : caption,
- "back_button" : Label::BackButton (),
- "abort_button" : Label::AbortButton (),
- "next_button" : Label::FinishButton (),
- "fallback_functions" : global_handlers,
- ]);
- if (ret != `back && ret != `abort && ret != `cancel)
- {
- return_tab = CWMTab::CurrentTab ();
- // TODO store current tab here
- }
- return ret;
- }
-
- /**
- * Run dialog with detailed settings
- * @param type string specification of the type of detail settings
- * @return symbol for wizard sequencer
- */
- symbol DetailsDialog (string type) {
- map<string,symbol()> dialogs = Bootloader::blDialogs ();
- if (! haskey (dialogs, type))
- {
- Report::Message (
- // message
- _("There are no options to set for the current boot loader."));
- return `back;
- }
- symbol () dialog = (symbol())dialogs[type]:nil;
- return dialog ();
- }
-
- /**
- * Run dialog for kernel section editation
- * @return symbol for wizard sequencer
- */
- symbol KernelSectionDialog () {
- y2milestone ("Running kernel section dialog");
-
- term contents = `HBox (`HSpacing (2), `VBox (
- `VStretch (),
- // heading
- `Left (`Heading (_("Kernel Section"))),
- `VSpacing (1),
- "name",
- `VStretch (),
- // frame
- `Frame (_("Section Settings"), `HBox (`HSpacing (2), `VBox (
- `VSpacing (1),
- "kernel",
- `VSpacing (1),
- "initrd",
- `VSpacing (1),
- `HBox (
- `HWeight (1, "root"),
- `HWeight (1, "vga")
- ),
- `VSpacing (1),
- "append",
- `VSpacing (1)
- ), `HSpacing (2))),
- `VStretch ()
- ), `HSpacing (2));
-
- list<string> widget_names = ["name", "kernel", "initrd", "root", "vga", "append"];
- map<string,map<string,any> > widget_descr = (map<string,map<string,any> >)
- union (CommonSectionWidgets (), Bootloader::blWidgetMaps ());
- // dialog caption
- string caption = _("Boot Loader Settings: Section Management");
- return CWM::ShowAndRun ($[
- "widget_descr" : widget_descr,
- "widget_names" : widget_names,
- "contents" : contents,
- "caption" : caption,
- "back_button" : Label::BackButton (),
- "abort_button" : Label::AbortButton (),
- "next_button" : Label::OKButton (),
- "fallback_functions" : section_handlers,
- ]);
- }
-
- /**
- * Run dialog for kernel section editation
- * @return symbol for wizard sequencer
- */
- symbol ChainloaderSectionDialog () {
- y2milestone ("Running chainloader section dialog");
-
- term contents = `HBox (`HSpacing (4), `VBox (
- // label
- `Left (`Heading (_("Other System Section"))),
- `VSpacing (2),
- "name",
- `VStretch (),
- // part two - section settings
- `HBox (
- // frame
- `Frame (_("Section Settings"), `HBox (`HSpacing (2), `VBox (
- `VSpacing (2),
- `HBox (
- `HSpacing (4),
- "chainloader",
- `HSpacing (4)
- ),
- `VSpacing (2)
- ), `HSpacing (2)))),
- `VStretch ()
- ), `HSpacing (4));
-
- list<string> widget_names = ["name", "chainloader"];
- map<string,map<string,any> > widget_descr = (map<string,map<string,any> >)
- union (CommonSectionWidgets (), Bootloader::blWidgetMaps ());
- // dialog caption
- string caption = _("Boot Loader Settings: Section Management");
- return CWM::ShowAndRun ($[
- "widget_descr" : widget_descr,
- "widget_names" : widget_names,
- "contents" : contents,
- "caption" : caption,
- "back_button" : Label::BackButton (),
- "abort_button" : Label::AbortButton (),
- "next_button" : Label::OKButton (),
- "fallback_functions" : section_handlers,
- ]);
- }
-
- /**
- * Run dialog for kernel section editation
- * @return symbol for wizard sequencer
- */
- symbol AddNewSectionDialog () {
- y2milestone ("Running new section dialog");
-
- term contents = `HBox (`HStretch (), `VBox (
- `VStretch (),
- "section_type",
- `VStretch ()
- ), `HStretch ());
-
- list<string> widget_names = ["section_type"];
- map<string,map<string,any> > widget_descr = (map<string,map<string,any> >)
- union (CommonSectionWidgets (), Bootloader::blWidgetMaps ());
- // dialog caption
- string caption = _("Boot Loader Settings: Section Management");
- return CWM::ShowAndRun ($[
- "widget_descr" : widget_descr,
- "widget_names" : widget_names,
- "contents" : contents,
- "caption" : caption,
- "back_button" : Label::BackButton (),
- "abort_button" : Label::AbortButton (),
- "next_button" : Label::NextButton (),
- ]);
- }
-
- /**
- * Switch the section type to be edited
- * @return symbol for wizard sequencer to determine which dialog to show
- */
- symbol EditSectionSwitch () {
- string type = BootCommon::current_section["type"]:"";
- if (type == "chainloader")
- return `chainloader;
-
- else
- return `kernel;
- }
-
- /**
- * Store the modified section
- * @return symbol always `next
- */
- symbol StoreSection () {
- BootCommon::current_section["__changed"] = true;
- if (BootCommon::current_section["type"]:"" == "xen")
- {
- BootCommon::current_section = (map<string,any>)union (
- $[
- "xen" : BootCommon::UsingXenPae() ? "/boot/xen-pae.gz" : "/boot/xen.gz",
- "xen_append" : "",
- ],
- BootCommon::current_section);
- }
- y2milestone ("Storing section: index: %1, contents: %2",
- BootCommon::current_section_index,
- BootCommon::current_section);
- if (BootCommon::current_section_index == -1)
- {
- BootCommon::sections
- = add (BootCommon::sections, BootCommon::current_section);
- }
- else
- {
- BootCommon::sections[BootCommon::current_section_index]
- = BootCommon::current_section;
- }
- return `next;
- }
-
- /**
- * Run dialog
- * @return symbol for wizard sequencer
- */
- symbol runEditFilesDialog () ``{
- Bootloader::blSave (false, false, false);
- map<string,string> files = BootCommon::GetFilesContents ();
- string defaultv = files["default"]:"";
- files = filter (string k, string v, files, ``(k != "default"));
- list filenames = [];
- foreach (string k, string v, files, ``{
- filenames = add (filenames, k);
- });
- term cb = nil;
- if (size (files) > 1)
- cb = `ComboBox (`id (`filename), `opt (`notify, `hstretch),
- // combobox label
- _("&Filename"), filenames);
- else
- // label. %1 is name of file (eg. /etc/lilo.conf
- cb = `Left (`Label (sformat (_("Filename: %1"), filenames[0]:"")));
-
- term contents = `HBox (`HSpacing (2), `VBox (
- `VSpacing (2),
- cb,
- `VSpacing (2),
- `MultiLineEdit (`id (`file), `opt (`hstretch, `vstretch),
- // multiline edit header
- _("Fi&le Contents")),
- `VSpacing (2)
- ), `HSpacing (2));
-
- // dialog caption
- string caption = _("Expert Manual Configuration");
- string help = getExpertManualHelp ();
-
- list exits = [`back, `next, `abort, `ok, `apply, `accept];
-
- Wizard::SetContentsButtons (caption, contents, help,
- Label::BackButton (), Label::OKButton ());
-
- Wizard::RestoreBackButton ();
- Wizard::RestoreAbortButton ();
-
- string filename = filenames[0]:"";
- if (defaultv != "")
- filename = defaultv;
- if (size (files) > 1)
- UI::ChangeWidget (`id (`filename), `Value, filename);
- UI::ChangeWidget (`id (`file), `Value, files[filename]:"");
-
- any ret = nil;
- while (ret == nil || ! contains (exits, ret))
- {
- ret = UI::UserInput ();
- if (ret == `filename)
- {
- files[filename] = (string)UI::QueryWidget (`id (`file), `Value);
- filename = (string)UI::QueryWidget (`id (`filename), `Value);
- UI::ChangeWidget (`id (`file), `Value, files[filename]:"");
- }
- if (ret == `next)
- {
- files[filename] = (string)UI::QueryWidget (`id (`file), `Value);
- BootCommon::SetFilesContents (files);
- Bootloader::blRead (false);
- BootCommon::changed = true;
- BootCommon::location_changed = true;
- }
- if (ret == `abort)
- {
- if (! confirmAbortPopup ())
- ret = nil;
- }
- }
- return (symbol)ret;
- }
-
-
- }
-