Module: ActionHandler

Defined in:
lib/rui/toolkits/kde/kde.rb,
lib/rui/toolkits/qt/qt.rb

Instance Method Summary collapse

Instance Method Details

#action_collectionObject



132
133
134
# File 'lib/rui/toolkits/qt/qt.rb', line 132

def action_collection
  @action_collection ||= { }
end

#action_list_entriesObject



136
137
138
# File 'lib/rui/toolkits/qt/qt.rb', line 136

def action_list_entries
  @action_list_entries ||= Hash.new {|h, x| h[x] = [] }
end

#action_parentObject



139
140
141
# File 'lib/rui/toolkits/kde/kde.rb', line 139

def action_parent
  self
end

#add_action(name, a) ⇒ Object



154
155
156
# File 'lib/rui/toolkits/qt/qt.rb', line 154

def add_action(name, a)
  action_parent.action_collection[name] = a
end

#get_slot(s = nil, &blk) ⇒ Object



121
122
123
124
125
126
127
# File 'lib/rui/toolkits/kde/kde.rb', line 121

def get_slot(s = nil, &blk)
  target, slot = if block_given?
    [Qt::SignalBlockInvocation.new(action_parent, blk, 'invoke()'), SLOT('invoke()')]
  else
    [action_parent, SLOT(s)]
  end
end

#plug_action_list(name, actions) ⇒ Object



143
144
145
# File 'lib/rui/toolkits/kde/kde.rb', line 143

def plug_action_list(name, actions)
  plugActionList(name.to_s, actions)
end

#regular_action(name, opts = { }, &blk) ⇒ Object



129
130
131
132
133
134
135
136
137
# File 'lib/rui/toolkits/kde/kde.rb', line 129

def regular_action(name, opts, &blk)
  a = KDE::Action.new(KDE::Icon.from_theme(opts[:icon]), 
                  opts[:text], action_parent)
  action_collection.add_action(name.to_s, a)  
  a.connect(SIGNAL('triggered(bool)'), &blk)
  a.tool_tip = opts[:tooltip] if opts[:tooltip]
  a.shortcut = opts[:shortcut] if opts[:shortcut]
  a
end

#std_action(name, &blk) ⇒ Object



116
117
118
119
# File 'lib/rui/toolkits/kde/kde.rb', line 116

def std_action(action, opts = {}, &blk)
  target, slot = get_slot(opts[:slot], &blk)
  KDE::StandardAction.method_missing(action, target, slot, action_collection)
end

#unplug_action_list(name) ⇒ Object



147
148
149
# File 'lib/rui/toolkits/kde/kde.rb', line 147

def unplug_action_list(name)
  unplugActionList(name.to_s)
end