Class: Yast::PopupClass

Inherits:
Module
  • Object
show all
Defined in:
library/general/src/modules/Popup.rb

Instance Method Summary collapse

Instance Method Details

#AnyMessage(headline, message) ⇒ Object

Generic message popup

Show a message with optional headline above and wait until user clicked “OK”.

Parameters:

  • headline (String)

    optional headline or Popup::NoHeadline()

  • message (String)

    the message (maybe multi-line) to display.



1026
1027
1028
1029
1030
# File 'library/general/src/modules/Popup.rb', line 1026

def AnyMessage(headline, message)
  anyMessageInternal(headline, message)

  nil
end

#anyMessageDetailsInternal(headline, message, details) ⇒ Object

Internal function - wrapper for anyMessageDetailsInternalType call



974
975
976
977
978
979
980
981
982
983
984
985
# File 'library/general/src/modules/Popup.rb', line 974

def anyMessageDetailsInternal(headline, message, details)
  anyMessageDetailsInternalType(
    headline,
    message,
    details,
    false,
    0,
    0
  )

  nil
end

#anyMessageDetailsInternalType(headline, message, details, richtext, width, height) ⇒ Object

Generic message popup with Details button - internal

Show a message with optional headline above and wait until user clicked “OK” or “Details”. On “Details”, show window with detailed information.

Parameters:

  • headline (String)

    optional headline or Popup::NoHeadline()

  • message (String)

    the message (maybe multi-line) to display.

  • details (String)

    the detailed information text



855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
# File 'library/general/src/modules/Popup.rb', line 855

def anyMessageDetailsInternalType(headline, message, details, richtext, width, height)
  button_box = ButtonBox(
    PushButton(Id(:ok_msg), Opt(:default, :okButton), Label.OKButton),
    # FIXME: BNC #422612, Use `opt(`noSanityCheck) later
    # button label
    PushButton(Id(:details), Opt(:cancelButton), _("&Details..."))
  )

  success = UI.OpenDialog(
    Opt(:decorated),
    if richtext
      popupLayoutInternalRich(
        headline,
        message,
        button_box,
        width,
        height
      )
    else
      popupLayoutInternal(headline, message, button_box)
    end
  )

  UI.SetFocus(Id(:ok_msg))

  loop do
    ret = UI.UserInput
    break if ret != :details

    success2 = UI.OpenDialog(
      Opt(:decorated),
      HBox(
        VSpacing(@default_height),
        VBox(
          HSpacing(@default_width),
          VSpacing(0.5),
          RichText(
            Builtins.mergestring(
              Builtins.splitstring(ERB::Util.html_escape(details), "\n"),
              "<br>"
            )
          ),
          VSpacing(),
          ButtonBox(
            PushButton(
              Id(:ok),
              Opt(:default, :key_F10, :okButton),
              Label.OKButton
            )
          )
        )
      )
    )

    if success2 == true
      UI.UserInput
      UI.CloseDialog
    end
  end
  UI.CloseDialog if success == true

  nil
end

#anyMessageInternal(headline, message) ⇒ Object

Internal function - wrapper for anyMessageInternal call



960
961
962
963
964
# File 'library/general/src/modules/Popup.rb', line 960

def anyMessageInternal(headline, message)
  anyMessageInternalType(headline, message, false, 0, 0)

  nil
end

#anyMessageInternalRich(headline, message, width, height) ⇒ Object

Internal function - wrapper for anyMessageInternal call



967
968
969
970
971
# File 'library/general/src/modules/Popup.rb', line 967

def anyMessageInternalRich(headline, message, width, height)
  anyMessageInternalType(headline, message, true, width, height)

  nil
end

#anyMessageInternalType(headline, message, richtext, width, height) ⇒ Object

Generic message popup - internal

Show a message with optional headline above and wait until user clicked “OK”.

Parameters:

  • headline (String)

    optional headline or Popup::NoHeadline()

  • message (String)

    the message (maybe multi-line) to display.



926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
# File 'library/general/src/modules/Popup.rb', line 926

def anyMessageInternalType(headline, message, richtext, width, height)
  button_box = ButtonBox(
    PushButton(
      Id(:ok_msg),
      Opt(:default, :key_F10, :okButton),
      Label.OKButton
    )
  )

  success = UI.OpenDialog(
    Opt(:decorated),
    if richtext
      popupLayoutInternalRich(
        headline,
        message,
        button_box,
        width,
        height
      )
    else
      popupLayoutInternal(headline, message, button_box)
    end
  )

  if success == true
    UI.SetFocus(Id(:ok_msg))
    UI.UserInput
    UI.CloseDialog
  end

  nil
end

#AnyQuestion(headline, message, yes_button_message, no_button_message, focus) ⇒ Object

Generic question popup with two buttons.

Style guide hint: The first button has to have the semantics of “yes”, “OK”, “continue” etc., the second its opposite (“no”, “cancel”, …). NEVER use this generic question popup to simply exchange the order of yes/no, continue/cancel or ok/cancel buttons!

![screenshots/AnyQuestion.png](../../screenshots/AnyQuestion.png)

Examples:

Popup::AnyQuestion( Label::WarningMsg(), “Do really want to …?”, “Install”, “Don't do it”, `focus_no );

Parameters:

  • headline (String)

    headline or Popup::NoHeadline()

  • message (String)

    message string

  • yes_button_message (String)

    label on affirmative buttons (on left side)

  • no_button_message (String)

    label on negating button (on right side)

  • focus (Symbol)

    `focus_yes (first button) or `focus_no (second button)

Returns:

  • true: first button has been clicked false: second button has been clicked

See Also:



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'library/general/src/modules/Popup.rb', line 305

def AnyQuestion(headline, message, yes_button_message, no_button_message, focus)
  button_box = AnyQuestionButtonBox(
    yes_button_message,
    no_button_message,
    focus
  )
  success = UI.OpenDialog(
    Opt(:decorated),
    popupLayoutInternal(
      headline,
      message,
      button_box
    )
  )

  ret = nil

  if success == true
    ret = UI.UserInput
    UI.CloseDialog
  end

  ret == :yes
end

#AnyQuestion3(headline, message, yes_button_message, no_button_message, retry_button_message, focus) ⇒ Object

Generic question popup with three buttons.

Examples:

Popup::AnyQuestion3( Label::WarningMsg(), _(“… failed”), _(“Continue”), _(“Cancel”), _(“Retry”), `focus_yes );

Parameters:

  • headline (String)

    headline or Popup::NoHeadline()

  • message (String)

    message string

  • yes_button_message (String)

    label on affirmative button (on left side)

  • no_button_message (String)

    label on negating button (middle)

  • retry_button_message (String)

    label on retry button (on right side)

  • focus (Symbol)

    `focus_yes (first button), `focus_no (second button) or `focus_retry (third button)

Returns:

    • `yes: first button has been clicked

    • `no: second button has been clicked

    • `retry: third button has been clicked

See Also:



1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
# File 'library/general/src/modules/Popup.rb', line 1630

def AnyQuestion3(headline, message, yes_button_message, no_button_message, retry_button_message, focus)
  yes_button = Empty()
  no_button = Empty()
  retry_button = Empty()

  if focus == :focus_no
    yes_button = PushButton(
      Id(:yes),
      Opt(:key_F10, :okButton),
      yes_button_message
    )
    no_button = PushButton(
      Id(:no),
      Opt(:default, :key_F9, :cancelButton),
      no_button_message
    )
    retry_button = PushButton(
      Id(:retry),
      Opt(:key_F6, :customButton),
      retry_button_message
    )
  elsif focus == :focus_yes
    yes_button = PushButton(
      Id(:yes),
      Opt(:default, :key_F10, :okButton),
      yes_button_message
    )
    no_button = PushButton(
      Id(:no),
      Opt(:key_F9, :cancelButton),
      no_button_message
    )
    retry_button = PushButton(
      Id(:retry),
      Opt(:key_F6, :customButton),
      retry_button_message
    )
  else
    yes_button = PushButton(
      Id(:yes),
      Opt(:key_F10, :okButton),
      yes_button_message
    )
    no_button = PushButton(
      Id(:no),
      Opt(:key_F9, :cancelButton),
      no_button_message
    )
    retry_button = PushButton(
      Id(:retry),
      Opt(:default, :key_F6, :customButton),
      retry_button_message
    )
  end

  button_box = ButtonBox(yes_button, no_button, retry_button)

  success = UI.OpenDialog(
    Opt(:decorated),
    popupLayoutInternal(
      headline,
      message,
      button_box
    )
  )

  ret = nil

  if success == true
    ret = Convert.to_symbol(UI.UserInput)
    UI.CloseDialog
  end

  ret
end

#AnyQuestionButtonBox(yes_button_message, no_button_message, focus) ⇒ Yast::Term

Button box for the AnyQuestion Dialog (internal function).

Parameters:

  • yes_button_message (String)

    label on affirmative buttons (on left side)

  • no_button_message (String)

    label on negating button (on right side)

  • focus (Symbol)

    `focus_yes (first button) or `focus_no (second button)

Returns:

  • (Yast::Term)

    button box



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
# File 'library/general/src/modules/Popup.rb', line 256

def AnyQuestionButtonBox(yes_button_message, no_button_message, focus)
  yes_button = Empty()
  no_button = Empty()

  if focus == :focus_no
    yes_button = PushButton(Id(:yes), Opt(:okButton), yes_button_message)
    no_button = PushButton(
      Id(:no_button),
      Opt(:default, :cancelButton),
      no_button_message
    )
  else
    yes_button = PushButton(
      Id(:yes),
      Opt(:default, :okButton),
      yes_button_message
    )
    no_button = PushButton(
      Id(:no_button),
      Opt(:cancelButton),
      no_button_message
    )
  end

  button_box = ButtonBox(yes_button, no_button)
  deep_copy(button_box)
end

#AnyQuestionRichText(headline, richtext, hdim, vdim, yes_button_message, no_button_message, focus) ⇒ Object

Show a question that might need scrolling.

Parameters:

  • headline (String)

    short headline

  • richtext (String)

    text input as a rich text

  • hdim (Fixnum)

    initial horizontal dimension of the popup

  • vdim (Fixnum)

    initial vertical dimension of the popup

  • yes_button_message (String)

    message on the left/true button

  • no_button_message (String)

    message on the right/false button

  • focus (Symbol)

    `focus_yes, `focus_no, `focus_none

Returns:

  • left button pressed?



674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
# File 'library/general/src/modules/Popup.rb', line 674

def AnyQuestionRichText(headline, richtext, hdim, vdim, yes_button_message, no_button_message, focus)
  yes_button = PushButton(
    Id(:ok),
    if focus == :focus_yes
      Opt(:default, :key_F10, :okButton)
    else
      Opt(:key_F10, :okButton)
    end,
    yes_button_message
  )

  no_button = PushButton(
    Id(:cancel),
    focus == :focus_no ? Opt(:default, :key_F9) : Opt(:key_F9),
    no_button_message
  )

  d = HBox(
    VSpacing(vdim),
    VBox(
      HSpacing(hdim),
      if Ops.greater_than(Builtins.size(headline), 0)
        Left(Heading(headline))
      else
        Empty()
      end,
      VSpacing(0.2),
      RichText(richtext),
      ButtonBox(yes_button, no_button)
    )
  )

  success = UI.OpenDialog(Opt(:decorated), d)
  ui = nil

  if success == true
    ui = UI.UserInput
    UI.CloseDialog
  end

  ui == :ok
end

#anyRichMessageInternal(headline, message, width, height) ⇒ Object

Generic message popup - internal

Show a message with optional headline above and wait until user clicked “OK”.

Parameters:

  • headline (String)

    optional headline or Popup::NoHeadline()

  • message (String)

    the message (maybe multi-line) to display.



994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
# File 'library/general/src/modules/Popup.rb', line 994

def anyRichMessageInternal(headline, message, width, height)
  button_box = ButtonBox(
    PushButton(Id(:ok_msg), Opt(:default, :key_F10), Label.OKButton)
  )

  success = UI.OpenDialog(
    Opt(:decorated),
    popupLayoutInternalRich(
      headline,
      message,
      button_box,
      width,
      height
    )
  )

  if success == true
    UI.SetFocus(Id(:ok_msg))
    UI.UserInput
    UI.CloseDialog
  end

  nil
end

#AnyTimedMessage(headline, message, timeout) ⇒ void

This method returns an undefined value.

Generic message popup

Show a message with optional headline above and wait until user clicked “OK” or until a timeout runs out.

Parameters:

  • headline (String)

    optional headline or Popup::NoHeadline()

  • message (String)

    the message (maybe multi-line) to display.

  • timeout (Fixnum)

    After timeout seconds dialog will be automatically closed



1772
1773
1774
1775
1776
# File 'library/general/src/modules/Popup.rb', line 1772

def AnyTimedMessage(headline, message, timeout)
  anyTimedMessageInternal(headline, message, timeout)

  nil
end

#anyTimedMessageInternal(headline, message, timeout) ⇒ Object

Internal function - wrapper for anyTimedMessageTypeInternal call



212
213
214
215
216
217
218
219
220
221
222
223
# File 'library/general/src/modules/Popup.rb', line 212

def anyTimedMessageInternal(headline, message, timeout)
  anyTimedMessageTypeInternal(
    headline,
    message,
    timeout,
    false,
    0,
    0
  )

  nil
end

#anyTimedMessageTypeInternal(headline, message, timeout, richtext, width, height) ⇒ void

This method returns an undefined value.

Internal version of AnyTimedMessage

Show a message with optional headline above and wait until user clicked “OK” or until a timeout runs out.

Parameters:

  • headline (String)

    optional headline or Popup::NoHeadline()

  • message (String)

    the message (maybe multi-line) to display.

  • timeout (Fixnum)

    After timeout seconds dialog will be automatically closed



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
208
209
# File 'library/general/src/modules/Popup.rb', line 165

def anyTimedMessageTypeInternal(headline, message, timeout, richtext, width, height)
  button_box = ButtonBox(
    # FIXME: BNC #422612, Use `opt(`noSanityCheck) later
    PushButton(Id(:stop), Opt(:cancelButton), Label.StopButton),
    PushButton(Id(:ok_msg), Opt(:default, :okButton), Label.OKButton)
  )

  success = UI.OpenDialog(
    Opt(:decorated),
    popupLayoutInternalTypeWithLabel(
      headline,
      message,
      button_box,
      Builtins.sformat("%1", timeout),
      richtext,
      width,
      height
    )
  )

  UI.SetFocus(Id(:ok_msg)) if success == true

  button = nil

  while Ops.greater_than(timeout, 0) && button != :ok_msg
    button = Convert.to_symbol(UI.TimeoutUserInput(1000))

    if button == :stop
      while UI.UserInput != :ok_msg

      end
      break
    end

    timeout = Ops.subtract(timeout, 1)

    if success == true
      UI.ChangeWidget(Id(:label), :Value, Builtins.sformat("%1", timeout))
    end
  end

  UI.CloseDialog if success == true

  nil
end

#AnyTimedRichMessage(headline, message, timeout) ⇒ Object



1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
# File 'library/general/src/modules/Popup.rb', line 1778

def AnyTimedRichMessage(headline, message, timeout)
  anyTimedRichMessageInternal(
    headline,
    message,
    timeout,
    @default_width,
    @default_height
  )

  nil
end

#anyTimedRichMessageInternal(headline, message, timeout, width, height) ⇒ Object

Internal function - wrapper for anyTimedMessageTypeInternal call



226
227
228
229
230
231
232
233
234
235
236
237
# File 'library/general/src/modules/Popup.rb', line 226

def anyTimedRichMessageInternal(headline, message, timeout, width, height)
  anyTimedMessageTypeInternal(
    headline,
    message,
    timeout,
    true,
    width,
    height
  )

  nil
end

#ClearFeedbackvoid

This method returns an undefined value.

Clear feedback message



1034
1035
1036
1037
1038
1039
# File 'library/general/src/modules/Popup.rb', line 1034

def ClearFeedback
  UI.CloseDialog if @feedback_open
  @feedback_open = false

  nil
end

#ConfirmAbort(severity) ⇒ Boolean

Confirmation for “Abort” button during installation.

According to the “severity” parameter an appropriate text will be displayed indicating what the user has to expect when he really aborts now.

![screenshots/ConfirmAbort.png](../../screenshots/ConfirmAbort.png)

Examples:

Popup::ConfirmAbort ( `painless );

Parameters:

  • severity (Symbol)

    `painless, `incomplete, `unusable

Returns:

  • (Boolean)


729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
# File 'library/general/src/modules/Popup.rb', line 729

def ConfirmAbort(severity)
  what_will_happen = ""

  # Confirm user request to abort installation
  abort_label = _("Really abort the installation?")
  # Button that will really abort the installation
  abort_button = _("&Abort Installation")
  # Button that will continue with the installation
  continue_button = _("&Continue Installation")

  if severity == :painless
    if Mode.repair
      # Confirm user request to abort System Repair
      abort_label = _("Really abort YaST System Repair?")
      # Button that will really abort the repair
      abort_button = _("Abort System Repair")
      # Button that will continue with the repair
      continue_button = _("&Continue System Repair")
    else
      # Warning text for aborting an installation before anything is installed
      what_will_happen = _(
        "If you abort the installation now,\n" \
          "Linux will not be installed.\n" \
          "Your hard disk will remain untouched."
      )
    end
  elsif severity == :incomplete
    # Warning text for aborting an installation during the install process
    # - After some installation steps have been performed - e.g.
    # disks formatted / some packages already installed
    what_will_happen = _(
      "If you abort the installation now, you will\n" \
        "have an incomplete Linux system\n" \
        "that might or might not be usable.\n" \
        "You might need to reinstall.\n"
    )
  elsif severity == :unusable
    # Warning text for aborting an installation during the install process
    # right in the middle of some critical process (e.g. formatting)
    what_will_happen = _(
      "If you abort the installation now,\n" \
        "Linux will be unusable.\n" \
        "You will need to reinstall."
    )
  else
    Builtins.y2error("Unknown symbol for ConfirmAbort")
  end

  message = Ops.add(Ops.add(abort_label, "\n\n"), what_will_happen)

  button_box = AnyQuestionButtonBox(
    abort_button,
    continue_button,
    :focus_no
  )
  success = UI.OpenDialog(
    Opt(:decorated),
    popupLayoutInternal(
      NoHeadline(),
      message,
      button_box
    )
  )

  user_ret = nil
  if success == true
    user_ret = UI.UserInput
    UI.CloseDialog
  end

  ret = user_ret == :yes

  Builtins.y2debug("ConfirmAbort returned: %1", ret)

  ret
end

#ContinueCancel(message) ⇒ Boolean

Dialog which displays the “message” and has a Continue and a Cancel button.

This popup should be used to confirm possibly dangerous actions. The default button is Continue. Returns true if Continue is clicked.

![screenshots/ContinueCancel.png](../../screenshots/ContinueCancel.png)

Examples:

Popup::ContinueCancel ( “Please insert required CD-ROM.” );

Parameters:

  • message (String)

    message string

Returns:

  • (Boolean)

See Also:



552
553
554
555
556
557
# File 'library/general/src/modules/Popup.rb', line 552

def ContinueCancel(message)
  ret = ContinueCancelHeadline(NoHeadline(), message)
  Builtins.y2debug("ContinueCancel returned: %1", ret)

  ret
end

#ContinueCancelHeadline(headline, message) ⇒ Boolean

Dialog which displays the “message” and has a Continue and a Cancel button.

This popup should be used to confirm possibly dangerous actions and if it's useful to display a short headline (without headline Popup::ContinueCancel() can be used). The default button is Continue.

Returns true if Continue is clicked.

![screenshot/ContinueCancelHeadline.png](../../screenshot/ContinueCancelHeadline.png)

Examples:

Popup::ContinueCancelHeadline ( “Short Header”, “Going on with action.…?” );

Parameters:

  • headline (String)

    short headline or Popup::NoHeadline()

  • message (String)

    message string

Returns:

  • (Boolean)

See Also:



523
524
525
526
527
528
529
530
531
532
533
534
535
# File 'library/general/src/modules/Popup.rb', line 523

def ContinueCancelHeadline(headline, message)
  ret = AnyQuestion(
    headline,
    message,
    Label.ContinueButton,
    Label.CancelButton,
    :focus_yes
  )

  Builtins.y2debug("ContinueCancelHeadline returned: %1", ret)

  ret
end

#Error(message) ⇒ Object

Show an error message and wait until user clicked “OK”.

![screenshots/Error.png](../../screenshots/Error.png)

Examples:

Popup::Error(“The configuration was not succesful.” );

Parameters:

  • message (String)

    error message string

See Also:



1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
# File 'library/general/src/modules/Popup.rb', line 1322

def Error(message)
  lines = Builtins.splitstring(message, "\n")
  if @switch_to_richtext &&
      Ops.greater_than(Builtins.size(lines), @too_many_lines)
    anyMessageInternalRich(
      Label.ErrorMsg,
      ERB::Util.html_escape(message),
      @default_width,
      @default_height
    )
  else
    anyMessageInternal(Label.ErrorMsg, message)
  end

  nil
end

#ErrorAnyQuestion(headline, message, yes_button_message, no_button_message, focus) ⇒ Object

Generic error question popup with two buttons.

Style guide hint: The first button has to have the semantics of “yes”, “OK”, “continue” etc., the second its opposite (“no”, “cancel”, …). NEVER use this generic question popup to simply exchange the order of yes/no, continue/cancel or ok/cancel buttons!

![screenshots/AnyQuestion.png](../../screenshots/AnyQuestion.png)

Examples:

Popup::ErrorAnyQuestion( Label::WarningMsg(), “Do really want to …?”, “Install”, “Don't do it”, `focus_no );

Parameters:

  • headline (String)

    headline or Popup::NoHeadline()

  • message (String)

    message string

  • yes_button_message (String)

    label on affirmative buttons (on left side)

  • no_button_message (String)

    label on negating button (on right side)

  • focus (Symbol)

    `focus_yes (first button) or `focus_no (second button)

Returns:

  • true: first button has been clicked false: second button has been clicked

See Also:



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# File 'library/general/src/modules/Popup.rb', line 351

def ErrorAnyQuestion(headline, message, yes_button_message, no_button_message, focus)
  button_box = AnyQuestionButtonBox(
    yes_button_message,
    no_button_message,
    focus
  )
  success = UI.OpenDialog(
    Opt(:decorated),
    popupLayoutInternal(
      headline,
      message,
      button_box
    )
  )

  ret = nil

  if success == true
    ret = UI.UserInput
    UI.CloseDialog
  end

  ret == :yes
end

#ErrorDetails(message, details) ⇒ Object

Show an error message with Details button and wait until user clicked “OK”.

Examples:

Popup::ErrorDetails(“The configuration was not succesful.”, “Service failed to start”);

Parameters:

  • message (String)

    error message string

  • details (String)

    detailed information string

See Also:



1430
1431
1432
1433
1434
1435
1436
1437
1438
# File 'library/general/src/modules/Popup.rb', line 1430

def ErrorDetails(message, details)
  anyMessageDetailsInternal(
    Label.ErrorMsg,
    message,
    details
  )

  nil
end

#Feedback(headline, message, &block) ⇒ Object

Run the block with a feeback popup The popup is automatically closed at the end (even when an exception is raised)

Parameters:

  • headline (String)

    popup headline (displayed in bold)

  • message (String)

    message with details, displayed below the headline

  • block

    block to execute

See Also:

  • and {ClearFeedback} for details


1070
1071
1072
1073
1074
1075
1076
1077
# File 'library/general/src/modules/Popup.rb', line 1070

def Feedback(headline, message, &block)
  raise ArgumentError, "block must be supplied" unless block

  ShowFeedback(headline, message)
  block.call
ensure
  ClearFeedback()
end

#LongError(message) ⇒ Object

Show a long error and wait until user clicked “OK”.

Parameters:

  • message (String)

    message string (may contain rich text tags)



1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
# File 'library/general/src/modules/Popup.rb', line 1342

def LongError(message)
  anyMessageInternalRich(
    Label.ErrorMsg,
    message,
    @default_width,
    @default_height
  )

  nil
end

#LongErrorGeometry(message, width, height) ⇒ Object

Show a long error message and wait until user clicked “OK”. Size of the popup window is adjustable.

Parameters:

  • message (String)

    message string (may contain rich text tags)

  • width (Fixnum)

    width of the popup window

  • height (Fixnum)

    height of the popup window



1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
# File 'library/general/src/modules/Popup.rb', line 1358

def LongErrorGeometry(message, width, height)
  anyMessageInternalRich(
    Label.ErrorMsg,
    message,
    width,
    height
  )

  nil
end

#LongMessage(message) ⇒ Object

Show a long message and wait until user clicked “OK”.

Parameters:

  • message (String)

    message string (may contain rich text tags)



1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
# File 'library/general/src/modules/Popup.rb', line 1100

def LongMessage(message)
  anyMessageInternalRich(
    NoHeadline(),
    message,
    @default_width,
    @default_height
  )

  nil
end

#LongMessageGeometry(message, width, height) ⇒ Object

Show a long message and wait until user clicked “OK”. Size of the popup window is adjustable.

Parameters:

  • message (String)

    message string (may contain rich text tags)

  • width (Fixnum)

    width of the popup window

  • height (Fixnum)

    height of the popup window



1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
# File 'library/general/src/modules/Popup.rb', line 1116

def LongMessageGeometry(message, width, height)
  anyMessageInternalRich(
    NoHeadline(),
    message,
    width,
    height
  )

  nil
end

#LongNotify(message) ⇒ Object

Show a long notify message and wait until user clicked “OK”.

Parameters:

  • message (String)

    message string (may contain rich text tags)



1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
# File 'library/general/src/modules/Popup.rb', line 1459

def LongNotify(message)
  anyMessageInternalRich(
    NoHeadline(),
    message,
    @default_width,
    @default_height
  )

  nil
end

#LongNotifyGeometry(message, width, height) ⇒ Object

Show a long notify message and wait until user clicked “OK”. Size of the popup window is adjustable.

Parameters:

  • message (String)

    message string (may contain rich text tags)

  • width (Fixnum)

    width of the popup window

  • height (Fixnum)

    height of the popup window



1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
# File 'library/general/src/modules/Popup.rb', line 1475

def LongNotifyGeometry(message, width, height)
  anyMessageInternalRich(
    NoHeadline(),
    message,
    width,
    height
  )

  nil
end

#LongText(headline, richtext, hdim, vdim) ⇒ Object

Show a long text that might need scrolling.

Pass a RichText widget with the parameters appropriate for your text - i.e. without special parameters for HTML-like text or with `opt(`plainText) for plain ASCII text without HTML tags.

![screenshots/LongText.png](../../screenshots/LongText.png)

Examples:

Popup::LongText ( “Package description”, `Richtext(“<p>Hello, this is a long description .….</p>”), 50, 20 );

Parameters:

  • headline (String)

    short headline

  • richtext (Yast::Term)

    text input is `Richtext()

  • hdim (Fixnum)

    initial horizontal dimension of the popup

  • vdim (Fixnum)

    initial vertical dimension of the popup



633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
# File 'library/general/src/modules/Popup.rb', line 633

def LongText(headline, richtext, hdim, vdim)
  richtext = deep_copy(richtext)
  success = UI.OpenDialog(
    Opt(:decorated),
    HBox(
      VSpacing(vdim),
      VBox(
        HSpacing(hdim),
        Left(Heading(headline)),
        VSpacing(0.2),
        richtext, # scrolled text
        ButtonBox(
          PushButton(
            Id(:ok),
            Opt(:default, :key_F10, :okButton),
            Label.OKButton
          )
        )
      )
    )
  )

  if success == true
    UI.SetFocus(Id(:ok))
    UI.UserInput
    UI.CloseDialog
  end

  nil
end

#LongWarning(message) ⇒ Object

Show a long warning and wait until user clicked “OK”.

Parameters:

  • message (String)

    message string (may contain rich text tags)



1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
# File 'library/general/src/modules/Popup.rb', line 1213

def LongWarning(message)
  anyMessageInternalRich(
    Label.WarningMsg,
    message,
    @default_width,
    @default_height
  )

  nil
end

#LongWarningGeometry(message, width, height) ⇒ Object

Show a long warning and wait until user clicked “OK”. Size of the popup window is adjustable

Parameters:

  • message (String)

    message string (may contain rich text tags)

  • width (Fixnum)

    width of the popup window

  • height (Fixnum)

    height of the popup window



1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
# File 'library/general/src/modules/Popup.rb', line 1229

def LongWarningGeometry(message, width, height)
  anyMessageInternalRich(
    Label.WarningMsg,
    message,
    width,
    height
  )

  nil
end

#mainObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'library/general/src/modules/Popup.rb', line 43

def main
  Yast.import "UI"

  textdomain "base"

  Yast.import "Label"
  Yast.import "Mode"
  Yast.import "Directory"

  @feedback_open = false

  # default size of the richtext widget in richtext popups
  @default_width = 60
  @default_height = 10

  # if error message is too long, show LongError instead of Error Popup
  @switch_to_richtext = true

  # lines of message text which force usage of RichText
  @too_many_lines = 20
end

#Message(message) ⇒ Object

Show a simple message and wait until user clicked “OK”.

![screenshots/Message.png](../../screenshots/Message.png)

Examples:

Popup::Message(“This is an information about … .” );

Parameters:

  • message (String)

    message string

See Also:



1091
1092
1093
1094
1095
# File 'library/general/src/modules/Popup.rb', line 1091

def Message(message)
  anyMessageInternal(NoHeadline(), message)

  nil
end

#MessageDetails(message, details) ⇒ Object

Show a message with Details button and wait until user clicked “OK”.

Examples:

Popup::MessageDetails(“This is an information about … .”, “This service is intended to…”);

Parameters:

  • message (String)

    message string

  • details (String)

    detailed information string

See Also:



1182
1183
1184
1185
1186
1187
1188
1189
1190
# File 'library/general/src/modules/Popup.rb', line 1182

def MessageDetails(message, details)
  anyMessageDetailsInternal(
    NoHeadline(),
    message,
    details
  )

  nil
end

#ModuleError(text) ⇒ Symbol

Special error popup for YCP modules that don't work.

The user can choose one of:

  • “back” - go back to the previous module

  • “next” - skip this faulty module and directly go to the next one

  • “again” - try it again (after fixing something in the code, of course)

  • “cancel” - exit program

![screenshots/ModuleError.png](../../screenshots/ModuleError.png)

Examples:

Popup::ModuleError( “The module ” + symbolof(argterm) + “ does not work.” );

Parameters:

Returns:

  • (Symbol)

    `back, `again, `cancel, `next



1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
# File 'library/general/src/modules/Popup.rb', line 1720

def ModuleError(text)
  success = UI.OpenDialog(
    Opt(:decorated, :warncolor),
    HBox(
      HSpacing(1),
      VBox(
        VSpacing(0.2),
        Heading(text),
        ButtonBox(
          PushButton(
            Id(:back),
            Opt(:key_F8, :customButton),
            Label.BackButton
          ),
          PushButton(
            Id(:again),
            Opt(:key_F6, :customButton),
            Label.RetryButton
          ),
          PushButton(
            Id(:cancel),
            Opt(:key_F9, :cancelButton),
            Label.QuitButton
          ),
          PushButton(Id(:next), Opt(:key_F10, :okButton), Label.NextButton)
        ),
        VSpacing(0.2)
      ),
      HSpacing(1)
    )
  )
  ret = nil

  if success == true
    ret = Convert.to_symbol(UI.UserInput)
    UI.CloseDialog
  end

  ret
end

#NoHeadlineObject

Indicator for empty headline for popups that can optionally have one

This is really just an alias for the empty string “”, but it is slightly better readable.

Returns:

  • empty string (“”)



245
246
247
# File 'library/general/src/modules/Popup.rb', line 245

def NoHeadline
  ""
end

#Notify(message) ⇒ Object

Show a notification message and wait until user clicked “OK”.

![screenshots/Notify.png](../../screenshots/Notify.png)

Examples:

Popup::Notify(“Your printer is ready for use.” );

Parameters:

  • message (String)

    notify message string

See Also:



1450
1451
1452
1453
1454
# File 'library/general/src/modules/Popup.rb', line 1450

def Notify(message)
  anyMessageInternal("", message)

  nil
end

#NotifyDetails(message, details) ⇒ Object

Show a notify message with Details button and wait until user clicked “OK”.

Parameters:

  • message (String)

    error message string

  • details (String)

    detailed information string

See Also:



1540
1541
1542
1543
1544
1545
1546
1547
1548
# File 'library/general/src/modules/Popup.rb', line 1540

def NotifyDetails(message, details)
  anyMessageDetailsInternal(
    NoHeadline(),
    message,
    details
  )

  nil
end

#popupLayoutInternal(headline, message, button_box) ⇒ Object

Internal function - wrapper for popupLayoutInternalTypeWithLabel call



127
128
129
130
131
132
133
134
135
136
137
138
# File 'library/general/src/modules/Popup.rb', line 127

def popupLayoutInternal(headline, message, button_box)
  button_box = deep_copy(button_box)
  popupLayoutInternalTypeWithLabel(
    headline,
    message,
    button_box,
    nil,
    false,
    0,
    0
  )
end

#popupLayoutInternalRich(headline, message, button_box, width, height) ⇒ Object

Internal function - wrapper for popupLayoutInternalTypeWithLabel call



141
142
143
144
145
146
147
148
149
150
151
152
# File 'library/general/src/modules/Popup.rb', line 141

def popupLayoutInternalRich(headline, message, button_box, width, height)
  button_box = deep_copy(button_box)
  popupLayoutInternalTypeWithLabel(
    headline,
    message,
    button_box,
    nil,
    true,
    width,
    height
  )
end

#popupLayoutInternalTypeWithLabel(headline, message, button_box, label, richtext, width, height) ⇒ Yast::Term

Internal function that returns a popup dialog with an additional label.

Parameters:

  • headline (String)

    headline to show or Popup::NoHeadline()

  • message (String)

    message text to show

  • button_box (Yast::Term)

    term with one or more buttons

  • label (String)

    second label with id `label which can be used e.g. for time out value displaying

Returns:

  • (Yast::Term)

    the layout contents as a term



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
# File 'library/general/src/modules/Popup.rb', line 73

def popupLayoutInternalTypeWithLabel(headline, message, button_box, label, richtext, width, height)
  button_box = deep_copy(button_box)
  content = Empty()

  rt = VWeight(
    1,
    VBox(
      HSpacing(width),
      HBox(
        VSpacing(height),
        RichText(message)
      )
    )
  )

  if Ops.greater_than(Builtins.size(headline), 0)
    content = VBox(
      VSpacing(0.4),
      VBox(
        Left(Heading(headline)),
        VSpacing(0.2),
        richtext ? rt : Left(Label(message)),
        VSpacing(0.2),
        !label.nil? && label != "" ? Label(Id(:label), label) : Empty()
      )
    ) # no headline
  else
    content = VBox(
      VSpacing(0.4),
      VBox(
        richtext ? rt : VCenter(Label(message)),
        VSpacing(0.2),
        !label.nil? && label != "" ? Label(Id(:label), label) : Empty()
      )
    )
  end

  dialog = HBox(
    HSpacing(1),
    VBox(
      VSpacing(0.2),
      content,
      richtext ? Empty() : VStretch(),
      button_box,
      richtext ? Empty() : VStretch(),
      VSpacing(0.2)
    ),
    HSpacing(1)
  )

  deep_copy(dialog)
end

#ReallyAbort(have_changes) ⇒ Object

Confirmation popup when user clicked “Abort”.

Set “have changes” to “true” when there are changes that will be lost. Note: If there are none, it is good policy to ask for confirmation anyway, but of course with “have_changes” set to “false” so the user isn't warned about changes that might be lost.

Parameters:

  • have_changes (Boolean)

    true: There are changes that will be lost false: No changes



818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
# File 'library/general/src/modules/Popup.rb', line 818

def ReallyAbort(have_changes)
  focus = :focus_yes

  # Confirm aborting the program
  message = _("Really abort?")

  if have_changes
    focus = :focus_no

    # Additional hint when trying to abort program in spite of changes
    message = Ops.add(
      Ops.add(message, "\n"),
      _("All changes will be lost!")
    )
  end

  ret = AnyQuestion(
    NoHeadline(),
    message,
    Label.YesButton,
    Label.NoButton,
    focus
  )

  Builtins.y2debug("ReallyAbort returned: %1", ret)

  ret
end

#ShowFeedback(headline, message) ⇒ void

This method returns an undefined value.

Show popup with a headline and a message for feedback

Parameters:

  • headline (String)

    headline of Feedback popup

  • message (String)

    the feedback message



1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
# File 'library/general/src/modules/Popup.rb', line 1045

def ShowFeedback(headline, message)
  UI.CloseDialog if @feedback_open
  button_box = Empty()
  UI.BusyCursor
  UI.OpenDialog(
    Opt(:decorated),
    popupLayoutInternal(
      headline,
      message,
      button_box
    )
  )

  @feedback_open = true

  nil
end

#ShowFile(headline, filename) ⇒ Object

Show the contents of an entire file in a popup.

Notice: This is a WFM function, NOT an UI function!

Examples:

Popup::ShowFile (“Boot Messages”, “/var/log/boot.msg”);

Parameters:

  • headline (String)

    headline text

  • filename (String)

    filename with path of the file to show



1899
1900
1901
1902
1903
1904
1905
# File 'library/general/src/modules/Popup.rb', line 1899

def ShowFile(headline, filename)
  text = Convert.to_string(SCR.Read(path(".target.string"), filename))

  ShowText(headline, text)

  nil
end

#ShowText(headline, text) ⇒ Object

Show the contents of an entire file in a popup.

Examples:

Popup::ShowText (“Boot Messages”, “kernel panic”);

Parameters:

  • headline (String)

    headline text

  • text (String)

    text to show



1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
# File 'library/general/src/modules/Popup.rb', line 1854

def ShowText(headline, text)
  heading = if Builtins.size(headline) == 0
    VSpacing(0.2)
  else
    Heading(headline)
  end

  success = UI.OpenDialog(
    Opt(:decorated),
    VBox(
      HSpacing(70), # force width
      heading,
      VWeight(
        1,
        HBox(
          VSpacing(18), # force height
          HSpacing(0.7),
          RichText(Id(:text), Opt(:plainText), text),
          HSpacing(0.7)
        )
      ),
      VSpacing(0.3),
      ButtonBox(
        PushButton(Opt(:default, :key_F10, :okButton), Label.OKButton)
      ),
      VSpacing(0.3)
    )
  )

  if success == true
    UI.UserInput
    UI.CloseDialog
  end

  nil
end

#ShowTextTimed(headline, text, timeout) ⇒ Object

Show the contents of an entire file in a popup.

Examples:

Popup::ShowText (“Boot Messages”, “kernel panic”, 10);

Parameters:

  • headline (String)

    headline text

  • text (String)

    text to show

  • timeout (Fixnum)

    text to show



1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
# File 'library/general/src/modules/Popup.rb', line 1799

def ShowTextTimed(headline, text, timeout)
  heading = if Builtins.size(headline) == 0
    VSpacing(0.2)
  else
    Heading(headline)
  end

  success = UI.OpenDialog(
    Opt(:decorated),
    VBox(
      HSpacing(70), # force width
      heading,
      VWeight(
        1,
        HBox(
          VSpacing(18), # force height
          HSpacing(0.7),
          RichText(Id(:text), Opt(:plainText), text),
          HSpacing(0.7)
        )
      ),
      VSpacing(0.3),
      Label(Id(:label), Builtins.sformat("%1", timeout)),
      VSpacing(0.2),
      ButtonBox(
        PushButton(
          Id(:ok_msg),
          Opt(:default, :key_F10, :okButton),
          Label.OKButton
        )
      ),
      VSpacing(0.3)
    )
  )

  button = nil

  while Ops.greater_than(timeout, 0) && button != :ok_msg
    button = Convert.to_symbol(UI.TimeoutUserInput(1000))
    timeout = Ops.subtract(timeout, 1)

    UI.ChangeWidget(Id(:label), :Value, Builtins.sformat("%1", timeout))
  end

  UI.CloseDialog if success == true

  nil
end

#TimedAnyQuestion(headline, message, yes_button_message, no_button_message, focus, timeout_seconds) ⇒ Boolean

Timed question popup with two buttons and time display

Parameters:

  • headline (String)

    headline or Popup::NoHeadline()

  • message (String)

    message string

  • yes_button_message (String)

    label on affirmative buttons (on left side)

  • no_button_message (String)

    label on negating button (on right side)

  • focus (Symbol)

    `focus_yes (first button) or `focus_no (second button)

  • timeout_seconds (Fixnum)

    timeout, if 0, normal behaviour

Returns:

  • (Boolean)

    True if Yes, False if no

See Also:



386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# File 'library/general/src/modules/Popup.rb', line 386

def TimedAnyQuestion(headline, message, yes_button_message, no_button_message, focus, timeout_seconds)
  button_box = AnyQuestionButtonBox(
    yes_button_message,
    no_button_message,
    focus
  )
  timed = ReplacePoint(
    Id(:replace_buttons),
    VBox(
      HCenter(Label(Id(:remaining_time), Ops.add("", timeout_seconds))),
      ButtonBox(
        # FIXME: BNC #422612, Use `opt(`noSanityCheck) later
        PushButton(Id(:timed_stop), Opt(:cancelButton), Label.StopButton),
        PushButton(
          Id(:timed_ok),
          Opt(:default, :key_F10, :okButton),
          Label.OKButton
        )
      ),
      VSpacing(0.2)
    )
  )

  success = UI.OpenDialog(
    Opt(:decorated),
    popupLayoutInternal(headline, message, timed)
  )

  while Ops.greater_than(timeout_seconds, 0)
    which_input = UI.TimeoutUserInput(1000)

    break if which_input == :timed_ok
    if which_input == :timed_stop
      UI.ReplaceWidget(Id(:replace_buttons), button_box)
      which_input = UI.UserInput while which_input == :timed_stop
      break
    end
    timeout_seconds = Ops.subtract(timeout_seconds, 1)

    next unless success

    UI.ChangeWidget(
      Id(:remaining_time),
      :Value,
      Ops.add("", timeout_seconds)
    )
  end

  UI.CloseDialog if success == true

  which_input == :yes
end

#TimedError(message, timeout_seconds) ⇒ void

This method returns an undefined value.

Show an error message and wait specified amount of time or until user clicked “OK”.

![screenshots/TimedErrorPopup.png](../../screenshots/TimedErrorPopup.png)

Parameters:

  • message (String)

    error message string

  • timeout_seconds (Fixnum)

    time out in seconds

See Also:



1379
1380
1381
1382
1383
1384
1385
1386
1387
# File 'library/general/src/modules/Popup.rb', line 1379

def TimedError(message, timeout_seconds)
  anyTimedMessageInternal(
    Label.ErrorMsg,
    message,
    timeout_seconds
  )

  nil
end

#TimedErrorAnyQuestion(headline, message, yes_button_message, no_button_message, focus, timeout_seconds) ⇒ Boolean

Timed error question popup with two buttons and time display

Parameters:

  • headline (String)

    headline or Popup::NoHeadline()

  • message (String)

    message string

  • yes_button_message (String)

    label on affirmative buttons (on left side)

  • no_button_message (String)

    label on negating button (on right side)

  • focus (Symbol)

    `focus_yes (first button) or `focus_no (second button)

  • timeout_seconds (Fixnum)

    timeout, if 0, normal behaviour

Returns:

  • (Boolean)

    True if Yes, False if no

See Also:



449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'library/general/src/modules/Popup.rb', line 449

def TimedErrorAnyQuestion(headline, message, yes_button_message, no_button_message, focus, timeout_seconds)
  button_box = AnyQuestionButtonBox(
    yes_button_message,
    no_button_message,
    focus
  )
  timed = ReplacePoint(
    Id(:replace_buttons),
    VBox(
      HCenter(Label(Id(:remaining_time), Ops.add("", timeout_seconds))),
      ButtonBox(
        # FIXME: BNC #422612, Use `opt(`noSanityCheck) later
        PushButton(Id(:timed_stop), Opt(:cancelButton), Label.StopButton),
        PushButton(
          Id(:timed_ok),
          Opt(:default, :key_F10, :okButton),
          Label.OKButton
        )
      ),
      VSpacing(0.2)
    )
  )

  success = UI.OpenDialog(
    Opt(:decorated),
    popupLayoutInternal(headline, message, timed)
  )

  while Ops.greater_than(timeout_seconds, 0)
    which_input = UI.TimeoutUserInput(1000)

    break if which_input == :timed_ok
    if which_input == :timed_stop
      UI.ReplaceWidget(Id(:replace_buttons), button_box)
      which_input = UI.UserInput while which_input == :timed_stop
      break
    end
    timeout_seconds = Ops.subtract(timeout_seconds, 1)

    next unless success

    UI.ChangeWidget(
      Id(:remaining_time),
      :Value,
      Ops.add("", timeout_seconds)
    )
  end

  UI.CloseDialog if success == true

  which_input == :yes
end

#TimedLongError(message, timeout_seconds) ⇒ Object

Show a long error message and wait until user clicked “OK” or time is out.

Parameters:

  • message (String)

    message string (may contain rich text tags)

  • timeout_seconds (Fixnum)

    time out in seconds



1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
# File 'library/general/src/modules/Popup.rb', line 1393

def TimedLongError(message, timeout_seconds)
  anyTimedRichMessageInternal(
    Label.ErrorMsg,
    message,
    timeout_seconds,
    @default_width,
    @default_height
  )

  nil
end

#TimedLongErrorGeometry(message, timeout_seconds, width, height) ⇒ Object

Show a long error message and wait until user clicked “OK” or time is out. Size of the popup window is adjustable.

Parameters:

  • message (String)

    message string (may contain rich text tags)

  • timeout_seconds (Fixnum)

    time out in seconds

  • width (Fixnum)

    width of the popup window

  • height (Fixnum)

    height of the popup window



1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
# File 'library/general/src/modules/Popup.rb', line 1411

def TimedLongErrorGeometry(message, timeout_seconds, width, height)
  anyTimedRichMessageInternal(
    Label.ErrorMsg,
    message,
    timeout_seconds,
    width,
    height
  )

  nil
end

#TimedLongMessage(message, timeout_seconds) ⇒ Object

Show a long message and wait until user clicked “OK” or time is out.

Parameters:

  • message (String)

    message string (may contain rich text tags)

  • timeout_seconds (Fixnum)

    time out in seconds



1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
# File 'library/general/src/modules/Popup.rb', line 1145

def TimedLongMessage(message, timeout_seconds)
  anyTimedRichMessageInternal(
    NoHeadline(),
    message,
    timeout_seconds,
    @default_width,
    @default_height
  )

  nil
end

#TimedLongMessageGeometry(message, timeout_seconds, width, height) ⇒ Object

Show a long message and wait until user clicked “OK” or time is out. Size of the popup window is adjustable.

Parameters:

  • message (String)

    message string (may contain rich text tags)

  • timeout_seconds (Fixnum)

    time out in seconds

  • width (Fixnum)

    width of the popup window

  • height (Fixnum)

    height of the popup window



1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
# File 'library/general/src/modules/Popup.rb', line 1163

def TimedLongMessageGeometry(message, timeout_seconds, width, height)
  anyTimedRichMessageInternal(
    NoHeadline(),
    message,
    timeout_seconds,
    width,
    height
  )

  nil
end

#TimedLongNotify(message, timeout_seconds) ⇒ Object

Show a long error message and wait until user clicked “OK” or time is out.

Parameters:

  • message (String)

    message string (may contain rich text tags)

  • timeout_seconds (Fixnum)

    time out in seconds



1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
# File 'library/general/src/modules/Popup.rb', line 1504

def TimedLongNotify(message, timeout_seconds)
  anyTimedRichMessageInternal(
    NoHeadline(),
    message,
    timeout_seconds,
    @default_width,
    @default_height
  )

  nil
end

#TimedLongNotifyGeometry(message, timeout_seconds, width, height) ⇒ Object

Show a long notify message and wait until user clicked “OK” or time is out. Size of the popup window is adjustable.

Parameters:

  • message (String)

    message string (may contain rich text tags)

  • timeout_seconds (Fixnum)

    time out in seconds

  • width (Fixnum)

    width of the popup window

  • height (Fixnum)

    height of the popup window



1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
# File 'library/general/src/modules/Popup.rb', line 1522

def TimedLongNotifyGeometry(message, timeout_seconds, width, height)
  anyTimedRichMessageInternal(
    NoHeadline(),
    message,
    timeout_seconds,
    width,
    height
  )

  nil
end

#TimedLongWarning(message, timeout_seconds) ⇒ Object

Show a long warning message and wait until user clicked “OK” or time is out.

Parameters:

  • message (String)

    message string (may contain rich text tags)

  • timeout_seconds (Fixnum)

    time out in seconds



1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
# File 'library/general/src/modules/Popup.rb', line 1264

def TimedLongWarning(message, timeout_seconds)
  anyTimedRichMessageInternal(
    Label.WarningMsg,
    message,
    timeout_seconds,
    @default_width,
    @default_height
  )

  nil
end

#TimedLongWarningGeometry(message, timeout_seconds, width, height) ⇒ Object

Show a long warning and wait until user clicked “OK” or time is out. Size of the popup window is adjustable.

Parameters:

  • message (String)

    message string (may contain rich text tags)

  • timeout_seconds (Fixnum)

    time out in seconds

  • width (Fixnum)

    width of the popup window

  • height (Fixnum)

    height of the popup window



1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
# File 'library/general/src/modules/Popup.rb', line 1282

def TimedLongWarningGeometry(message, timeout_seconds, width, height)
  anyTimedRichMessageInternal(
    Label.WarningMsg,
    message,
    timeout_seconds,
    width,
    height
  )

  nil
end

#TimedMessage(message, timeout_seconds) ⇒ Object

Show a message and wait until user clicked “OK” or time is out

Parameters:

  • message (String)

    message string

  • timeout_seconds (Fixnum)

    time out in seconds



1131
1132
1133
1134
1135
1136
1137
1138
1139
# File 'library/general/src/modules/Popup.rb', line 1131

def TimedMessage(message, timeout_seconds)
  anyTimedMessageInternal(
    NoHeadline(),
    message,
    timeout_seconds
  )

  nil
end

#TimedNotify(message, timeout_seconds) ⇒ Object

Show a long notify message and wait until user clicked “OK” or the time is out.

Parameters:

  • message (String)

    message string (may contain rich text tags)

  • timeout_seconds (Fixnum)

    time out in seconds



1490
1491
1492
1493
1494
1495
1496
1497
1498
# File 'library/general/src/modules/Popup.rb', line 1490

def TimedNotify(message, timeout_seconds)
  anyTimedMessageInternal(
    NoHeadline(),
    message,
    timeout_seconds
  )

  nil
end

#TimedOKCancel(message, timeout_seconds) ⇒ Object

Display a message with a timeout

Display a message with a timeout and return when the user clicks “OK”, “Cancel” or when the timeout expires (“OK” is assumed then).

There is also a “stop” button that will stop the countdown. If the user clicks that, the popup will wait forever (or until “OK” or “Cancel” is clicked, of course).

Examples:

boolean ret = Popup::TimedOKCancel(“This is a timed message”, 2 );

Parameters:

  • message (String)

    message to display

  • timeout_seconds (Fixnum)

    the timeout in seconds

Returns:

  • true –> “OK” or timer expired
    false –> “Cancel”



1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
# File 'library/general/src/modules/Popup.rb', line 1566

def TimedOKCancel(message, timeout_seconds)
  success = UI.OpenDialog(
    Opt(:decorated),
    HBox(
      HSpacing(1),
      VBox(
        VSpacing(0.2),
        Label(message),
        HCenter(Label(Id(:remaining_time), Ops.add("", timeout_seconds))),
        ButtonBox(
          PushButton(Id(:timed_stop), Opt(:customButton), Label.StopButton),
          PushButton(
            Id(:timed_ok),
            Opt(:default, :key_F10, :okButton),
            Label.OKButton
          ),
          PushButton(
            Id(:timed_cancel),
            Opt(:key_F9, :cancelButton),
            Label.CancelButton
          )
        ),
        VSpacing(0.2)
      )
    )
  )

  while Ops.greater_than(timeout_seconds, 0)
    which_input = UI.TimeoutUserInput(1000)
    break if which_input == :timed_ok
    break if which_input == :timed_cancel
    if which_input == :timed_stop
      which_input = UI.UserInput while which_input == :timed_stop
      break
    end
    timeout_seconds = Ops.subtract(timeout_seconds, 1)
    UI.ChangeWidget(
      Id(:remaining_time),
      :Value,
      Ops.add("", timeout_seconds)
    )
  end
  UI.CloseDialog if success == true

  which_input != :timed_cancel
end

#TimedWarning(message, timeout_seconds) ⇒ void

This method returns an undefined value.

Show a warning message and wait specified amount of time or until user clicked “OK”.

![screenshots/TimedWarningPopup.png](../../screenshots/TimedWarningPopup.png)

Parameters:

  • message (String)

    warning message string

  • timeout_seconds (Fixnum)

    time out in seconds

See Also:



1250
1251
1252
1253
1254
1255
1256
1257
1258
# File 'library/general/src/modules/Popup.rb', line 1250

def TimedWarning(message, timeout_seconds)
  anyTimedMessageInternal(
    Label.WarningMsg,
    message,
    timeout_seconds
  )

  nil
end

#Warning(message) ⇒ Object

Show a warning message and wait until user clicked “OK”.

![screenshots/Warning.png](../../screenshots/Warning.png)

Examples:

Popup::Warning(“Something is wrong. Please check your configuration.” );

Parameters:

  • message (String)

    warning message string

See Also:



1204
1205
1206
1207
1208
# File 'library/general/src/modules/Popup.rb', line 1204

def Warning(message)
  anyMessageInternal(Label.WarningMsg, message)

  nil
end

#WarningDetails(message, details) ⇒ Object

Show a warning with Details button and wait until user clicked “OK”.

Examples:

Popup::WarningDetails(“Something is wrong. Please check your configuration.”, “possible problem is in…” );

Parameters:

  • message (String)

    warning message string

  • details (String)

    detailed information string

See Also:



1301
1302
1303
1304
1305
1306
1307
1308
1309
# File 'library/general/src/modules/Popup.rb', line 1301

def WarningDetails(message, details)
  anyMessageDetailsInternal(
    Label.WarningMsg,
    message,
    details
  )

  nil
end

#YesNo(message) ⇒ Boolean

Display a yes/no question and wait for answer.

Should be used for decisions about two about equivalent paths, not for simple confirmation - use “Popup::ContinueCancel()” for those. The default button is Yes. Returns true if Yes is clicked.

![screenshots/YesNo.png](../../screenshots/YesNo.png)

Examples:

Popup::YesNo ( “Create a backup of the config files?” );

Parameters:

  • message (String)

    message string

Returns:

  • (Boolean)

    true if [Yes] has been pressed

See Also:



611
612
613
614
615
616
617
# File 'library/general/src/modules/Popup.rb', line 611

def YesNo(message)
  ret = YesNoHeadline(NoHeadline(), message)

  Builtins.y2debug("YesNo returned: %1", ret)

  ret
end

#YesNoHeadline(headline, message) ⇒ Boolean

This dialog displays “message” (a question) and has a Yes and a No button.

It should be used for decisions about two about equivalent paths, not for simple confirmation - use “Popup::ContinueCancel()” for those. A short headline can be displayed (without headline you can use Popup::YesNo()).

The default button is Yes.

Returns true if Yes is clicked.

![screenshots/YesNoHeadline.png](../../screenshots/YesNoHeadline.png)

Examples:

Popup::YesNoHeadline ( “Resize Windows Partition?”, “… explanation of dangers …” );

Parameters:

  • headline (String)

    short headline or Popup::NoHeadline()

  • message (String)

    message string

Returns:

  • (Boolean)

    true if [Yes] has been pressed

See Also:



580
581
582
583
584
585
586
587
588
589
590
591
592
# File 'library/general/src/modules/Popup.rb', line 580

def YesNoHeadline(headline, message)
  ret = AnyQuestion(
    headline,
    message,
    Label.YesButton,
    Label.NoButton,
    :focus_yes
  )

  Builtins.y2debug("YesNoHeadline returned: %1", ret)

  ret
end