Class: KeepYourHead::Application

Inherits:
Gnome::App
  • Object
show all
Defined in:
lib/Keepyourhead/Application.rb

Constant Summary collapse

Opts =
GetoptLong.new(
  [ '--edit', '-e', GetoptLong::OPTIONAL_ARGUMENT ],
  [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
  [ '--train', "-t", GetoptLong::OPTIONAL_ARGUMENT ]
)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplication

Returns a new instance of Application.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/Keepyourhead/Application.rb', line 26

def initialize
  print Project::BANNER

  #Gdk::Threads.init
  Gnome::Program.new( Project::NAME, Project::VERSION)
  Gtk.init

#   @start = "welcome"
  @start = "edit"

  @filename = "database.xfc"

  Opts.each{ |opt,arg| 
    case opt
    when "--edit"
      @start = "edit"
      @filename = arg if arg
    when "--train"
      @start = "train"
      @filename = arg if arg
    when "--help"
      puts "      ...asdasd\n      endl\n    end\n  }\n\n#   $width = 800\n#   $width = (Gdk::Screen.default.width * 0.7).to_i\n\n  $cache = Cache.new\n\n  $preferences = Preferences.new\n  $database = Database::Database.new\n\n\n  case @start\n  when \"train\"\n    DialogQuestionStart.new\n  when \"edit\"\n    WindowEdit.new $database\n  end\nend\n"

Class Method Details

.runObject



87
88
89
90
# File 'lib/Keepyourhead/Application.rb', line 87

def self.run
  $application = Application.new
  $application.mainloop
end

Instance Method Details

#mainloopObject



83
84
85
# File 'lib/Keepyourhead/Application.rb', line 83

def mainloop
  Gtk.main
end

#quitObject



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/Keepyourhead/Application.rb', line 70

def quit
  $cache.writeBack
  $cache = nil

  $database.writeBack
  $database = nil

  $preferences.writeBack
  $preferences = nil

  Gtk.main_quit
end