/* ***********************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 "Recherche_Callbacks.h"
#include "Recherche_Interface.h"
#include "../Recherche.h"
#include "Combo.h"
#include "../Settings_Port.h"
#include "../Debug.h"
#include "../Macro.h"

void on_window_Recherche_destroy (GtkObject * object, gpointer user_data)
{
	window_Recherche = NULL;
}


void on_radiobutton_Recherche_Mac_clicked (GtkButton * button, gpointer user_data)
{
	DEBUG_ACTION_USER();
	gtk_widget_set_sensitive (entry_Recherche_Mac, TRUE);
	gtk_widget_set_sensitive (entry_Recherche_Ip, FALSE);
	gtk_widget_set_sensitive (entry_Recherche_Hostname, FALSE);
	gtk_widget_set_sensitive (combobox_Recherche_Port, FALSE);
}


void on_radiobutton_Recherche_Ip_clicked (GtkButton * button, gpointer user_data)
{
	DEBUG_ACTION_USER();
	gtk_widget_set_sensitive (entry_Recherche_Mac, FALSE);
	gtk_widget_set_sensitive (entry_Recherche_Ip, TRUE);
	gtk_widget_set_sensitive (entry_Recherche_Hostname, FALSE);
	gtk_widget_set_sensitive (combobox_Recherche_Port, FALSE);
}


void on_radiobutton_Recherche_Hostname_clicked (GtkButton * button, gpointer user_data)
{	
	DEBUG_ACTION_USER();
	gtk_widget_set_sensitive (entry_Recherche_Mac, FALSE);
	gtk_widget_set_sensitive (entry_Recherche_Ip, FALSE);
	gtk_widget_set_sensitive (entry_Recherche_Hostname, TRUE);
	gtk_widget_set_sensitive (combobox_Recherche_Port, FALSE);
}


void on_radiobutton_Recherche_Port_clicked (GtkButton * button, gpointer user_data)
{	
	DEBUG_ACTION_USER();
	gtk_widget_set_sensitive (entry_Recherche_Mac, FALSE);
	gtk_widget_set_sensitive (entry_Recherche_Ip, FALSE);
	gtk_widget_set_sensitive (entry_Recherche_Hostname, FALSE);
	gtk_widget_set_sensitive (combobox_Recherche_Port, TRUE);
}


void on_button_Recherche_Close_clicked (GtkButton * button, gpointer user_data)
{
	DEBUG_ACTION_USER();
	gtk_widget_hide (window_Recherche);
}


void on_button_Recherche_clicked (GtkButton * button, gpointer user_data)
{	
	gchar     *combo = NULL;
	
	DEBUG_ACTION_USER();
	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_Recherche_Ip)))
		Recherche_Par_Addresse_IP ((gchar *) gtk_entry_get_text (GTK_ENTRY (entry_Recherche_Ip)));
	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_Recherche_Mac)))
		Recherche_Par_Addresse_MAC ((gchar *) gtk_entry_get_text (GTK_ENTRY (entry_Recherche_Mac)));
	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_Recherche_Hostname)))
		Recherche_Par_HostName ((gchar *) gtk_entry_get_text (GTK_ENTRY (entry_Recherche_Hostname)));	
	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_Recherche_Port))){
		combo = Recuperation_Texte_Combo (combobox_Recherche_Port);
		Recherche_Par_Port (Num_Du_Port(combo));
		MYFREE (combo);
	}
}
