Class: Yast::IconClass
- Inherits:
-
Module
- Object
- Module
- Yast::IconClass
- Defined in:
- library/general/src/modules/Icon.rb
Instance Method Summary collapse
-
#Error ⇒ Yast::Term
Returns UI term `Image() widget with an error-icon.
-
#Image(icon_type, options) ⇒ Object
Returns `Image() term defined by parameters.
-
#Info ⇒ Yast::Term
Returns UI term `Image() widget with an info-icon.
- #LazyInit ⇒ Object
- #main ⇒ Object
-
#Simple(icon_type) ⇒ Object
Function calls Icon::Image with default options.
-
#Warning ⇒ Yast::Term
Returns UI term `Image() widget with a warning-icon.
Instance Method Details
#Error ⇒ Yast::Term
Returns UI term `Image() widget with an error-icon.
139 140 141 |
# File 'library/general/src/modules/Icon.rb', line 139 def Error Image("error", {}) end |
#Image(icon_type, options) ⇒ Object
Returns Image() term defined by parameters. Returns
Empty() if the current
UI doesn't support images.
Structure:
options = $[
"id" : any_icon_id,
"label" : (string) icon_label, // (used if icon is missing)
"margin_left" : 0, // HSpacing on the left
"margin_right" : 5, // HSpacing on the right
]
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'library/general/src/modules/Icon.rb', line 89 def Image(icon_type, ) = deep_copy() LazyInit() return Empty() if !@has_image_support icon_id = Ops.get(, "id") icon_id = Builtins.sformat("icon_id_%1", icon_type) if icon_id.nil? icon_label = Ops.get_string(, "label", icon_type) icon_name = Ops.get(@icons_map, icon_type) ? Ops.get(@icons_map, icon_type, "") : icon_type this_image = term(:Image, Id(icon_id), icon_name, icon_label) # left and/or right margin defined if Ops.get_integer(, "margin_left", 0) != 0 || Ops.get_integer(, "margin_right", 0) != 0 ret = HBox( HSpacing(Ops.get_integer(, "margin_left", 0)), this_image, HSpacing(Ops.get_integer(, "margin_right", 0)) ) deep_copy(ret) # no margin defined else deep_copy(this_image) end end |
#Info ⇒ Yast::Term
Returns UI term `Image() widget with an info-icon.
146 147 148 |
# File 'library/general/src/modules/Icon.rb', line 146 def Info Image("info", {}) end |
#LazyInit ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'library/general/src/modules/Icon.rb', line 42 def LazyInit return if !@has_image_support.nil? display_info = UI.GetDisplayInfo @has_image_support = Ops.get_boolean( display_info, "HasImageSupport", false ) @icons_map = { "warning" => "dialog-warning", "info" => "dialog-information", "error" => "dialog-error", "question" => "dialog-question" } nil end |
#main ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'library/general/src/modules/Icon.rb', line 33 def main Yast.import "UI" textdomain "base" @has_image_support = nil @icons_map = {} end |
#Simple(icon_type) ⇒ Object
Function calls Icon::Image with default options
125 126 127 |
# File 'library/general/src/modules/Icon.rb', line 125 def Simple(icon_type) Image(icon_type, {}) end |
#Warning ⇒ Yast::Term
Returns UI term `Image() widget with a warning-icon.
132 133 134 |
# File 'library/general/src/modules/Icon.rb', line 132 def Warning Image("warning", {}) end |