/* ***********************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 <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>

#include "Root_Interface.h"
#include "About_Interface.h"
#include "Maemo.h"
#include "../Declaration_Constante.h"
#include "../Image.h"
#include "../main.h"
#include "../Macro.h"


gboolean on_window_About_delete_event(GtkWidget  *widget, GdkEvent *event, gpointer user_data) {
  return TRUE;
}


void on_button_About_Bouton_Fermer_clicked  (GtkButton *button,gpointer user_data){
  gtk_widget_hide (window_About);
}



void create_about (void) {
  GtkTextBuffer *buffer = NULL;

#ifndef         __MAEMO
  window_About = gtk_window_new (GTK_WINDOW_TOPLEVEL);
#else
  window_About  = gtk_window_new_maemo ();
#endif

  gtk_window_set_title (GTK_WINDOW (window_About), "About");
  gtk_window_set_position (GTK_WINDOW (window_About), GTK_WIN_POS_CENTER_ON_PARENT);
  gtk_window_set_modal (GTK_WINDOW (window_About), TRUE);
  gtk_window_set_resizable (GTK_WINDOW (window_About), FALSE);

  about_icon_pixbuf = Chargement_Image (PATH_ICONE "AutoScan.png", COULEUR);
  if (about_icon_pixbuf) {
    gtk_window_set_icon (GTK_WINDOW (window_About), about_icon_pixbuf);
    gdk_pixbuf_unref (about_icon_pixbuf);
  }
  gtk_window_set_type_hint (GTK_WINDOW (window_About), GDK_WINDOW_TYPE_HINT_DIALOG);
  gtk_window_set_transient_for (GTK_WINDOW (window_About), GTK_WINDOW (window_root));

  vbox_About = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox_About);
  gtk_container_add (GTK_CONTAINER (window_About), vbox_About);

  image_About = gtk_image_new_from_file (PATH_ICONE "Logo.png");
  gtk_widget_show (image_About);
  gtk_box_pack_start (GTK_BOX (vbox_About), image_About, TRUE, TRUE, 0);

  label_About_Nom_application = gtk_label_new (VERSION_AUTOSCAN);
  gtk_widget_show (label_About_Nom_application);
  gtk_box_pack_start (GTK_BOX (vbox_About), label_About_Nom_application, FALSE, FALSE, 9);

  label_About_Droits = gtk_label_new ("AutoScan is a utility for network exploration\nCopyright (C) 2004-2008 \n\nDeveloper : Thierry Lagarde\nBeta testor : S\303\251bastien Desbrosses\n");
  gtk_widget_show (label_About_Droits);
  gtk_box_pack_start (GTK_BOX (vbox_About), label_About_Droits, FALSE, FALSE, 0);
  gtk_label_set_justify (GTK_LABEL (label_About_Droits), GTK_JUSTIFY_CENTER);

  scrolledwindow_About_Texte = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow_About_Texte);
  gtk_box_pack_start (GTK_BOX (vbox_About), scrolledwindow_About_Texte, FALSE, FALSE, 0);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_About_Texte), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow_About_Texte), GTK_SHADOW_IN);

  textview_About_Texte = gtk_text_view_new ();
  gtk_widget_show (textview_About_Texte);
  gtk_container_add (GTK_CONTAINER (scrolledwindow_About_Texte), textview_About_Texte);
  gtk_text_view_set_editable (GTK_TEXT_VIEW (textview_About_Texte), FALSE);
  gtk_text_view_set_accepts_tab (GTK_TEXT_VIEW (textview_About_Texte), FALSE);
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview_About_Texte), GTK_WRAP_WORD);
  gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview_About_Texte), FALSE);
  gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview_About_Texte)), "This program is free software; you can redistribute it and/or modify it under the terms of GNU GPL version 2.\nSee http://www.fsf.org for more information.\n\n\nDeveloper :\n Thierry Lagarde <thierry@autoscan-network.com>\n       Nantes, France\n\nDocumentation:\nS\303\251bastien BATARD \n  <fazer.sb@free.fr>\nJean-Luc BIORD \n  <http://qtfr.org>\n\nBeta testor, Gentoo Developer : \nS\303\251bastien Desbrosses\n  <gentoo@autoscan-network.com>\n\nLogo :\nCrystal GT : \nhttp://www.linuxcult.com/forum/crystal.php\nNuvoX  : \nhttp://www.kde-look.org/content/show.php?content=38467\n\nOther\nNessus : www.nessus.org\n\n\n\n", -1);
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview_About_Texte));
  gtk_text_buffer_get_end_iter (buffer, &iter);
  gtk_text_buffer_insert (buffer, &iter, version_compiled, -1);

  hbox_About_Bouton_Fermer = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox_About_Bouton_Fermer);
  gtk_box_pack_start (GTK_BOX (vbox_About), hbox_About_Bouton_Fermer, FALSE, FALSE, 3);

  fixed_About = gtk_fixed_new ();
  gtk_widget_show (fixed_About);
  gtk_box_pack_start (GTK_BOX (hbox_About_Bouton_Fermer), fixed_About, TRUE, TRUE, 0);

  button_About_Bouton_Fermer = gtk_button_new_from_stock ("gtk-close");
  gtk_widget_show (button_About_Bouton_Fermer);
  gtk_box_pack_start (GTK_BOX (hbox_About_Bouton_Fermer), button_About_Bouton_Fermer, FALSE, FALSE, 7);

  g_signal_connect ((gpointer) window_About, "delete_event", G_CALLBACK (on_window_About_delete_event), NULL);
  g_signal_connect ((gpointer) button_About_Bouton_Fermer, "clicked", G_CALLBACK(on_button_About_Bouton_Fermer_clicked),NULL);

}
