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 <<-endl
			...asdasd
			endl
		end
	}

#		$width = 800
#		$width = (Gdk::Screen.default.width * 0.7).to_i

	$cache = Cache.new

	$preferences = Preferences.new
	$database = Database::Database.new


	case @start
	when "train"
		DialogQuestionStart.new
	when "edit"
		WindowEdit.new $database
	end
end

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