home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
boot
/
i386
/
root
/
usr
/
share
/
YaST2
/
include
/
bootloader
/
generic
/
sections_widget.ycp
< prev
next >
Wrap
Text File
|
2006-11-29
|
6KB
|
247 lines
/**
* File:
* include/bootloader/generic/sections_widget.ycp
*
* Module:
* Bootloader installation and configuration
*
* Summary:
* Common widgets for being used by several bootloaders
*
* Authors:
* Jiri Srain <jsrain@suse.cz>
* alterered by jplack@suse.de
*
* $Id: sections_widget.ycp 33332 2006-10-12 07:37:32Z jplack $
*
*/
{
textdomain "bootloader";
include "bootloader/routines/popups.ycp";
// sections list widget
/**
* Refresh and redraw widget wits sections
* @param sects list of current sections
*/
void _RedrawSectionsTable (list<map<string,any> > sects) {
/*
boolean elilo = Bootloader::getLoaderType () == "elilo";
list sec = maplist (map<string,any> s, sects, {
string image = s["kernel"]:"";
string root = s["root"]:"";
return `item (`id (s["name"]:""),
tolower (BootCommon::globals["default"]:"")
== tolower (s["name"]:"")
? UI::Glyph (`CheckMark) : "",
s["name"]:"",
(image == nil || image == "")
// table header
? _("Other")
// table header
: _("Image"),
(image != "" && image != nil)
? sformat ("%1 (%2%3)",
image,
elilo
? ""
: BootCommon::splitPath (image)[0]:"",
root == "" ? ""
: ((elilo ? "" : ", ")
+ sformat ("root=%1", root)))
: s["chainloader"]:""
);
});
*/
list sec = maplist (map<string,any> s, sects, {
string name = s["name"]:"";
string type = s["type"]:"";
string summary = mergestring(
maplist(
string k, any v,
filter(string k, any v, s,
``( k!="name" && k!="type" && k!="lines_cache_id" &&
substring(k,0,2) != "__" && k!="initial" && k!="original_name" &&
v != "false"
)
),
{
return (v=="true") ? k : k + "=" + tostring(v);
}
),
", "
);
// Upcase word 'type'
type = toupper(substring(type,0,1)) + substring(type,1);
return `item (`id (name),
BootCommon::globals["default"]:"" == name ? UI::Glyph (`CheckMark) : "",
name,
type,
summary
);
});
UI::ChangeWidget (`id (`sects), `Items, sec);
}
/**
* Init function of widget
* @param widget string id of the widget
*/
void _SectionsInit (string widget) {
_RedrawSectionsTable (BootCommon::sections);
UI::SetFocus (`id (`sects));
}
/**
* Handle function of a widget
* @param widget string widget key
* @param event map event description of event that occured
* @return symbol to return to wizard sequencer, or nil
*/
symbol _SectionsHandle (string widget, map event) {
any op = event["ID"]:nil;
if (event["ID"]:nil == `sects
&& event["EventReason"]:"" == "Activated"
&& event["EventType"]:"" == "WidgetEvent")
{
op = `edit;
}
y2milestone ("Handling sections widget, event %1", op);
string current = (string)UI::QueryWidget (`id (`sects), `CurrentItem);
integer counter = 0;
integer index = 0;
foreach (map<string,any> s, BootCommon::sections, {
if (s["name"]:"" == current)
index = counter;
counter = counter + 1;
});
list<map<string,any> > sects = BootCommon::sections;
if (op == `up)
{
if (index > 0)
{
sects = (list<map<string,any > >)
BootCommon::swapItems(sects, index, index - 1);
index = index - 1;
BootCommon::sections = sects;
_RedrawSectionsTable (sects);
UI::ChangeWidget (`id (`sects), `CurrentItem,
sects[index, "name"]:"");
BootCommon::changed = true;
}
}
else if (op == `down)
{
if (index < (size(sects) - 1))
{
sects = (list<map<string,any> >)
BootCommon::swapItems(sects, index, index + 1);
index = index + 1;
BootCommon::sections = sects;
_RedrawSectionsTable (sects);
UI::ChangeWidget (`id (`sects), `CurrentItem,
sects[index, "name"]:"");
BootCommon::changed = true;
}
}
else if (op == `default)
{
BootCommon::globals["default"] = current;
_RedrawSectionsTable (sects);
UI::ChangeWidget (`id (`sects), `CurrentItem, current);
BootCommon::changed = true;
}
else if (op == `add || op == `edit)
{
map<string,any> selected = sects[index]:$[];
string name = selected["name"]:"";
BootCommon::current_section = selected;
BootCommon::current_section_index = op == `add ? -1 : index;
BootCommon::current_section_name = name;
y2internal ("Selected section: %1", BootCommon::current_section);
return (symbol)op;
}
else if (op == `delete && confirmSectionDeletePopup (current))
{
BootCommon::removed_sections = add (BootCommon::removed_sections,
sects[index, "original_name"]:"");
sects = remove (sects, index);
if (current == BootCommon::globals["default"]:"")
{
BootCommon::globals["default"] = BootCommon::sections[0, "name"]:"";
}
BootCommon::sections = sects;
_RedrawSectionsTable (sects);
BootCommon::changed = true;
}
UI::SetFocus (`id (`sects));
return nil;
}
/**
* Get map of widget
* @return a map of widget
*/
map<string,any> genericSectionsListWidget () {
return $[
"widget" : `custom,
"custom_widget" : `VBox (
`HBox (
`Table (`id (`sects),
`opt (`keepSorting, `notify),
`header (
// table header, Def stands for default
_("Def."),
// table header
_("Label"),
// table header
_("Type"),
// table header; header for section details, either
// the specification of the kernel image to load,
// or the specification of device to boot from
_("Section Summary")
), []),
`HSpacing (1),
`VBox (
`VStretch (),
// pushbutton
`PushButton (`id (`up), _("&Up")),
// pushbutton
`PushButton (`id (`down), _("&Down")),
`VStretch ()
)
),
`HBox (
`PushButton (`id (`add), `opt (`key_F3), Label::AddButton ()),
`PushButton (`id (`edit), `opt (`key_F4), Label::EditButton ()),
`PushButton (`id (`delete), `opt (`key_F5),
Label::DeleteButton ()),
`HStretch (),
// pushbutton
`PushButton (`id (`default), _("Set as De&fault"))
)
),
"init" : _SectionsInit,
"handle" : _SectionsHandle,
"help" : generic_Help("section-list"),
];
}
} // include end