Sha256: 7e2a521fb7b92b5de88626c20e9c3b7b59abac00195090eed631b821e770da07

Contents?: true

Size: 1.46 KB

Versions: 8

Compression:

Stored size: 1.46 KB

Contents

require "forwardable"

require "rabbit/action"
require "rabbit/progress"

module Rabbit
  module Renderer
    module Display
      module Progress
        extend Forwardable

        def_delegator(:@progress, :foreground, :progress_foreground)
        def_delegator(:@progress, :foreground=, :progress_foreground=)
        def_delegator(:@progress, :background, :progress_background)
        def_delegator(:@progress, :background=, :progress_background=)
        def_delegator(:@progress, :clear_color, :clear_progress_color)

        def initialize(*args, &block)
          super
          init_progress
        end

        private
        def init_progress
          @progress = Rabbit::Progress.new
        end

        def start_progress(max)
          return if max.zero?
          update_menu
          @progress.start_progress(max, @canvas.window)
          adjust_progress_window
        end

        def update_progress(i)
          @progress.update_progress(i)
          Utils.process_pending_events
        end

        def end_progress
          @progress.end_progress
          GLib::Timeout.add(100) do
            @progress.window.hide
            update_menu
            false
          end
        end

        def configured(x, y, w, h)
          super
          adjust_progress_window
        end

        def adjust_progress_window
          if @window
            Utils.move_to_top_left(@window, @progress.window)
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rabbit-2.2.0 lib/rabbit/renderer/display/progress.rb
rabbit-2.1.9 lib/rabbit/renderer/display/progress.rb
rabbit-2.1.8 lib/rabbit/renderer/display/progress.rb
rabbit-2.1.7 lib/rabbit/renderer/display/progress.rb
rabbit-2.1.6 lib/rabbit/renderer/display/progress.rb
rabbit-2.1.5 lib/rabbit/renderer/display/progress.rb
rabbit-2.1.4 lib/rabbit/renderer/display/progress.rb
rabbit-2.1.3 lib/rabbit/renderer/display/progress.rb