/* ***********************IMPORTANT *********************************************
 *  Copyright (C) 2004-2007 Thierry Lagarde <tlagarde@users.sourceforge.net>
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License.
 *
 *
 *                      ********************
 *
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *
 *                      ********************
 *
 *
 * You are highly encouraged to send your changes to <tlagarde@users.sourceforge.net>
 * for possible incorporation into the main distribution.
 * By sending these changes to <tlagarde@users.sourceforge.net>,
 * it is assumed that you are offering <tlagarde@users.sourceforge.net>
 * the unlimited, non-exclusive right to reuse, modify, and relicense the code.
 *
 *
 *                      ********************
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **************************************************************************************/
#include <gtk/gtk.h>

#include "Erreur_Callbacks.h"
#include "Erreur_Interface.h"
#include "Root_Interface.h"
#include "Maemo.h"

void Affiche_Win_Erreur (void){
	if (window_Erreur == NULL)
		create_window_Erreur ();
	gtk_widget_show (window_Erreur);
}

void create_window_Erreur (void)
{
#ifndef         __MAEMO
	window_Erreur = gtk_window_new (GTK_WINDOW_TOPLEVEL);
#else
	window_Erreur = gtk_window_new_maemo ();
#endif

	gtk_window_set_title (GTK_WINDOW (window_Erreur), "Error");
	gtk_window_set_resizable (GTK_WINDOW (window_Erreur), FALSE);
	gtk_window_set_modal (GTK_WINDOW (window_Erreur), TRUE);
	gtk_window_set_position (GTK_WINDOW (window_Erreur), GTK_WIN_POS_CENTER);

	vbox_Erreur = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox_Erreur);
	gtk_container_add (GTK_CONTAINER (window_Erreur), vbox_Erreur);

	label_Erreur = gtk_label_new ("[ERROR_AGENT] \n(%s)\n[%s](%s:%d): \n%s ");
	gtk_widget_show (label_Erreur);
	gtk_box_pack_start (GTK_BOX (vbox_Erreur), label_Erreur, FALSE, FALSE, 10);

	hbox_Erreur = gtk_hbox_new (TRUE, 0);
	gtk_widget_show (hbox_Erreur);
	gtk_box_pack_start (GTK_BOX (vbox_Erreur), hbox_Erreur, FALSE, TRUE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (hbox_Erreur), 10);

	button_Erreur_Inform = gtk_button_new ();
	gtk_widget_show (button_Erreur_Inform);
	gtk_box_pack_start (GTK_BOX (hbox_Erreur), button_Erreur_Inform, FALSE, FALSE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (button_Erreur_Inform), 3);

	alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0);
	gtk_widget_show (alignment1);
	gtk_container_add (GTK_CONTAINER (button_Erreur_Inform), alignment1);

	hbox5 = gtk_hbox_new (FALSE, 2);
	gtk_widget_show (hbox5);
	gtk_container_add (GTK_CONTAINER (alignment1), hbox5);

	image1 = gtk_image_new_from_stock ("gtk-dialog-warning", GTK_ICON_SIZE_BUTTON);
	gtk_widget_show (image1);
	gtk_box_pack_start (GTK_BOX (hbox5), image1, FALSE, FALSE, 0);

	label7 = gtk_label_new_with_mnemonic ("Inform developper");
	gtk_widget_show (label7);
	gtk_box_pack_start (GTK_BOX (hbox5), label7, FALSE, FALSE, 0);

	button_Erreur_Quitter = gtk_button_new_from_stock ("gtk-close");
	gtk_widget_show (button_Erreur_Quitter);
	gtk_box_pack_start (GTK_BOX (hbox_Erreur), button_Erreur_Quitter, TRUE, TRUE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (button_Erreur_Quitter), 3);

	g_signal_connect ((gpointer) window_Erreur, "delete_event", G_CALLBACK (on_window_Erreur_delete_event), NULL);
	g_signal_connect ((gpointer) button_Erreur_Inform, "clicked", G_CALLBACK (on_button_Erreur_Inform_clicked), NULL);
	g_signal_connect ((gpointer) button_Erreur_Quitter, "clicked", G_CALLBACK (on_button_Erreur_Quitter_clicked), NULL);
}
