Module: Yast::BootloaderRoutinesCommonOptionsInclude

Defined in:
src/include/bootloader/routines/common_options.rb

Instance Method Summary (collapse)

Instance Method Details

- (Hash{String => Object}) CommonCheckboxWidget(label, help)

Generic widget of a checkbox There is not defined valid function if it is necessary create own definition of widget

Parameters:

  • string

    lable of widget

  • help (String)

    text for widget

Returns:

  • (Hash{String => Object})

    CWS widget



109
110
111
112
113
114
115
116
117
# File 'src/include/bootloader/routines/common_options.rb', line 109

def CommonCheckboxWidget(label, help)
  {
    "widget" => :checkbox,
    "label"  => label,
    "init"   => fun_ref(method(:InitGlobalBool), "void (string)"),
    "store"  => fun_ref(method(:StoreGlobalBool), "void (string, map)"),
    "help"   => help
  }
end

- (Hash{String => Object}) CommonInputFieldBrowseWidget(label, help, id)

Generic widget of a inputfield + browse button There is not defined valid function if it is necessary create own definition of widget

Parameters:

  • string

    lable of widget

  • help (String)

    text for widget

  • id (String)

    of widget

Returns:

  • (Hash{String => Object})

    CWS widget



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'src/include/bootloader/routines/common_options.rb', line 142

def CommonInputFieldBrowseWidget(label, help, id)
  browse = Ops.add("browse", id)
  {
    "widget"        => :custom,
    "custom_widget" => HBox(
      Left(InputField(Id(id), Opt(:hstretch), label)),
      VBox(
        Label(""),
        PushButton(Id(browse), Opt(:notify), Label.BrowseButton)
      )
    ),
    "init"          => fun_ref(method(:InitGlobalStr), "void (string)"),
    "store"         => fun_ref(
      method(:StoreGlobalStr),
      "void (string, map)"
    ),
    "handle"        => fun_ref(
      method(:HandleGlobalBrowse),
      "symbol (string, map)"
    ),
    "handle_events" => [browse],
    "help"          => help
  }
end

- (Hash{String => Object}) CommonInputFieldWidget(label, help)

Generic widget of a inputfield/textentry (widget) There is not defined valid function if it is necessary create own definition of widget

Parameters:

  • string

    lable of widget

  • help (String)

    text for widget

Returns:

  • (Hash{String => Object})

    CWS widget



125
126
127
128
129
130
131
132
133
# File 'src/include/bootloader/routines/common_options.rb', line 125

def CommonInputFieldWidget(label, help)
  {
    "widget" => :textentry,
    "label"  => label,
    "init"   => fun_ref(method(:InitGlobalStr), "void (string)"),
    "store"  => fun_ref(method(:StoreGlobalStr), "void (string, map)"),
    "help"   => help
  }
end

- (Hash{String => Object}) CommonIntFieldWidget(label, help, min, max)

Generic widget of a intfield (widget) There is not defined valid function if it is necessary create own definition of widget

Parameters:

  • string

    lable of widget

  • help (String)

    text for widget

  • integer

    minimal value

  • integer

    maximal value

Returns:

  • (Hash{String => Object})

    CWS widget



175
176
177
178
179
180
181
182
183
184
185
# File 'src/include/bootloader/routines/common_options.rb', line 175

def CommonIntFieldWidget(label, help, min, max)
  {
    "widget"  => :intfield,
    "label"   => label,
    "minimum" => min,
    "maximum" => max,
    "init"    => fun_ref(method(:InitGlobalStr), "void (string)"),
    "store"   => fun_ref(method(:StoreGlobalStr), "void (string, map)"),
    "help"    => help
  }
end

- (Hash{String => map<String,Object>}) CommonOptions

Common widgets of global settings

Returns:

  • (Hash{String => map<String,Object>})

    CWS widgets



202
203
204
# File 'src/include/bootloader/routines/common_options.rb', line 202

def CommonOptions
  { "timeout" => TimeoutWidget() }
end

- (Symbol) HandleGlobalBrowse(widget, _event)

Handle function of a widget (IntField + browse button)

Parameters:

  • widget (String)

    any widget key

  • event (Hash)

    map event description of event that occured

Returns:

  • (Symbol)

    nil



95
96
97
98
99
100
101
# File 'src/include/bootloader/routines/common_options.rb', line 95

def HandleGlobalBrowse(widget, _event)
  current = Convert.to_string(UI.QueryWidget(Id(widget), :Value))
  # file open popup caption
  current = UI.AskForExistingFile(current, "*", _("Select File"))
  UI.ChangeWidget(Id(widget), :Value, current) if !current.nil?
  nil
end

- (Object) InitGlobalBool(widget)

Init function for widget value (CheckBox)

Parameters:

  • widget (String)

    any id of the widget



56
57
58
59
60
61
# File 'src/include/bootloader/routines/common_options.rb', line 56

def InitGlobalBool(widget)
  value = Ops.get(BootCommon.globals, widget, "false") == "true"
  UI.ChangeWidget(Id(widget), :Value, value)

  nil
end

- (Object) InitGlobalInt(widget)

Init function for widget value (IntField)

Parameters:

  • widget (String)

    any id of the widget



74
75
76
77
78
79
# File 'src/include/bootloader/routines/common_options.rb', line 74

def InitGlobalInt(widget)
  value = Builtins.tointeger(Ops.get(BootCommon.globals, widget, "0"))
  UI.ChangeWidget(Id(widget), :Value, value)

  nil
end

- (Object) InitGlobalStr(widget)

Init function for widget value (InputField)

Parameters:

  • widget (String)

    any id of the widget



31
32
33
34
35
36
37
38
39
# File 'src/include/bootloader/routines/common_options.rb', line 31

def InitGlobalStr(widget)
  UI.ChangeWidget(
    Id(widget),
    :Value,
    Ops.get(BootCommon.globals, widget, "")
  )

  nil
end

- (Object) initialize_bootloader_routines_common_options(include_target)



23
24
25
26
27
# File 'src/include/bootloader/routines/common_options.rb', line 23

def initialize_bootloader_routines_common_options(include_target)
  textdomain "bootloader"

  Yast.include include_target, "bootloader/routines/common_helps.rb"
end

- (Object) StoreGlobalBool(widget, _event)

Init function for widget value (CheckBox)

Parameters:

  • widget (String)

    any id of the widget



65
66
67
68
69
70
# File 'src/include/bootloader/routines/common_options.rb', line 65

def StoreGlobalBool(widget, _event)
  value = Convert.to_boolean(UI.QueryWidget(Id(widget), :Value))
  Ops.set(BootCommon.globals, widget, value ? "true" : "false")

  nil
end

- (Object) StoreGlobalInt(widget, _event)

Store function of a widget (IntField)

Parameters:

  • widget (String)

    any widget key

  • event (Hash)

    map event description of event that occured



84
85
86
87
88
89
# File 'src/include/bootloader/routines/common_options.rb', line 84

def StoreGlobalInt(widget, _event)
  value = Convert.to_integer(UI.QueryWidget(Id(widget), :Value))
  Ops.set(BootCommon.globals, widget, Builtins.tostring(value))

  nil
end

- (Object) StoreGlobalStr(widget, _event)

Store function of a widget (InputField)

Parameters:

  • widget (String)

    any widget key

  • event (Hash)

    map event description of event that occured



44
45
46
47
48
49
50
51
52
# File 'src/include/bootloader/routines/common_options.rb', line 44

def StoreGlobalStr(widget, _event)
  Ops.set(
    BootCommon.globals,
    widget,
    Convert.to_string(UI.QueryWidget(Id(widget), :Value))
  )

  nil
end

- (Hash{String => Object}) TimeoutWidget

Common widget of a Timeout

Returns:

  • (Hash{String => Object})

    CWS widget



189
190
191
192
193
194
195
196
197
198
199
# File 'src/include/bootloader/routines/common_options.rb', line 189

def TimeoutWidget
  {
    "widget"  => :intfield,
    "label"   => Ops.get(@common_descriptions, "timeout", "timeout"),
    "minimum" => -1,
    "maximum" => 600,
    "init"    => fun_ref(method(:InitGlobalInt), "void (string)"),
    "store"   => fun_ref(method(:StoreGlobalInt), "void (string, map)"),
    "help"    => Ops.get(@common_help_messages, "timeout", "")
  }
end