Module: Yast::PartitioningEpSettingsInclude

Defined in:
../../src/include/partitioning/ep-settings.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) CreateSettingsPanel(user_data)



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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File '../../src/include/partitioning/ep-settings.rb', line 71

def CreateSettingsPanel(user_data)
  user_data = deep_copy(user_data)
  _PreselectVisibleFields = lambda do
    hidden_fields = StorageSettings.GetHiddenFields
    Builtins.maplist(Integer.Range(Builtins.size(@visible_fields))) do |i|
      label = Ops.get_string(@visible_fields, [i, :label], "")
      fields = Ops.get_list(@visible_fields, [i, :fields], [])
      selected = !Builtins::Multiset.includes(hidden_fields, fields)
      Item(Id(i), label, selected)
    end
  end

  mount_by_items = Builtins.maplist(@mount_bys) do |item_id, label|
    Item(Id(item_id), label)
  end

  filesystems = Builtins.filter(
    [:ext2, :ext3, :ext4, :reiser, :xfs, :btrfs]
  ) do |fs|
    FileSystems.IsSupported(fs) && !FileSystems.IsUnsupported(fs)
  end

  filesystem_items = Builtins.maplist(filesystems) do |fs|
    Item(Id(fs), FileSystems.GetName(fs, "Error"))
  end

  partalign_items = Builtins.maplist([:align_optimal, :align_cylinder]) do |pal|
    Item(Id(pal), Builtins.substring(Builtins.sformat("%1", pal), 7))
  end


  UI.ReplaceWidget(
    :tree_panel,
    Greasemonkey.Transform(
      VBox(
        # dialog heading
        term(:IconAndHeading, _("Settings"), StorageIcons.settings_icon),
        VBox(
          Left(
            term(
              :ComboBoxSelected,
              Id(:default_mountby),
              Opt(:notify),
              # combo box label
              _("Default Mount by"),
              mount_by_items,
              Id(Storage.GetDefaultMountBy)
            )
          ),
          Left(
            term(
              :ComboBoxSelected,
              Id(:default_fs),
              Opt(:notify),
              # combo box label
              _("Default File System"),
              filesystem_items,
              Id(Partitions.DefaultFs)
            )
          ),
          Left(
            term(
              :ComboBoxSelected,
              Id(:part_align),
              Opt(:notify),
              # combo box label
              _("Alignment of Newly Created Partitions"),
              partalign_items,
              Id(Storage.GetPartitionAlignment)
            )
          ),
          VSpacing(1),
          Left(
            term(
              :ComboBoxSelected,
              Id(:display_name),
              Opt(:notify),
              # combo box label
              _("Show Storage Devices by"),
              [
                # combo box entry
                Item(Id(:device), _("Device Name")),
                # combo box entry
                Item(Id(:id), _("Device ID")),
                # combo box entry
                Item(Id(:path), _("Device Path"))
              ],
              Id(StorageSettings.GetDisplayName)
            )
          ),
          #This looks extremely ugly, but obviously there are few other means how
          #to make MultiSelection widget smaller, yet still readable
          Left(
            HBox(
              MultiSelectionBox(
                Id(:visible_fields),
                Opt(:shrinkable, :notify),
                # multi selection box label
                _("Visible Information on Storage Devices"),
                _PreselectVisibleFields.call
              ),
              HStretch()
            )
          )
        ),
        VStretch()
      )
    )
  )


  # helptext
  helptext = _("<p>This view shows general storage\nsettings:</p>")

  # helptext
  helptext = Ops.add(
    helptext,
    _(
      "<p><b>Default Mount by</b> gives the mount by\n" +
        "method for newly created file systems. <i>Device Name</i> uses the kernel\n" +
        "device name, which is not persistent. <i>Device ID</i> and <i>Device Path</i>\n" +
        "use names generated by udev from hardware information. These should be\n" +
        "persistent but unfortunately this is not always true. Finally <i>UUID</i> and\n" +
        "<i>Volume Label</i> use the file systems UUID and label.</p>\n"
    )
  )

  # helptext
  helptext = Ops.add(
    helptext,
    _(
      "<p><b>Default File System</b> gives the file\nsystem type for newly created file systems.</p>\n"
    )
  )

  # helptext
  helptext = Ops.add(
    helptext,
    _(
      "<p><b>Alignment of Newly Created Partitions</b>\n" +
        "determines how created partitions are aligned. <b>cylinder</b> is the traditional alignment at cylinder boundaries of the disk. <b>optimal</b> aligns the \n" +
        "partitions for best performance according to hints provided by the Linux \n" +
        "kernel or tries to be compatible with Windows Vista and Win 7.</p>\n"
    )
  )

  # helptext
  helptext = Ops.add(
    helptext,
    _(
      "<p><b>Show Storage Devices by</b> controls\nthe name displayed for hard disks in the navigation tree.</p>"
    )
  )

  # helptext
  helptext = Ops.add(
    helptext,
    _(
      "<p><b>Visible Information On Storage\nDevices</b> allows to hide information in the tables and overview.</p>"
    )
  )

  Wizard.RestoreHelp(helptext)

  nil
end

- (Object) DestroySettingsPanel(user_data)



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
# File '../../src/include/partitioning/ep-settings.rb', line 262

def DestroySettingsPanel(user_data)
  user_data = deep_copy(user_data)
  selected = Convert.convert(
    UI.QueryWidget(Id(:visible_fields), :SelectedItems),
    :from => "any",
    :to   => "list <integer>"
  )
  selected_labels = []

  Builtins.foreach(selected) do |i|
    selected_labels = Builtins.add(
      selected_labels,
      Ops.get_string(@visible_fields, [i, :label], "")
    )
  end

  default_mount = Convert.to_symbol(
    UI.QueryWidget(Id(:default_mountby), :Value)
  )
  default_fs = Convert.to_symbol(UI.QueryWidget(Id(:default_fs), :Value))
  part_align = Convert.to_symbol(UI.QueryWidget(Id(:part_align), :Value))

  Storage.SetDefaultMountBy(default_mount)
  Partitions.SetDefaultFs(default_fs)
  Storage.SetPartitionAlignment(part_align)
  StorageSettings.InvertVisibleFields(@visible_fields, selected)

  nil
end

- (Object) HandleSettingsPanel(user_data, event)



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File '../../src/include/partitioning/ep-settings.rb', line 239

def HandleSettingsPanel(user_data, event)
  user_data = deep_copy(user_data)
  event = deep_copy(event)
  case Event.IsWidgetValueChanged(event)
    when :display_name
      StorageSettings.SetDisplayName(
        Convert.to_symbol(UI.QueryWidget(Id(:display_name), :Value))
      )
      UpdateNavigationTree(nil)
  end

  case Event.IsWidgetActivated(event)
    when :next
      DestroySettingsPanel(user_data)
  end

  if !StorageSettings.GetModified
    StorageSettings.SetModified
    Wizard.SetNextButton(:next, Label.NextButton)
  end

  nil
end

- (Object) initialize_partitioning_ep_settings(include_target)



28
29
30
31
32
33
34
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/include/partitioning/ep-settings.rb', line 28

def initialize_partitioning_ep_settings(include_target)
  textdomain "storage"


  @visible_fields = [
    # list entry
    { :label => _("Label"), :fields => [:label] },
    # list entry
    { :label => _("UUID"), :fields => [:uuid] },
    # list entry
    { :label => _("Mount by"), :fields => [:mount_by] },
    # list entry
    { :label => _("Used by"), :fields => [:used_by] },
    # list entry
    { :label => _("BIOS ID"), :fields => [:bios_id] },
    # list entry
    {
      :label  => _("Cylinder information"),
      :fields => Builtins.toset([:start_cyl, :end_cyl, :num_cyl, :cyl_size])
    },
    # list entry
    {
      :label  => _("Fibre Channel information"),
      :fields => Builtins.toset([:fc_wwpn, :fc_fcp_lun, :fc_port_id])
    },
    # list entry
    { :label => _("Encryption"), :fields => [:encrypted] }
  ]

  @mount_bys = {
    # combo box entry
    :device => _("Device Name"),
    # combo box entry
    :label  => _("Volume Label"),
    # combo box entry
    :uuid   => _("UUID"),
    # combo box entry
    :id     => _("Device ID"),
    # combo box entry
    :path   => _("Device Path")
  }
end