/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * main.c
 * Copyright (C) Administrator 2010 <administrator@>
 * 
 * GRAFFITI 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 3 of the License, or
 * (at your option) any later version.
 * 
 * GRAFFITI 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>

#include <config.h>

#include <gtk/gtk.h>
#include <gdk/gdk.h>



/*
 * Standard gettext macros.
 */
#ifdef ENABLE_NLS
#  include <libintl.h>
#  undef _
#  define _(String) dgettext (PACKAGE, String)
#  ifdef gettext_noop
#    define N_(String) gettext_noop (String)
#  else
#    define N_(String) (String)
#  endif
#else
#  define textdomain(String) (String)
#  define gettext(String) (String)
#  define dgettext(Domain,Message) (Message)
#  define dcgettext(Domain,Message,Type) (Message)
#  define bindtextdomain(Domain,Directory) (Domain)
#  define _(String) (String)
#  define N_(String) (String)
#endif



#include "callbacks.h"

/* For testing propose use the local (not installed) ui file */
/* #define UI_FILE PACKAGE_DATA_DIR"/graffiti/ui/graffiti.ui" */
#define UI_FILE "graffiti.ui"


//GtkWidget *window;


GtkWidget* create_window (void)
{
	
	GtkBuilder *builder;
	GError* error = NULL;

	builder = gtk_builder_new ();
	if (!gtk_builder_add_from_file (builder, UI_FILE, &error))
	{
		g_warning ("Couldn't load builder file: %s", error->message);
		g_error_free (error);
	}

	/* This is important */
	gtk_builder_connect_signals (builder, NULL);
	window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));

	label_x = (GtkLabel *)GTK_WIDGET (gtk_builder_get_object (builder,"texto"));
	label_Xmax = (GtkLabel *)GTK_WIDGET (gtk_builder_get_object (builder,"label_Xmax"));
	label_Ymax = (GtkLabel *)GTK_WIDGET (gtk_builder_get_object (builder,"label_Ymax"));
	label_Xmin = (GtkLabel *)GTK_WIDGET (gtk_builder_get_object (builder,"label_Xmin"));
	label_Ymin = (GtkLabel *)GTK_WIDGET (gtk_builder_get_object (builder,"label_Ymin"));
	label_Xreal = (GtkLabel *)GTK_WIDGET (gtk_builder_get_object (builder,"label_Xreal"));
	label_Yreal = (GtkLabel *)GTK_WIDGET (gtk_builder_get_object (builder,"label_Yreal"));
	label_Xdiagonal = (GtkLabel *)GTK_WIDGET (gtk_builder_get_object (builder,"label_Xdiagonal"));
	label_Ydiagonal = (GtkLabel *)GTK_WIDGET (gtk_builder_get_object (builder,"label_Ydiagonal"));
	label_S1 = (GtkLabel *)GTK_WIDGET (gtk_builder_get_object (builder,"label_S1"));
	label_S2 = (GtkLabel *)GTK_WIDGET (gtk_builder_get_object (builder,"label_S2"));
	label_zoom_X = (GtkLabel *)GTK_WIDGET (gtk_builder_get_object (builder,"valor_zoom_X"));
	label_zoom_Y = (GtkLabel *)GTK_WIDGET (gtk_builder_get_object (builder,"valor_zoom_Y"));
	label_seleccionada = (GtkLabel *)GTK_WIDGET (gtk_builder_get_object (builder,"label_seleccionada"));
	color_S1=(GtkColorButton *)GTK_WIDGET (gtk_builder_get_object (builder,"colorbutton1"));
	color_S2=(GtkColorButton *)GTK_WIDGET (gtk_builder_get_object (builder,"colorbutton2"));
	color_S3=(GtkColorButton *)GTK_WIDGET (gtk_builder_get_object (builder,"colorbutton3"));
	color_S4=(GtkColorButton *)GTK_WIDGET (gtk_builder_get_object (builder,"colorbutton4"));
	draw_area = (GtkDrawingArea *)GTK_WIDGET (gtk_builder_get_object (builder,"drawingarea1"));

	g_object_unref (builder);
	
	return window;
}


int main (int argc, char *argv[])
{
 	//GtkWidget *window;


#ifdef ENABLE_NLS
	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
#endif

	
	gtk_set_locale ();
	gtk_init (&argc, &argv);

	window = create_window ();
	gtk_widget_show (window);
	
	//funcion que lee los datos de la linea de comandos.
	read_standar(argc,argv);	
	
	gtk_main ();
	
	return 0;
}
