Class: Ig3tool::ToolWindow

Inherits:
Object
  • Object
show all
Defined in:
lib/ui/toolwindow.rb

Overview

1 Minuut

Constant Summary collapse

ICON_BASEPATH =
Pathname.new(__FILE__).parent.parent + "glade/icons"
@@windows =
{}

Instance Method Summary collapse

Constructor Details

#initialize(klasses) ⇒ ToolWindow



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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/ui/toolwindow.rb', line 44

def initialize (klasses)
	window = Gtk::Window.new
	window.title = "Ig3tool"
	window.type_hint = Gdk::Window::TYPE_HINT_NORMAL
	#window.keep_above = true
	window.move(0,0)

	bigbox = Gtk::VBox.new(true)
	bigbox.border_width = 6
	bigbox.spacing = 12
	window.add(bigbox)


	klasses.each do |klass|
		name = klass::MENU_PATH.last
		icon = (klass::ICON || "no.xpm")
		button = create_button(name, icon.to_s)
		button.signal_connect("clicked") do
			Thread.new do
				@@windows[klass] ||= klass.new
				@@windows[klass].show
				@@windows[klass].present
			end
		end
		bigbox.add(button)
	end

	window.signal_connect("delete-event") do
		not ask_to_quit(window)
	end
	window.signal_connect("destroy") do
		Gtk::main_quit
	end

	GLib::Timeout.add_seconds(30) {
		begin
			if XScreenSaver.idle_time >= SALES_WINDOW_TIMEOUT
				klass = SalesWindow
				@@windows[klass] ||= klass.new
				@@windows[klass].show
				@@windows[klass].present
				@@windows[klass].focus_smartzap
			end
		rescue Exception => e
			puts "No XTimeout"
		end
		true
	}

	bigbox.show_all
	size = window.size_request
	size[0] += 24
	size[1] += klasses.length * 12
	window.set_default_size(*size)
	window.show_all
end