Class: Yast::WizardClass

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) AbortAcceptButtonBox

Returns a button box with buttons “Abort”, “Accept”

Returns:

  • a widget tree



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File '../../src/modules/Wizard.rb', line 220

def AbortAcceptButtonBox
  HBox(
    HWeight(1, ReplacePoint(Id(:back_rep), Empty())), # Layout trick to make sure the center button is centered
    HStretch(),
    HWeight(
      1,
      ReplacePoint(
        Id(:rep_abort), # Make sure HideAbortButton() works (bnc #444176)
        PushButton(Id(:abort), Opt(:key_F9), Label.AbortButton)
      )
    ),
    HStretch(),
    HWeight(
      1,
      PushButton(Id(:accept), Opt(:key_F10, :default), Label.AcceptButton)
    )
  )
end

- (Object) AbortApplyFinishButtonBox

Returns a button box with buttons “Abort”, “Apply”, “Finish”

Returns:

  • a widget tree



262
263
264
265
266
267
268
269
# File '../../src/modules/Wizard.rb', line 262

def AbortApplyFinishButtonBox
  ButtonBox(
    PushButton(Id(:abort, :cancelButton, :key_F9), Label.AbortButton),
    # button text
    PushButton(Id(:apply, :applyButton), _("&Apply")),
    PushButton(Id(:finish, :okButton, :key_F10), Label.FinishButton)
  )
end

- (Object) AbortInstallationAcceptButtonBox

Returns a button box with buttons “Abort Installation”, “Accept”

Returns:

  • a widget tree



243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File '../../src/modules/Wizard.rb', line 243

def AbortInstallationAcceptButtonBox
  ButtonBox(
    PushButton(
      Id(:abort),
      Opt(:key_F9, :cancelButton),
      Label.AbortInstallationButton
    ),
    PushButton(
      Id(:accept),
      Opt(:key_F10, :okButton, :default),
      Label.AcceptButton
    )
  )
end

- (Yast::Term) AcceptDialog

Note:

This is a stable API function

Returns a standard wizard dialog with buttons “Cancel”, “Accept”

Returns:

  • (Yast::Term)

    describing the dialog.



413
414
415
# File '../../src/modules/Wizard.rb', line 413

def AcceptDialog
  GenericDialog(CancelAcceptButtonBox())
end

- (Array<Hash>) AddMenu(_Menu, title, id)

Add Menu

Parameters:

  • Menu (Array<Hash>)

    Menu data

  • title (String)

    Menu Title

  • id (String)

    Menu ID

Returns:

  • (Array<Hash>)

    Updated Menu Data



1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
# File '../../src/modules/Wizard.rb', line 1756

def AddMenu(_Menu, title, id)
  _Menu = deep_copy(_Menu)
  if haveFancyUI
    UI.WizardCommand(term(:AddMenu, title, id))
  else
    _Menu = Builtins.add(
      _Menu,
      { "type" => "Menu", "title" => title, "id" => id }
    )
  end
  deep_copy(_Menu)
end

- (Array<Hash>) AddMenuEntry(_Menu, parent_id, title, id)

Add Menu Entry

Parameters:

  • Menu (Array<Hash>)

    Menu data

  • parent_id (String)

    Menu Parent

  • title (String)

    Menu Title

  • id (String)

    Menu ID

Returns:

  • (Array<Hash>)

    Updated Menu Data



1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
# File '../../src/modules/Wizard.rb', line 1803

def AddMenuEntry(_Menu, parent_id, title, id)
  _Menu = deep_copy(_Menu)
  if haveFancyUI
    UI.WizardCommand(term(:AddMenuEntry, parent_id, title, id))
  else
    _Menu = Builtins.add(
      _Menu,
      {
        "type"   => "MenuEntry",
        "parent" => parent_id,
        "title"  => title,
        "id"     => id
      }
    )
  end
  deep_copy(_Menu)
end

- (Array<Hash>) AddSubMenu(_Menu, parent_id, title, id)

Add Sub Menu

Parameters:

  • Menu (Array<Hash>)

    Menu data

  • parent_id (String)

    Menu Parent

  • title (String)

    Menu Title

  • id (String)

    Menu ID

Returns:

  • (Array<Hash>)

    Updated Menu Data



1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
# File '../../src/modules/Wizard.rb', line 1777

def AddSubMenu(_Menu, parent_id, title, id)
  _Menu = deep_copy(_Menu)
  if haveFancyUI
    UI.WizardCommand(term(:AddSubMenu, parent_id, title, id))
  else
    _Menu = Builtins.add(
      _Menu,
      {
        "type"   => "SubMenu",
        "parent" => parent_id,
        "title"  => title,
        "id"     => id
      }
    )
  end
  deep_copy(_Menu)
end

- (Array<Hash>) AddTreeItem(_Tree, parent, title, id)

Add Tree Item to tree enabled Wizard

Parameters:

  • Tree (Array<Hash>)

    Tree Data

  • parent (String)

    Parent of this item

  • title (String)

    Item Title

  • id (String)

    Item ID

Returns:

  • (Array<Hash>)

    Updated Tree Data



1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
# File '../../src/modules/Wizard.rb', line 1620

def AddTreeItem(_Tree, parent, title, id)
  _Tree = deep_copy(_Tree)
  if haveFancyUI
    UI.WizardCommand(term(:AddTreeItem, parent, title, id))
  else
    _Tree = Builtins.add(
      _Tree,
      { "parent" => parent, "title" => title, "id" => id }
    )
  end
  deep_copy(_Tree)
end

- (Object) BackAbortInstallationNextButtonBox

Returns a button box with buttons “Back”, “Abort Installation”, “Next”

Returns:

  • a widget tree



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
# File '../../src/modules/Wizard.rb', line 133

def BackAbortInstallationNextButtonBox
  HBox(
    HWeight(
      1,
      ReplacePoint(
        Id(:rep_help),
        PushButton(Id(:help), Opt(:key_F1, :helpButton), Label.HelpButton)
      )
    ),
    HStretch(),
    HWeight(
      1,
      ReplacePoint(
        Id(:rep_back),
        PushButton(Id(:back), Opt(:key_F8), Label.BackButton)
      )
    ),
    HStretch(),
    ReplacePoint(
      Id(:rep_abort),
      PushButton(Id(:abort), Opt(:key_F9), Label.AbortInstallationButton)
    ),
    HStretch(),
    HWeight(
      1,
      ReplacePoint(
        Id(:rep_next),
        PushButton(Id(:next), Opt(:key_F10, :default), Label.NextButton)
      )
    )
  )
end

- (Object) BackAbortNextButtonBox

Returns a button box with buttons “Back”, “Abort”, “Next”

Returns:

  • a widget tree



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
127
# File '../../src/modules/Wizard.rb', line 96

def BackAbortNextButtonBox
  HBox(
    HWeight(
      1,
      ReplacePoint(
        Id(:rep_help),
        PushButton(Id(:help), Opt(:key_F1, :helpButton), Label.HelpButton)
      )
    ),
    HStretch(),
    HWeight(
      1,
      ReplacePoint(
        Id(:rep_back),
        PushButton(Id(:back), Opt(:key_F8), Label.BackButton)
      )
    ),
    HStretch(),
    ReplacePoint(
      Id(:rep_abort),
      PushButton(Id(:abort), Opt(:key_F9), Label.AbortButton)
    ),
    HStretch(),
    HWeight(
      1,
      ReplacePoint(
        Id(:rep_next),
        PushButton(Id(:next), Opt(:key_F10, :default), Label.NextButton)
      )
    )
  )
end

- (Object) BackNextButtonBox

Returns a button box with buttons “Back”, “Next”

Returns:

  • a widget tree



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File '../../src/modules/Wizard.rb', line 170

def BackNextButtonBox
  HBox(
    HWeight(
      1,
      ReplacePoint(
        Id(:rep_back),
        PushButton(Id(:back), Opt(:key_F8), Label.BackButton)
      )
    ),
    HStretch(),
    HWeight(
      1,
      ReplacePoint(
        Id(:rep_next),
        PushButton(Id(:next), Opt(:key_F10, :default), Label.NextButton)
      )
    )
  )
end

- (Object) CancelAcceptButtonBox

Returns a button box with buttons “Cancel”, “Accept”

Returns:

  • a widget tree



194
195
196
197
198
199
200
201
202
203
# File '../../src/modules/Wizard.rb', line 194

def CancelAcceptButtonBox
  ButtonBox(
    PushButton(Id(:cancel), Opt(:key_F9, :cancelButton), Label.CancelButton),
    PushButton(
      Id(:accept),
      Opt(:key_F10, :default, :okButton),
      Label.AcceptButton
    )
  )
end

- (Object) CancelOKButtonBox

Returns a button box with buttons “Cancel”, “OK”

Returns:

  • a widget tree



209
210
211
212
213
214
# File '../../src/modules/Wizard.rb', line 209

def CancelOKButtonBox
  ButtonBox(
    PushButton(Id(:cancel), Opt(:key_F9, :cancelButton), Label.CancelButton),
    PushButton(Id(:ok), Opt(:key_F10, :default, :okButton), Label.OKButton)
  )
end

- (Object) ClearContents

Note:

This is a stable API function

Clear the wizard contents.

This may sound silly, but it gives much faster feedback to the user if used properly: Whenever the user clicks “Next” or “Back”, call ClearContents() prior to any lengthy operation -> the user notices instant response, even though he may in fact still have to wait.



931
932
933
934
935
# File '../../src/modules/Wizard.rb', line 931

def ClearContents
  SetContents("", Empty(), "", false, false)

  nil
end

- (Object) ClearTitleIcon

Note:

Deprecated. Do nothing.

Clear the wizard 'title' icon, i.e. replace it with nothing

See Also:



1206
1207
1208
# File '../../src/modules/Wizard.rb', line 1206

def ClearTitleIcon
  nil
end

- (Object) CloseDialog

Note:

This is a stable API function

Close a wizard dialog.



708
709
710
711
712
713
714
715
716
717
718
# File '../../src/modules/Wizard.rb', line 708

def CloseDialog
  if IsWizardDialog()
    UI.CloseDialog
  else
    Builtins.y2error(
      "Wizard::CloseDialog(): Topmost dialog is not a wizard dialog!"
    )
  end

  nil
end

- (Object) CreateDialog

Create and open a typical installation wizard dialog.

For backwards compatibility only - don't use this any more in new modules.



833
834
835
836
837
838
839
840
841
# File '../../src/modules/Wizard.rb', line 833

def CreateDialog
  # Set productname for help text
  @product_name = OSRelease.ReleaseName if @product_name == ""
  UI.SetProductName(@product_name)

  OpenNextBackDialog()

  nil
end

- (void) CreateMenu(_Menu)

This method returns an undefined value.

Create the menu in the dialog

Parameters:

  • Menu (Array<Hash>)

    Menu data



1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
# File '../../src/modules/Wizard.rb', line 1855

def CreateMenu(_Menu)
  _Menu = deep_copy(_Menu)
  if !haveFancyUI
    menu_term = HBox()
    Builtins.foreach(_Menu) do |m|
      if Ops.get_string(m, "type", "") == "Menu"
        menu_items = CreateMenuInternal(_Menu, Ops.get_string(m, "id", ""))
        Builtins.y2debug("menu_items: %1", menu_items)
        menu_term = Builtins.add(
          menu_term,
          MenuButton(Ops.get_string(m, "title", ""), menu_items)
        )
      end
    end
    Builtins.y2milestone("menu: %1", menu_term)
    UI.ReplaceWidget(Id(:topmenu), Left(menu_term))
  end
  nil
end

- (Array) CreateMenuInternal(_Menu, parent)

Create the Menu Items

Parameters:

  • Menu (Array<Hash>)

    Menu data

  • parent (String)

    Menu Parent

Returns:

  • (Array)

    Menu Items



1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
# File '../../src/modules/Wizard.rb', line 1827

def CreateMenuInternal(_Menu, parent)
  _Menu = deep_copy(_Menu)
  m = Builtins.filter(_Menu) do |c|
    Ops.get_string(c, "parent", "") == parent
  end

  mm = Builtins.maplist(m) do |cc|
    if Ops.get_string(cc, "type", "") == "MenuEntry"
      _MenuEntry = Ops.get_string(cc, "id", "")
      next Item(Id(_MenuEntry), Ops.get_string(cc, "title", ""))
    elsif Ops.get_string(cc, "type", "") == "SubMenu"
      _SubMenu = Ops.get_string(cc, "id", "")
      next term(
        :menu,
        Ops.get_string(cc, "title", ""),
        CreateMenuInternal(_Menu, _SubMenu)
      )
    end
  end
  Builtins.y2debug("items: %1", mm)
  deep_copy(mm)
end

- (Object) CreateTree(_Tree, title)

Create the tree in the dialog, replaces helpspace with new tree widget

Parameters:

  • Tree (Array<Hash>)

    Tree data

  • title (String)

    Tree title



1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
# File '../../src/modules/Wizard.rb', line 1683

def CreateTree(_Tree, title)
  _Tree = deep_copy(_Tree)
  if !haveFancyUI
    items = []
    Builtins.foreach(_Tree) do |i|
      if Ops.get_string(i, "parent", "") == ""
        items = Builtins.add(
          items,
          Item(
            Id(Ops.get_string(i, "id", "")),
            Ops.get_string(i, "title", ""),
            CreateTreeInternal(_Tree, Ops.get_string(i, "id", ""))
          )
        )
      end
    end
    Builtins.y2debug("tree items: %1", items)

    ReplaceCustomHelp(
      VBox(
        term(:Tree, Id(:wizardTree), Opt(:notify, :vstretch), title, items),
        VSpacing(1)
      )
    )
  end

  nil
end

- (Object) CreateTreeDialog

Create and open a Tree wizard dialog.

For backwards compatibility only - don't use this any more in new modules.



1607
1608
1609
1610
# File '../../src/modules/Wizard.rb', line 1607

def CreateTreeDialog
  OpenTreeNextBackDialog()
  nil
end

- (Array) CreateTreeInternal(_Tree, parent)

Create the Tree Items

Parameters:

  • Tree (Array<Hash>)

    Tree data

  • parent (String)

    Parent of current Item

Returns:

  • (Array)

    Tree Items



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
# File '../../src/modules/Wizard.rb', line 1639

def CreateTreeInternal(_Tree, parent)
  _Tree = deep_copy(_Tree)
  m = Builtins.filter(_Tree) do |c|
    Ops.get_string(c, "parent", "") == parent
  end
  ccbak = nil # #38596, broken recursion for iterators
  mm = Builtins.maplist(m) do |cc|
    _TreeEntry = Ops.get_string(cc, "id", "")
    ccbak = deep_copy(cc)
    items = CreateTreeInternal(_Tree, _TreeEntry)
    cc = deep_copy(ccbak)
    if Ops.greater_than(Builtins.size(items), 0)
      next Item(
        Id(Ops.get_string(cc, "id", "")),
        Ops.get_string(cc, "title", ""),
        items
      )
    else
      next Item(
        Id(Ops.get_string(cc, "id", "")),
        Ops.get_string(cc, "title", "")
      )
    end
  end
  Builtins.y2debug("items: %1", mm)
  deep_copy(mm)
end

- (Object) DeleteMenus

Delete Menu items



1739
1740
1741
1742
1743
1744
1745
1746
1747
# File '../../src/modules/Wizard.rb', line 1739

def DeleteMenus
  if haveFancyUI
    UI.WizardCommand(term(:DeleteMenus))
  else
    UI.ReplaceWidget(Id(:topmenu), Empty())
  end

  nil
end

- (Object) DeleteTreeItems

Delete Tree items



1727
1728
1729
1730
1731
1732
1733
1734
1735
# File '../../src/modules/Wizard.rb', line 1727

def DeleteTreeItems
  if haveFancyUI
    UI.WizardCommand(term(:DeleteTreeItems))
  else
    ReplaceCustomHelp(Empty())
  end

  nil
end

- (Object) DisableAbortButton

Note:

This is a stable API function

Disable the wizard's “Abort” button.

See Also:



1317
1318
1319
1320
1321
1322
1323
# File '../../src/modules/Wizard.rb', line 1317

def DisableAbortButton
  if UI.WizardCommand(term(:EnableAbortButton, false)) == false
    UI.ChangeWidget(Id(:abort), :Enabled, false)
  end

  nil
end

- (Object) DisableBackButton

Note:

This is a stable API function

Disable the wizard's “Back” button.

See Also:



1369
1370
1371
1372
1373
1374
1375
# File '../../src/modules/Wizard.rb', line 1369

def DisableBackButton
  if UI.WizardCommand(term(:EnableBackButton, false)) == false
    UI.ChangeWidget(Id(:back), :Enabled, false)
  end

  nil
end

- (Object) DisableCancelButton

Note:

This is a stable API function

Disable the wizard's “Cancel” button.



1396
1397
1398
1399
1400
1401
1402
# File '../../src/modules/Wizard.rb', line 1396

def DisableCancelButton
  if UI.WizardCommand(term(:EnableCancelButton, false)) == false
    UI.ChangeWidget(Id(:cancel), :Enabled, false)
  end

  nil
end

- (Object) DisableNextButton

Note:

This is a stable API function

Disable the wizard's “Next” (or “Accept”) button.

See Also:



1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
# File '../../src/modules/Wizard.rb', line 1331

def DisableNextButton
  if UI.WizardCommand(term(:EnableNextButton, false)) == false
    if UI.WidgetExists(Id(:next))
      UI.ChangeWidget(Id(:next), :Enabled, false)
    elsif UI.WidgetExists(Id(:accept))
      UI.ChangeWidget(Id(:accept), :Enabled, false)
    else
      Builtins.y2error(-1, "Neither `next nor `accept widgets exist")
    end
  end

  nil
end

- (Object) EnableAbortButton

Note:

This is a stable API function

Enable the wizard's “Abort” button.



1303
1304
1305
1306
1307
1308
1309
# File '../../src/modules/Wizard.rb', line 1303

def EnableAbortButton
  if UI.WizardCommand(term(:EnableAbortButton, true)) == false
    UI.ChangeWidget(Id(:abort), :Enabled, true)
  end

  nil
end

- (Object) EnableBackButton

Note:

This is a stable API function

Enable the wizard's “Back” button.

See Also:



1382
1383
1384
1385
1386
1387
1388
# File '../../src/modules/Wizard.rb', line 1382

def EnableBackButton
  if UI.WizardCommand(term(:EnableBackButton, true)) == false
    UI.ChangeWidget(Id(:back), :Enabled, true)
  end

  nil
end

- (Object) EnableCancelButton

Note:

This is a stable API function

Enable the wizard's “Cancel” button.



1410
1411
1412
1413
1414
1415
1416
# File '../../src/modules/Wizard.rb', line 1410

def EnableCancelButton
  if UI.WizardCommand(term(:EnableCancelButton, true)) == false
    UI.ChangeWidget(Id(:cancel), :Enabled, true)
  end

  nil
end

- (Object) EnableNextButton

Note:

This is a stable API function

Enable the wizard's “Next” (or “Accept”) button.

See Also:



1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
# File '../../src/modules/Wizard.rb', line 1351

def EnableNextButton
  if UI.WizardCommand(term(:EnableNextButton, true)) == false
    if UI.WidgetExists(Id(:next))
      UI.ChangeWidget(Id(:next), :Enabled, true)
    else
      UI.ChangeWidget(Id(:accept), :Enabled, true)
    end
  end

  nil
end

- (Yast::Term) GenericDialog(button_box)

Note:

This is a stable API function

Create a Generic Dialog

Returns a term describing a generic wizard dialog with a configurable button box.

Parameters:

  • button_box (Yast::Term)

    term that contains a `HBox() with buttons in it

Returns:

  • (Yast::Term)

    term describing the dialog.



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
# File '../../src/modules/Wizard.rb', line 283

def GenericDialog(button_box)
  button_box = deep_copy(button_box)
  VBox(
    Id(:WizardDialog),
    ReplacePoint(Id(:topmenu), Empty()),
    HBox(
      HSpacing(1),
      VBox(
        VSpacing(0.2),
        HBox(
          # translators: dialog title to appear before any content is initialized
          Heading(Id(:title), Opt(:hstretch), _("Initializing ...")),
          HStretch(),
          ReplacePoint(Id(:relnotes_rp), Empty())
        ),
        VWeight(
          1, # Layout trick: Lower layout priority with weight
          HVCenter(Opt(:hvstretch), ReplacePoint(Id(:contents), Empty()))
        )
      ),
      HSpacing(1)
    ),
    ReplacePoint(Id(:rep_button_box), button_box),
    VSpacing(0.2)
  )
end

- (Yast::Term) GenericTreeDialog(button_box)

Note:

This is a stable API function

Create a Generic Tree Dialog

Returns a term describing a wizard dialog with left menu tree, right contents and a configurable button box.

Parameters:

  • button_box (Yast::Term)

    term that contains a `HBox() with buttons in it

Returns:

  • (Yast::Term)

    term describing the dialog.



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
# File '../../src/modules/Wizard.rb', line 324

def GenericTreeDialog(button_box)
  button_box = deep_copy(button_box)
  VBox(
    Id(:WizardDialog),
    ReplacePoint(Id(:topmenu), Empty()),
    HBox(
      HSpacing(1),
      HWeight(
        30,
        ReplacePoint(
          Id(:helpSpace), #`RichText(`id(`HelpText), "")
          Empty()
        )
      ),
      HSpacing(1),
      HWeight(
        70,
        VBox(
          VSpacing(0.2),
          HBox(
            # translators: dialog title to appear before any content is initialized
            Heading(
              Id(:title),
              Opt(:hstretch),
              _("YaST\nInitializing ...\n")
            ),
            HStretch()
          ),
          VWeight(
            1, # Layout trick: Lower layout priority with weight
            HVCenter(Opt(:hvstretch), ReplacePoint(Id(:contents), Empty()))
          )
        )
      ),
      HSpacing(1)
    ),
    ReplacePoint(Id(:rep_button_box), button_box),
    VSpacing(0.2)
  )
end

- (Boolean) HasWidgetWizard

Returns whether the `Wizard widget is available.

Returns:

  • (Boolean)

    available

See Also:

  • #367213.


1423
1424
1425
1426
1427
1428
1429
1430
# File '../../src/modules/Wizard.rb', line 1423

def HasWidgetWizard
  if !UI.HasSpecialWidget(:Wizard)
    Builtins.y2milestone("no Wizard available")
    return false
  end

  true
end

- (Object) haveFancyUI



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File '../../src/modules/Wizard.rb', line 71

def haveFancyUI
  if @have_fancy_ui_cache == nil
    ui_info = UI.GetDisplayInfo

    @have_fancy_ui_cache = UI.HasSpecialWidget(:Wizard) == true &&
      Ops.greater_or_equal(Ops.get_integer(ui_info, "Depth", 0), 15) &&
      Ops.greater_or_equal(Ops.get_integer(ui_info, "DefaultWidth", 0), 800) &&
      # some netbooks use such a strange resolution (fate#306298)
      Ops.greater_or_equal(
        Ops.get_integer(ui_info, "DefaultHeight", 0),
        576
      )

    # have_fancy_ui_cache = false;

    UI.SetFunctionKeys(Label.DefaultFunctionKeyMap)
  end

  @have_fancy_ui_cache
end

- (Object) HideAbortButton

Note:

This is a stable API function

Hide the Wizard's “Abort” button. Restore it later with RestoreAbortButton():



1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
# File '../../src/modules/Wizard.rb', line 1076

def HideAbortButton
  if UI.WizardCommand(term(:SetAbortButtonLabel, "")) == false
    if UI.WidgetExists(Id(:rep_abort))
      UI.ReplaceWidget(Id(:rep_abort), Empty())
    elsif UI.WidgetExists(Id(:cancel))
      UI.ReplaceWidget(Id(:cancel), Empty())
    end
  end

  nil
end

- (Object) HideBackButton

Note:

This is a stable API function

Hide the Wizard's “Back” button. Restore it later with RestoreBackButton():

See Also:



1032
1033
1034
1035
1036
1037
1038
1039
1040
# File '../../src/modules/Wizard.rb', line 1032

def HideBackButton
  if UI.WizardCommand(term(:SetBackButtonLabel, "")) == false
    if UI.WidgetExists(Id(:rep_back))
      UI.ReplaceWidget(Id(:rep_back), Empty())
    end
  end

  nil
end

- (Object) HideNextButton

Note:

This is a stable API function

Hide the Wizard's “Next” button. Restore it later with RestoreNextButton():

See Also:



1015
1016
1017
1018
1019
1020
1021
1022
1023
# File '../../src/modules/Wizard.rb', line 1015

def HideNextButton
  if UI.WizardCommand(term(:SetNextButtonLabel, "")) == false
    if UI.WidgetExists(Id(:rep_next))
      UI.ReplaceWidget(Id(:rep_next), Empty())
    end
  end

  nil
end

- (Object) HideReleaseNotesButton

Hide the “Release Notes” button, if there is any



1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
# File '../../src/modules/Wizard.rb', line 1460

def HideReleaseNotesButton
  # has wizard? continue
  #    otherwise use dedicated ReplacePoint or reuse the back button
  # hide-releasenotes-button failed? continue
  #   reuse use dedicated ReplacePoint or the back button
  if HasWidgetWizard() == false ||
      UI.WizardCommand(term(:HideReleaseNotesButton)) == false
    @relnotes_button_label = ""
    @relnotes_button_id = ""
    if UI.WidgetExists(Id(:relnotes_rp))
      UI.ReplaceWidget(Id(:relnotes_rp), Empty())
    elsif UI.WidgetExists(Id(:back_rep))
      UI.ReplaceWidget(Id(:back_rep), Empty())
    end
  end

  nil
end

- (Boolean) IsWizardDialog

Check if the topmost dialog is a wizard dialog (i.e. has a widget with id(WizardDialog) )

Returns:

  • (Boolean)

    True if topmost dialog is a wizard dialog, false otherwise



371
372
373
374
# File '../../src/modules/Wizard.rb', line 371

def IsWizardDialog
  UI.WidgetExists(Id(:WizardDialog)) == true ||
    UI.WidgetExists(:wizard) == true
end

- (Object) main



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
# File '../../src/modules/Wizard.rb', line 35

def main
  Yast.import "UI"
  textdomain "base"

  Yast.import "Desktop"
  Yast.import "Label"
  Yast.import "Popup"
  Yast.import "Directory"
  Yast.import "OSRelease"

  @have_fancy_ui_cache = nil

  # this variable is set from Product:: constructor
  # to setup correct &product; macro in UI
  @product_name = ""



  #
  # Screenshot Functions
  #


  # Currently used screenshot name.
  # Initially, it must match the UI default, "yast2"
  @screenshot_name = "yast2"

  # Screenshot names overriden by nested SetScreenShotName calls
  @screenshot_name_stack = []

  # Handling of relnotes button when creating a wizard over existing one
  # Cannot be handled by libyui for NCurses
  @relnotes_button_label = ""
  @relnotes_button_id = "";
end

- (Yast::Term) NextBackDialog

Note:

This is a stable API function

Returns a standard wizard dialog with buttons “Next”, “Back”, “Abort”.

Returns:

  • (Yast::Term)

    describing the dialog.



402
403
404
# File '../../src/modules/Wizard.rb', line 402

def NextBackDialog
  GenericDialog(BackAbortNextButtonBox())
end

- (Yast::Term) OKDialog

Note:

This is a stable API function

Returns a standard wizard dialog with buttons “Cancel”, “OK”

Returns:

  • (Yast::Term)

    describing the dialog.



423
424
425
# File '../../src/modules/Wizard.rb', line 423

def OKDialog
  GenericDialog(CancelOKButtonBox())
end

- (Object) OpenAbortApplyFinishDialog

Open a dialog with “Accept”, “Cancel” and set the keyboard focus to “Accept”.



528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
# File '../../src/modules/Wizard.rb', line 528

def OpenAbortApplyFinishDialog
  if haveFancyUI
    UI.OpenDialog(
      Opt(:wizardDialog),
      Wizard(
        :apply,
        _("&Apply"),
        :abort,
        Label.AbortButton,
        :finish,
        Label.FinishButton
      )
    )
  else
    OpenDialog(GenericDialog(AbortApplyFinishButtonBox()))
    UI.SetFocus(Id(:finish))
  end

  nil
end

- (Object) OpenAcceptAbortStepsDialog

Open a dialog with “Accept”, “Cancel” that will also accept workflow steps.



579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
# File '../../src/modules/Wizard.rb', line 579

def OpenAcceptAbortStepsDialog
  if haveFancyUI
    UI.OpenDialog(
      Opt(:wizardDialog),
      Wizard(
        Opt(:stepsEnabled),
        :no_back_button,
        "",
        :abort,
        Label.AbortButton,
        :accept,
        Label.AcceptButton
      )
    )

    # Don't let sloppy calls to Wizard::SetContents() disable this button by accident
    UI.WizardCommand(term(:ProtectNextButton, true))
  else
    OpenDialog(GenericDialog(AbortAcceptButtonBox()))
  end

  nil
end

- (Object) OpenAcceptDialog

Open a dialog with “Accept”, “Cancel” and set the keyboard focus to “Accept”.



472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File '../../src/modules/Wizard.rb', line 472

def OpenAcceptDialog
  if haveFancyUI
    UI.OpenDialog(
      Opt(:wizardDialog),
      Wizard(
        :no_back_button,
        "",
        :cancel,
        Label.CancelButton,
        :accept,
        Label.AcceptButton
      )
    )

    # Don't let sloppy calls to Wizard::SetContents() disable this button by accident
    UI.WizardCommand(term(:ProtectNextButton, true))
  else
    OpenDialog(AcceptDialog())
    UI.SetFocus(Id(:accept))
  end

  nil
end

- (Object) OpenAcceptStepsDialog

Open a dialog with “Accept”, “Cancel” that will also accept workflow steps.



552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
# File '../../src/modules/Wizard.rb', line 552

def OpenAcceptStepsDialog
  if haveFancyUI
    UI.OpenDialog(
      Opt(:wizardDialog),
      Wizard(
        Opt(:stepsEnabled),
        :no_back_button,
        "",
        :cancel,
        Label.CancelButton,
        :accept,
        Label.AcceptButton
      )
    )

    # Don't let sloppy calls to Wizard::SetContents() disable this button by accident
    UI.WizardCommand(term(:ProtectNextButton, true))
  else
    OpenAcceptDialog()
  end

  nil
end

- (Object) OpenCancelOKDialog

Overview Dialog en.opensuse.org/YaST/Style_Guide#Single_Configuration.2FOverview.2FEdit_Dialog dialog with Cancel and OK buttons (cancel has function as abort)



1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
# File '../../src/modules/Wizard.rb', line 1046

def OpenCancelOKDialog
  if haveFancyUI
    UI.OpenDialog(
      Opt(:wizardDialog),
      Wizard(
        :back,
        Label.BackButton,
        :abort,
        Label.CancelButton,
        :next,
        Label.OKButton
      )
    )
    HideBackButton()
  else
    OpenDialog(NextBackDialog())
    UI.SetFocus(Id(:next))
  end

  nil
end

- (void) OpenCustomDialog(help_space_contents, button_box)

This method returns an undefined value.

Open a wizard dialog with simple layout

no graphics, no steps, only a help widget buttons (by default “Back”, “Abort”, “Next”).

This is the only type of wizard dialog which still allows replacing the help space - either already upon opening it or later with Wizard::ReplaceCustomHelp().

If help_space_contents is 'nil', the normal help widget will remain. If button_box is 'nil', Wizard::BackAbortNextButtonBox() is used.

Parameters:

  • help_space_contents (Yast::Term)

    Help space contents

  • button_box (Yast::Term)

    Buttom Box

See Also:



672
673
674
675
676
677
678
679
680
681
682
683
684
# File '../../src/modules/Wizard.rb', line 672

def OpenCustomDialog(help_space_contents, button_box)
  help_space_contents = deep_copy(help_space_contents)
  button_box = deep_copy(button_box)
  button_box = BackAbortNextButtonBox() if button_box == nil

  UI.OpenDialog(Opt(:wizardDialog), GenericDialog(button_box))

  if help_space_contents != nil
    UI.ReplaceWidget(Id(:helpSpace), help_space_contents)
  end

  nil
end

- (Object) OpenDialog(dialog)

Note:

This is a stable API function

Open any wizard dialog.

Parameters:

  • dialog (Yast::Term)

    a wizard dialog, e.g. Wizard::GenericDialog()



434
435
436
437
438
439
440
441
442
# File '../../src/modules/Wizard.rb', line 434

def OpenDialog(dialog)
  dialog = deep_copy(dialog)
  UI.OpenDialog(Opt(:wizardDialog), dialog)
  if ! @relnotes_button_id.empty?
    ShowReleaseNotesButton(@relnotes_button_label, @relnotes_button_id)
  end

  nil
end

- (Object) OpenLeftTitleNextBackDialog

Open a dialog with “Back”, “Next”, “Abort” that has the title on the left, as wanted by the installation visual design



631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
# File '../../src/modules/Wizard.rb', line 631

def OpenLeftTitleNextBackDialog
  if haveFancyUI
    UI.OpenDialog(
      Opt(:wizardDialog),
      Wizard(
        Opt(:titleOnLeft),
        :back,
        Label.BackButton,
        :abort,
        Label.AbortButton,
        :next,
        Label.NextButton
      )
    )
  else
    OpenNextBackDialog()
  end

  nil
end

- (Object) OpenNextBackDialog

Open a dialog with buttons “Next”, “Back”, “Abort” and set the keyboard focus to “Next”.



448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# File '../../src/modules/Wizard.rb', line 448

def OpenNextBackDialog
  if haveFancyUI
    UI.OpenDialog(
      Opt(:wizardDialog),
      Wizard(
        :back,
        Label.BackButton,
        :abort,
        Label.AbortButton,
        :next,
        Label.NextButton
      )
    )
  else
    OpenDialog(NextBackDialog())
    UI.SetFocus(Id(:next))
  end

  nil
end

- (Object) OpenNextBackStepsDialog

Open a dialog with “Back”, “Next”, “Abort” that will also accept workflow steps.



606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
# File '../../src/modules/Wizard.rb', line 606

def OpenNextBackStepsDialog
  if haveFancyUI
    UI.OpenDialog(
      Opt(:wizardDialog),
      Wizard(
        Opt(:stepsEnabled),
        :back,
        Label.BackButton,
        :abort,
        Label.AbortButton,
        :next,
        Label.NextButton
      )
    )
  else
    OpenNextBackDialog()
  end

  nil
end

- (Object) OpenOKDialog

Open a dialog with “OK”, “Cancel” and set the keyboard focus to “OK”.



500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
# File '../../src/modules/Wizard.rb', line 500

def OpenOKDialog
  if haveFancyUI
    UI.OpenDialog(
      Opt(:wizardDialog),
      Wizard(
        :no_back_button,
        "",
        :cancel,
        Label.CancelButton,
        :ok,
        Label.OKButton
      )
    )

    # Don't let sloppy calls to Wizard::SetContents() disable this button by accident
    UI.WizardCommand(term(:ProtectNextButton, true))
  else
    OpenDialog(OKDialog())
    UI.SetFocus(Id(:ok))
  end

  nil
end

- (Object) OpenTreeNextBackDialog

Open a Tree dialog with buttons “Next”, “Back”, “Abort” and set the keyboard focus to “Next”.



1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
# File '../../src/modules/Wizard.rb', line 1580

def OpenTreeNextBackDialog
  if haveFancyUI
    UI.OpenDialog(
      Opt(:wizardDialog),
      Wizard(
        Opt(:treeEnabled),
        :back,
        Label.BackButton,
        :abort,
        Label.AbortButton,
        :next,
        Label.NextButton
      )
    )
  else
    OpenDialog(GenericTreeDialog(BackAbortNextButtonBox()))
    UI.SetFocus(Id(:next))
  end

  nil
end

- (Object) QueryTreeItem

Query Tree Item

Returns:

  • Tree Item



1670
1671
1672
1673
1674
1675
1676
# File '../../src/modules/Wizard.rb', line 1670

def QueryTreeItem
  if haveFancyUI
    return Convert.to_string(UI.QueryWidget(Id(:wizard), :CurrentItem))
  else
    return Convert.to_string(UI.QueryWidget(Id(:wizardTree), :CurrentItem))
  end
end

- (void) ReplaceButtonBox(button_box)

This method returns an undefined value.

PRIVATE - Replace the entire Wizard button box with a new one.

Parameters:

  • button_box (Yast::Term)

    Button Box term



1290
1291
1292
1293
1294
1295
# File '../../src/modules/Wizard.rb', line 1290

def ReplaceButtonBox(button_box)
  button_box = deep_copy(button_box)
  UI.ReplaceWidget(Id(:rep_button_box), button_box)

  nil
end

- (Object) ReplaceCustomHelp(contents)

Replace the help widget for dialogs opened with Wizard::OpenCustomDialog().

Parameters:

  • contents (Yast::Term)

    Replace custom help with supplied contents



690
691
692
693
694
695
696
697
698
699
700
701
# File '../../src/modules/Wizard.rb', line 690

def ReplaceCustomHelp(contents)
  contents = deep_copy(contents)
  if UI.WidgetExists(Id(:helpSpace))
    UI.ReplaceWidget(Id(:helpSpace), contents)
  else
    Builtins.y2error(
      "Wizard::ReplaceHelpSpace() works only for dialogs opened with Wizard::OpenSimpleDialog() !"
    )
  end

  nil
end

- (Object) ReplaceHelp(contents)

Deprecated.

Replace the wizard help subwindow with a custom widget.

Parameters:

  • contents (Yast::Term)

    Replace Help with contents



804
805
806
807
808
809
810
811
812
813
814
815
816
# File '../../src/modules/Wizard.rb', line 804

def ReplaceHelp(contents)
  contents = deep_copy(contents)
  if UI.WidgetExists(Id(:helpSpace))
    Builtins.y2warning("Wizard::ReplaceHelp() is deprecated!")
    UI.ReplaceWidget(Id(:helpSpace), contents)
  else
    Builtins.y2error(
      "Wizard::ReplaceHelp() is not supported by the new Qt wizard!"
    )
  end

  nil
end

- (Object) RestoreAbortButton

Note:

This is a stable API function

Restore the wizard 'abort' button.

See Also:



1118
1119
1120
1121
1122
# File '../../src/modules/Wizard.rb', line 1118

def RestoreAbortButton
  SetAbortButton(:abort, Label.AbortButton)

  nil
end

- (Object) RestoreBackButton

Note:

This is a stable API function

Restore the wizard 'back' button.

See Also:



1094
1095
1096
1097
1098
# File '../../src/modules/Wizard.rb', line 1094

def RestoreBackButton
  SetBackButton(:back, Label.BackButton)

  nil
end

- (Object) RestoreHelp(help_text)

Restore the wizard help subwindow.

Parameters:

  • help_text (String)

    Help text



822
823
824
825
826
# File '../../src/modules/Wizard.rb', line 822

def RestoreHelp(help_text)
  SetHelpText(help_text)

  nil
end

- (Object) RestoreNextButton

Note:

This is a stable API function

Restore the wizard 'next' button.

See Also:



1106
1107
1108
1109
1110
# File '../../src/modules/Wizard.rb', line 1106

def RestoreNextButton
  SetNextButton(:next, Label.NextButton)

  nil
end

- (Object) RestoreScreenShotName

Restore the screenshot name.

If it does not match a SetScreenShotName, “yast2” is used and a y2error logged.



1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
# File '../../src/modules/Wizard.rb', line 1559

def RestoreScreenShotName
  @screenshot_name = Ops.get(@screenshot_name_stack, 0)
  if @screenshot_name == nil
    @screenshot_name = "yast2"
    Builtins.y2error(1, "No screenshot name to restore!")
  else
    @screenshot_name_stack = Builtins.remove(@screenshot_name_stack, 0)
  end

  nil
end

- (Object) RetranslateButtons

Retranslate the wizard buttons.

This will revert button labels and IDs to the default that were used upon Wizard::CreateDialog(), Wizard::OpenNextBackDialog(), or Wizard::OpenAcceptDialog().



1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
# File '../../src/modules/Wizard.rb', line 1486

def RetranslateButtons
  if UI.WidgetExists(Id(:WizardDialog)) == true
    ReplaceButtonBox(
      UI.WidgetExists(Id(:accept)) ?
        AbortAcceptButtonBox() :
        BackAbortNextButtonBox()
    ) # Qt wizard
  else
    UI.WizardCommand(term(:RetranslateInternalButtons))

    if UI.WidgetExists(:accept)
      UI.WizardCommand(term(:SetBackButtonLabel, ""))
      UI.WizardCommand(term(:SetAbortButtonLabel, Label.AbortButton))
      UI.WizardCommand(term(:SetNextButtonLabel, Label.AcceptButton))
    else
      UI.WizardCommand(term(:SetBackButtonLabel, Label.BackButton))
      UI.WizardCommand(term(:SetAbortButtonLabel, Label.AbortButton))
      UI.WizardCommand(term(:SetNextButtonLabel, Label.NextButton))
    end
  end

  nil
end

- (Object) SelectTreeItem(tree_item)

Select Tree item

Parameters:

  • tree_item (String)

    tree item



1715
1716
1717
1718
1719
1720
1721
1722
1723
# File '../../src/modules/Wizard.rb', line 1715

def SelectTreeItem(tree_item)
  if haveFancyUI
    UI.WizardCommand(term(:SelectTreeItem, tree_item))
  else
    UI.ChangeWidget(Id(:wizardTree), :CurrentItem, tree_item)
  end

  nil
end

- (Object) SetAbortButton(id, label)

Note:

This is a stable API function

Set the dialog's “Abort” button with a new label and a new ID

Parameters:

  • id (Object)

    Button ID

  • label (String)

    Button Label



992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
# File '../../src/modules/Wizard.rb', line 992

def SetAbortButton(id, label)
  id = deep_copy(id)
  if UI.WizardCommand(term(:SetAbortButtonLabel, label)) == true
    UI.WizardCommand(term(:SetAbortButtonID, id))
  else
    if UI.WidgetExists(Id(:rep_abort))
      UI.ReplaceWidget(
        Id(:rep_abort),
        PushButton(Id(id), Opt(:key_F9), label)
      )
    end
  end

  nil
end

- (Object) SetBackButton(id, label)

Note:

This is a stable API function

Set the dialog's “Back” button with a new label and a new ID

Parameters:

  • id (Object)

    Button ID

  • label (String)

    Button Label



968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
# File '../../src/modules/Wizard.rb', line 968

def SetBackButton(id, label)
  id = deep_copy(id)
  if UI.WizardCommand(term(:SetBackButtonLabel, label)) == true
    UI.WizardCommand(term(:SetBackButtonID, id))
  else
    if UI.WidgetExists(Id(:rep_back))
      UI.ReplaceWidget(
        Id(:rep_back),
        PushButton(Id(id), Opt(:key_F8), label)
      )
    end
  end

  nil
end

- (Object) SetContents(title, contents, help_text, has_back, has_next)

Note:

This is a stable API function

Set the contents of a wizard dialog

How the general framework for the installation wizard should look like. This function creates and shows a dialog.

Example file (../examples/wizard1.ycp):

# encoding: utf-8

# ***************************************************************************
#
# Copyright (c) 2002 - 2012 Novell, Inc.
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, contact Novell, Inc.
#
# To contact Novell about this file by physical or electronic mail,
# you may find current contact information at www.novell.com
#
# ***************************************************************************
# Trivial wizard dialog example
#
# Author: Stefan Hundhammer <sh@suse.de>
#
# $Id$
module Yast
  class Wizard1Client < Client
    def main
      Yast.import "UI"
      Yast.import "Wizard"


      Wizard.CreateDialog

      @contents = Label("Wizard contents")
      @headline = "Trivial Wizard Example"
      @help_text = "<p>Help text</p>"

      Wizard.SetContents(
        @headline,
        @contents,
        @help_text,
        false, # have back button
        true
      ) # have next button

      Wizard.UserInput
      UI.CloseDialog

      nil
    end
  end
end

Yast::Wizard1Client.new.main

Parameters:

  • title (String)

    Dialog Title

  • contents (Yast::Term)

    The Dialog contents

  • help_text (String)

    Help text

  • has_back (Boolean)

    Is the Back button enabled?

  • has_next (Boolean)

    Is the Next button enabled?



913
914
915
916
917
918
# File '../../src/modules/Wizard.rb', line 913

def SetContents(title, contents, help_text, has_back, has_next)
  contents = deep_copy(contents)
  SetContentsFocus(title, contents, help_text, has_back, has_next, true)

  nil
end

- (Object) SetContentsButtons(title, contents, help_text, back_label, next_label)

Set contents and Buttons of wizard dialog

Additionally set its title, help_text and buttons labels. Enables both back and next button.

Parameters:

  • title (String)

    title of window

  • contents (Yast::Term)

    contents of dialog

  • help_text (String)

    help text

  • back_label (String)

    label of back button

  • next_label (String)

    label of next button



1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
# File '../../src/modules/Wizard.rb', line 1142

def SetContentsButtons(title, contents, help_text, back_label, next_label)
  contents = deep_copy(contents)
  UI.PostponeShortcutCheck

  RestoreBackButton()
  RestoreNextButton()

  if UI.WizardCommand(term(:SetBackButtonLabel, back_label)) == true
    UI.WizardCommand(term(:SetNextButtonLabel, next_label))
    SetContents(title, contents, help_text, true, true)
  else
    # Set button labels first to avoid geometry problems: SetContents()
    # calls ReplaceWidget() wich triggers a re-layout.

    if UI.WidgetExists(Id(:back))
      UI.ChangeWidget(Id(:back), :Label, back_label)
    end
    if UI.WidgetExists(Id(:next))
      UI.ChangeWidget(Id(:next), :Label, next_label)
    end
    SetContents(title, contents, help_text, true, true)
  end
  SetHelpText(help_text)
  UI.CheckShortcuts

  nil
end

- (Object) SetContentsFocus(title, contents, help_text, has_back, has_next, set_focus)

Set the contents of a wizard dialog and define if to move focus to next button

How the general framework for the installation wizard should look like. This function creates and shows a dialog.

Parameters:

  • title (String)

    Dialog Title

  • contents (Yast::Term)

    The Dialog contents

  • help_text (String)

    Help text

  • has_back (Boolean)

    Is the Back button enabled?

  • has_next (Boolean)

    Is the Next button enabled?

  • set_focus (Boolean)

    Should the focus be set to Next button?



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
# File '../../src/modules/Wizard.rb', line 861

def SetContentsFocus(title, contents, help_text, has_back, has_next, set_focus)
  contents = deep_copy(contents)
  if UI.WizardCommand(term(:SetDialogHeading, title)) == true
    UI.WizardCommand(term(:SetHelpText, help_text))
    UI.WizardCommand(term(:EnableNextButton, has_next))
    UI.WizardCommand(term(:EnableBackButton, has_back))
    UI.WizardCommand(term(:SetFocusToNextButton)) if set_focus
  else
    if UI.WidgetExists(Id(:next))
      UI.ChangeWidget(Id(:next), :Enabled, has_next)
      UI.SetFocus(Id(:next))
    end

    if UI.WidgetExists(Id(:back))
      UI.ChangeWidget(Id(:back), :Enabled, has_back)
    end
    if UI.WidgetExists(Id(:abort))
      UI.ChangeWidget(Id(:abort), :Enabled, true)
    end
    if UI.WidgetExists(Id(:title))
      UI.ChangeWidget(Id(:title), :Value, title)
    end

    UI.SetFocus(Id(:accept)) if UI.WidgetExists(Id(:accept)) if set_focus
  end

  SetHelpText(help_text)
  UI.ReplaceWidget(Id(:contents), contents)

  nil
end

- (Boolean) SetDesktopIcon(file)

Note:

do nothing. Title icon do not provide additional value

Sets the icon specified in a .desktop file got as parameter. Desktop file is placed in a special directory (/usr/share/applications/YaST2). Parameter file is realative to that directory without “.desktop” suffix. Warning: There are no desktop files in inst-sys. Use “SetTitleIcon” instead. and is distracting

// Opens /usr/share/applications/YaST2/lan.desktop // Reads “Icon” entry from there // Sets the icon. SetDesktopIcon (“lan”)

Parameters:

  • file (String)

    Icon name

Returns:

  • (Boolean)

    true on success



1251
1252
1253
# File '../../src/modules/Wizard.rb', line 1251

def SetDesktopIcon(file)
  true
end

- (Boolean) SetDesktopTitle(file)

Sets the window title according to the name specified in a .desktop file got as parameter. Desktop file is placed in a special directory (/usr/share/applications/YaST2). Parameter file is realative to that directory without “.desktop” suffix.

// Opens /usr/share/applications/YaST2/lan.desktop // Reads (localized) “name” entry from there // Sets the window title. SetDesktopTitle (“lan”)

Parameters:

  • file (String)

    desktop file

Returns:

  • (Boolean)

    true on success



1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
# File '../../src/modules/Wizard.rb', line 1224

def SetDesktopTitle(file)
  description = Desktop.ParseSingleDesktopFile(file)

  # fallback name for the dialog title
  name = Ops.get(description, "Name", _("Module"))

  Builtins.y2debug("Set dialog title: %1", name)
  SetDialogTitle(name)

  Builtins.haskey(description, "Name")
end

- (Boolean) SetDesktopTitleAndIcon(file)

Deprecated.

Use SetDesktopTitle only as icon setting is removed

Convenience function to avoid 2 calls if application needs to set both dialog title and icon from desktop file specified as parameter. Desktop file is placed in a special directory (/usr/share/applications/YaST2). Parameter file is realative to that directory without “.desktop” suffix. Warning: There are no desktop files in inst-sys. // Opens /usr/share/applications/YaST2/lan.desktop // Reads “Icon” and “Name” entries from there // Sets the icon, sets the dialog title SetDialogTitleAndIcon (“lan”)

Parameters:

  • file (String)

    desktop file name

Returns:

  • (Boolean)

    true on success



1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
# File '../../src/modules/Wizard.rb', line 1271

def SetDesktopTitleAndIcon(file)
  result = true

  description = Desktop.ParseSingleDesktopFile(file)

  # fallback name for the dialog title
  name = Ops.get(description, "Name", _("Module"))

  Builtins.y2debug("Set dialog title: %1", name)
  SetDialogTitle(name)

  result && Builtins.haskey(description, "Name")
end

- (Object) SetDialogTitle(titleText)

Sets the dialog title shown in the window manager's title bar.

SetDialogTitle (“DNS Server Configuration”);

Parameters:

  • titleText (String)

    title of the dialog



1178
1179
1180
1181
1182
# File '../../src/modules/Wizard.rb', line 1178

def SetDialogTitle(titleText)
  UI.WizardCommand(term(:SetDialogTitle, titleText))

  nil
end

- (Object) SetFocusToBackButton

Note:

This is a stable API function

Set the keyboard focus to the wizard's “Back” (or “Cancel”) button.



1527
1528
1529
1530
1531
1532
1533
# File '../../src/modules/Wizard.rb', line 1527

def SetFocusToBackButton
  if UI.WizardCommand(term(:SetFocusToBackButton)) == false
    UI.SetFocus(UI.WidgetExists(Id(:back)) ? Id(:back) : Id(:cancel))
  end

  nil
end

- (Object) SetFocusToNextButton

Note:

This is a stable API function

Set the keyboard focus to the wizard's “Next” (or “Accept”) button.



1515
1516
1517
1518
1519
1520
1521
# File '../../src/modules/Wizard.rb', line 1515

def SetFocusToNextButton
  if UI.WizardCommand(term(:SetFocusToNextButton)) == false
    UI.SetFocus(UI.WidgetExists(Id(:next)) ? Id(:next) : Id(:accept))
  end

  nil
end

- (Object) SetHelpText(help_text)

Set a new help text.

Examples:

Wizard::SetHelpText(“This is a help Text”);

Parameters:

  • help_text (String)

    Help text



790
791
792
793
794
795
796
# File '../../src/modules/Wizard.rb', line 790

def SetHelpText(help_text)
  if UI.WizardCommand(term(:SetHelpText, help_text)) == false
    UI.ChangeWidget(Id(:WizardDialog), :HelpText, help_text)
  end

  nil
end

- (Object) SetNextButton(id, label)

Note:

This is a stable API function

Set the dialog's “Next” button with a new label and a new ID

Parameters:

  • id (Object)

    Button ID

  • label (String)

    Button Label



944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
# File '../../src/modules/Wizard.rb', line 944

def SetNextButton(id, label)
  id = deep_copy(id)
  if UI.WizardCommand(term(:SetNextButtonLabel, label)) == true
    UI.WizardCommand(term(:SetNextButtonID, id))
  else
    if UI.WidgetExists(Id(:rep_next))
      UI.ReplaceWidget(
        Id(:rep_next),
        PushButton(Id(id), Opt(:key_F10, :default), label)
      )
    end
  end

  nil
end

- (void) SetProductName(name)

This method returns an undefined value.

Set the product name for UI

Parameters:

  • name (String)

    the product name



1880
1881
1882
1883
1884
1885
1886
# File '../../src/modules/Wizard.rb', line 1880

def SetProductName(name)
  Builtins.y2milestone("Setting product name to '%1'", name)
  @product_name = name
  UI.SetProductName(@product_name)

  nil
end

- (Object) SetScreenShotName(name)

Set a name for the current dialog:

Declare a name for the current dialog to ease making screenshots. By convention, the name is rpm-name-without-yast2-sorting-prefix-description The calls may be nested.

Parameters:

  • s

    eg. “mail-1-conntype”

See Also:



1544
1545
1546
1547
1548
1549
1550
1551
1552
# File '../../src/modules/Wizard.rb', line 1544

def SetScreenShotName(name)
  @screenshot_name_stack = Builtins.prepend(
    @screenshot_name_stack,
    @screenshot_name
  )
  @screenshot_name = name

  nil
end

- (Object) SetTitleIcon(icon_name)

Note:

Deprecated. Do nothing.

Sets the wizard 'title' icon to the specified icon from the standard icon directory.

SetTitleIcon (“yast-dns-server”);

Parameters:

  • icon_name (String)

    name (without path) of the new icon

See Also:



1196
1197
1198
# File '../../src/modules/Wizard.rb', line 1196

def SetTitleIcon(icon_name)
  nil
end

- (Object) ShowHelp(help_text)

Note:

This is a stable API function

Open a popup dialog that displays a help text (rich text format).

Parameters:

  • help_text (String)

    the text to display



383
384
385
386
387
388
389
390
391
392
393
# File '../../src/modules/Wizard.rb', line 383

def ShowHelp(help_text)
  Popup.LongText(
    # Heading for help popup window
    _("Help"),
    RichText(help_text),
    50,
    20
  )

  nil
end

- (Object) ShowReleaseNotesButton(label, id)

Show a “Release Notes” button with the specified label and ID if there is a “steps” panel



1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
# File '../../src/modules/Wizard.rb', line 1434

def ShowReleaseNotesButton(label, id)
  # has wizard? continue
  #   otherwise use dedicated ReplacePoint or reuse the back button
  # show-releasenotes-button failed? continue
  #   use dedicated ReplacePoint or reuse the back button
  if HasWidgetWizard() == false ||
      UI.WizardCommand(term(:ShowReleaseNotesButton, label, id)) == false
    @relnotes_button_label = label
    @relnotes_button_id = id
    if UI.WidgetExists(Id(:relnotes_rp))
      UI.ReplaceWidget(Id(:relnotes_rp), PushButton(Id(id), Opt(:relNotesButton), label))
    # Reuse Back button
    # TODO: can this situation happen
    elsif UI.WidgetExists(Id(:back_rep))
      UI.ReplaceWidget(Id(:back_rep), PushButton(Id(id), label))
    else
      Builtins.y2warning("Widget `back_rep does not exist")
    end
  end

  nil
end

- (Object) TimeoutUserInput(timeout_millisec)

Substitute for UI::TimeoutUserInput

Analogical to Wizard::UserInput.

Parameters:

  • timeout_millisec (Fixnum)


748
749
750
751
752
753
754
755
# File '../../src/modules/Wizard.rb', line 748

def TimeoutUserInput(timeout_millisec)
  input = UI.TimeoutUserInput(timeout_millisec)

  return :next if input == :accept
  return :back if input == :cancel

  deep_copy(input)
end

- (Object) TimeoutWaitForEvent(timeout_millisec)

Substitute for UI::WaitForEvent with timeout

Analog to Wizard::UserInput.



776
777
778
779
780
781
782
783
# File '../../src/modules/Wizard.rb', line 776

def TimeoutWaitForEvent(timeout_millisec)
  input = UI.WaitForEvent(timeout_millisec)

  Ops.set(input, "ID", :next) if Ops.get(input, "ID") == :accept
  Ops.set(input, "ID", :back) if Ops.get(input, "ID") == :cancel

  deep_copy(input)
end

- (maybe normalized) UserInput

Substitute for UI::UserInput

This function transparently handles different variations of the wizard layout. Returns next ifnext or accept were clicked,back if back orcancel were clicked. Simply replace ret = UI::UserInput() with ret = Wizard::UserInput()

Returns:

  • (maybe normalized)

    widget ID



732
733
734
735
736
737
738
739
# File '../../src/modules/Wizard.rb', line 732

def UserInput
  input = UI.UserInput

  return :next if input == :accept
  return :back if input == :cancel

  deep_copy(input)
end

- (Object) WaitForEvent

Substitute for UI::WaitForEvent

Analog to Wizard::UserInput.



762
763
764
765
766
767
768
769
# File '../../src/modules/Wizard.rb', line 762

def WaitForEvent
  input = UI.WaitForEvent

  Ops.set(input, "ID", :next) if Ops.get(input, "ID") == :accept
  Ops.set(input, "ID", :back) if Ops.get(input, "ID") == :cancel

  deep_copy(input)
end