Module: Yast::SysconfigDialogsInclude

Defined in:
../../src/include/sysconfig/dialogs.rb

Instance Method Summary (collapse)

Instance Method Details

- (Hash) add_new_variable

Display dialog for new variable. This dialog is used at autoinstalation config mode only - some packages may not be available at configure time, but they will be present at installation, so it is possible to change them even if they are not displayed. the new variable), “file” (location of variable) and “value” (value to write)

Returns:

  • (Hash)

    Map with keys “ui” (ok orcancel - user input), “name” (name of



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File '../../src/include/sysconfig/dialogs.rb', line 173

def add_new_variable
  UI.OpenDialog(
    Opt(:decorated),
    VBox(
      HBox(
        # text entry label
        TextEntry(Id(:name), _("&Variable Name"), ""),
        # text entry label
        TextEntry(Id(:value), _("V&alue"), "")
      ),
      VSpacing(1),
      HBox(
        # text entry label
        TextEntry(Id(:file), _("&File Name"), "")
      ),
      VSpacing(1),
      ButtonBox(
        PushButton(Id(:ok), Opt(:key_F10), Label.OKButton),
        PushButton(Id(:cancel), Opt(:key_F9), Label.CancelButton)
      )
    )
  )

  ui = nil

  name = ""
  file = ""

  while ui != :ok && ui != :cancel
    ui = Convert.to_symbol(UI.UserInput)

    name = Convert.to_string(UI.QueryWidget(Id(:name), :Value))
    file = Convert.to_string(UI.QueryWidget(Id(:file), :Value))

    if ui == :ok
      if name == ""
        # warning popup message - variable name is empty
        Popup.Warning(_("Missing variable name value."))
        ui = nil
      elsif Ops.less_or_equal(Builtins.size(file), 1)
        # warning popup message - file name is empty
        Popup.Warning(_("Missing file name value."))
        ui = nil
      elsif Builtins.substring(file, 0, 1) != "/"
        # warning popup message - file name is required with absolute path
        Popup.Warning(_("Missing absolute path in file name."))
        ui = nil
      end
    end
  end

  value = Convert.to_string(UI.QueryWidget(Id(:value), :Value))

  UI.CloseDialog

  { "ui" => ui, "name" => name, "value" => value, "file" => file }
end

- (Hash) display_search_dialog

Display search dialog

Returns:

  • (Hash)

    Search option values selected in the dialog



27
28
29
30
31
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File '../../src/include/sysconfig/dialogs.rb', line 27

def display_search_dialog
  UI.OpenDialog(
    Opt(:decorated),
    VBox(
      HSpacing(60),
      # search popup window header
      Heading(_("Search for a Configuration Variable")),
      VSpacing(0.5),
      HBox(
        VSpacing(10),
        HSpacing(2),
        VBox(
          VSpacing(1),
          # text entry label
          TextEntry(Id(:search_entry), _("&Search for:")),
          VSpacing(1),
          # check box label
          Left(CheckBox(Id(:ignore), _("&Case Sensitive Search"), false)),
          # check box label
          Left(CheckBox(Id(:nkey), _("Search &Variable Name"), true)),
          # check box label
          Left(CheckBox(Id(:ndescr), _("Search &description"), true)),
          # check box label
          Left(CheckBox(Id(:nvalue), _("Search &value"), false)),
          VSpacing(1)
        ),
        HSpacing(2)
      ),
      VSpacing(0.5),
      ButtonBox(
        # push button label
        PushButton(Id(:ok), Opt(:default, :key_F10), Label.OKButton),
        # push button label
        PushButton(Id(:cancel), Opt(:key_F9), Label.CancelButton)
      )
    )
  )

  UI.SetFocus(Id(:search_entry))

  ui = Convert.to_symbol(UI.UserInput)

  while ui != :ok && ui != :cancel
    ui = Convert.to_symbol(UI.UserInput)
  end

  ret = {}

  if ui == :ok
    ret = Builtins.add(
      ret,
      "search",
      Convert.to_string(UI.QueryWidget(Id(:search_entry), :Value))
    )
    ret = Builtins.add(
      ret,
      "insensitive",
      !Convert.to_boolean(UI.QueryWidget(Id(:ignore), :Value))
    )
    ret = Builtins.add(
      ret,
      "varname",
      Convert.to_boolean(UI.QueryWidget(Id(:nkey), :Value))
    )
    ret = Builtins.add(
      ret,
      "value",
      Convert.to_boolean(UI.QueryWidget(Id(:nvalue), :Value))
    )
    ret = Builtins.add(
      ret,
      "description",
      Convert.to_boolean(UI.QueryWidget(Id(:ndescr), :Value))
    )
  end

  UI.CloseDialog
  deep_copy(ret)
end

- (Hash) display_variables_dialog(header, label, table_content, ok_label, cancel_label, checkboxlabel, checkboxvalue)

Display dialog with selected variables

Parameters:

  • header (String)

    Heading in the dialog

  • label (String)

    Label in the dialog

  • table_content (Array)

    Table content list

  • ok_label (String)

    OK button label

  • cancel_label (String)

    Cancel button label

  • checkboxlabel (String)

    Optional check box widget is displayed when size of checkboxlabel is greater than zero

  • checkboxvalue (Boolean)

    Check box value

Returns:

  • (Hash)

    Selected variable, checkbox value (nil if it wasn't used), user input values



116
117
118
119
120
121
122
123
124
125
126
127
128
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
157
158
159
160
161
162
163
164
165
# File '../../src/include/sysconfig/dialogs.rb', line 116

def display_variables_dialog(header, label, table_content, ok_label, cancel_label, checkboxlabel, checkboxvalue)
  table_content = deep_copy(table_content)
  UI.OpenDialog(
    Opt(:decorated),
    HBox(
      VSpacing(17),
      VBox(
        HSpacing(70),
        #heading of popup
        Heading(header),
        label == "" ? Empty() : Label(label),
        VSpacing(0.5),
        # table column header
        Table(
          Id(:table),
          Header(
            _("Name"),
            _("NEW VALUE"),
            _("Old Value"),
            _("File"),
            _("Description")
          ),
          table_content
        ),
        Ops.greater_than(Builtins.size(checkboxlabel), 0) ?
          CheckBox(Id(:chbox), checkboxlabel, checkboxvalue) :
          Empty(),
        VSpacing(0.5),
        ButtonBox(
          # push button label
          PushButton(Id(:action), Opt(:default, :key_F10), ok_label),
          # push button label
          PushButton(Id(:cancel), Opt(:key_F9), cancel_label)
        )
      )
    )
  )

  ret = Convert.to_symbol(UI.UserInput)
  selected = Convert.to_string(UI.QueryWidget(Id(:table), :CurrentItem))
  box = nil

  if Ops.greater_than(Builtins.size(checkboxlabel), 0)
    box = Convert.to_boolean(UI.QueryWidget(Id(:chbox), :Value))
  end

  UI.CloseDialog

  { "ui" => ret, "selected" => selected, "checkbox" => box }
end

- (Object) initialize_sysconfig_dialogs(include_target)



11
12
13
14
15
16
17
18
19
20
21
22
23
# File '../../src/include/sysconfig/dialogs.rb', line 11

def initialize_sysconfig_dialogs(include_target)
  Yast.import "UI"

  textdomain "sysconfig"

  Yast.import "Sysconfig"

  Yast.import "Popup"
  Yast.import "Label"

  Yast.include include_target, "sysconfig/helps.rb"
  Yast.include include_target, "sysconfig/routines.rb"
end