#include <gtk/gtk.h>
#ifdef G_OS_WIN32
# include <glib/gwin32.h>
#endif
/*
#if HAVE_PATHS_H
# include <paths.h>
#endif

#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
*/
#undef GTK_DISABLE_DEPRECATED
#define GTK_STYLE_PROVIDER_PRIORITY_FORCE G_MAXUINT
#define GDK_PIXBUF_ENABLE_BACKEND
#define GTK_ENABLE_BROKEN
#define GDK_DISABLE_DEPRECATION_WARNINGS

#ifdef G_OS_WIN32
#define APP_EXTENSION ".exe"
#else
#define APP_EXTENSION
#endif

#ifdef G_OS_WIN32
#include <windows.h>
#include <pbt.h>
#include <fcntl.h>
#include <conio.h>
#endif
/*
#ifdef G_OS_WIN32
static gboolean init_console_done = FALSE;
#endif
*/
#define COMMAND_HISTORY		"command_history"

#if defined(G_OS_WIN32) || defined(__APPLE__)
#  define RC_DIR		".arabtex-0.0.1a"
#else
#  define RC_DIR		".arabtex-0.0.1a"
#endif
//#include "version.h"
//http://stuff.mit.edu/afs/athena/astaff/source/src-9.2/third/gtk2/gtk/gtkprogressbar.c
//#define BUFFSIZE	        8192
#define BUFFSIZE                   1024
#define PREFSBUFSIZE	           1024
#define DEFAULT_MESSAGE_FONT	   "Sans 12"
#define MIN_HORIZONTAL_BAR_WIDTH   150
#define MIN_HORIZONTAL_BAR_HEIGHT  20
#define MIN_VERTICAL_BAR_WIDTH     22
#define MIN_VERTICAL_BAR_HEIGHT    80
#define MAX_ENTRY_LENGTH	       8191
#define MAX_HISTORY_SIZE		   16
#define MAX_TEXT_LENGTH            80
#define TEXT_SPACING               2
/**.........................................................................*/
#define ARABTEX_NAME  "arabTeX"
#define ARABTEX_VERS  "0.0.1a"
#define CLEAN         "*.log  log.pdf  *.aux  *.out  *.dvi    assistant.png   *.toc  *.err   *.fls  *.fdb*  *synctex.gz  *.fdb_latexmk  *.blg   *.bbl  *.lg *.odt    *.idv   *.4tc    *.4ct  *.tmp  *.mp  *.xref"
#define COMMON_RC	  "arabtexrc"
#define COPY	      "  meRead.txt     settings/meRead.txt"
#define COPYRIGHT	  "© arabTeX : 2007-2014.\n»» sèlim,b.  سَلِــبم   ُبو راس  ««" /*»» */
#define COPYRIGHT2    "© arabTeX:2007-2014 / »» sèlim,b.  سَلِــبم   ُبو راس  ««" /*»» */
#define CUSTOM	      "settings/arabTeX.log"
#define FILE_NAME     "pixmaps/emblem-shared.png"
#define FILENAME4	  "selim3.txt"
#define FNAME         "*.log"
#define FNAME2        "meRead.txt"
#define FOLDER_NAME   "pixmaps/folder-documents.png"
#define FORUM         "s.bouras.free.fr/forum/"
#define HEART         "'♥''♥'♥"
#define HEART2        "»»»  I "HEART".. A.r.a.b.T.e.X    ...    محرر تخ  «««"
#define HOMEPAGE_URI  "s.bouras.free.fr/arabtex"
#define LAUNCH        "s.bouras.free.fr/arabtex/"
#define LIONTEX       "./pixmaps/lion.png"
#define LOG		      "a.log"
#define LOG2		  "settings/arabTeX.log"
#define LOG3		  "settings/arabTeX.log"
#define MAIL		  " »» s.bouras@free.fr ««  "
#define MEREAD		  "meRead.txt"
#define MEREAD2		  "settings/arabTeX.log"
#define SELIMB        "./pixmaps/selim2.xpm"
#define SELIMB2       "./pixmaps/selim2.png"
#define TEST		  "settings/sassia.txt"
#define THELOGFILE    "                                         »».....................................    THE LOG FILE    .....................................««\n"
#define THELOGFILEEND "»».....................................    THE LOG FILE END   ..................................««\n"
#define VERSION	      ARABTEX_NAME " - Version " ARABTEX_VERS
//#define VERSION		        "0.0.1a"
/**---------------------------------------  MATH  LaTeX -------------------------------------------------------**/
/**............................... LaTeX CMD...................................*/
#define ASSIST		            " *.tex"
#define DEFAULT_FILE            " assistant.tex"
#define DVI_TO_PS               " arab.ps arab.dvi "
#define DVI_VIEW      		    " *.dvi"
#define FILE_TO_COMPILE         " *.tex"
#define LATEX_FILE              " arab.tex"
#define LOG_STATUS_VIEW_PDF     " log.pdf"
#define LOG_VIEW                LOG   //" arabTeX.log."
#define LOG_VIEW_CMD	        " "
#define PDF_VIEW      		    " arab.pdf"
#define PNG_VIEW                " *1.png"
#define PS_TO_PDF               " arab.pdf"
#define PS_VIEW      		    " arab.ps"
 /**..................................... BEGIN WINDOWZ......................**/
#define GO_UP                   "pixmaps/edit-redo-rtl.png"
#define MPOST_CMD	            "O:/TeX/WIN/myMiKTEX/miktex/bin/mpost --interaction nonstopmode %s"
#define LATEX_CMD               "O:/TeX/WIN/myMiKTEX//miktex/bin/latex.exe  -synctex=1 -interaction=nonstopmode "
//#define LATEX_CMD             "latex -interaction=nonstopmode test.tex|bibtex test.aux|latex -interaction=nonstopmode test.tex ; xdvi test.dvi"
#define XELATEX_CMD             "O:/TeX/WIN/myMiKTEX/miktex/bin/xelatex.exe -synctex=1 -interaction=nonstopmode arab.tex  " //\"LATEX\"
#define DVI2PS_CMD	            "O:/TeX/WIN/myMiKTEX/miktex/bin/dvips -Pdownload35    -o "
//#define DVI2PS_CMD	        "dvips -o assistant.ps assistant.dvi
#define PS2PDF_CMD	            "O:/TeX/WIN/myMiKTEX/miktex/bin/ps2pdf assistant.ps "
#define DVI2PDF_CMD	            "O:/TeX/WIN/myMiKTEX/miktex/bin/dvipdfm assistant.dvi"
//#define DVI2PDF_CMD	        "C:/Users/selimb/Desktop/TeX/myMiKTEX/miktex/bin/dvipdfmx -D assistant assistant.dvi"
#define DVI2PNG_CMD	            "O:/TeX/WIN/myMiKTEX/miktex/bin/dvipng  -T tight -D 120  "
#define PDF_LATEX_CMD	        "O:/TeX/WIN/myMiKTEX/miktex/bin/pdflatex -synctex=1 -interaction=nonstopmode "
//............................... VIEW CMD...................................
#define DVI_VIEW_CMD	        "O:/TeX/WIN/myMiKTEX/miktex/bin/yap.exe "
#define PS_VIEW_CMD	            "O:/TeX/WIN/Evince-2.32.0.145/bin/evince.exe " //"H:/TeX/WIN/TeX/gs9.10/bin/gswin32c.exe"
#define GHOST_CMD	            "O:/TeX/WINX/Ghostgum/gsview/gsview32.exe"
//#define PS_VIEW_CMD	        "gv %s ghostscript  %s"
#define PDF_VIEW_CMD	        "O:/TeX/WIN/Evince-2.32.0.145/bin/evince.exe "
#define PNG_VIEW_CMD	        "sh -x $(which xdg-open) "
                   //#define CUSTOM_CMD           	    "mkdir  settings" //guiTeX/guiTeX.log   guiTeX/custom.log   guiTeX/meRead.txt
                  ////"`tempfile 2>/dev/null` || tempfile=$HOME/.config/guiTeX/custom.log$$"
#define CUSTOM_CMD       	    "mkdir  settings && break && COPY assistant.log > settings/custom.log"
                                //  "`tempfile 2>/dev/null` || tempfile=settings/custom.log$$"
//tempfile=$HOME/.config/guiTeX/custom.log$$"
#define SETTINGS                "  settings /s /q  "
#define RMDIR_CMD               "DEL  "
#define CLEAN_CMD               "DEL  "
           //"DEL  $TMP"
           //#define CHMOD_CMD   "chmod 0744  ./settings"
           //#define CLEAN_CMD   "DEL  "  //   "DEL  %s"

#define COPY_CMD	            "COPY  "
//#define CHMOD_CMD             "chmod 0744  ./settings"
#define DEFAULT_BROWSER_CMD	    "O:/PERSO/FOX/firefox.exe   "
#define LAUNCH_CMD         	    "O:/PERSO/FOX/firefox.exe   "
#define TERM_CMD                "cmd "
#define SHOW_LOG3_CMD           "cmd "    //"while read line; do echo -e $line ; done < assistant.log "
#define SHOW_TERM_CMD           "cmd "    //"while read line; do echo -e $line ; done < assistant.log "
#define HTML_CMD       	        "O:/TeX/WIN/myMiKTEX/miktex/bin/htlatex  %s"
/** .....................................END   WINDOWZ......................*/
/**..................................... BEGIN NUX......................
#define GO_UP                       "/usr/share/icons/gnome/24x24/actions/edit-redo-rtl.png"
#define MPOST_CMD	                "mpost --interaction nonstopmode "
#define LATEX_CMD                   "latex -synctex=1 -interaction=nonstopmode   ''"
#define SELIM_CMD                   "latex -synctex=1 -interaction=nonstopmode   "
//#define LATEX_CMD                 "latex -interaction=nonstopmode test.tex|bibtex test.aux|latex -interaction=nonstopmode test.tex ; xdvi test.dvi"
#define XELATEX_CMD                 "xelatex -synctex=1 -interaction=nonstopmode %s  " //\"LATEX\"
#define DVI2PS_CMD	                "dvips -o  *.ps  *.dvi "
//#define DVI2PS_CMD	            "dvips -Pdownload35    -o assistant.ps  assistant.dvi "
//#define DVI2PS_CMD	            "dvips -Ppdf -t   a4  assistant.dvi"
//#define DVI2PS_CMD	            "dvips -o assistant.ps assistant.dvi "
#define PS2PDF_CMD	                "ps2pdf   *.ps "
#define DVI2PDF_CMD	                "dvipdfm  *.dvi"
//#define DVI2PDF_CMD	            "dvipdfmx -D assistant assistant.dvi"
#define DVI2PNG_CMD	                "dvipng  -T tight -D 120  "
//#define PDF_LATEX_CMD	            "pdflatex -synctex=1 -interaction=nonstopmode "
#define PDF_LATEX_CMD	            "pdflatex   -shell-escape -src  -synctex=1 -interaction=nonstopmode"
#define HTML_CMD       	            "htlatex  arab.tex"
//............................... VIEW CMD...................................
#define DVI_VIEW_CMD	            "sh -x $(which xdg-open)  "
#define PS_VIEW_CMD	                "sh -x $(which xdg-open)  "
//#define PS_VIEW_CMD	            "gv %s ghostscript  %s"
#define PDF_VIEW_CMD	            "sh -x $(which xdg-open)  "
#define PNG_VIEW_CMD	            "sh -x $(which xdg-open)  "
#define LOG_VIEW_CMD	            "sh -x $(which xdg-open)  "
//..........................COMMANDES NUX .......................
#define CUSTOM_CMD       	        "mkdir -p settings && touch settings/custom.log"  //"`tempfile 2>/dev/null` || tempfile=$HOME/.config/guiTeX/custom.log$$"
#define CUSTOM2_CMD                 "rm -fr  $TMP"
#define CHMOD_CMD                   "chmod 0744  ./settings"
//#define CLEAN_CMD                 system("rm -rf %s ")
#define COPY_CMD	                "cp  "
#define CLEAN_CMD                   "rm -rf  "
#define SETTINGS                    "  settings/"
#define RMDIR_CMD                   "rm -rf  "
#ifdef __APPLE__
# define DEFAULT_BROWSER_CMD	"open '%s'"
#else
# define DEFAULT_BROWSER_CMD	"sh -x $(which xdg-open)  '%s'"
#endif
#define LAUNCH_CMD              "exo-open --launch WebBrowser     "
//#define LAUNCH_CMD              "sh -x $(which xdg-open)  "
//#define LAUNCH_CMD      	    "xdg-open  '%s'"
//#define DEFAULT_BROWSER_CMD	"xdg-open  '%s'"
//#define DEFAULT_BROWSER_CMD	"exo-open --launch WebBrowser
#define THUNAR_CMD	            "sh -x $(which xdg-open)  '.'"
//#define TERMINAL_CMD	        "./textviewer.sh  'assistant.log' "   //<---------------   super !!
#define TERM_CMD	            "exo-open --launch TerminalEmulator && ./textviewer.sh  '*.log'"
#define SHOW_TERM_CMD           "while read line; do echo -e $line ; done <  *.log && exo-open --launch TerminalEmulator"
//#define SED_CMD       	    " sed 's/\/opt\/omni\/lbin/\/opt\/tools\/bin/g' "
------------------------------------ CMD ------------------*/
//#define TERMINAL_CMD	        "sh -x $(which xdg-open)  ./textviewer.sh   assistant.log "
//#define TERMINAL_CMD	        "exo-open --launch TerminalEmulator "
/*#define TERMINAL_CMD	        "/home/xfce/com radio"*/
#define DIRNAME_CMD             "pwd . %s" /*	"dirname stdio.h  %s  " */
#define DIRNAME2_CMD            "echo  `pwd %s`  > selim"
#define DIR2                    "selim"
/*#define FILEBRIEF_CMD       	"file --brief %s  -> file.log"*/
#define FILEBRIEF_CMD       	"file --brief %s"
/*#define FILEBRIEF_CMD       	"echo \"`./textviewer.sh %s`\" > file.log" */
/*-----------------------------  END   *_CMD ------------------*/
/**--------------------------------------- ALL ---------------------------------------**/
/*..................... COLOR Shell .......................*/
#define RED                     "'\e[0;31m'"
/*.........................................................*/
#define CAT_CMD           "cat `\"(gtk_entry_get_text(GTK_ENTRY (entry)))\" `> " CUSTOM
//#define ENTRY1_CMD	  gtk_entry_get_text(entry1) ................failed
#define ENTRY_CMD	      "echo  ` \"(gtk_entry_get_text(GTK_ENTRY (entry)))\" `  > " CUSTOM
/*"%d.pdf"
* fopen (docs.actif->chemin, "w");
* fprintf (fichier, "%s", locale);*/
/* g_strdup_printf ("%s.pdf *", g_path_get_basename (docs.actif->chemin))*/
#define DIRNAME                	"."
#define HTML		         g_strdup_printf ("%s ", g_path_get_basename (docs.actif->chemin))
#define FILEBRIEF		     g_strdup_printf ("%s ", g_path_get_basename (docs.actif->chemin))
//#define THUNAR     		"."   // <-----  inutile voir "#define THUNAR_CMD"   ligne 150.1" ici "defs.h"
/*#define TERMINAL      	"$HOME/my_radios"      */
//#define TERMINAL      	g_strdup_printf ("%s ", g_path_get_basename (docs.actif->chemin))
//#define TERMINAL              "echo -n  `cat    assistant.log` "
/* g_strdup_printf ("%s ", g_path_get_basename (docs.actif->chemin))*/
/*#ifdef G_OS_WIN32
#  define REMOTE_CMD_PORT	50215
#endif */
/**-------------------------------------END   ALL ---------------------------------------**/
/** ..................................... END  NUX......................*/
/**------------------------------------  END MATH LaTeX ---------------------------------------**/
/*.....................................  CUSTOM DEFS voir configure.c    ................................................*/
/*  char *home  = getenv("HOME");
    char *lang  = getenv("LANG");
    char *shell = getenv("SHELL");
*/
 /* docs.dir_name = g_strdup (g_get_home_dir ());*/
/*  docs.dir_name = g_strdup (g_get_current_dir ());*/
//#define LOG2_CMD       	 "`touch settings/.guiTeX.log`"  //mkdir -p $HOME/.config/guiTeX &&  <----- debut de main.c
//#define LOG3_CMD       	 "TMP=`mktemp settings/.guiTeX.log.XXXXXXX` || exit 1;"
//#define CUSTOM_CMD       	"mkdir -p \"homedir\"/.config/guiTeX && touch \"homedir\"/.config/guiTeX/custom.log"
//#define CUSTOM	                "\"homedir\"/guiTeX/.config/custom.log"
//#define CUSTOM_DEL_CMD        "rm -rf /home/selimb/.config/guiTeX/.custom.log" ......... remplace par CLEAN_CMD
//#define CUSTOM_CMD           	"mkdir  settings" //guiTeX/guiTeX.log   guiTeX/custom.log   guiTeX/meRead.txt   //"`tempfile 2>/dev/null` || tempfile=$HOME/.config/guiTeX/custom.log$$"
/*.................................... FIN CUSTOM DEFS .......................................*/

