/*************************************************************************************************************
* This file contains dialogs creation and showing functions
* 2012/10 by Dlxko
* Version 4.0
**************************************************************************************************************/
#include "Dialogs.h"

// Local static variables
static GtkWidget *dialog_window;

// Function to show error and exit client
void function_show_error(char input_message[DIALOG_BUFFER_SIZE])
{
	GtkWidget *dialog_widget;
	dialog_widget = gtk_message_dialog_new(GTK_WINDOW(dialog_window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, input_message);
	gtk_window_set_title(GTK_WINDOW(dialog_widget), LANG_ERROR_WINDOW_TITLE);
	gtk_dialog_run(GTK_DIALOG(dialog_widget));
	gtk_widget_destroy(dialog_widget);
	function_exit_client(1);
}

// Function to show warning message
void function_show_warning(char input_message[DIALOG_BUFFER_SIZE])
{
	GtkWidget *dialog_widget;
	dialog_widget = gtk_message_dialog_new(GTK_WINDOW(dialog_window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, input_message);
	gtk_window_set_title(GTK_WINDOW(dialog_widget), LANG_WARNING_WINDOW_TITLE);
	gtk_dialog_run(GTK_DIALOG(dialog_widget));
	gtk_widget_destroy(dialog_widget);
}

// Function to show warning message
void function_show_warning_ftp(char input_message[DIALOG_BUFFER_SIZE], int fx_type)
{
	GtkWidget *dialog_widget;
	dialog_widget = gtk_message_dialog_new(GTK_WINDOW(dialog_window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, input_message);
	gtk_window_set_title(GTK_WINDOW(dialog_widget), LANG_WARNING_WINDOW_TITLE);
	gtk_dialog_run(GTK_DIALOG(dialog_widget));
	gtk_widget_destroy(dialog_widget);
	if (fx_type == 1)
		active_ftp_upload = false;
	else if (fx_type == 2)
		active_ftp_download = false;
}

// Function to create dialog window
void create_dialog_window()
{
	dialog_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_size_request (GTK_WIDGET (dialog_window), 300, 80);
	gtk_window_set_title (GTK_WINDOW (dialog_window), LANG_DIALOG_WINDOW_NAME);
	gtk_window_set_icon(GTK_WINDOW(dialog_window), default_icon);
}