class Gtk::ActionGroup - gtk3-3.1.8 Documentation

# class Gtk::ActionGroup

### Public Instance Methods

add_action(action, options={}) click to toggle source

    # File lib/gtk3/action-group.rb, line 20
    def add_action(action, options={})
      accelerator = options[:accelerator]

      if accelerator
        add_action_with_accel(action, accelerator)
      else
        add_action_raw(action)
      end
    end

Also aliased as: add_action_raw
add_action_raw(action, options={})
Alias for: add_action
add_actions(actions) click to toggle source

    # File lib/gtk3/action-group.rb, line 30
    def add_actions(actions)
      actions.each do |config|
        if config.is_a?(Array)
          name        = config[0]
          stock_id    = config[1]
          label       = config[2]
          accelerator = config[3]
          tooltip     = config[4]
          callback    = config[5]
        else
          name        = config[:name]
          stock_id    = config[:stock_id]
          label       = config[:label]
          accelerator = config[:accelerator]
          tooltip     = config[:tooltip]
          callback    = config[:callback]
        end

        action = Action.new(name,
                            :label    => translate_string(label),
                            :tooltip  => translate_string(tooltip),
                            :stock_id => stock_id)
        action.signal_connect("activate") do
          callback.call(self, action)
        end
        add_action(action, :accelerator => accelerator)
      end
    end

add_radio_actions(actions, default_value=nil) { |connected_action, current_action| ... } click to toggle source

    # File lib/gtk3/action-group.rb, line 91
    def add_radio_actions(actions, default_value=nil)
      actions.each_with_index do |config, i|
        if config.is_a?(Array)
          name        = config[0]
          stock_id    = config[1]
          label       = config[2]
          accelerator = config[3]
          tooltip     = config[4]
          value       = config[5]
        else
          name        = config[:name]
          stock_id    = config[:stock_id]
          label       = config[:label]
          accelerator = config[:accelerator]
          tooltip     = config[:tooltip]
          value       = config[:value]
        end

        action = RadioAction.new(name,
                                 value,
                                 :label    => translate_string(label),
                                 :tooltip  => translate_string(tooltip),
                                 :stock_id => stock_id)
        action.active = true if value == default_value
        if i.zero?
          action.signal_connect("changed") do |connected_action, current_action|
            yield(connected_action, current_action)
          end
        end
        add_action(action, :accelerator => accelerator)
      end
    end

add_toggle_actions(actions) click to toggle source

    # File lib/gtk3/action-group.rb, line 59
    def add_toggle_actions(actions)
      actions.each do |config|
        if config.is_a?(Array)
          name        = config[0]
          stock_id    = config[1]
          label       = config[2]
          accelerator = config[3]
          tooltip     = config[4]
          callback    = config[5]
          is_active   = config[6]
        else
          name        = config[:name]
          stock_id    = config[:stock_id]
          label       = config[:label]
          accelerator = config[:accelerator]
          tooltip     = config[:tooltip]
          callback    = config[:callback]
          is_active   = config[:is_active]
        end

        action = ToggleAction.new(name,
                                  :label    => translate_string(label),
                                  :tooltip  => translate_string(tooltip),
                                  :stock_id => stock_id)
        action.active = is_active
        action.signal_connect("activate") do
          callback.call(self, action)
        end
        add_action(action, :accelerator => accelerator)
      end
    end

translate_string(string) click to toggle source

    # File lib/gtk3/action-group.rb, line 125
    def translate_string(string)
      return nil if string.nil?

      translate_string_raw(string)
    end

Also aliased as: translate_string_raw
translate_string_raw(string)
Alias for: translate_string