[yast-commit] r54324 - in /trunk/sound: package/yast2-sound.changes sound/src/options.ycp

Author: lslezak Date: Mon Dec 22 11:09:14 2008 New Revision: 54324 URL: http://svn.opensuse.org/viewcvs/yast?rev=54324&view=rev Log: - allow entering only ASCII characters in the kernel module options dialog (bnc#447018) Modified: trunk/sound/package/yast2-sound.changes trunk/sound/sound/src/options.ycp Modified: trunk/sound/package/yast2-sound.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/package/yast2-sound.changes... ============================================================================== --- trunk/sound/package/yast2-sound.changes (original) +++ trunk/sound/package/yast2-sound.changes Mon Dec 22 11:09:14 2008 @@ -5,6 +5,8 @@ - abort immediately when there is no change (bnc#458317) - sound, joystick - hide the Back button in the overview dialog (bnc#440561, bnc#440559) +- allow entering only ASCII characters in the kernel module options + dialog (bnc#447018) ------------------------------------------------------------------- Tue Dec 2 12:48:10 CET 2008 - lslezak@suse.cz Modified: trunk/sound/sound/src/options.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/options.ycp?rev=5... ============================================================================== --- trunk/sound/sound/src/options.ycp (original) +++ trunk/sound/sound/src/options.ycp Mon Dec 22 11:09:14 2008 @@ -30,6 +30,8 @@ import "Wizard"; import "Label"; import "Popup"; + import "String"; + import "Report"; include "sound/ui.ycp"; // ReallyAbort include "sound/routines.ycp"; // get_module_params, restore_mod_params @@ -308,15 +310,9 @@ { y2milestone("possible_values: %1", possible_values); - term yes_button = `PushButton( `id(`ok), `opt(`default, `key_F10), Label::OKButton()); - term no_button = `PushButton( `id(`cancel), `opt (`key_F9), Label::CancelButton()); - - term button_box = `HBox( - `HStretch (), - `HWeight( 1, yes_button), - `HSpacing(2), - `HWeight( 1, no_button ), - `HStretch () + term button_box = `ButtonBox ( + `PushButton( `id(`ok), `opt(`okButton, `default, `key_F10), Label::OKButton()), + `PushButton( `id(`cancel), `opt(`cancelButton, `key_F9), Label::CancelButton()) ); list<term> items = getPossibleValues(possible_values, value); @@ -339,9 +335,50 @@ UI::OpenDialog(`opt(`decorated), content); - any ret = UI::UserInput(); - string option_name = new_option ? (string)UI::QueryWidget(`id(`option_name), `Value) : name; - string option_value = (string)UI::QueryWidget(`id(`option_value), `Value); + any ret = nil; + string option_name = ""; + string option_value = ""; + + while(true) + { + ret = UI::UserInput(); + + // validate the input + option_name = new_option ? (string)UI::QueryWidget(`id(`option_name), `Value) : name; + option_value = (string)UI::QueryWidget(`id(`option_value), `Value); + + // do not validate if the Cancel button has been pressed + if (ret == `cancel) + { + break; + } + + // all non-ASCII characters from value + string extra_chars = deletechars(option_value, String::CGraph()); + + if (extra_chars != "") + { + Report::Error(sformat(_("Value of the option contains invalid\ncharacters '%1'.\n\nEnter a valid value."), extra_chars)); + UI::SetFocus(`id(`option_value)); + continue; + } + + // check the option name if it's entered by user + if (new_option) + { + // all non-ASCII characters from name + extra_chars = deletechars(option_name, String::CGraph()); + + if (extra_chars != "") + { + Report::Error(sformat(_("Name of the option contains invalid\ncharacters '%1'.\n\nEnter a valid name."), extra_chars)); + UI::SetFocus(`id(`option_name)); + continue; + } + } + + break; + } UI::CloseDialog(); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
lslezak@svn.opensuse.org