1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
9 require 'action_provider'
12 include ActionProvider
14 def actions(parent, collection, policy)
15 actions = (@action_data || []).map{|data| create_action(data, parent, collection, policy) }
19 def create_action(data, parent, collection, policy)
20 icon = if data.opts[:icon]
21 KDE::Icon.new(data.opts[:icon])
25 text = data.opts[:text] || data.id.to_s
26 a = KDE::Action.new(icon, text, parent)
27 collection.add_action(data.id.to_s, a)
28 if data.opts.has_key?(:checked)
30 a.checked = data.opts[:checked]
31 a.connect(SIGNAL('toggled(bool)')) do |value|
32 data.action[value, policy]
35 a.on(:triggered) { data.action[policy] }