#!/usr/bin/python
# -*- coding: ISO-8859-1 -*-
#
# Fichero:	gui.py
# Copyright:	Junta de Andaluca <devmaster@guadalinex.org>
# Autor:	Maria Dolores Perez Gutierez y Nestor Chacon Manzano
# Fecha:	lun mar 27 17:01:27 CET 2006
# Licencia:	GPL v.2
#
# generated by wxGlade 0.3.5.1 on Thu Dec  8 12:30:21 2005
#
# Codigo correspondiente a ventana principal de interfaz de configuracion

import os
from wizard import *
from ayuda import *
from inicSquid import *
from func import integridad_config

# Ventana principal del programa
# tiene cuatro botones que dan acceso a otras tantas secciones
# Asistente, Avanzado, Ayuda y Salir
class MyFrame(wx.MDIParentFrame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
	
	# internacionalizacion
	wx.Locale_AddCatalogLookupPathPrefix("/etc/acept/watcherCat/lang")
	locale = wx.Locale(wx.LANGUAGE_DEFAULT)
	a=locale.AddCatalog("acept")
	_=wx.GetTranslation

        try:
		kwds["style"] = wx.ICONIZE|wx.MINIMIZE|wx.MINIMIZE_BOX|wx.MAXIMIZE|wx.MAXIMIZE_BOX|wx.SYSTEM_MENU |wx.CLOSE_BOX
	except:
		kwds["style"] = wx.ICONIZE|wx.MINIMIZE|wx.MINIMIZE_BOX|wx.MAXIMIZE|wx.MAXIMIZE_BOX|wx.SYSTEM_MENU
        wx.MDIParentFrame.__init__(self, *args, **kwds)
        self.bitmap_button_1 = wx.lib.buttons.GenBitmapTextButton(self, -1, wx.Bitmap("/usr/share/acept/pixmaps/gaim_info.png", wx.BITMAP_TYPE_ANY),label=_("Asistente"))
        self.bitmap_button_2 = wx.lib.buttons.GenBitmapTextButton(self, -1, wx.Bitmap("/usr/share/acept/pixmaps/gnome-devel.png", wx.BITMAP_TYPE_ANY),label=_("Configuracion Avanzada"))
        self.bitmap_button_3 = wx.lib.buttons.GenBitmapTextButton(self, -1, wx.Bitmap("/usr/share/acept/pixmaps/stock_logout.png", wx.BITMAP_TYPE_ANY),label="   "+_("Salir"))
        self.bitmap_button_4 = wx.lib.buttons.GenBitmapTextButton(self, -1, wx.Bitmap("/usr/share/acept/pixmaps/ayuda.png", wx.BITMAP_TYPE_ANY),label="   "+_("Ayuda"))

        self.__set_properties()
        self.__do_layout()
        # end wxGlade
	wx.EVT_BUTTON(self, self.bitmap_button_1.GetId(), self.asistente)
	wx.EVT_BUTTON(self, self.bitmap_button_2.GetId(), self.avanzado)
	wx.EVT_CLOSE(self,self.salir)
	wx.EVT_BUTTON(self, self.bitmap_button_3.GetId(), self.salir)
	wx.EVT_BUTTON(self, self.bitmap_button_4.GetId(), self.ayuda)


    def __set_properties(self):
        # begin wxGlade: MyFrame.__set_properties
        self.SetTitle("ACEPT")
        _icon = wx.EmptyIcon()
        _icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/fondo_junta.gif", wx.BITMAP_TYPE_ANY))
        self.SetIcon(_icon)
        self.bitmap_button_1.SetSize(self.bitmap_button_1.GetBestSize())
        self.bitmap_button_2.SetSize(self.bitmap_button_2.GetBestSize())
        self.bitmap_button_3.SetSize(self.bitmap_button_3.GetBestSize())
        self.bitmap_button_4.SetSize(self.bitmap_button_3.GetBestSize())
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyFrame.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_3 = wx.BoxSizer(wx.VERTICAL)
        sizer_4 = wx.BoxSizer(wx.VERTICAL)
        sizer_6 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_5 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_2.Add((20, 20), 0, 0, 0)
        sizer_3.Add((20, 20), 0, 0, 0)
        sizer_5.Add(self.bitmap_button_1, 1, wx.EXPAND, 0)
        sizer_5.Add((20, 20), 0, 0, 0)
        sizer_5.Add(self.bitmap_button_2, 1, wx.EXPAND, 0)
        sizer_4.Add(sizer_5, 1, wx.EXPAND, 0)
        sizer_4.Add((20, 20), 0, 0, 0)
        sizer_6.Add(self.bitmap_button_4, 1, wx.EXPAND, 0)
        sizer_6.Add((20, 20), 0, 0, 0)
        sizer_6.Add(self.bitmap_button_3, 1, wx.EXPAND, 0)
        sizer_4.Add(sizer_6, 1, wx.EXPAND, 0)
        sizer_3.Add(sizer_4, 1, wx.EXPAND, 0)
        sizer_3.Add((20, 20), 0, 0, 0)
        sizer_2.Add(sizer_3, 1, wx.EXPAND, 0)
        sizer_2.Add((20, 20), 0, 0, 0)
        sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
        self.SetAutoLayout(True)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        sizer_1.SetSizeHints(self)
        self.Layout()
        # end wxGlade

    # Cierra todo 
    def salir(self,event):
	from sys import stderr
	# Mata el proceso inicial que autentica si el usuario es root o no
	# Configura squid
    	stderr=""
	mata_wxsu()
	self.Destroy()

    def avanzado(self,event):
    	self.Hide()
	win_acept=MyFrame1(self, -1, "")
    	win_acept.Show()
 
    def ayuda(self,event):
    	self.Hide()
	win_ayuda=MyHelp1(self, -1, "")
    	win_ayuda.Show()
    
    def asistente(self,event):
    	self.Hide()
	win_asistente=MyWizard0(self, -1, "")
    	win_asistente.Show()
	


# end of class MyFrame

class Inicio_App(wx.App):
        """ Inicializa el entorno Grfico """
        def OnInit(self):
    	    wx.InitAllImageHandlers()
	    self.myframe=MyFrame(None,-1,"")
            self.myframe.Show()
            
            return True

integridad_config()
inicio=Inicio_App()
inicio.MainLoop()
