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:<table> <tr><td>Table</td><td>`table</td></tr> <tr><td>Button add</td><td>`add_button</td></tr> <tr><td>Button edit</td><td>`edit_button</td></tr> <tr><td>Button delete</td><td>`delete_button</td></tr> </table>

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:



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

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"))
  )

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

#mainObject



34
35
36
# File 'library/general/src/modules/UIHelper.rb', line 34

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 <emphasis>xsize</emphasis>&nbsp;x&nbsp;<emphasis>ysize</emphasis>.

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&nbsp;x&nbsp;ysize.



125
126
127
128
129
130
131
132
133
134
135
# File 'library/general/src/modules/UIHelper.rb', line 125

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.



103
104
105
106
107
108
109
110
111
112
113
114
# File 'library/general/src/modules/UIHelper.rb', line 103

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