#!/usr/bin/python
# -*- coding: utf-8 -*-

import pygtk
pygtk.require("2.0")
import gtk
import gladevcp.makepins
from gladevcp.gladebuilder import GladeBuilder
import hal
import linuxcnc
import sys,os
xmlname = "mygui.glade"
s = linuxcnc.stat()
c = linuxcnc.command()
class Mygui(object):
	def run(): 
        	program_start_line = 0
        	c.mode(linuxcnc.MODE_AUTO)
        	c.auto(linuxcnc.AUTO_RUN, program_start_line)
	def on_window1_destroy(self, widget, data=None):
		print "quit++"
		gtk.main_quit()
	def __init__(self):
		self.builder = gtk.Builder()
		self.builder.add_from_file(xmlname)
		halcomp = hal.component("mygui")
		self.builder.connect_signals(self)
		self.window = self.builder.get_object("window1")
		self.window.show()
		#self.window.fullscreen()
		panel = gladevcp.makepins.GladePanel( halcomp, xmlname, self.builder, None)


if __name__ == "__main__":
	app = Mygui()
	res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd", "-f", "./mode.hal"])
	if res: raise SystemExit, res
	gtk.main()
