Sha256: d6985f805788dd29201114091fe13a71e9900731ae506db571d2bd9d184462db

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true
class Shoes
  class Dialog
    def initialize
      @gui = Shoes.backend::Dialog.new
    end

    def alert(msg = '')
      @gui.alert msg
    end

    def confirm(msg = '')
      @gui.confirm msg
    end

    def dialog_chooser(title, folder = false, style = :open)
      @gui.dialog_chooser title, folder, style
    end

    def ask(msg, args)
      ask_me = Shoes.app(title: args[:title] || "Shoes asks:",
                         width: 300, height: 125,
                         modal: true) do
        stack do
          para msg, margin: 10

          @e = edit_line margin_left: 10,
                         width:       width - 20,
                         secret:      args[:secret]

          flow margin_top: 10 do
            button "OK", margin_left: 150 do
              @result = @e.text
              quit
            end

            button "Cancel" do
              @result = nil
              quit
            end
          end
        end

        def result
          @result
        end
      end

      ask_me.wait_until_closed
      ask_me.result
    end

    def ask_color(title)
      @gui.ask_color title
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shoes-core-4.0.0.pre11 lib/shoes/dialog.rb
shoes-core-4.0.0.pre10 lib/shoes/dialog.rb
shoes-core-4.0.0.pre9 lib/shoes/dialog.rb