Class: Yast::GreasemonkeyClass

Inherits:
Module
  • Object
show all
Defined in:
../../src/modules/Greasemonkey.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) ComboBoxSelected(old)

ComboBoxSelected

ComboBoxSelected(id(wish),opt(<code>notify), “Wish”, [</code>item(id(time), "Time"), item(id(<code>love), "Love"), </code>item(id(money), "Money") ], id(love))

ComboBox(id(wish),opt(<code>notify), “Wish”, [</code>item(id(time), "Time", false), item(id(<code>love), "Love", true), </code>item(id(money), "Money", false) ])



113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File '../../src/modules/Greasemonkey.rb', line 113

def ComboBoxSelected(old)
  old = deep_copy(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

- (Object) FrameWithMarginBox(old)



90
91
92
93
94
95
96
97
98
# File '../../src/modules/Greasemonkey.rb', line 90

def FrameWithMarginBox(old)
  old = deep_copy(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

- (Object) IconAndHeading(old)

IconAndHeading

`IconAndHeading(“title”, “icon”)

Left(HBox(<code>Image(“icon”, “”), </code>Heading("title")));



209
210
211
212
213
214
215
216
217
218
219
220
# File '../../src/modules/Greasemonkey.rb', line 209

def IconAndHeading(old)
  old = deep_copy(old)
  args = Builtins.argsof(old)

  title = Ops.get_string(args, 0, "")
  icon = Ops.add(
    Ops.add(Directory.icondir, "22x22/apps/"),
    Ops.get_string(args, 1, "")
  )

  Left(HBox(Image(icon, ""), Heading(title)))
end

- (Object) LeftCheckBox(old)

LeftCheckBox

LeftCheckBox(id(), `opt(), “text”)

Left(CheckBox(id(),opt(), “text”))



171
172
173
174
# File '../../src/modules/Greasemonkey.rb', line 171

def LeftCheckBox(old)
  old = deep_copy(old)
  Left(Builtins.toterm(:CheckBox, Builtins.argsof(old)))
end

- (Object) LeftCheckBoxWithAttachment(old)

LeftCheckBoxWithAttachment

LeftCheckBoxWithAttachment(id(), `opt(), “text”, contents)

<code>VBox( </code>Left(Radiobutton(id(), <code>opt(), "text")), </code>HBox(`HSpacing(4), contents) )



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File '../../src/modules/Greasemonkey.rb', line 185

def LeftCheckBoxWithAttachment(old)
  old = deep_copy(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()
    return VBox(Builtins.toterm(:LeftCheckBox, tmp1))
  else
    return VBox(
      Builtins.toterm(:LeftCheckBox, tmp1),
      HBox(HSpacing(4), tmp2)
    )
  end
end

- (Object) LeftRadioButton(old)

LeftRadioButton

LeftRadioButton(id(), `opt(), “text”)

Left(RadioButton(id(),opt(), “text”))



134
135
136
137
# File '../../src/modules/Greasemonkey.rb', line 134

def LeftRadioButton(old)
  old = deep_copy(old)
  Left(Builtins.toterm(:RadioButton, Builtins.argsof(old)))
end

- (Object) LeftRadioButtonWithAttachment(old)

LeftRadioButtonWithAttachment

LeftRadioButtonWithAttachment(id(), `opt(), “text”, contents)

<code>VBox( </code>Left(Radiobutton(id(), <code>opt(), "text")), </code>HBox(`HSpacing(4), contents) )



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File '../../src/modules/Greasemonkey.rb', line 148

def LeftRadioButtonWithAttachment(old)
  old = deep_copy(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()
    return VBox(Builtins.toterm(:LeftRadioButton, tmp1))
  else
    return VBox(
      Builtins.toterm(:LeftRadioButton, tmp1),
      HBox(HSpacing(4), tmp2)
    )
  end
end

- (Object) main



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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 '../../src/modules/Greasemonkey.rb', line 32

def main
  Yast.import "Directory"


  @handlers = {
    :VStackFrames                  => fun_ref(
      method(:VStackFrames),
      "term (term)"
    ),
    :FrameWithMarginBox            => fun_ref(
      method(:FrameWithMarginBox),
      "term (term)"
    ),
    :ComboBoxSelected              => fun_ref(
      method(:ComboBoxSelected),
      "term (term)"
    ),
    :LeftRadioButton               => fun_ref(
      method(:LeftRadioButton),
      "term (term)"
    ),
    :LeftRadioButtonWithAttachment => fun_ref(
      method(:LeftRadioButtonWithAttachment),
      "term (term)"
    ),
    :LeftCheckBox                  => fun_ref(
      method(:LeftCheckBox),
      "term (term)"
    ),
    :LeftCheckBoxWithAttachment    => fun_ref(
      method(:LeftCheckBoxWithAttachment),
      "term (term)"
    ),
    :IconAndHeading                => fun_ref(
      method(:IconAndHeading),
      "term (term)"
    )
  }
end

- (Object) Register(s, handler)



223
224
225
226
227
228
229
230
231
232
# File '../../src/modules/Greasemonkey.rb', line 223

def Register(s, handler)
  handler = deep_copy(handler)
  if Builtins.haskey(@handlers, s)
    Builtins.y2error("handler for %1 already registered", s)
    return false
  else
    Ops.set(@handlers, s, handler)
    return true
  end
end

- (Object) Transform(old)



235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File '../../src/modules/Greasemonkey.rb', line 235

def Transform(old)
  old = deep_copy(old)
  s = Builtins.symbolof(old)

  handler = Ops.get(@handlers, s)
  return Transform(handler.call(old)) if handler != nil

  new = 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

  deep_copy(new)
end

- (Object) VStackFrames(old)



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File '../../src/modules/Greasemonkey.rb', line 72

def VStackFrames(old)
  old = deep_copy(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

  deep_copy(new)
end