Skip to content

Commit

Permalink
new generation of popup library
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Nov 13, 2017
1 parent f38c87b commit 8e24912
Show file tree
Hide file tree
Showing 8 changed files with 472 additions and 1 deletion.
1 change: 1 addition & 0 deletions library/general/example/popup_manual_tester.sh
@@ -0,0 +1 @@
Y2DIR=$(dirname "$0")/../src /sbin/yast2 $(dirname "$0")/popup_params.rb
43 changes: 43 additions & 0 deletions library/general/example/popup_params.rb
@@ -0,0 +1,43 @@
# rubocop:disable all
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
56 changes: 56 additions & 0 deletions library/general/example/popup_serie.rb
@@ -0,0 +1,56 @@
require "yast"

require "yast2/popup"

Yast2::Popup.show("Simple text")

Yast2::Popup.show("Long text\n" * 50)

Yast2::Popup.show("Simple text with details", details: "More details here")

Yast2::Popup.show("Simple text with timeout", timeout: 10)

Yast2::Popup.show("Continue/Cancel buttons", buttons: :continue_cancel)

Yast2::Popup.show("Yes/No buttons", buttons: :yes_no)

Yast2::Popup.show("Yes/No buttons with No focused", buttons: :yes_no, focus: :no)

Yast2::Popup.show("Yes/No buttons with timeout returning focused item", buttons: :yes_no, focus: :no, timeout: 10)

Yast2::Popup.show("Own buttons", buttons: { button1: "button 1", button2: "button 2" }, focus: :button2)

Yast2::Popup.show("Richtext is set to <b>false</b>", richtext: false)

Yast2::Popup.show("Richtext is set to <b>:auto</b>", richtext: :auto)

Yast2::Popup.show("Long text. Richtext is set to <b>:auto</b>\n" * 50, richtext: :auto)

Yast2::Popup.show("Richtext is set to <b>true</b>", richtext: true)

Yast2::Popup.show("Long text. Richtext is set to <b>true</b><br>" * 50, richtext: true)

Yast2::Popup.show("Long text with newlines. Richtext is set to <b>true</b>\n" * 50, richtext: true)

Yast2::Popup.show(":notice style", style: :notice)

Yast2::Popup.show(":important style", style: :important)

Yast2::Popup.show(":warning style", style: :warning)

Yast2::Popup.show("Headline set", headline: "Headline")

Yast2::Popup.show("Headline set to :error", headline: :error)

Yast2::Popup.show(
"All options",
headline: "Headline",
details: "details",
timeout: 10,
buttons: :yes_no,
focus: :no,
richtext: false,
style: :important
)

Yast2::Popup.feedback("feedback for time consuming operation", headline: "Syncing...") { sleep(5) }
1 change: 1 addition & 0 deletions library/general/example/popup_series_tester.sh
@@ -0,0 +1 @@
Y2DIR=$(dirname "$0")/../src /sbin/yast2 $(dirname "$0")/popup_serie.rb
6 changes: 5 additions & 1 deletion library/general/src/Makefile.am
Expand Up @@ -93,7 +93,11 @@ ylib2_DATA = \
lib/ui/text_helpers.rb \
lib/ui/widgets.rb

EXTRA_DIST = $(module_DATA) $(client_DATA) $(scrconf_DATA) $(agent_SCRIPTS) $(ydata_DATA) $(fillup_DATA) $(ylib_DATA) $(ylib2_DATA)
ylib3dir = "${yast2dir}/lib/yast2"
ylib3_DATA = \
lib/yast2/popup.rb

EXTRA_DIST = $(module_DATA) $(client_DATA) $(scrconf_DATA) $(agent_SCRIPTS) $(ydata_DATA) $(fillup_DATA) $(ylib_DATA) $(ylib2_DATA) $(ylib3_DATA)


include $(top_srcdir)/Makefile.am.common

0 comments on commit 8e24912

Please sign in to comment.