Class: Yast::IconClass
- Inherits:
-
Module
- Object
- Module
- Yast::IconClass
- Defined in:
- ../../library/general/src/modules/Icon.rb
Instance Method Summary (collapse)
-
- (Yast::Term) Error
Returns UI term `Image() widget with an error-icon.
-
- (Object) IconPath(icon_type)
Returns path to an image.
-
- (Object) Image(icon_type, options)
Returns `Image() term defined by parameters.
-
- (Yast::Term) Info
Returns UI term `Image() widget with an info-icon.
- - (Object) LazyInit
- - (Object) main
-
- (Object) Simple(icon_type)
Function calls Icon::Image with default options.
-
- (Yast::Term) Warning
Returns UI term `Image() widget with a warning-icon.
Instance Method Details
- (Yast::Term) Error
Returns UI term `Image() widget with an error-icon.
177 178 179 |
# File '../../library/general/src/modules/Icon.rb', line 177 def Error Image("error", {}) end |
- (Object) IconPath(icon_type)
Returns path to an image
Icon::IconPath (“warning”) -> “/usr/share/YaST2/theme/current/icons/32x32/apps/msg_warning.png”
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File '../../library/general/src/modules/Icon.rb', line 80 def IconPath(icon_type) LazyInit() icon_path = nil if Ops.get(@icons_map, icon_type) icon_path = Ops.add( @icon_32x32_path, Ops.get(@icons_map, icon_type, "") ) else icon_path = Ops.add(Ops.add(@icon_32x32_path, icon_type), ".png") Builtins.y2debug( "Image '%1' is not defined, using '%2'", icon_type, icon_path ) end icon_path end |
- (Object) Image(icon_type, options)
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
]
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File '../../library/general/src/modules/Icon.rb', line 129 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) this_image = term(:Image, Id(icon_id), IconPath(icon_type), 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)) ) return deep_copy(ret) # no margin defined else return deep_copy(this_image) end end |
- (Yast::Term) Info
Returns UI term `Image() widget with an info-icon.
184 185 186 |
# File '../../library/general/src/modules/Icon.rb', line 184 def Info Image("info", {}) end |
- (Object) LazyInit
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File '../../library/general/src/modules/Icon.rb', line 47 def LazyInit return if !@has_image_support.nil? display_info = UI.GetDisplayInfo @has_image_support = Ops.get_boolean( display_info, "HasImageSupport", false ) @icon_32x32_path = Ops.add( Directory.themedir, "/current/icons/32x32/apps/" ) @icons_map = { "warning" => "msg_warning.png", "info" => "msg_info.png", "error" => "msg_error.png", "question" => "msg_question.png" } nil end |
- (Object) main
35 36 37 38 39 40 41 42 43 44 45 |
# File '../../library/general/src/modules/Icon.rb', line 35 def main Yast.import "UI" textdomain "base" Yast.import "Directory" @has_image_support = nil @icons_map = {} @icon_32x32_path = nil end |
- (Object) Simple(icon_type)
Function calls Icon::Image with default options
163 164 165 |
# File '../../library/general/src/modules/Icon.rb', line 163 def Simple(icon_type) Image(icon_type, {}) end |
- (Yast::Term) Warning
Returns UI term `Image() widget with a warning-icon.
170 171 172 |
# File '../../library/general/src/modules/Icon.rb', line 170 def Warning Image("warning", {}) end |