Sha256: 8197ca57e3a9158408cc675d2e5a02b30e2b86ea6ed036f9374d68b065f5bec7

Contents?: true

Size: 902 Bytes

Versions: 1

Compression:

Stored size: 902 Bytes

Contents

require 'green_shoes'

module Breaktime
  # The shoes GUI app for notifying the user about their imminent breaktime.
  #
  # They have 10 seconds to cancel the break. If they cancel the process exits
  # with EX_BREAK_CANCELLED, otherwise EX_OK. This is used by calling processes
  # to determine what to do.
  Shoes.app :height => 60, :width => 380, :title => 'Take a break!' do
    seconds = 10
    str = "Take a break! You have %d seconds to cancel."

    background white
    flow :margin => 4 do
      @sent = para str % seconds
      every 1 do |i|
        if i >= seconds
          exit Breaktime::EX_OK
        else
          @sent.text = str % (seconds - i)
        end
      end
    end
    flow do
      button "Cancel" do
        exit Breaktime::EX_BREAK_CANCELLED
      end

      button "Gimme 5", :align => :right do
        exit Breaktime::EX_BREAK_DELAYED
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
breaktime-0.1.4 lib/breaktime/dialog.rb