Module: UI::Greasemonkey
- Extended by:
- Yast::UIShortcuts
- Includes:
- Yast::UIShortcuts
- Defined in:
- library/general/src/lib/ui/greasemonkey.rb
Overview
UI layout helpers.
These started out in the Expert Partitioner in yast2-storage. The use case is reusing pieces of this legacy code in the new yast2-partitioner. That is why the API and the implementation look old.
Constant Summary collapse
Class Method Summary collapse
- .ComboBoxSelected(old) ⇒ Yast::Term
- .FrameWithMarginBox(old) ⇒ Yast::Term
- .IconAndHeading(old) ⇒ Yast::Term
- .LeftCheckBox(old) ⇒ Yast::Term
-
.LeftCheckBoxWithAttachment(old) ⇒ Yast::Term
NOTE: that it does not expand the nested Greasemonkey term LeftCheckBox! #transform does that.
- .LeftRadioButton(old) ⇒ Yast::Term
-
.LeftRadioButtonWithAttachment(old) ⇒ Yast::Term
NOTE: that it does not expand the nested Greasemonkey term LeftRadioButton! #transform does that.
-
.Transform(old) ⇒ Yast::Term
Recursively apply all Greasemonkey methods on old.
-
.transform ⇒ Yast::Term
Recursively apply all Greasemonkey methods on old.
-
.VStackFrames(old) ⇒ Yast::Term
Wrap terms in a VBox with small vertical spacings in between.
Class Method Details
.ComboBoxSelected(old) ⇒ Yast::Term
125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'library/general/src/lib/ui/greasemonkey.rb', line 125 def ComboBoxSelected(old) args = Builtins.argsof(old) tmp = Builtins.sublist(args, 0, Ops.subtract(Builtins.size(args), 2)) items = Ops.get_list(args, Ops.subtract(Builtins.size(args), 2), []) id = Ops.get_term(args, Ops.subtract(Builtins.size(args), 1), Id()) items = Builtins.maplist(items) do |item| Item(Ops.get(item, 0), Ops.get(item, 1), Ops.get(item, 0) == id) end Builtins.toterm(:ComboBox, Builtins.add(tmp, items)) end |
.FrameWithMarginBox(old) ⇒ Yast::Term
93 94 95 96 97 98 99 100 |
# File 'library/general/src/lib/ui/greasemonkey.rb', line 93 def FrameWithMarginBox(old) title = Ops.get_string(old, 0, "error") args = Builtins.sublist(Builtins.argsof(old), 1) Frame( title, Builtins.toterm(:MarginBox, Builtins.union([1.45, 0.45], args)) ) end |
.IconAndHeading(old) ⇒ Yast::Term
229 230 231 232 233 234 235 236 |
# File 'library/general/src/lib/ui/greasemonkey.rb', line 229 def IconAndHeading(old) args = Builtins.argsof(old) title = Ops.get_string(args, 0, "") icon = Ops.get_string(args, 1, "") Left(HBox(Image(icon, ""), Heading(title))) end |
.LeftCheckBox(old) ⇒ Yast::Term
185 186 187 |
# File 'library/general/src/lib/ui/greasemonkey.rb', line 185 def LeftCheckBox(old) Left(Builtins.toterm(:CheckBox, Builtins.argsof(old))) end |
.LeftCheckBoxWithAttachment(old) ⇒ Yast::Term
NOTE: that it does not expand the nested Greasemonkey term LeftCheckBox! #transform does that.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'library/general/src/lib/ui/greasemonkey.rb', line 201 def LeftCheckBoxWithAttachment(old) args = Builtins.argsof(old) tmp1 = Builtins.sublist(args, 0, Ops.subtract(Builtins.size(args), 1)) tmp2 = Ops.get(args, Ops.subtract(Builtins.size(args), 1)) if tmp2 == Empty() VBox(Builtins.toterm(:LeftCheckBox, tmp1)) else VBox( Builtins.toterm(:LeftCheckBox, tmp1), HBox(HSpacing(4), tmp2) ) end end |
.LeftRadioButton(old) ⇒ Yast::Term
146 147 148 |
# File 'library/general/src/lib/ui/greasemonkey.rb', line 146 def LeftRadioButton(old) Left(Builtins.toterm(:RadioButton, Builtins.argsof(old))) end |
.LeftRadioButtonWithAttachment(old) ⇒ Yast::Term
NOTE: that it does not expand the nested Greasemonkey term LeftRadioButton! #transform does that.
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'library/general/src/lib/ui/greasemonkey.rb', line 162 def LeftRadioButtonWithAttachment(old) args = Builtins.argsof(old) tmp1 = Builtins.sublist(args, 0, Ops.subtract(Builtins.size(args), 1)) tmp2 = Ops.get(args, Ops.subtract(Builtins.size(args), 1)) if tmp2 == Empty() VBox(Builtins.toterm(:LeftRadioButton, tmp1)) else VBox( Builtins.toterm(:LeftRadioButton, tmp1), HBox(HSpacing(4), tmp2) ) end end |
.Transform(old) ⇒ Yast::Term
Recursively apply all Greasemonkey methods on old
242 243 244 245 246 247 248 249 250 251 252 |
# File 'library/general/src/lib/ui/greasemonkey.rb', line 242 def Transform(old) s = Builtins.symbolof(old) handler = Greasemonkey.method(s) if @handlers.include?(s) return Transform(handler.call(old)) if !handler.nil? Builtins::List.reduce(Builtins.toterm(s), Builtins.argsof(old)) do |tmp, arg| arg = Transform(Convert.to_term(arg)) if Ops.is_term?(arg) Builtins.add(tmp, arg) end end |
.transform ⇒ Yast::Term
Recursively apply all Greasemonkey methods on old
255 256 257 258 259 260 261 262 263 264 265 |
# File 'library/general/src/lib/ui/greasemonkey.rb', line 255 def Transform(old) s = Builtins.symbolof(old) handler = Greasemonkey.method(s) if @handlers.include?(s) return Transform(handler.call(old)) if !handler.nil? Builtins::List.reduce(Builtins.toterm(s), Builtins.argsof(old)) do |tmp, arg| arg = Transform(Convert.to_term(arg)) if Ops.is_term?(arg) Builtins.add(tmp, arg) end end |
.VStackFrames(old) ⇒ Yast::Term
Wrap terms in a VBox with small vertical spacings in between.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'library/general/src/lib/ui/greasemonkey.rb', line 71 def VStackFrames(old) frames = Convert.convert( Builtins.argsof(old), from: "list", to: "list <term>" ) new = VBox() Builtins.foreach(frames) do |frame| new = Builtins.add(new, VSpacing(0.45)) if Builtins.size(new) != 0 new = Builtins.add(new, frame) end new end |