Author: jreidinger
Date: Tue Mar 24 14:21:05 2009
New Revision: 56369
URL: http://svn.opensuse.org/viewcvs/yast?rev=56369&view=rev
Log:
simplicy browse buttons, remove browse from widget which need device
Modified:
branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/section_widgets.ycp
Modified: branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/section_widgets.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/section_widgets.ycp?rev=56369&r1=56368&r2=56369&view=diff
==============================================================================
--- branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/section_widgets.ycp (original)
+++ branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/section_widgets.ycp Tue Mar 24 14:21:05 2009
@@ -55,9 +55,23 @@
}
}
+boolean validate_initrd(string widget, map event){
+ string value = (string) UI::QueryWidget(`id(widget),`Value);
+ if (!Mode::installation() && !Mode::repair()){
+ if (!FileUtils::Exists(value)){
+ if (!Popup::YesNo(_("Initrd file doesn't exist now. Do you really want use it?"))){
+ UI::SetFocus(`id(widget));
+ return false;
+ }
+ }
+ }
+}
+
map validation_map = $[
"image" : validate_image,
+ "initrd" : validate_initrd,
];
+
/**
* Init function for widget value
* @param widget any id of the widget
@@ -115,6 +129,24 @@
*/
symbol HandleSectionBrowse (string widget, map event) {
string current = (string)UI::QueryWidget (`id (widget), `Value);
+ if (current == "" || current == nil)
+ current = "/boot";
+ // file open popup caption
+ current = UI::AskForExistingFile (current, "*", _("Select File"));
+ if (current != nil)
+ UI::ChangeWidget (`id (widget), `Value, current);
+ return nil;
+}
+
+/**
+ * Handle function of a widget (InputField + browse button)
+ * Asks for directory instead file
+ * @param widget any widget key
+ * @param event map event description of event that occured
+ * @return symbol nil
+ */
+symbol HandleSectionBrowseDirectory (string widget, map event) {
+ string current = (string)UI::QueryWidget (`id (widget), `Value);
// file open popup caption
current = UI::AskForExistingFile (current, "*", _("Select File"));
if (current != nil)
@@ -155,6 +187,14 @@
return ret;
}
+
+map SectionInputFieldBrowseDirectoryWidget(string label, string help, string id){
+ map ret = SectionInputFieldBrowseWidget(label,help,id);
+ ret["handle"] = HandleSectionBrowseDirectory;
+ return ret;
+}
+
+
void InitSectionInt(string widget){
integer value = tointeger(BootCommon::current_section[widget]:"0");
UI::ChangeWidget (`id (widget), `Value, value);
@@ -225,137 +265,8 @@
BootCommon::current_section[widget] = value;
}
-/**
- * Init function of widget
- * @param widget any id of the widget
- */
-void KernelImageInit (string widget) {
- string image = BootCommon::current_section["image"]:"";
- list<string> available = [image];
- UI::ChangeWidget (`id (widget), `Items, available);
- SectionOptionInit (widget);
-}
/**
- * Handle function of a widget
- * @param widget any widget key
- * @param event map event description of event that occured
- * @return symbol to return to wizard sequencer, or nil
- */
-symbol KernelImageHandle (string widget, map event) {
- string current = (string)UI::QueryWidget (`id (widget), `Value);
- // file open popup caption
- current = UI::AskForExistingFile (current, "*", _("Kernel Image"));
- if (current != nil)
- UI::ChangeWidget (`id (widget), `Value, current);
- return nil;
-}
-
-/**
- * Init function of widget
- * @param widget any id of the widget
- */
-void InitrdInit (string widget) {
- string initrd = BootCommon::current_section["initrd"]:"";
- list<string> available = [initrd];
- UI::ChangeWidget (`id (widget), `Items, available);
- SectionOptionInit (widget);
-}
-
-/**
- * Handle function of the initrd widget
- * @param widget any widget key
- * @param event map event description of event that occured
- * @return symbol to return to wizard sequencer, or nil
- */
-symbol InitrdHandle (string widget, map event) {
- string current = (string)UI::QueryWidget (`id (widget), `Value);
- // file open popup caption
- current = UI::AskForExistingFile (current, "*", _("Initial RAM Disk"));
- if (current != nil)
- UI::ChangeWidget (`id (widget), `Value, current);
- return nil;
-}
-
-/**
- * Init function of widget
- * @param widget any id of the widget
- */
-void XenInit (string widget) {
- string xen = BootCommon::current_section["xen"]:"";
- if (xen == "")
- xen = "/boot/xen.gz";
- list<string> available = [xen];
- UI::ChangeWidget (`id (widget), `Items, available);
- UI::ChangeWidget (`id (widget), `Value, xen );
-}
-
-/**
- * Handle function of a widget
- * @param widget any widget key
- * @param event map event description of event that occured
- * @return symbol to return to wizard sequencer, or nil
- */
-symbol XenHandle (string widget, map event) {
- string current = (string)UI::QueryWidget (`id (widget), `Value);
- // file open popup caption
- current = UI::AskForExistingFile (current, "*", _("Xen hypervisor"));
- if (current != nil)
- UI::ChangeWidget (`id (widget), `Value, current);
- return nil;
-}
-
-/**
- * Handle function of a widget
- * @param widget any widget key
- * @param event map event description of event that occured
- * @return symbol to return to wizard sequencer, or nil
- */
-symbol TargetHandle (string widget, map event) {
- string current = (string)UI::QueryWidget (`id (widget), `Value);
- // file open popup caption
- if (current == nil || current == "")
- current = "/boot";
- current = UI::AskForExistingDirectory (current, _("Target directory"));
- if (current != nil)
- UI::ChangeWidget (`id (widget), `Value, current);
- return nil;
-}
-
-/**
- * Handle function of a widget
- * @param widget any widget key
- * @param event map event description of event that occured
- * @return symbol to return to wizard sequencer, or nil
- */
-symbol ParmfileHandle (string widget, map event) {
- string current = (string)UI::QueryWidget (`id (widget), `Value);
- // file open popup caption
- if (current == nil || current == "")
- current = "/boot/";
- current = UI::AskForExistingFile (current, "*" , _("Select parmfile"));
- if (current != nil)
- UI::ChangeWidget (`id (widget), `Value, current);
- return nil;
-}
-
-/**
- * Handle function of a widget
- * @param widget any widget key
- * @param event map event description of event that occured
- * @return symbol to return to wizard sequencer, or nil
- */
-symbol DumptoHandle (string widget, map event) {
- string current = (string)UI::QueryWidget (`id (widget), `Value);
- // file open popup caption
- if (current == nil || current == "")
- current = "/dev/";
- current = UI::AskForExistingFile (current, "" , _("Select device"));
- if (current != nil)
- UI::ChangeWidget (`id (widget), `Value, current);
- return nil;
-}
-/**
* Init function of the root device widget
* @param widget any id of the widget
*/
@@ -436,21 +347,6 @@
}
/**
- * Handle function of the chainloader widget
- * @param widget any widget key
- * @param event map event description of event that occured
- * @return symbol to return to wizard sequencer, or nil
- */
-symbol ChainloaderHandle (string widget, map event) {
- string current = (string)UI::QueryWidget (`id (widget), `Value);
- // file open popup caption
- current = UI::AskForExistingFile (current, "*", _("Device to Boot"));
- if (current != nil)
- UI::ChangeWidget (`id (widget), `Value, current);
- return nil;
-}
-
-/**
* Widget for selecting section type
* @return term widget
*/
@@ -562,113 +458,31 @@
grub_descriptions["image"]:"image",
grub_help_messages["image"]:"",
"image"),
- "initrd" : $[
- "widget" : `custom,
- "custom_widget" : Stage::initial ()
- ? `InputField (`id ("initrd"), `opt (`hstretch),
- // text entry
- grub_descriptions["initrd"]:"initrd")
- : `HBox (
- `ComboBox (`id ("initrd"), `opt (`editable, `hstretch),
- // combo box
- grub_descriptions["initrd"]:"initrd",
- []),
- `VBox (
- `Label (""),
- `PushButton (`id (`initrd_browse),
- Label::BrowseButton ())
- )
- ),
- "init" : InitrdInit,
- "handle" : InitrdHandle,
- "handle_events" : [ `initrd_browse ],
- "help" : grub_help_messages["initrd"]:"",
- ],
- "xen" : $[
- "widget" : `custom,
- "custom_widget" : Stage::initial ()
- ? `InputField (`id ("xen"), `opt (`hstretch),
- _("Hypervisor")// text entry
- )
- : `HBox (
- `ComboBox (`id ("xen"), `opt (`editable, `hstretch),
- // combo box
- _("Hypervisor"),
- []),
- `VBox (
- `Label (""),
- `PushButton (`id (`xen_browse),
- Label::BrowseButton ())
- )
- ),
- "init" : XenInit,
- "handle" : XenHandle,
- "handle_events" : [ `xen_browse ],
- "help" : grub_help_messages["xen"]:"",
- ],
- "target" : $[
- "widget" : `custom,
- "custom_widget" :
- `HBox (
- `InputField (`id ("target"), `opt (`hstretch),
- zipl_descriptions["target"]:"target"),
- `VBox (
- `Label (""),
- `PushButton (`id (`target_browse),
- Label::BrowseButton ())
- )
- ),
- "handle" : TargetHandle,
- "handle_events" : [ `target_browse ],
- "help" : zipl_help_messages["target"]:"",
- ],
- "parmfile" : $[
- "widget" : `custom,
- "custom_widget" :
- `HBox (
- `InputField (`id ("parmfile"), `opt (`hstretch),
- zipl_descriptions["parmfile"]:"parmfile"),
- `VBox (
- `Label (""),
- `PushButton (`id (`parm_browse),
- Label::BrowseButton ())
- )
- ),
- "handle" : ParmfileHandle,
- "handle_events" : [ `parm_browse ],
- "help" : zipl_help_messages["parmfile"]:"",
- ],
- "dumpto" : $[
- "widget" : `custom,
- "custom_widget" :
- `HBox (
- `InputField (`id ("dumpto"), `opt (`hstretch),
- zipl_descriptions["dumpto"]:"dumpto"),
- `VBox (
- `Label (""),
- `PushButton (`id (`dumpto_browse),
- Label::BrowseButton ())
- )
- ),
- "handle" : DumptoHandle,
- "handle_events" : [ `dumpto_browse ],
- "help" : zipl_help_messages["dumpto"]:"",
+ "initrd" : SectionInputFieldBrowseWidget(
+ grub_descriptions["initrd"]:"initrd",
+ grub_help_messages["initrd"]:"",
+ "initrd"),
+ "xen" : SectionInputFieldBrowseWidget(
+ grub_descriptions["xen"]:"xen",
+ grub_help_messages["xen"]:"",
+ "xen"),
+ "target" : SectionInputFieldBrowseDirectoryWidget(
+ zipl_descriptions["target"]:"target",
+ zipl_help_messages["target"]:"",
+ "target"),
+ "parmfile" : SectionInputFieldBrowseWidget(
+ zipl_descriptions["parmfile"]:"parmfile",
+ zipl_help_messages["parmfile"]:"",
+ "parmfile"),
+ "dumpto" : $[ //FIXME when exist browse device use it
+ "label" : zipl_descriptions["dumpto"]:"dumpto",
+ "widget" : `textentry,
+ "help" : zipl_help_messages["dumpto"]:""
],
- "dumptofs" : $[
- "widget" : `custom,
- "custom_widget" :
- `HBox (
- `InputField (`id ("dumptofs"), `opt (`hstretch),
- zipl_descriptions["dumptofs"]:"dumptofs"),
- `VBox (
- `Label (""),
- `PushButton (`id (`dumptofs_browse),
- Label::BrowseButton ())
- )
- ),
- "handle" : DumptoHandle,
- "handle_events" : [ `dumptofs_browse ],
- "help" : zipl_help_messages["dumptofs"]:"",
+ "dumptofs" : $[ //FIXME when exist browse device use it
+ "label" : zipl_descriptions["dumptofs"]:"dumptofs",
+ "widget" : `textentry,
+ "help" : zipl_help_messages["dumptofs"]:""
],
"root" : $[
"widget" : `combobox,
@@ -689,7 +503,6 @@
"help" : grub_help_messages["vgamode"]:"",
],
"append" : $[
- // text entry
"label" : grub_descriptions["append"]:"append",
"widget" : `textentry,
"help" : grub_help_messages["append"]:""
@@ -710,23 +523,10 @@
"help" : zipl_help_messages["list"]:"",
],
"chainloader" : $[
- "widget" : `custom,
- "custom_widget" : `HBox (
- `ComboBox (`id ("chainloader"),
- `opt (`editable, `hstretch),
- // combo box
- grub_descriptions["chainloader"]:"chainloader",
- []),
- `VBox (
- `Label (""),
- `PushButton (`id (`chainloader_browse),
- Label::BrowseButton ())
- )
- ),
+ "widget" : `combobox,
"init" : ChainloaderInit,
- "handle" : ChainloaderHandle,
- "handle_events" : [ `chainloader_browse ],
- "help" : grub_help_messages["chainloader"]:""
+ "help" : grub_help_messages["chainloader"]:"",
+ "opt" : [ `editable, `hstretch ],
],
"section_type" : $[
"widget" : `func,
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org