Class: Gtk2AppLib::Dialogs

Inherits:
Object
  • Object
show all
Includes:
Missing
Defined in:
lib/gtk2applib.rb,
lib/gtk2applib/dialogs/core.rb,
lib/gtk2applib/dialogs/auth.rb,
lib/gtk2applib/dialogs/entry.rb,
lib/gtk2applib/dialogs/login.rb,
lib/gtk2applib/dialogs/question.rb,
lib/gtk2applib/dialogs/get_date.rb,
lib/gtk2applib/dialogs/pick_one.rb,
lib/gtk2applib/dialogs/text_view.rb,
lib/gtk2applib/dialogs/show_image.rb,
lib/gtk2applib/dialogs/choose_tags.rb,
lib/gtk2applib/dialogs/quick_message.rb

Overview

reeks in here!

Defined Under Namespace

Classes: Auth, ChooseTags, Entry, GetDate, PickOne, Question, QuickMessage, ShowImage, TextView

Constant Summary

DIALOG =
Hash.new { nil }

Constants included from Missing

Missing::REQUIRES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Missing

missing

Constructor Details

#initialize(options = Constants::HNIL) ⇒ Dialogs



136
137
138
# File 'lib/gtk2applib.rb', line 136

def initialize(options=Constants::HNIL)
  @options = KeyValues.new(options, DIALOG[:dialogs])
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(missing, *arguments, &block) ⇒ Object



140
141
142
# File 'lib/gtk2applib.rb', line 140

def method_missing(missing, *arguments, &block)
  Missing.missing(missing, self, arguments, block) { super }
end

Class Method Details

.bless(key, value = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/gtk2applib/dialogs/core.rb', line 7

def self.bless(key, value = {})
  dialog_key = DIALOG[key]
  if dialog_key.nil? then
    dialog_key = KeyValues.new(value)
    dialog_key.default = Constants::HNIL
    DIALOG[key] = dialog_key
  else
    # using supplement because
    # we don't want to over-ride user configured defaults.
    dialog_key.supplement(value)
  end
end

.dialogsObject



132
133
134
# File 'lib/gtk2applib.rb', line 132

def self.dialogs
  require 'gtk2applib/dialogs/core'
end

Instance Method Details

#auth(*options) ⇒ (String,String)?

Returns the username and password



47
48
49
50
51
# File 'lib/gtk2applib/dialogs/auth.rb', line 47

def auth(*options)
  username, password, *options = Parameters.map(options)
  options.push(DIALOG[:auth])
  Auth.new(username, password, @options.dup(*options)).run
end

#choose_tags(*options) ⇒ Array of String, Nil

Displays a list (words) of labeled toggle-buttons one can toggle. If a label for a toggle-button is in tags, the button will be "on". One can also add labels in an entry box. Returns a list of selected labels, including those entered in the entry box.



77
78
79
80
81
# File 'lib/gtk2applib/dialogs/choose_tags.rb', line 77

def choose_tags(*options)
  tags, options = Parameters.map(options)
  options.push(DIALOG[:choose_tags])
  ChooseTags.new(tags, @options.dup(*options)).run
end

#entry(*options) ⇒ String, Nil

Edits message in a text view



31
32
33
34
35
# File 'lib/gtk2applib/dialogs/entry.rb', line 31

def entry(*options)
  prompt, *options =  Parameters.map(options)
  options.push(DIALOG[:entry])
  Entry.new(prompt, @options.dup(*options)).run
end

#get_date(*options) ⇒ Date, Nil

Display a calendar from which one can select a date.



38
39
40
41
42
# File 'lib/gtk2applib/dialogs/get_date.rb', line 38

def get_date(*options)
  date, *options = Parameters.map(options)
  options.push(DIALOG[:get_date])
  GetDate.new(date, @options.dup(*options)).run
end

#login(*options) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/gtk2applib/dialogs/login.rb', line 8

def (*options)
  username, password, *options = Parameters.map(options)
  session = nil
  while !session do
    username, password = self.auth(username, password, *options)
    session = yield(username, password, *options)
  end
  return session
end

#pick_one(*options) ⇒ String, Nil

Displays a combo-box from which on can select an item from list and/or entry.



43
44
45
46
47
# File 'lib/gtk2applib/dialogs/pick_one.rb', line 43

def pick_one(*options)
  list, *options = Parameters.map(*options)
  options.push(DIALOG[:pick_one])
  PickOne.new(list, @options.dup(*options)).run
end

#question?(*options) ⇒ Boolean

A dialog with a quick question, returning a yes or no answer (true or false (or nil if the window is closed)).



30
31
32
33
34
# File 'lib/gtk2applib/dialogs/question.rb', line 30

def question?(*options)
  question, *options = Parameters.map(options)
  options.push(DIALOG[:question])
  Question.new(question, @options.dup(*options)).run
end

#quick_message(*options) ⇒ Object

Function to open a dialog box displaying the message provided.



35
36
37
38
39
# File 'lib/gtk2applib/dialogs/quick_message.rb', line 35

def quick_message(*options)
  message, *options = Parameters.map(options)
  options.push(DIALOG[:quick_message])
  QuickMessage.new(@options.dup(*options)).run(message)
end

#show_image(*parameters) ⇒ Object

Function to open a dialog box displaying the message provided.



34
35
36
37
38
39
# File 'lib/gtk2applib/dialogs/show_image.rb', line 34

def show_image(*parameters)
  uri, cache_directory, *options = Parameters.map(*parameters)
  raise "Need cache_directory" if cache_directory.nil?
  options.push(DIALOG[:show_image])
  ShowImage.new(uri, cache_directory, @options.dup(*options)).run
end

#text_view(*options) ⇒ Object

Edits message in a text view



29
30
31
32
33
# File 'lib/gtk2applib/dialogs/text_view.rb', line 29

def text_view(*options)
  message, *options = Parameters.map(options)
  options.push(DIALOG[:text_view])
  TextView.new(message, @options.dup(*options)).run
end