Sha256: 50bc0f828aeca23eb56357dfc28cd2d13399075a698a72b52bb467c8d7792bf8

Contents?: true

Size: 1.73 KB

Versions: 47

Compression:

Stored size: 1.73 KB

Contents

module Redcar
  class ToolBar
    class Item
      class Separator < Item
        def initialize(options={})
          super(nil, options)
        end
        
        def is_unique?
          true
        end
      end

      attr_reader :text, :command, :priority, :value, :icon, :barname
 
      # Create a new Item, with the given text to display in the toolbar, and
      # either:
      #   the Redcar::Command that is run when the item is selected.
      #   or a block to run when the item is selected
      def initialize(text, options={}, &block)
        @text = text
        
        if options.respond_to?('[]')
          @command = options[:command] || block
	        @priority = options[:priority] # Currently not utilized
          @value = options[:value]
          @icon = options[:icon]
          @barname = options[:barname]
        # This branch is for compatibility with old code. Please use :command 
        # option in new code
        # FIXME: Should this be removed at some point?
        else
          @command = options || block
        end
        
        @priority ||= ToolBar::DEFAULT_PRIORITY
      end
      
      # Call this to signal that the toolbar item has been selected by the user.
      def selected(with_key=false)
        if @value
          @command.new.run(:value => @value)
        else  
          @command.new.run#(:with_key => with_key)
        end
      end
      
      def type
        @type
      end
      
      def type
        @type
      end
      
      def merge(other)
        @command = other.command
        @priority = other.priority
      end
      
      def ==(other)
        text == other.text and command == other.command
      end
      
      def is_unique?
        false
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 2 rubygems

Version Path
redcar-0.13 plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.13.5dev plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.13.4dev plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.13.3dev plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.13.2dev plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.13.1dev plugins/application/lib/application/toolbar/item.rb
redcar-0.12.1 plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.13.0dev plugins/application/lib/application/toolbar/item.rb
redcar-0.12 plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.12.27dev plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.12.26dev plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.12.25dev plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.12.24dev plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.12.23dev plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.12.22dev plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.12.21dev plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.12.20dev plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.12.19dev plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.12.18dev plugins/application/lib/application/toolbar/item.rb
redcar-dev-0.12.17dev plugins/application/lib/application/toolbar/item.rb