Update connect/disconnect action states.
[kaya.git] / lib / action_provider.rb
bloba458bd906c7ba5890ab737dbb6990067acfb3750
1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
2
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.
8 Action = Struct.new(:id, :opts, :action)
10 module ActionProvider
11   def action(id, opts = {}, &action)
12     @action_data ||= []
13     @action_data << Action.new(id, opts, action)
14   end
15   
16   def each_action(&blk)
17     @action_data.each(&blk)
18   end
19 end
21 class ActionProviderClient < KDE::XMLGUIClient
22   include ActionHandler
23   
24   def initialize(parent, provider)
25     super(parent)
26     @parent = parent
28     setGUI(provider.gui)
29     provider.each_action do |action|
30       regular_action(action.id, action.opts) do
31         action.action[@parent]
32       end
33     end
34   end
35   
36   def action_parent
37     @parent
38   end
39 end