Class: Yast::OnlineUpdateDialogsClass

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) ConfirmAbortUpdate(how_to)

ConfirmAbortUpdate has same layout as/but different text than ConfirmAbort



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
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
# File '../../src/modules/OnlineUpdateDialogs.rb', line 145

def ConfirmAbortUpdate(how_to)
  what_will_happen = ""

  if how_to == :painless
    # Warning text for aborting the update before a patch is installed
    what_will_happen = _(
      "If you abort the installation now, no patch will be installed.\nYour installation will remain untouched.\n"
    )
  elsif how_to == :incomplete
    # Warning text for aborting if some patches are installed, some not
    what_will_happen = _(
      "Patch download and installation in progress.\n" +
        "If you abort the installation now, the update is incomplete.\n" +
        "Repeat the update, including the download, if desired.\n"
    )
  elsif how_to == :unusable
    # Warning text for aborting an installation during the install process
    what_will_happen = _(
      "If you abort the installation now,\n" +
        "at least one patch is not installed correctly.\n" +
        "You will need to do the update again."
    )
  elsif how_to == :done
    Builtins.y2debug("Aborting after everything should be installed?")
  else
    Builtins.y2warning(
      "Unknown symbol for what will happen when aborting - please correct in calling module"
    )
  end

  UI.OpenDialog(
    Opt(:decorated),
    HBox(
      HSpacing(1),
      VBox(
        VSpacing(0.2),
        HCenter(
          HSquash(
            VBox(
              # Confirm user request to abort installation
              Left(Label(_("Really abort YaST Online Update?"))),
              Left(Label(what_will_happen))
            )
          )
        ),
        HBox(
          # Button that will really abort the installation
          PushButton(Id(:really_abort), _("&Abort Update")),
          HStretch(),
          # Button that will continue with the installation
          PushButton(Id(:continue), Opt(:default), _("&Continue Update"))
        ),
        VSpacing(0.2)
      ),
      HSpacing(1)
    )
  )

  ret = UI.UserInput
  UI.CloseDialog

  ret == :really_abort
end

- (Object) DisplayMsgYou(message, header, yes_button, no_button)



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File '../../src/modules/OnlineUpdateDialogs.rb', line 209

def DisplayMsgYou(message, header, yes_button, no_button)
  UI.OpenDialog(
    Opt(:decorated),
    HBox(
      HSpacing(1),
      VBox(
        Left(Heading(header)),
        VSpacing(0.2),
        Label(message),
        HBox(
          PushButton(Id(:yes), yes_button),
          PushButton(Id(:no), Opt(:default), no_button)
        ),
        VSpacing(0.2)
      ),
      HSpacing(1)
    )
  )
  ret = UI.UserInput
  UI.CloseDialog
  ret == :yes
end

- (Object) DisplayMsgYouOk(message, header, ok_button)



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File '../../src/modules/OnlineUpdateDialogs.rb', line 233

def DisplayMsgYouOk(message, header, ok_button)
  UI.OpenDialog(
    Opt(:decorated),
    HBox(
      HSpacing(1),
      VBox(
        Left(Heading(header)),
        VSpacing(0.2),
        Label(message),
        HBox(PushButton(Id(:ok), Opt(:default), ok_button)),
        VSpacing(0.2)
      ),
      HSpacing(1)
    )
  )
  ret = UI.UserInput
  UI.CloseDialog
  ret == :ok
end

- (Object) ErrorPopup(message, details)



140
141
142
# File '../../src/modules/OnlineUpdateDialogs.rb', line 140

def ErrorPopup(message, details)
  Convert.to_symbol(ErrorPopupGeneric(message, details, :plain))
end

- (Object) ErrorPopupGeneric(message, details, type)



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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File '../../src/modules/OnlineUpdateDialogs.rb', line 40

def ErrorPopupGeneric(message, details, type)
  details = _("No details available.") if Builtins.size(details) == 0

  detailsStringOn = _("&Details <<")
  detailsStringOff = _("&Details >>")

  detailsButton = PushButton(Id(:details), detailsStringOff)

  heading = _("Error")

  buttons = nil
  if type == :skip
    buttons = HBox(
      detailsButton,
      PushButton(Id(:tryagain), _("Try again")),
      PushButton(Id(:skip), _("Skip Patch")),
      PushButton(Id(:all), _("Skip All")),
      PushButton(Id(:abort), _("Abort Update"))
    )
  elsif type == :ignore
    buttons = HBox(
      detailsButton,
      PushButton(Id(:ok), Label.IgnoreButton),
      PushButton(Id(:abort), _("Abort Update"))
    )
  elsif type == :ignorewarning
    heading = _("Warning")
    buttons = HBox(
      detailsButton,
      PushButton(Id(:retry), Label.RetryButton),
      PushButton(Id(:ok), Label.IgnoreButton),
      PushButton(Id(:abort), _("Abort Update"))
    )
  else
    buttons = HBox(detailsButton, PushButton(Id(:ok), Label.OKButton))
  end

  UI.OpenDialog(
    Opt(:decorated),
    VBox(
      HBox(HSpacing(0.5), Left(Heading(heading))),
      VSpacing(0.2),
      Label(message),
      ReplacePoint(Id(:rp), HBox(HSpacing(0))),
      buttons
    )
  )

  ret = nil
  showDetails = false

  while ret != :ok && ret != :tryagain && ret != :all && ret != :abort &&
      ret != :skip &&
      ret != :retry
    ret = UI.UserInput

    if ret == :details
      if showDetails
        UI.ReplaceWidget(Id(:rp), VSpacing(0))
        UI.ChangeWidget(Id(:details), :Label, detailsStringOff)
      else
        UI.ReplaceWidget(
          Id(:rp),
          HBox(
            HSpacing(0.5),
            HWeight(1, RichText(Opt(:plainText), details)),
            HSpacing(0.5)
          )
        )
        UI.ChangeWidget(Id(:details), :Label, detailsStringOn)
      end
      showDetails = !showDetails
    end
  end

  UI.CloseDialog

  if type != :plain
    return deep_copy(ret)
  else
    if ret == :ok
      return true
    else
      return false
    end
  end
end

- (Object) IgnorePopup(message, details)



132
133
134
# File '../../src/modules/OnlineUpdateDialogs.rb', line 132

def IgnorePopup(message, details)
  Convert.to_symbol(ErrorPopupGeneric(message, details, :ignore))
end

- (Object) IgnoreWarningPopup(message, details)



128
129
130
# File '../../src/modules/OnlineUpdateDialogs.rb', line 128

def IgnoreWarningPopup(message, details)
  Convert.to_symbol(ErrorPopupGeneric(message, details, :ignorewarning))
end

- (Object) main



28
29
30
31
32
33
34
35
36
37
38
# File '../../src/modules/OnlineUpdateDialogs.rb', line 28

def main
  Yast.import "UI"

  textdomain "online-update"

  Yast.import "Label"
  Yast.import "Mode"
  Yast.import "Package"
  Yast.import "Popup"
  Yast.import "Wizard"
end

- (Object) MessagePopup(patches, pre)



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File '../../src/modules/OnlineUpdateDialogs.rb', line 253

def MessagePopup(patches, pre)
  patches = deep_copy(patches)
  message = ""
  details = ""

  i = 0
  while Ops.less_than(i, Builtins.size(patches))
    patch = Ops.get(patches, i, {})

    name = Ops.get_string(patch, "name", "")
    summary = Ops.get_string(patch, "summary", "")

    info = ""
    if pre
      info = Ops.get_string(patch, "preinformation", "")
    else
      info = Ops.get_string(patch, "postinformation", "")
    end

    header = Builtins.sformat(_("<b>Patch:</b> %1<br>"), name)
    header = Ops.add(
      header,
      Builtins.sformat(_("<b>Summary:</b> %1<br>"), summary)
    )

    message = Ops.add(message, header)
    message = Ops.add(Ops.add(Ops.add(message, "<pre>"), info), "</pre>")

    packages = Ops.get_list(patch, "packages", [])

    if Ops.greater_than(Builtins.size(packages), 0)
      details = Ops.add(details, header)

      details = Ops.add(details, _("<b>Packages:</b>"))

      details = Ops.add(details, "<ul>")

      Builtins.foreach(packages) do |p|
        details = Ops.add(Ops.add(Ops.add(details, "<li>"), p), "</li>")
      end

      details = Ops.add(details, "</ul>")
    end

    i = Ops.add(i, 1)
  end

  detailsStringOn = _("Patch &Details <<")
  detailsStringOff = _("Patch &Details >>")

  detailsButton = PushButton(Id(:details), detailsStringOff)

  detailsTerm = HBox(
    HSpacing(0.5),
    HWeight(1, RichText(Opt(:plainText), details)),
    HSpacing(0.5)
  )

  buttons = nil
  if pre
    buttons = HBox(
      details == "" ? VSpacing(0) : detailsButton,
      PushButton(Id(:ok), _("Install Patch")),
      PushButton(Id(:skip), _("Skip Patch"))
    )
  else
    buttons = HBox(
      details == "" ? VSpacing(0) : detailsButton,
      PushButton(Id(:ok), Label.OKButton)
    )
  end

  w = 20
  h = 5

  if Ops.greater_than(Builtins.size(message), 100)
    w = 60
    h = 15
  end

  Builtins.y2milestone("Going to open the message dialog")

  UI.OpenDialog(
    Opt(:decorated),
    VBox(
      HSpacing(w),
      VSpacing(0.2),
      HBox(VSpacing(h), RichText(message)),
      ReplacePoint(Id(:rp), VSpacing(0)),
      buttons
    )
  )

  Builtins.y2milestone("Dialog opened")

  ret = nil
  showDetails = false

  while ret != :ok && ret != :skip
    ret = Convert.to_symbol(UI.UserInput)

    if ret == :details
      if showDetails
        UI.ReplaceWidget(Id(:rp), HSpacing(0))
        UI.ChangeWidget(Id(:details), :Label, detailsStringOff)
      else
        UI.ReplaceWidget(
          Id(:rp),
          HBox(HSpacing(0.5), HWeight(1, RichText(details)), HSpacing(0.5))
        )
        UI.ChangeWidget(Id(:details), :Label, detailsStringOn)
      end
      showDetails = !showDetails
    end
  end

  UI.CloseDialog

  if ret == :ok
    return true
  else
    return false
  end
end

- (Object) SkipPopup(message, details)



136
137
138
# File '../../src/modules/OnlineUpdateDialogs.rb', line 136

def SkipPopup(message, details)
  Convert.to_symbol(ErrorPopupGeneric(message, details, :skip))
end