• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-sysconfig / 10734385351

06 Sep 2024 07:34AM UTC coverage: 21.272%. Remained the same
10734385351

push

github

lslezak
Clean merge of SP7

398 of 1871 relevant lines covered (21.27%)

3.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/include/sysconfig/dialogs.rb
1
# encoding: utf-8
2

3
# File:        include/sysconfig/dialogs.ycp
4
# Package:        Configuration of sysconfig
5
# Summary:        Dialogs definitions
6
# Authors:        Ladislav Slezak <lslezak@suse.cz>
7
#
8
# $Id$
9
module Yast
×
10
  module SysconfigDialogsInclude
×
11
    def initialize_sysconfig_dialogs(include_target)
×
12
      Yast.import "UI"
×
13

14
      textdomain "sysconfig"
×
15

16
      Yast.import "Sysconfig"
×
17

18
      Yast.import "Popup"
×
19
      Yast.import "Label"
×
20

21
      Yast.include include_target, "sysconfig/helps.rb"
×
22
      Yast.include include_target, "sysconfig/routines.rb"
×
23
    end
×
24

25
    # Display search dialog
26
    # @return [Hash] Search option values selected in the dialog
27
    def display_search_dialog
×
28
      UI.OpenDialog(
×
29
        Opt(:decorated),
×
30
        VBox(
×
31
          HSpacing(60),
×
32
          # search popup window header
33
          Heading(_("Search for a Configuration Variable")),
×
34
          VSpacing(0.5),
×
35
          HBox(
×
36
            VSpacing(10),
×
37
            HSpacing(2),
×
38
            VBox(
×
39
              VSpacing(1),
×
40
              # text entry label
41
              TextEntry(Id(:search_entry), _("&Search for:")),
×
42
              VSpacing(1),
×
43
              # check box label
44
              Left(CheckBox(Id(:ignore), _("&Case Sensitive Search"), false)),
×
45
              # check box label
46
              Left(CheckBox(Id(:nkey), _("Search &Variable Name"), true)),
×
47
              # check box label
48
              Left(CheckBox(Id(:ndescr), _("Search &description"), true)),
×
49
              # check box label
50
              Left(CheckBox(Id(:nvalue), _("Search &value"), false)),
×
51
              VSpacing(1)
×
52
            ),
×
53
            HSpacing(2)
×
54
          ),
×
55
          VSpacing(0.5),
×
56
          ButtonBox(
×
57
            # push button label
58
            PushButton(Id(:ok), Opt(:default, :key_F10), Label.OKButton),
×
59
            # push button label
60
            PushButton(Id(:cancel), Opt(:key_F9), Label.CancelButton)
×
61
          )
×
62
        )
×
63
      )
×
64

65
      UI.SetFocus(Id(:search_entry))
×
66

67
      ui = Convert.to_symbol(UI.UserInput)
×
68

69
      while ui != :ok && ui != :cancel
×
70
        ui = Convert.to_symbol(UI.UserInput)
×
71
      end
×
72

73
      ret = {}
×
74

75
      if ui == :ok
×
76
        ret = Builtins.add(
×
77
          ret,
×
78
          "search",
×
79
          Convert.to_string(UI.QueryWidget(Id(:search_entry), :Value))
×
80
        )
×
81
        ret = Builtins.add(
×
82
          ret,
×
83
          "insensitive",
×
84
          !Convert.to_boolean(UI.QueryWidget(Id(:ignore), :Value))
×
85
        )
×
86
        ret = Builtins.add(
×
87
          ret,
×
88
          "varname",
×
89
          Convert.to_boolean(UI.QueryWidget(Id(:nkey), :Value))
×
90
        )
×
91
        ret = Builtins.add(
×
92
          ret,
×
93
          "value",
×
94
          Convert.to_boolean(UI.QueryWidget(Id(:nvalue), :Value))
×
95
        )
×
96
        ret = Builtins.add(
×
97
          ret,
×
98
          "description",
×
99
          Convert.to_boolean(UI.QueryWidget(Id(:ndescr), :Value))
×
100
        )
×
101
      end
×
102

103
      UI.CloseDialog
×
104
      deep_copy(ret)
×
105
    end
×
106

107
    # Display dialog with selected variables
108
    # @param [String] header Heading in the dialog
109
    # @param [String] label Label in the dialog
110
    # @param [Array] table_content Table content list
111
    # @param [String] ok_label OK button label
112
    # @param [String] cancel_label Cancel button label
113
    # @param [String] checkboxlabel Optional check box widget is displayed when size of checkboxlabel is greater than zero
114
    # @param [Boolean] checkboxvalue Check box value
115
    # @return [Hash] Selected variable, checkbox value (nil if it wasn't used), user input values
116
    def display_variables_dialog(header, label, table_content, ok_label, cancel_label, checkboxlabel, checkboxvalue)
×
117
      table_content = deep_copy(table_content)
×
118
      UI.OpenDialog(
×
119
        Opt(:decorated),
×
120
        HBox(
×
121
          VSpacing(17),
×
122
          VBox(
×
123
            HSpacing(70),
×
124
            #heading of popup
125
            Heading(header),
×
126
            label == "" ? Empty() : Label(label),
×
127
            VSpacing(0.5),
×
128
            # table column header
129
            Table(
×
130
              Id(:table),
×
131
              Header(
×
132
                _("Name"),
×
133
                _("NEW VALUE"),
×
134
                _("Old Value"),
×
135
                _("File"),
×
136
                _("Description")
×
137
              ),
×
138
              table_content
×
139
            ),
×
140
            Ops.greater_than(Builtins.size(checkboxlabel), 0) ?
×
141
              CheckBox(Id(:chbox), checkboxlabel, checkboxvalue) :
×
142
              Empty(),
×
143
            VSpacing(0.5),
×
144
            ButtonBox(
×
145
              # push button label
146
              PushButton(Id(:action), Opt(:default, :key_F10), ok_label),
×
147
              # push button label
148
              PushButton(Id(:cancel), Opt(:key_F9), cancel_label)
×
149
            )
×
150
          )
×
151
        )
×
152
      )
×
153

154
      ret = Convert.to_symbol(UI.UserInput)
×
155
      selected = Convert.to_string(UI.QueryWidget(Id(:table), :CurrentItem))
×
156
      box = nil
×
157

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

162
      UI.CloseDialog
×
163

164
      { "ui" => ret, "selected" => selected, "checkbox" => box }
×
165
    end
×
166

167

168
    # Display dialog for new variable. This dialog is used at autoinstalation config mode
169
    # only - some packages may not be available at configure time, but they will be present
170
    # at installation, so it is possible to change them even if they are not displayed.
171
    # @return [Hash] Map with keys "ui" (`ok or `cancel - user input), "name" (name of
172
    # the new variable), "file" (location of variable) and "value" (value to write)
173
    def add_new_variable
×
174
      UI.OpenDialog(
×
175
        Opt(:decorated),
×
176
        VBox(
×
177
          HBox(
×
178
            # text entry label
179
            TextEntry(Id(:name), _("&Variable Name"), ""),
×
180
            # text entry label
181
            TextEntry(Id(:value), _("V&alue"), "")
×
182
          ),
×
183
          VSpacing(1),
×
184
          HBox(
×
185
            # text entry label
186
            TextEntry(Id(:file), _("&File Name"), "")
×
187
          ),
×
188
          VSpacing(1),
×
189
          ButtonBox(
×
190
            PushButton(Id(:ok), Opt(:key_F10), Label.OKButton),
×
191
            PushButton(Id(:cancel), Opt(:key_F9), Label.CancelButton)
×
192
          )
×
193
        )
×
194
      )
×
195

196
      ui = nil
×
197

198
      name = ""
×
199
      file = ""
×
200

201
      while ui != :ok && ui != :cancel
×
202
        ui = Convert.to_symbol(UI.UserInput)
×
203

204
        name = Convert.to_string(UI.QueryWidget(Id(:name), :Value))
×
205
        file = Convert.to_string(UI.QueryWidget(Id(:file), :Value))
×
206

207
        if ui == :ok
×
208
          if name == ""
×
209
            # warning popup message - variable name is empty
210
            Popup.Warning(_("Missing variable name value."))
×
211
            ui = nil
×
212
          elsif Ops.less_or_equal(Builtins.size(file), 1)
×
213
            # warning popup message - file name is empty
214
            Popup.Warning(_("Missing file name value."))
×
215
            ui = nil
×
216
          elsif Builtins.substring(file, 0, 1) != "/"
×
217
            # warning popup message - file name is required with absolute path
218
            Popup.Warning(_("Missing absolute path in file name."))
×
219
            ui = nil
×
220
          end
×
221
        end
×
222
      end
×
223

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

226
      UI.CloseDialog
×
227

228
      { "ui" => ui, "name" => name, "value" => value, "file" => file }
×
229
    end
×
230
  end
×
231
end
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc