[yast-commit] r63922 - in /branches/SuSE-Code-11-SP2-Branch/yast2/library/modules: Popup.ycp Report.ycp
Author: aschnell Date: Fri May 6 14:31:39 2011 New Revision: 63922 URL: http://svn.opensuse.org/viewcvs/yast?rev=63922&view=rev Log: - backported some functions need by storag Modified: branches/SuSE-Code-11-SP2-Branch/yast2/library/modules/Popup.ycp branches/SuSE-Code-11-SP2-Branch/yast2/library/modules/Report.ycp Modified: branches/SuSE-Code-11-SP2-Branch/yast2/library/modules/Popup.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/yast2/... ============================================================================== --- branches/SuSE-Code-11-SP2-Branch/yast2/library/modules/Popup.ycp (original) +++ branches/SuSE-Code-11-SP2-Branch/yast2/library/modules/Popup.ycp Fri May 6 14:31:39 2011 @@ -329,7 +329,7 @@ symbol focus ) { term button_box = AnyQuestionButtonBox ( yes_button_message, no_button_message, focus); - boolean success = (boolean) UI::OpenDialog( + boolean success = (boolean) UI::OpenDialog( `opt(`decorated), popupLayoutInternal( headline, message, Icon::IconPath ("question"), button_box ) ); @@ -346,6 +346,52 @@ /** + * Generic error question popup with two buttons. + * + * Style guide hint: The first button has to have the semantics of "yes", + * "OK", "continue" etc., the second its opposite ("no", "cancel", ...). + * NEVER use this generic question popup to simply exchange the order of + * yes/no, continue/cancel or ok/cancel buttons! + * + * @param headline headline or Popup::NoHeadline() + * @param message message string + * @param yes_button_message label on affirmative buttons (on left side) + * @param no_button_message label on negating button (on right side) + * @param focus `focus_yes (first button) or `focus_no (second button) + * @screenshot screenshots/AnyQuestion.png + * + * @return true: first button has been clicked + * false: second button has been clicked + * + * @see YesNo + * @see ContinueCancel + * + * @example Popup::ErrorAnyQuestion( Label::WarningMsg(), "Do really want to ...?", "Install", "Don't do it", `focus_no ); + */ +global boolean ErrorAnyQuestion(string headline, + string message, + string yes_button_message, + string no_button_message, + symbol focus) +{ + term button_box = AnyQuestionButtonBox ( yes_button_message, no_button_message, focus); + boolean success = (boolean) UI::OpenDialog( + `opt(`decorated), + popupLayoutInternal( headline, message, Icon::IconPath ("error"), button_box ) + ); + + any ret = nil; + + if (success == true) { + ret = UI::UserInput(); + UI::CloseDialog(); + } + + return ret == `yes; +} + + +/** * Timed question popup with two buttons and time display * * @param headline headline or Popup::NoHeadline() @@ -411,6 +457,71 @@ /** + * Timed error question popup with two buttons and time display + * + * @param headline headline or Popup::NoHeadline() + * @param message message string + * @param yes_button_message label on affirmative buttons (on left side) + * @param no_button_message label on negating button (on right side) + * @param focus `focus_yes (first button) or `focus_no (second button) + * @param timeout_seconds timeout, if 0, normal behaviour + * @return boolean True if Yes, False if no + * @see AnyQuestion + */ +global boolean TimedErrorAnyQuestion( string headline, + string message, + string yes_button_message, + string no_button_message, + symbol focus , + integer timeout_seconds) +{ + term button_box = AnyQuestionButtonBox ( yes_button_message, no_button_message, focus); + term timed = + `ReplacePoint(`id(`replace_buttons) , + `VBox( + `HCenter( + `Label(`id(`remaining_time), "" + timeout_seconds) + ), + `ButtonBox ( + // FIXME: BNC #422612, Use `opt(`noSanityCheck) later + `PushButton (`id (`timed_stop), `opt (`cancelButton), Label::StopButton()), + `PushButton (`id (`timed_ok), `opt (`default, `key_F10, `okButton), Label::OKButton()) + ), + `VSpacing(0.2) + ) + ); + + + boolean success = (boolean) UI::OpenDialog( + `opt(`decorated), + popupLayoutInternal( headline, message, Icon::IconPath ("error"), timed ) + ); + + any which_input = nil; + + while (timeout_seconds > 0) { + which_input = UI::TimeoutUserInput( 1000 ); + + if (which_input == `timed_ok) + break; + if (which_input == `timed_stop) + { + UI::ReplaceWidget(`id(`replace_buttons), button_box); + while (which_input == `timed_stop) + which_input = UI::UserInput(); + break; + } + timeout_seconds = timeout_seconds - 1; + if (success == true) UI::ChangeWidget (`id(`remaining_time), `Value, ""+timeout_seconds); + } + + if (success == true) UI::CloseDialog(); + + return which_input == `yes; +} + + +/** * Dialog which displays the "message" and has a <b>Continue</b> * and a <b>Cancel</b> button. * @@ -928,7 +1039,7 @@ { anyMessageInternal( headline, message, Icon::IconPath ("info") ); } - + /** * Clear feedback message Modified: branches/SuSE-Code-11-SP2-Branch/yast2/library/modules/Report.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/yast2/... ============================================================================== --- branches/SuSE-Code-11-SP2-Branch/yast2/library/modules/Report.ycp (original) +++ branches/SuSE-Code-11-SP2-Branch/yast2/library/modules/Report.ycp Fri May 6 14:31:39 2011 @@ -128,7 +128,7 @@ // '%1' will be replaced by translated string "Yes" or "No" summary = Summary::AddListItem(summary, sformat(_("Log Errors: %1"), (log_errors) ? // translators: summary if the errors should be written to log file - _("Yes") + _("Yes") // translators: summary if the errors should be written to log file : _("No"))); summary = Summary::CloseList(summary); @@ -328,6 +328,57 @@ return ret; } + +/** + * Question with headline and Yes/No Buttons + * @param headline Popup Headline + * @param message Popup Message + * @param yes_button_message Yes Button Message + * @param no_button_message No Button Message + * @param focus Which Button has the focus + * @return boolean True if Yes is pressed, otherwise false + */ +global boolean ErrorAnyQuestion(string headline, + string message, + string yes_button_message, + string no_button_message, + symbol focus) +{ + if (log_yesno_messages) + { + y2milestone(1, "%1", message); + } + + boolean ret = false; + if (display_yesno_messages) + { + if (timeout_yesno_messages > 0) + { + ret = Popup::TimedErrorAnyQuestion( + headline, + message, + yes_button_message, + no_button_message, + focus, + timeout_yesno_messages); + } + else + { + ret = Popup::ErrorAnyQuestion( + headline, + message, + yes_button_message, + no_button_message, + focus ); + + } + } + + yesno_messages = add(yesno_messages, message); + return ret; +} + + /** * Store new message text * @param message_string message text, it can contain new line characters ("\n") -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
aschnell@svn2.opensuse.org