/* ***********************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 <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>

#include "Wizard_Callbacks_Add_Network.h"
#include "Wizard_Interface_Add_Network.h"
#include "Wizard_Interface.h" 
#include "Wizard_Callbacks.h" 
#include "../Declaration_Constante.h"
#include "../Image.h"
#include "Combo.h"
#include "../Debug.h"
#include "../Com/Initialisation_Com.h"

void Wizard_Interface_Add_Network_Page1(){
  gtk_label_set_text(label_wizard, "<span foreground=\"white\" font_desc=\"18\"><b>Network Wizard</b></span>");
  gtk_label_set_use_markup (GTK_LABEL (label_wizard), TRUE);
  gtk_widget_set_sensitive (button_wizard_Revenir, FALSE);

  hbox_wizard_Intro_Add_Network = gtk_hbox_new (FALSE, 0);
  viewport_wizard_Contenu = hbox_wizard_Intro_Add_Network;
  gtk_widget_show (hbox_wizard_Intro_Add_Network);
  gtk_container_add (GTK_CONTAINER (viewport_wizard), hbox_wizard_Intro_Add_Network);

  eventbox_wizard_Intro_Add_Network = gtk_event_box_new ();
  gtk_widget_show (eventbox_wizard_Intro_Add_Network);
  gtk_box_pack_start (GTK_BOX (hbox_wizard_Intro_Add_Network), eventbox_wizard_Intro_Add_Network, FALSE, TRUE, 0);

  image_wizard_Intro_Add_Network = gtk_image_new_from_file (PATH_ICONE "Add_Network.png");
  gtk_widget_modify_bg (eventbox_wizard_Intro_Add_Network, GTK_STATE_NORMAL, &Couleur_Bleu);
  gtk_widget_show (image_wizard_Intro_Add_Network);
  gtk_container_add (GTK_CONTAINER (eventbox_wizard_Intro_Add_Network), image_wizard_Intro_Add_Network);

  eventbox_label_wizard_Intro_Add_Network = gtk_event_box_new ();
  gtk_widget_show (eventbox_label_wizard_Intro_Add_Network);
  gtk_box_pack_start (GTK_BOX (hbox_wizard_Intro_Add_Network), eventbox_label_wizard_Intro_Add_Network, TRUE, TRUE, 0);

  label_wizard_Intro_Add_Network = gtk_label_new ("This Wizard will add a network\n");
  gtk_widget_modify_bg (eventbox_label_wizard_Intro_Add_Network, GTK_STATE_NORMAL, &Couleur_Blanc);
  gtk_widget_show (label_wizard_Intro_Add_Network);
  gtk_container_add (GTK_CONTAINER (eventbox_label_wizard_Intro_Add_Network), label_wizard_Intro_Add_Network);
  gtk_label_set_use_markup (GTK_LABEL (label_wizard_Intro_Add_Network), TRUE);
  gtk_label_set_line_wrap (GTK_LABEL (label_wizard_Intro_Add_Network), TRUE);

 
  Wizard_Bouton_Annuler = Wizard_Bouton_Annuler_Add_Network_Standard;
  Wizard_Bouton_Revenir = NULL;
  Wizard_Bouton_Avancer_Post = NULL;
  Wizard_Bouton_Avancer = Wizard_Bouton_Add_Network_Page2;
  Wizard_Bouton_Enable();
}


void Wizard_Interface_Add_Network_Page2(){
  GSList   *radiobutton_Network_New_group = NULL;

  gtk_label_set_text (label_wizard, "<span foreground=\"white\" font_desc=\"18\"><b>Network</b></span>");
  gtk_label_set_use_markup (GTK_LABEL (label_wizard), TRUE);
  gtk_widget_set_sensitive (button_wizard_Revenir, TRUE);


  vbox_Network = gtk_vbox_new (FALSE, 0);
  viewport_wizard_Contenu = vbox_Network;
  gtk_widget_show (vbox_Network);
  gtk_container_add (GTK_CONTAINER (viewport_wizard), vbox_Network);

  frame_Network_New = gtk_frame_new (NULL);
  gtk_widget_show (frame_Network_New);
  gtk_box_pack_start (GTK_BOX (vbox_Network), frame_Network_New, FALSE, TRUE, 4);

  vbox_Network_New = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox_Network_New);
  gtk_container_add (GTK_CONTAINER (frame_Network_New), vbox_Network_New);
  gtk_container_set_border_width (GTK_CONTAINER (vbox_Network_New), 4);

  hbox_Network_New_Name = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox_Network_New_Name);
  gtk_box_pack_start (GTK_BOX (vbox_Network_New), hbox_Network_New_Name, FALSE, TRUE, 0);

  label_Network_New_Name = gtk_label_new ("Name");
  gtk_widget_show (label_Network_New_Name);
  gtk_box_pack_start (GTK_BOX (hbox_Network_New_Name), label_Network_New_Name, FALSE, TRUE, 0);

  entry_Network_New_Name = gtk_entry_new ();
  gtk_widget_show (entry_Network_New_Name);
  gtk_box_pack_start (GTK_BOX (hbox_Network_New_Name), entry_Network_New_Name, TRUE, TRUE, 14);
  gtk_entry_set_text (GTK_ENTRY (entry_Network_New_Name), Wizard_Name_Network);

  combobox_Network_New_Name = creation_combo (FALSE);
  Creation_Combo_Liste_Fichier_Image (combobox_Network_New_Name, PATH_ICONE "Network/", FALSE);
  gtk_widget_show (combobox_Network_New_Name);
  gtk_box_pack_start (GTK_BOX (hbox_Network_New_Name), combobox_Network_New_Name, FALSE, TRUE, 0);
  Active_Combo_Correspondant_Chaine_Attache(combobox_Network_New_Name,Wizard_Chemin_Icon_Nework);

  expander_Network_Private_Subnet = gtk_expander_new (NULL);
  gtk_widget_show (expander_Network_Private_Subnet);
  gtk_box_pack_start (GTK_BOX (vbox_Network_New), expander_Network_Private_Subnet, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (expander_Network_Private_Subnet), 3);
  vbox_Network_Options = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox_Network_Options);
  gtk_container_add (GTK_CONTAINER (expander_Network_Private_Subnet), vbox_Network_Options);
  
  frame_Network_Private_Subnet = gtk_frame_new (NULL);
  gtk_widget_show (frame_Network_Private_Subnet);
  gtk_box_pack_start (GTK_BOX (vbox_Network_Options), frame_Network_Private_Subnet, TRUE, TRUE, 0);
  gtk_frame_set_shadow_type (GTK_FRAME (frame_Network_Private_Subnet), GTK_SHADOW_NONE);

  alignment_Network_Private_Subnet = gtk_alignment_new (0.5, 0.5, 1, 1);
  gtk_widget_show (alignment_Network_Private_Subnet);
  gtk_container_add (GTK_CONTAINER (frame_Network_Private_Subnet), alignment_Network_Private_Subnet);
  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment_Network_Private_Subnet), 0, 0, 12, 0);
 
  vbox_Network_Private_Subnet = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox_Network_Private_Subnet);
  gtk_container_add (GTK_CONTAINER (alignment_Network_Private_Subnet), vbox_Network_Private_Subnet);

  scrolledwindow_Network_Private_Subnet = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow_Network_Private_Subnet);
  gtk_box_pack_start (GTK_BOX (vbox_Network_Private_Subnet), scrolledwindow_Network_Private_Subnet, TRUE, TRUE, 0);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_Network_Private_Subnet), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow_Network_Private_Subnet), GTK_SHADOW_ETCHED_IN);

 
  Create_Liste_Subnet ();
  gtk_widget_show (treeview_Network_Private_Subnet);
  gtk_container_add (GTK_CONTAINER (scrolledwindow_Network_Private_Subnet), treeview_Network_Private_Subnet);
 
  hbox_Network_Private_Subnet_Modif = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox_Network_Private_Subnet_Modif);
  gtk_box_pack_start (GTK_BOX (vbox_Network_Private_Subnet), hbox_Network_Private_Subnet_Modif, FALSE, TRUE, 5);
 
  combobox_Network_Private_Subnet = creation_combo (FALSE);   
  creation_combo_class();
  Afficher_Liste_Subnet ();
  gtk_widget_show (combobox_Network_Private_Subnet);
  gtk_box_pack_start (GTK_BOX (hbox_Network_Private_Subnet_Modif), combobox_Network_Private_Subnet, TRUE, TRUE, 18);
  gtk_widget_set_sensitive (combobox_Network_Private_Subnet, FALSE);
 
  fixed_Network_Private_Subnet_Milieu = gtk_fixed_new ();
  gtk_widget_show (fixed_Network_Private_Subnet_Milieu);
  gtk_box_pack_start (GTK_BOX (hbox_Network_Private_Subnet_Modif), fixed_Network_Private_Subnet_Milieu, TRUE, TRUE, 0);

  spinbutton_Network_Private_Subnet_A_adj = gtk_adjustment_new (0, 0, 255, 1, 10, 10);
  spinbutton_Network_Private_Subnet_A = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_Network_Private_Subnet_A_adj), 1, 0);
  gtk_widget_show (spinbutton_Network_Private_Subnet_A);
  gtk_box_pack_start (GTK_BOX (hbox_Network_Private_Subnet_Modif), spinbutton_Network_Private_Subnet_A, FALSE, TRUE, 8);
  gtk_widget_set_sensitive (spinbutton_Network_Private_Subnet_A, FALSE);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton_Network_Private_Subnet_A), TRUE);

  spinbutton_Network_Private_Subnet_B_adj = gtk_adjustment_new (0, 0, 255, 1, 10, 10);
  spinbutton_Network_Private_Subnet_B = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_Network_Private_Subnet_B_adj), 1, 0);
  gtk_widget_show (spinbutton_Network_Private_Subnet_B);
  gtk_box_pack_start (GTK_BOX (hbox_Network_Private_Subnet_Modif), spinbutton_Network_Private_Subnet_B, FALSE, TRUE, 8);
  gtk_widget_set_sensitive (spinbutton_Network_Private_Subnet_B, FALSE);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton_Network_Private_Subnet_B), TRUE);

  spinbutton_Network_Private_Subnet_C_adj = gtk_adjustment_new (0, 0, 255, 1, 10, 10);
  spinbutton_Network_Private_Subnet_C = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_Network_Private_Subnet_C_adj), 1, 0);
  gtk_widget_show (spinbutton_Network_Private_Subnet_C);
  gtk_box_pack_start (GTK_BOX (hbox_Network_Private_Subnet_Modif), spinbutton_Network_Private_Subnet_C, FALSE, TRUE, 8);
  gtk_widget_set_sensitive (spinbutton_Network_Private_Subnet_C, FALSE);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton_Network_Private_Subnet_C), TRUE);

  fixed_Network_Private_Subnet_Droite = gtk_fixed_new ();
  gtk_widget_show (fixed_Network_Private_Subnet_Droite);
  gtk_box_pack_start (GTK_BOX (hbox_Network_Private_Subnet_Modif), fixed_Network_Private_Subnet_Droite, TRUE, TRUE, 0);

  hbox_Network_Private_Subnet_Button = gtk_hbox_new (TRUE, 0);
  gtk_widget_show (hbox_Network_Private_Subnet_Button);
  gtk_box_pack_start (GTK_BOX (vbox_Network_Private_Subnet), hbox_Network_Private_Subnet_Button, FALSE, TRUE, 5);

  button_Network_Private_Subnet_Add = gtk_button_new_from_stock ("gtk-add");
  gtk_widget_show (button_Network_Private_Subnet_Add);
  gtk_box_pack_start (GTK_BOX (hbox_Network_Private_Subnet_Button), button_Network_Private_Subnet_Add, FALSE, TRUE, 8);

  button_Network_Private_Subnet_Delete = gtk_button_new_from_stock ("gtk-delete");
  gtk_widget_show (button_Network_Private_Subnet_Delete);
  gtk_box_pack_start (GTK_BOX (hbox_Network_Private_Subnet_Button), button_Network_Private_Subnet_Delete, FALSE, TRUE, 8);
  gtk_widget_set_sensitive (button_Network_Private_Subnet_Delete, FALSE);

  button_Network_Private_Subnet_OK = gtk_button_new_from_stock ("gtk-ok");
  gtk_widget_show (button_Network_Private_Subnet_OK);
  gtk_box_pack_start (GTK_BOX (hbox_Network_Private_Subnet_Button), button_Network_Private_Subnet_OK, FALSE, TRUE, 8);
  gtk_widget_set_sensitive (button_Network_Private_Subnet_OK, FALSE);

  button_Network_Private_Subnet_Cancel = gtk_button_new_from_stock ("gtk-cancel");
  gtk_widget_show (button_Network_Private_Subnet_Cancel);
  gtk_box_pack_start (GTK_BOX (hbox_Network_Private_Subnet_Button), button_Network_Private_Subnet_Cancel, FALSE, TRUE, 8);
  gtk_widget_set_sensitive (button_Network_Private_Subnet_Cancel, FALSE);

  label_Network_Private_Subnet = gtk_label_new ("Private subnet");
  gtk_widget_show (label_Network_Private_Subnet);
  gtk_frame_set_label_widget (GTK_FRAME (frame_Network_Private_Subnet), label_Network_Private_Subnet);
  gtk_label_set_use_markup (GTK_LABEL (label_Network_Private_Subnet), TRUE);

  hbox_Network_SNMP = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox_Network_SNMP);
  gtk_box_pack_start (GTK_BOX (vbox_Network_Options), hbox_Network_SNMP, TRUE, TRUE, 0);
 
  label_Network_SNMP = gtk_label_new ("SNMP community name : ");
  gtk_widget_show (label_Network_SNMP);
  gtk_box_pack_start (GTK_BOX (hbox_Network_SNMP), label_Network_SNMP, FALSE, FALSE, 0);

  entry_Network_SNMP = gtk_entry_new ();
  gtk_widget_show (entry_Network_SNMP);
  gtk_box_pack_start (GTK_BOX (hbox_Network_SNMP), entry_Network_SNMP, TRUE, TRUE, 0);
  gtk_entry_set_text (GTK_ENTRY (entry_Network_SNMP), Wizard_Snmp_Community_Name);

  checkbutton_Ip_Dynamic = gtk_check_button_new_with_mnemonic ("Ip Dynamic");
  gtk_widget_show (checkbutton_Ip_Dynamic);
  gtk_box_pack_start (GTK_BOX (vbox_Network_Options), checkbutton_Ip_Dynamic, FALSE, FALSE, 0);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_Ip_Dynamic), Wizard_Ip_Dynamic);
  
  label_Network_Options = gtk_label_new ("Options");
  gtk_widget_show (label_Network_Options);
  gtk_expander_set_label_widget (GTK_EXPANDER (expander_Network_Private_Subnet), label_Network_Options);

  radiobutton_Network_New = gtk_radio_button_new_with_mnemonic (NULL, "New");
  gtk_widget_show (radiobutton_Network_New);
  gtk_frame_set_label_widget (GTK_FRAME (frame_Network_New), radiobutton_Network_New);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_Network_New), radiobutton_Network_New_group);
  radiobutton_Network_New_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_Network_New));

  frame_Network_Restore = gtk_frame_new (NULL);
  gtk_widget_show (frame_Network_Restore);
  gtk_box_pack_start (GTK_BOX (vbox_Network), frame_Network_Restore, FALSE, TRUE, 0);

  hbox_Network_Restore = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox_Network_Restore);
  gtk_container_add (GTK_CONTAINER (frame_Network_Restore), hbox_Network_Restore);

  entry_Network_Restore = gtk_entry_new ();
  gtk_widget_show (entry_Network_Restore);
  gtk_box_pack_start (GTK_BOX (hbox_Network_Restore), entry_Network_Restore, TRUE, TRUE, 0);
  GTK_WIDGET_UNSET_FLAGS(entry_Network_Restore, GTK_CAN_FOCUS);
  gtk_widget_set_sensitive (entry_Network_Restore, FALSE);
  gtk_entry_set_text(GTK_ENTRY (entry_Network_Restore),Wizard_Chemin_Fichier_Xml);

  button_Network_Restore_Ouvrir = gtk_button_new_from_stock ("gtk-open");
  gtk_widget_show (button_Network_Restore_Ouvrir);
  gtk_box_pack_start (GTK_BOX (hbox_Network_Restore), button_Network_Restore_Ouvrir, FALSE, FALSE, 0);
  gtk_widget_set_sensitive (button_Network_Restore_Ouvrir, FALSE);

  radiobutton_Network_Restore = gtk_radio_button_new_with_mnemonic (NULL, "Restore");
  gtk_widget_show (radiobutton_Network_Restore);
  gtk_frame_set_label_widget (GTK_FRAME (frame_Network_Restore), radiobutton_Network_Restore);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_Network_Restore), radiobutton_Network_New_group);
  radiobutton_Network_New_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_Network_Restore));

  if (!Wizard_Restauration_Fichier_Xml)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_Network_New), TRUE);
  else
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_Network_Restore), TRUE); 
  Wizard_Add_Network_New_Network_sensitive(!Wizard_Restauration_Fichier_Xml);

  g_signal_connect ((gpointer) combobox_Network_Private_Subnet, "changed", G_CALLBACK (Subnet_changed), NULL);
  g_signal_connect ((gpointer) spinbutton_Network_Private_Subnet_A, "changed", G_CALLBACK (Subnet_changed), NULL);
  g_signal_connect ((gpointer) spinbutton_Network_Private_Subnet_B, "changed", G_CALLBACK (Subnet_changed), NULL);
  g_signal_connect ((gpointer) spinbutton_Network_Private_Subnet_C, "changed", G_CALLBACK (Subnet_changed), NULL);
  g_signal_connect ((gpointer) button_Network_Private_Subnet_Add, "clicked", G_CALLBACK (on_button_Network_Private_Subnet_Add_clicked), NULL);
  g_signal_connect ((gpointer) button_Network_Private_Subnet_Delete, "clicked", G_CALLBACK (on_button_Network_Private_Subnet_Delete_clicked), NULL);
  g_signal_connect ((gpointer) button_Network_Private_Subnet_OK, "clicked", G_CALLBACK (on_button_Network_Private_Subnet_OK_clicked), NULL);
  g_signal_connect ((gpointer) button_Network_Private_Subnet_Cancel, "clicked", G_CALLBACK (on_button_Network_Private_Subnet_Cancel_clicked), NULL);
  g_signal_connect ((gpointer) radiobutton_Network_Restore, "clicked", G_CALLBACK (on_radiobutton_Select_Network_Restore_clicked), NULL);
  g_signal_connect ((gpointer) radiobutton_Network_New, "clicked", G_CALLBACK (on_radiobutton_Network_New_clicked), NULL);
  g_signal_connect ((gpointer) button_Network_Restore_Ouvrir, "clicked", G_CALLBACK (on_button_Network_Open_File_Xml_Restore), NULL);
  Pid_Agent_Initialisation = -1;

 
  Wizard_Bouton_Annuler = Wizard_Bouton_Annuler_Add_Network_Standard;
  Wizard_Bouton_Revenir = Wizard_Bouton_Add_Network_Page1;
  Wizard_Bouton_Avancer_Post = Wizard_Bouton_Post_Add_Network_Page3;
  Wizard_Bouton_Avancer = Wizard_Bouton_Add_Network_Page3;
  Wizard_Bouton_Enable();
}



void Wizard_Interface_Add_Network_Page3(){
  GSList   *radiobutton_Localisation_Localhost_group = NULL;

  gtk_label_set_text (label_wizard, "<span foreground=\"white\" font_desc=\"18\"><b>Where is located the network</b></span>");
  gtk_label_set_use_markup (GTK_LABEL (label_wizard), TRUE);

  vbox_Localisation = gtk_vbox_new (FALSE, 0);
  viewport_wizard_Contenu = vbox_Localisation;
  gtk_widget_show (vbox_Localisation);
  gtk_container_add (GTK_CONTAINER (viewport_wizard), vbox_Localisation);

  hbox_Localisation_Localhost = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox_Localisation_Localhost);
  gtk_box_pack_start (GTK_BOX (vbox_Localisation), hbox_Localisation_Localhost, FALSE, FALSE, 0);

  radiobutton_Localisation_Localhost = gtk_radio_button_new_with_mnemonic (NULL, "Localhost");
  gtk_widget_show (radiobutton_Localisation_Localhost);
  gtk_box_pack_start (GTK_BOX (hbox_Localisation_Localhost), radiobutton_Localisation_Localhost, FALSE, FALSE, 5);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_Localisation_Localhost), radiobutton_Localisation_Localhost_group);
  radiobutton_Localisation_Localhost_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_Localisation_Localhost));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_Localisation_Localhost), TRUE);

  frame_Localisation_Connect = gtk_frame_new (NULL);
  gtk_widget_show (frame_Localisation_Connect);
  gtk_box_pack_start (GTK_BOX (vbox_Localisation), frame_Localisation_Connect, FALSE, TRUE, 0);

  vbox_Localisation_Connect = gtk_vbox_new (TRUE, 0);
  gtk_widget_show (vbox_Localisation_Connect);
  gtk_container_add (GTK_CONTAINER (frame_Localisation_Connect), vbox_Localisation_Connect);
  gtk_container_set_border_width (GTK_CONTAINER (vbox_Localisation_Connect), 3);

  hbox_Localisation_Connect_Haut = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox_Localisation_Connect_Haut);
  gtk_box_pack_start (GTK_BOX (vbox_Localisation_Connect), hbox_Localisation_Connect_Haut, FALSE, TRUE, 3);

  label_Localisation_Connect_Ip_Address = gtk_label_new ("Ip Address");
  gtk_widget_show (label_Localisation_Connect_Ip_Address);
  gtk_box_pack_start (GTK_BOX (hbox_Localisation_Connect_Haut), label_Localisation_Connect_Ip_Address, FALSE, TRUE, 4);
  
  entry_Localisation_Connect_Ip_Address = gtk_entry_new ();
  gtk_widget_show (entry_Localisation_Connect_Ip_Address);
  gtk_box_pack_start (GTK_BOX (hbox_Localisation_Connect_Haut), entry_Localisation_Connect_Ip_Address, FALSE, TRUE, 0);
  gtk_widget_set_sensitive (entry_Localisation_Connect_Ip_Address, FALSE);

  label_Localisation_Connect_Port = gtk_label_new ("Port");
  gtk_widget_show (label_Localisation_Connect_Port);
  gtk_box_pack_start (GTK_BOX (hbox_Localisation_Connect_Haut), label_Localisation_Connect_Port, FALSE, FALSE, 19);

  spinbutton_Localisation_Connect_Port_adj = gtk_adjustment_new (4555, 0, 65535, 1, 10, 10);
  spinbutton_Localisation_Connect_Port = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_Localisation_Connect_Port_adj), 1, 0);
  gtk_widget_show (spinbutton_Localisation_Connect_Port);
  gtk_box_pack_start (GTK_BOX (hbox_Localisation_Connect_Haut), spinbutton_Localisation_Connect_Port, FALSE, TRUE, 0);
  gtk_widget_set_sensitive (spinbutton_Localisation_Connect_Port, FALSE);

  hbox_Localisation_Connect_Bas = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox_Localisation_Connect_Bas);
  gtk_box_pack_start (GTK_BOX (vbox_Localisation_Connect), hbox_Localisation_Connect_Bas, FALSE, TRUE, 0);

  label_Localisation_Connect_User = gtk_label_new ("User");
  gtk_widget_show (label_Localisation_Connect_User);
  gtk_box_pack_start (GTK_BOX (hbox_Localisation_Connect_Bas), label_Localisation_Connect_User, FALSE, TRUE, 19);

  entry_Localisation_Connect_User = gtk_entry_new ();
  gtk_widget_show (entry_Localisation_Connect_User);
  gtk_box_pack_start (GTK_BOX (hbox_Localisation_Connect_Bas), entry_Localisation_Connect_User, FALSE, TRUE, 0);
  gtk_widget_set_sensitive (entry_Localisation_Connect_User, FALSE);

  label_Localisation_Connect_Password = gtk_label_new ("Password");
  gtk_widget_show (label_Localisation_Connect_Password);
  gtk_box_pack_start (GTK_BOX (hbox_Localisation_Connect_Bas), label_Localisation_Connect_Password, FALSE, FALSE, 6);

  entry_Localisation_Connect_Password = gtk_entry_new ();
  gtk_widget_show (entry_Localisation_Connect_Password);
  gtk_box_pack_start (GTK_BOX (hbox_Localisation_Connect_Bas), entry_Localisation_Connect_Password, FALSE, TRUE, 0);
  gtk_widget_set_sensitive (entry_Localisation_Connect_Password, FALSE);
  gtk_entry_set_visibility (GTK_ENTRY (entry_Localisation_Connect_Password), FALSE);

  radiobutton_Localisation_Connect = gtk_radio_button_new_with_mnemonic (NULL, "Connect to host");
  gtk_widget_show (radiobutton_Localisation_Connect);
  gtk_frame_set_label_widget (GTK_FRAME (frame_Localisation_Connect), radiobutton_Localisation_Connect);
 
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_Localisation_Connect), radiobutton_Localisation_Localhost_group);
  radiobutton_Localisation_Localhost_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_Localisation_Connect));

  label_Localisation_Connecting = gtk_label_new ("");
  gtk_widget_show (label_Localisation_Connecting);
  gtk_box_pack_start (GTK_BOX (vbox_Localisation), label_Localisation_Connecting, FALSE, FALSE, 18);
  gtk_label_set_justify (GTK_LABEL (label_Localisation_Connecting), GTK_JUSTIFY_CENTER);

 
  g_signal_connect ((gpointer) radiobutton_Localisation_Localhost, "clicked", G_CALLBACK (on_radiobutton__Select_Network_Local_clicked), NULL);
  g_signal_connect ((gpointer) radiobutton_Localisation_Connect, "clicked", G_CALLBACK (on_radiobutton_Select_Network_Connect_clicked), NULL);

 
  Wizard_Bouton_Annuler = Wizard_Bouton_Annuler_Add_Network_Standard;
  Wizard_Bouton_Revenir = Wizard_Bouton_Add_Network_Page2;
  Wizard_Bouton_Avancer_Post = Wizard_Bouton_Post_Add_Network_Page4;
  Wizard_Bouton_Avancer = Wizard_Bouton_Add_Network_Page4;
  Wizard_Bouton_Enable();
}





void Wizard_Interface_Add_Network_Page4(){
  GSList   *radiobutton_Localisation_Localhost_group = NULL;
  gtk_label_set_text (label_wizard, "<span foreground=\"white\" font_desc=\"18\"><b>Initialize the Agent</b></span>");
  gtk_label_set_use_markup (GTK_LABEL (label_wizard), TRUE);

  vbox_Initialize = gtk_vbox_new (FALSE, 0);
  viewport_wizard_Contenu = vbox_Initialize;
  gtk_widget_show (vbox_Initialize);
  gtk_container_add (GTK_CONTAINER (viewport_wizard), vbox_Initialize);

  label_Initialize = gtk_label_new ("please wait ...");
  gtk_widget_show (label_Initialize);
  gtk_box_pack_start (GTK_BOX (vbox_Initialize), label_Initialize, FALSE, FALSE, 14);

  progressbar_Initialize = gtk_progress_bar_new ();
  gtk_widget_show (progressbar_Initialize);
  gtk_box_pack_start (GTK_BOX (vbox_Initialize), progressbar_Initialize, TRUE, FALSE, 11);
  gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progressbar_Initialize), "Connecting");

  combobox_Select_Interface = creation_combo (FALSE);
  gtk_widget_hide (combobox_Select_Interface);
  gtk_box_pack_start (GTK_BOX (vbox_Initialize), combobox_Select_Interface, FALSE, FALSE, 0);

 
  Wizard_Bouton_Annuler = NULL;
  Wizard_Bouton_Revenir = NULL;
  Wizard_Bouton_Avancer_Post = NULL;
  Wizard_Bouton_Avancer = NULL;
}



void Wizard_Interface_Add_Network_Page5(){
  gtk_widget_set_sensitive (button_wizard_Revenir, FALSE);
  gtk_label_set_text(label_wizard, "<span foreground=\"white\" font_desc=\"18\"><b>Summary</b></span>");
  gtk_label_set_use_markup (GTK_LABEL (label_wizard), TRUE);

  hbox_wizard_Final_Add_Network = gtk_hbox_new (FALSE, 0);
  viewport_wizard_Contenu = hbox_wizard_Final_Add_Network;
  gtk_widget_show (hbox_wizard_Final_Add_Network);
  gtk_container_add (GTK_CONTAINER (viewport_wizard), hbox_wizard_Final_Add_Network);

  eventbox_wizard_Final_Add_Network = gtk_event_box_new ();
  gtk_widget_show (eventbox_wizard_Final_Add_Network);
  gtk_box_pack_start (GTK_BOX (hbox_wizard_Final_Add_Network), eventbox_wizard_Final_Add_Network, FALSE, TRUE, 0);

  image_wizard_Final_Add_Network = gtk_image_new_from_file (PATH_ICONE "Add_Network.png");
  gtk_widget_modify_bg (eventbox_wizard_Final_Add_Network, GTK_STATE_NORMAL, &Couleur_Bleu);
  gtk_widget_show (image_wizard_Final_Add_Network);
  gtk_container_add (GTK_CONTAINER (eventbox_wizard_Final_Add_Network), image_wizard_Final_Add_Network);

  eventbox_label_wizard_Final_Add_Network = gtk_event_box_new ();
  gtk_widget_show (eventbox_label_wizard_Final_Add_Network);
  gtk_box_pack_start (GTK_BOX (hbox_wizard_Final_Add_Network), eventbox_label_wizard_Final_Add_Network, TRUE, TRUE, 0);

  label_wizard_Final_Add_Network = gtk_label_new ("Confirm the following information:\n\nName Network : \nInterface :\n");
  gtk_widget_modify_bg (eventbox_label_wizard_Final_Add_Network, GTK_STATE_NORMAL, &Couleur_Blanc);
  gtk_widget_show (label_wizard_Final_Add_Network);
  gtk_container_add (GTK_CONTAINER (eventbox_label_wizard_Final_Add_Network), label_wizard_Final_Add_Network);
  gtk_label_set_use_markup (GTK_LABEL (label_wizard_Final_Add_Network), TRUE);
  gtk_label_set_line_wrap (GTK_LABEL (label_wizard_Final_Add_Network), TRUE);

 
  Wizard_Bouton_Annuler = NULL;
  Wizard_Bouton_Revenir = NULL;
  Wizard_Bouton_Avancer_Post = NULL;
  Wizard_Bouton_Avancer = Wizard_Bouton_Add_Network_Fin;
  Wizard_Bouton_Enable();
}
