-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #532 from yast/all-in-one-overview
All in one overview
- Loading branch information
Showing
6 changed files
with
288 additions
and
7 deletions.
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,65 @@ | ||
# Simple example to demonstrate object oriented replace_point widget | ||
|
||
require_relative "example_helper" | ||
|
||
require "yast" | ||
|
||
require "cwm/widget" | ||
|
||
Yast.import "UI" | ||
Yast.import "CWM" | ||
Yast.import "Wizard" | ||
|
||
class SwitchWidget < CWM::PushButton | ||
def initialize(replace_point, widgets) | ||
@replace_point = replace_point | ||
@widgets = widgets | ||
end | ||
|
||
def label | ||
"Switch" | ||
end | ||
|
||
def handle | ||
@widgets.rotate! | ||
@replace_point.replace(@widgets.first) | ||
end | ||
end | ||
|
||
class PopupButtonWidget < CWM::PushButton | ||
def label | ||
"Popup" | ||
end | ||
|
||
def handle | ||
Yast::Popup.Message("Click!") | ||
end | ||
end | ||
|
||
class StoreWidget < CWM::InputField | ||
def label | ||
"write here" | ||
end | ||
|
||
def validate | ||
return true unless value.empty? | ||
|
||
Yast::Popup.Error("Empty value!") | ||
false | ||
end | ||
|
||
def store | ||
Yast::Popup.Message(value) | ||
end | ||
end | ||
|
||
widgets = [PopupButtonWidget.new, CWM::Empty.new(:empty), StoreWidget.new] | ||
replace_point = CWM::ReplacePoint.new(widget: widgets.first) | ||
|
||
content = Yast::Term.new(:VBox, | ||
SwitchWidget.new(replace_point, widgets), | ||
replace_point) | ||
|
||
Yast::Wizard.CreateDialog | ||
Yast::CWM.show(content) | ||
Yast::Wizard.CloseDialog |
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
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
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