-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f38c87b
commit 14495c1
Showing
4 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require "yast" | ||
|
||
require "yast2/popup" | ||
|
||
Yast.import "UI" | ||
|
||
include Yast::UIShortcuts | ||
|
||
def code(params) | ||
"Yast2::Popup.show(#{params})" | ||
end | ||
|
||
content = VBox( | ||
InputField(Id(:params), Opt(:notify), "Popup Params:"), | ||
VSpacing(1), | ||
InputField(Id(:code), Opt(:disable), "Code to run:"), | ||
VSpacing(1), | ||
PushButton(Id(:call), "Show") | ||
) | ||
|
||
Yast::UI.OpenDialog(content) | ||
loop do | ||
ret = Yast::UI.UserInput | ||
case ret | ||
when :params | ||
value = Yast::UI.QueryWidget(:params, :Value) | ||
Yast::UI.ChangeWidget(:code, :Value, code(value)) | ||
when :cancel | ||
break | ||
when :call | ||
begin | ||
value = Yast::UI.QueryWidget(:params, :Value) | ||
eval (code(value)) | ||
rescue => e | ||
Yast2::Popup.show("Failed with #{e.message}") | ||
end | ||
end | ||
end | ||
|
||
Yast::UI.CloseDialog | ||
|
||
nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Y2DIR=$(dirname "$0")/../src /sbin/yast2 $(dirname "$0")/popup_params.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module Yast2 | ||
class Popup | ||
class << self | ||
# Shows popup and return which symbol of pressed button | ||
# @param message [String] message to show | ||
# @param details [String, nil] hidden details that can be shown, if nil do not show | ||
# @param headline [Symbol, String] sets popup headline. String is shown and there is | ||
# predefined sets of symbols for common headlines. Set contain `:error`, `:warning` | ||
# @param timeout [Integer] how long wait till autoclose dialog. 0 means wait forever. | ||
# @param buttons [Hash<Symbol, String>, Symbol] specified which buttons popup will have. | ||
# it can be hash in format button_id => button_text, showed in same order as in hash. | ||
# The second option is symbol that specify one of predefined set of buttons. | ||
# Current set of predefined buttons are `:ok`, `:yes_no`, `:ok_cancel` | ||
# @param focus [Symbol, nil] what button focus. | ||
# Also it is button which is returned if timeout exceed. | ||
# if it is nil, then choose the first button. See buttons parameter. | ||
# @param richtext [Boolean] if use richtext widget. | ||
# Useful when report contain richtext tags or is long, so it have to be scrollable. | ||
# | ||
# @example pair of old and new API calls | ||
# Yast::Popup.Message(text) | ||
# Yast2::Popup.show(text) | ||
# | ||
# Yast::Popup.MessageDetails(text, details) | ||
# Yast2::Popup.show(text, details: details) | ||
# | ||
# Yast::Popup.TimedError(text, seconds) | ||
# Yast2::Popup.show(text, headline: :error, timeout: seconds) | ||
# | ||
# Yast::Popup.TimedErrorAnyQuestion(headline, message, yes_button_message, no_button_message, focus, timeout_seconds) | ||
# Yast2::Popup.show(message, headline: headline, timeout: timeout_seconds, buttons: { yes: yes_button_message, no: no_button_message), focus: :yes) | ||
|
||
# Yast::Popup.TimedLongNotify(message, timeout_seconds) | ||
# Yast2::Popup.show(message, richtext: true, timeout: timeout_seconds) | ||
def show(message, details: nil, headline: "", timeout: 0, focus: nil, buttons: :ok, richtext: false) | ||
end | ||
end | ||
end |