Class: KDE::ActionCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/mylibs.rb

Instance Method Summary collapse

Instance Method Details

#addNew(name, parent = self.parent, options = {}) ⇒ Object

Returns : KDE::Action.

Returns:

  • : KDE::Action



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
# File 'lib/mylibs.rb', line 227

def addNew(name, parent=self.parent, options = {})
    text = options[:text] || name
    icon = options[:icon]
    if icon then
        action = KDE::Action.new(KDE::Icon.new(icon), text, parent)
    else
        action = KDE::Action.new(text, parent)
    end
    shortCut = options[:shortCut]
    if shortCut then
        action.setShortcut(KDE::Shortcut.new(shortCut))
    end
    self.addAction(action.text, action)
    slot = options[:triggered]
    if slot then
        if slot.kind_of? Array then
            self.connect(action, SIGNAL(:triggered), slot[0], \
                           SLOT(slot[1]))
        else
            self.connect(action, SIGNAL(:triggered), parent, \
                           SLOT(slot))
        end
    end
    action
end