Class: Yast::UIHelperClass

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

Instance Method Summary collapse

Instance Method Details

#EditTable(table_header, table_contents, above_table, below_table, below_buttons, buttons) ⇒ Object

Create an edit table with basic buttons.

It contains table and buttons Add, Edit, Delete. User may specify table header and content, content that will be placed above table, between table and buttons, below buttons and rights from buttons (usually another button).

UI elements ids:

Tabletable</td></tr> <tr><td>Button add</td><td>add_button
Button editedit_button</td></tr> <tr><td>Button delete</td><td>delete_button

Parameters:

  • table_header (Yast::Term)

    Table header as defined in UI.

  • table_contents (Array)

    Table items.

  • above_table (Yast::Term)

    Content to place above table. There is no need to place caption here, because the dialog has its caption. Set it to nil if you do not want to place anything here.

  • below_table (Yast::Term)

    Contents to place between table and buttons. Set it to nil if you do not want to place anything here.

  • below_buttons (Yast::Term)

    Content to place below bottons. Set it to nil if you do not want to place anything here.

  • buttons (Yast::Term)

    Content to place rights from buttons. Usually an additional button, e.g. Set as default. Set it to nil if you do not want to place anything here.

Returns:

  • Content for the SetWizardContent[Buttons]()


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

def EditTable(table_header, table_contents, above_table, below_table, below_buttons, buttons)
  table_header = deep_copy(table_header)
  table_contents = deep_copy(table_contents)
  above_table = deep_copy(above_table)
  below_table = deep_copy(below_table)
  below_buttons = deep_copy(below_buttons)
  buttons = deep_copy(buttons)
  contents = VBox()
  contents = Builtins.add(contents, above_table) if nil != above_table

  contents = Builtins.add(
    contents,
    Table(Id(:table), Opt(:notify), table_header, table_contents)
  )
  contents = Builtins.add(contents, below_table) if nil != below_table

  but_box = HBox(
    Opt(:hstretch),
    PushButton(Id(:add_button), Opt(:key_F3), _("A&dd")),
    PushButton(Id(:edit_button), Opt(:key_F4), _("&Edit")),
    PushButton(Id(:delete_button), Opt(:key_F5), _("De&lete"))
  )

  but_box = Builtins.add(Builtins.add(but_box, HStretch()), buttons) if nil != buttons
  contents = Builtins.add(contents, but_box)
  contents = Builtins.add(contents, below_buttons) if nil != below_buttons
  deep_copy(contents)
end

#mainObject


32
33
34
# File 'library/general/src/modules/UIHelper.rb', line 32

def main
  textdomain "base"
end

#SizeAtLeast(content, xsize, ysize) ⇒ Object

Encloses the content into VBoxes and HBoxes

Enclose so that its size is at least xsize x ysize.

Parameters:

  • xsize (Float)

    Minimal size of content in the X direction

  • ysize (Float)

    Minimal size of content in the Y direction

  • content (Yast::Term)

    Content of the dialog

Returns:

  • Contents sized at least xsize x ysize.


121
122
123
124
125
126
127
128
129
130
131
# File 'library/general/src/modules/UIHelper.rb', line 121

def SizeAtLeast(content, xsize, ysize)
  content = deep_copy(content)
  xsize = deep_copy(xsize)
  ysize = deep_copy(ysize)
  VBox(
    VSpacing(0.4),
    HSpacing(xsize),
    HBox(HSpacing(1.6), VSpacing(ysize), content, HSpacing(1.6)),
    VSpacing(0.4)
  )
end

#SpacingAround(content, left, right, top, bottom) ⇒ Object

Encloses the content into VBoxes and HBoxes with the appropriate spacings around it.

Parameters:

  • content (Yast::Term)

    The term we are adding spacing to.

  • left (Float)

    Spacing on the left.

  • right (Float)

    Spacing on the right.

  • top (Float)

    Spacing on the top.

  • bottom (Float)

    Spacing on the bottom.

Returns:

  • Content with spacings around it.


99
100
101
102
103
104
105
106
107
108
109
110
# File 'library/general/src/modules/UIHelper.rb', line 99

def SpacingAround(content, left, right, top, bottom)
  content = deep_copy(content)
  left = deep_copy(left)
  right = deep_copy(right)
  top = deep_copy(top)
  bottom = deep_copy(bottom)
  HBox(
    HSpacing(left),
    VBox(VSpacing(top), content, VSpacing(bottom)),
    HSpacing(right)
  )
end