Class List Method List File List

# Module: Yast::KeyboardDialogsInclude

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

## Instance Method Summary (collapse)

- - (Object) initialize_keyboard_dialogs(include_target)
- - (Object) KeyboardDialog(args)

  main dialog for choosing keyboard (checking for “enable_back” and “enable_next” keys).

- - (Object) KeyboardExpertDialog

  Dialog with expert keyboard configuration.

## Instance Method Details

### - (`Object`) initialize_keyboard_dialogs(include_target)

    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    # File '../../src/include/keyboard/dialogs.rb', line 36

    def initialize_keyboard_dialogs(include_target)
      Yast.import "UI"
      textdomain "country"

      Yast.import "Keyboard"
      Yast.import "Label"
      Yast.import "Mode"
      Yast.import "Popup"
      Yast.import "Stage"
      Yast.import "Wizard"
    end

### - (`Object`) KeyboardDialog(args)

main dialog for choosing keyboard (checking for "enable_back" and "enable_next" keys)

Parameters:

- args: (`Hash`) —

  arguments forwarded from the initial client call

    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    # File '../../src/include/keyboard/dialogs.rb', line 217

    def KeyboardDialog(args)
      args = deep_copy(args)
      keyboard = ""

      keyboardsel = SelectionBox(
        Id(:keyboard),
        Opt(:notify),
        # title for selection box 'keyboard layout'
        _("&Keyboard Layout"),
        Keyboard.GetKeyboardItems
      )

      # title for input field to test the keyboard setting
      # (no more than about 25 characters!)
      test = InputField(Opt(:hstretch), _("&Test"))
      test = Empty() if Mode.config

      # Put test widget below selection list.
      #
      keyboardsel = VBox(
        keyboardsel,
        test,
        VSpacing(0.8),
        # push button
        PushButton(Id(:expert), _("E&xpert Settings..."))
      )

      # ----------------------------------------------------------------------
      # Build dialog
      # ----------------------------------------------------------------------

      contents = VBox(
        HBox(
          HWeight(20, HStretch()),
          HWeight(50, keyboardsel),
          HWeight(20, HStretch())
        ),
        VSpacing()
      )

      # help text for keyboard screen (header)
      help_text = _("\n<p><big><b>Keyboard Configuration</b></big></p>")

      if Stage.initial || Stage.firstboot
        help_text = Ops.add(
          help_text,
          # help text for keyboard screen (installation)
          _(
            "<p>\n" +
              "Choose the <b>Keyboard Layout</b> to use for\n" +
              "installation and in the installed system.  \n" +
              "Test the layout in <b>Test</b>.\n" +
              "For advanced options, such as repeat rate and delay, select <b>Expert Settings</b>.\n" +
              "</p>\n"
          )
        )
        # general help trailer
        help_text = Ops.add(
          help_text,
          _(
            "<p>\n" +
              "If unsure, use the default values already selected.\n" +
              "</p>"
          )
        )
      else
        help_text = Ops.add(
          help_text,
          # help text for keyboard screen (installation)
          _(
            "<p>\n" +
              "Choose the <b>Keyboard Layout</b> to use in the system.\n" +
              "For advanced options, such as repeat rate and delay, select <b>Expert Settings</b>.</p>\n" +
              "<p>Find more options as well as more layouts in the keyboard layout tool of your desktop environment.</p>\n"
          )
        )
      end

      # Screen title for keyboard screen
      Wizard.SetContents(
        _("System Keyboard Configuration"),
        contents,
        help_text,
        Ops.get_boolean(args, "enable_back", true),
        Ops.get_boolean(args, "enable_next", true)
      )

      Wizard.SetDesktopTitleAndIcon("keyboard")
      Wizard.SetTitleIcon("yast-keyboard") if Stage.initial || Stage.firstboot

      # Initially set the current keyboard to establish a consistent state.
      # Not on installed system, where it might clash with layout set different way
      Keyboard.Set(Keyboard.current_kbd) if Mode.installation

      UI.SetFocus(Id(:keyboard))

      ret = nil
      begin
        ret = Wizard.UserInput

        if ret == :abort && Popup.ConfirmAbort(:painless) && !Mode.config
          return :abort
        end
        ret = :next if ret == :ok

        KeyboardExpertDialog() if ret == :expert

        if ret == :next || ret == :keyboard
          # Get the selected keyboard.
          #
          keyboard = Convert.to_string(
            UI.QueryWidget(Id(:keyboard), :CurrentItem)
          )

          Builtins.y2milestone(
            "on entry %1 current %2 ret %3",
            Keyboard.keyboard_on_entry,
            Keyboard.current_kbd,
            keyboard
          )

          # Set it in Keyboard module.
          Keyboard.Set(keyboard) if Keyboard.current_kbd != keyboard

          if ret == :next && !Mode.config
            # User wants to keep his changes.
            # Set user_decision flag in keyboard module.
            #
            Keyboard.user_decision = true

            if Keyboard.Modified
              # User has chosen a different keyboard from the database.
              # ==> clear unique_key in the keyboard module to achieve
              # configured = no and needed = no in Keyboard::Save() for
              # _ALL_ keyboards.
              #
              Builtins.y2milestone(
                "Clearing unique key <%1> due to manual selection",
                Keyboard.unique_key
              )

              Keyboard.unique_key = ""
            end
          end
        end
      end until ret == :next || ret == :back || ret == :cancel

      if ret == :back || ret == :cancel
        Builtins.y2milestone(
          "`back or `cancel restoring: <%1>",
          Keyboard.keyboard_on_entry
        )

        # Reset keyboard to initial state.
        Keyboard.Set(Keyboard.keyboard_on_entry)
      end

      Convert.to_symbol(ret)
    end

### - (`Object`) KeyboardExpertDialog

Dialog with expert keyboard configuration

    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    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
    210
    211
    212
    # File '../../src/include/keyboard/dialogs.rb', line 49

    def KeyboardExpertDialog
      ret = :none
      # help text for keyboard expert screen
      help_text = _(
        "<p>\n" +
          "Here, fine tune various settings of the keyboard module.\n" +
          "These settings are written into the file <tt>/etc/sysconfig/keyboard</tt>.\n" +
          "If unsure, use the default values already selected.\n" +
          "</p>"
      ) +
        # help text for keyboard expert screen cont.
        _(
          "<p>Settings made here apply only to the console keyboard.  Configure the keyboard for the graphical user interface with another tool, such as SaX.</p>\n"
        )

      # general help trailer
      help_text = Ops.add(
        help_text,
        _(
          "<p>\n" +
            "For <b>Devices for Lock</b>, enter a space-separated list of devices to which to apply the Scroll Lock, Num Lock, and Caps Lock settings.\n" +
            "</p>"
        )
      )

      # label text

      UI.OpenDialog(
        Opt(:decorated),
        HBox(
          HWeight(30, RichText(help_text)),
          HStretch(),
          HSpacing(1),
          HWeight(
            70,
            VBox(
              HSpacing(60),
              # heading text
              Heading(_("Expert Keyboard Settings")),
              VSpacing(Opt(:vstretch), 1),
              Left(
                InputField(
                  Id(:rate),
                  Opt(:hstretch),
                  # label text
                  _("Repeat &Rate")
                )
              ),
              Left(
                InputField(
                  Id(:delay),
                  Opt(:hstretch),
                  # label text
                  _("De&lay before Repetition Starts")
                )
              ),
              VSpacing(Opt(:vstretch), 1),
              Frame(
                # frame label
                _("Start-Up States"),
                VBox(
                  Left(
                    ComboBox(
                      # combobox label
                      Id(:numlock),
                      _("&Num Lock On"),
                      [
                        # combobox item
                        Item(Id("bios"), _("BIOS Settings")),
                        # combobox item
                        Item(Id("yes"), _("Yes")),
                        # combobox item
                        Item(Id("no"), _("No")),
                        # combobox item
                        Item(Id("untouched"), _("<Untouched>"))
                      ]
                    )
                  ),
                  VSpacing(Opt(:vstretch), 1),
                  Left(
                    # checkbox label
                    CheckBox(Id(:capslock), _("Ca&ps Lock On"))
                  ),
                  Left(
                    # checkbox label
                    CheckBox(Id(:scrlock), _("&Scroll Lock On"))
                  )
                )
              ),
              VSpacing(Opt(:vstretch), 1),
              Left(
                InputField(
                  Id(:tty),
                  Opt(:hstretch),
                  # textentry label
                  _("&Devices for Lock")
                )
              ),
              VSpacing(Opt(:vstretch), 1),
              Left(
                # label text
                CheckBox(Id(:discaps), _("D&isable Caps Lock"))
              ),
              VSpacing(1),
              VStretch(),
              ButtonBox(
                PushButton(Id(:ok), Opt(:default), Label.OKButton),
                PushButton(Id(:cancel), Label.CancelButton)
              ),
              VSpacing(0.5)
            )
          )
        )
      )
      val = Keyboard.GetExpertValues
      val_on_entry = deep_copy(val)
      Builtins.y2milestone("map %1", val)
      UI.ChangeWidget(Id(:rate), :Value, Ops.get_string(val, "rate", ""))
      UI.ChangeWidget(Id(:rate), :ValidChars, "0123456789.")
      UI.ChangeWidget(Id(:delay), :Value, Ops.get_string(val, "delay", ""))
      UI.ChangeWidget(Id(:delay), :ValidChars, "0123456789")
      tmp = Ops.get_string(val, "numlock", "")
      tmp = "untouched" if tmp == ""
      UI.ChangeWidget(Id(:numlock), :Value, tmp)
      UI.ChangeWidget(
        Id(:capslock),
        :Value,
        Ops.get_boolean(val, "capslock", false)
      )
      UI.ChangeWidget(
        Id(:scrlock),
        :Value,
        Ops.get_boolean(val, "scrlock", false)
      )
      UI.ChangeWidget(Id(:tty), :Value, Ops.get_string(val, "tty", ""))
      UI.ChangeWidget(
        Id(:discaps),
        :Value,
        Ops.get_boolean(val, "discaps", false)
      )
      begin
        ret = Convert.to_symbol(UI.UserInput)
        if ret == :ok
          val = {}
          Ops.set(val, "rate", UI.QueryWidget(Id(:rate), :Value))
          Ops.set(val, "delay", UI.QueryWidget(Id(:delay), :Value))
          Ops.set(val, "numlock", "")
          tmp = Convert.to_string(UI.QueryWidget(Id(:numlock), :Value))
          Builtins.y2milestone("tmp %1", tmp)
          if Builtins.contains(["bios", "yes", "no"], tmp)
            Ops.set(val, "numlock", tmp)
          end
          Ops.set(val, "capslock", UI.QueryWidget(Id(:capslock), :Value))
          Ops.set(val, "scrlock", UI.QueryWidget(Id(:scrlock), :Value))
          Ops.set(val, "tty", UI.QueryWidget(Id(:tty), :Value))
          Ops.set(val, "discaps", UI.QueryWidget(Id(:discaps), :Value))
          Builtins.y2milestone("map ok %1", val)
          Keyboard.SetExpertValues(val)
        end
      end until ret == :cancel || ret == :ok
      UI.CloseDialog

      nil
    end