Class: Gtk2AppLib::Dialogs::Auth

Inherits:
Gtk::Dialog
  • Object
show all
Defined in:
lib/gtk2applib/dialogs/auth.rb

Overview

creates an Auth dialog

Instance Method Summary (collapse)

Constructor Details

- (Auth) initialize(username, password, options)

Returns a new instance of Auth



21
22
23
24
25
26
27
28
# File 'lib/gtk2applib/dialogs/auth.rb', line 21

def initialize(username, password, options)
  @options = options # defined: @options
  super(@options[:TITLE],
    @options[:WINDOW], @options[:FLAGS], *@options[:DIALOG_BUTTONS])
  @username = add_hbox(username, :USERNAME)
  @password = add_hbox(password, :PASSWORD)
  @password.visibility = false
end

Instance Method Details

- (Object) add_hbox(default, key)



14
15
16
17
18
19
# File 'lib/gtk2applib/dialogs/auth.rb', line 14

def add_hbox(default, key)
  # @options defined in initialize
  hbox = Widgets::HBox.new(self.vbox, *@options[:HBox])
  Widgets::Label.new(@options[key], hbox, *@options[:Label])
  Widgets::Entry.new(default, hbox, *@options[:Entry])
end

- (Object) run



30
31
32
33
34
35
36
37
38
# File 'lib/gtk2applib/dialogs/auth.rb', line 30

def run
  ret = nil
  self.show_all
  super { |response|
    ret=[@username.text.strip, @password.text.strip] if response == 1
  }
  self.destroy
  ret
end