/*
This source file is part of Scol
For the latest info, see http://www.scolring.org

Copyright (c) 2010 Stephane Bisaro, aka Iri <iri@irizone.net>

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.

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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser 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, or go to
http://www.gnu.org/copyleft/lesser.txt

For others informations, please contact us from http://www.scolring.org/
*/

#ifdef __cplusplus
#error This source file is not C++ but rather C. Please use a C-compiler
#endif



#include "../include/scol_gtk_main.h"


#if ((defined _WIN32) || (defined __WIN32__))
cbmachine ww;
#endif
mmachine  mm;

Scol2dGtkError ScolSerror;








int SCOLinitGtkClass (mmachine m)
{
    int k;

    MMechostr (MSKDEBUG, "SCOLinitGtkClass: loading\n");

    k = SCOLinit2dGTKclass (m);

    return k;
}


int Scolrelease ()
{
    int i, r;

    g_message ("library closing ...");

    g_log_remove_handler (NULL, ScolSerror->hLogApp);
    g_log_remove_handler ("GLib", ScolSerror->hLogGlib);
    g_log_remove_handler ("Gtk", ScolSerror->hLogGtk);

    /* stop all nested gtk loop */
    r = gtk_main_level ();
    for (i = 0; i < r; i++)
        gtk_main_quit ();

    /*#ifdef SCOL_GTK_DEBUG*/
    if (ScolSerror->pFileLog != NULL)
    {
        fclose (ScolSerror->pFileLog);
        ScolSerror->pFileLog = NULL;
    }
    /*#endif*/
    free (ScolSerror);

    MMechostr (0, "\nGTK+ library released !\n");
    return 0;
}


/*
    Fonctions de chargement / déchargement de la librairie / bibliothèque
    - Version MS Windows
    - Version GNU / Linux
    - Version Apple MacOS X : à faire ... :)
*/

// Do we need to export functions?
#if ((defined _WIN32) || (defined __WIN32__))
# define SCOL_GTK_PLUGIN_EXPORTS __declspec (dllexport)
#elif ((defined linux) || (defined __linux))
# define SCOL_GTK_PLUGIN_EXPORTS
#else
# error no platform supported
#endif

/*
Fonction de chargement de la librairie
*/
SCOL_GTK_PLUGIN_EXPORTS int ScolLoadPlugin (mmachine m)
{
    mm = m;
    return SCOLinitGtkClass(m);
}

/*
Fonction de déchargement de la librairie
*/
SCOL_GTK_PLUGIN_EXPORTS int ScolUnloadPlugin()
{
    Scolrelease ();
    return 0;
}

