Class: Yast::TabPanelClass

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) AddToHistory



112
113
114
115
116
117
# File '../../src/modules/TabPanel.rb', line 112

def AddToHistory
  @history = Builtins.filter(@history) { |s| s != @current_item }
  @history = Builtins.prepend(@history, @current_item)

  nil
end

- (Object) CallCreate



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File '../../src/modules/TabPanel.rb', line 50

def CallCreate
  tmp = Ops.get(@data, @current_item)
  create_func = Convert.convert(
    Ops.get(tmp, :create),
    :from => "any",
    :to   => "void (any)"
  )
  if create_func != nil
    user_data = Ops.get(tmp, :user_data)
    create_func.call(user_data)
  end

  nil
end

- (Object) CallDestroy



96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File '../../src/modules/TabPanel.rb', line 96

def CallDestroy
  tmp = Ops.get(@data, @current_item)
  destroy_func = Convert.convert(
    Ops.get(tmp, :destroy),
    :from => "any",
    :to   => "void (any)"
  )
  if destroy_func != nil
    user_data = Ops.get(tmp, :user_data)
    destroy_func.call(user_data)
  end

  nil
end

- (Object) CallHandle(event)



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File '../../src/modules/TabPanel.rb', line 80

def CallHandle(event)
  event = deep_copy(event)
  tmp = Ops.get(@data, @current_item)
  handle_func = Convert.convert(
    Ops.get(tmp, :handle),
    :from => "any",
    :to   => "void (any, map)"
  )
  if handle_func != nil
    user_data = Ops.get(tmp, :user_data)
    handle_func.call(user_data, event)
  end

  nil
end

- (Object) CallRefresh



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File '../../src/modules/TabPanel.rb', line 65

def CallRefresh
  tmp = Ops.get(@data, @current_item)
  refresh_func = Convert.convert(
    Ops.get(tmp, :refresh),
    :from => "any",
    :to   => "void (any)"
  )
  if refresh_func != nil
    user_data = Ops.get(tmp, :user_data)
    refresh_func.call(user_data)
  end

  nil
end

- (Object) Create



144
145
146
147
148
# File '../../src/modules/TabPanel.rb', line 144

def Create
  CallCreate()

  nil
end

- (Object) Destroy



174
175
176
177
178
# File '../../src/modules/TabPanel.rb', line 174

def Destroy
  CallDestroy()

  nil
end

- (Object) Handle(event)



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File '../../src/modules/TabPanel.rb', line 156

def Handle(event)
  event = deep_copy(event)
  widget = Event.IsMenu(event)

  if widget != nil && Builtins.haskey(@data, widget)
    if widget != @current_item
      CallDestroy()
      @current_item = widget
      AddToHistory()
      CallCreate()
    end
  else
    CallHandle(event)
  end

  nil
end

- (Object) Init(d, fallback)

When calling this function the DumbTab widget must already exist.

The tab with symbol fallback will be selected if no other tab is found in the tab history.



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File '../../src/modules/TabPanel.rb', line 124

def Init(d, fallback)
  d = deep_copy(d)
  @data = deep_copy(d)

  items = Builtins.maplist(@data) { |s, m| s }
  @current_item = Builtins.find(@history) { |s| Builtins.contains(items, s) }

  if @current_item == nil && Builtins.contains(items, fallback)
    @current_item = fallback
  end

  UI.ChangeWidget(:tab, :CurrentItem, @current_item) if @current_item != nil

  @current_item = Convert.to_symbol(UI.QueryWidget(:tab, :CurrentItem))

  CallCreate()

  nil
end

- (Object) main



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File '../../src/modules/TabPanel.rb', line 33

def main
  Yast.import "UI"


  Yast.import "Event"


  @data = nil

  @current_item = nil

  @history = []


  @empty_panel = VBox(VStretch(), HStretch())
end

- (Object) Refresh



150
151
152
153
154
# File '../../src/modules/TabPanel.rb', line 150

def Refresh
  CallRefresh()

  nil
end