void cairo_dock_replace_keys_by_identifier (const gchar *cConfFilePath, gchar *cReplacementConfFilePath, gchar iIdentifier)
{
	GKeyFile *pReplacementKeyFile = cairo_dock_open_key_file (cReplacementConfFilePath);
	if (pReplacementKeyFile == NULL)
		return ;
	
	g_print ("%s (%s <- %s, '%c')\n", __func__, cConfFilePath, cReplacementConfFilePath, iIdentifier);
	cairo_dock_replace_values_in_conf_file (cConfFilePath, pReplacementKeyFile, TRUE, iIdentifier);

	g_key_file_free (pReplacementKeyFile);
}
void cairo_dock_replace_values_in_conf_file (const gchar *cConfFilePath, GKeyFile *pValidKeyFile, gboolean bUseFileKeys, gchar iIdentifier)
{
	GKeyFile *pConfKeyFile = cairo_dock_open_key_file (cConfFilePath);
	if (pConfKeyFile == NULL)
		return ;

	g_print ("%s (%s)\n", __func__,cConfFilePath );
	cairo_dock_replace_key_values (pConfKeyFile, pValidKeyFile, bUseFileKeys, iIdentifier);

	cairo_dock_write_keys_to_file (pConfKeyFile, cConfFilePath);

	g_key_file_free (pConfKeyFile);
}
static gchar *_cairo_dock_generate_desktop_file_for_file (const gchar *cURI, const gchar *cDockName, double fOrder, GError **erreur)
{
	//\___________________ On recupere le type mime du fichier.
	gchar *cIconName = NULL, *cName = NULL, *cRealURI = NULL;
	gboolean bIsDirectory;
	int iVolumeID;
	double fUnusedOrder;
	if (! cairo_dock_fm_get_file_info (cURI, &cName, &cRealURI, &cIconName, &bIsDirectory, &iVolumeID, &fUnusedOrder, mySystem.iFileSortType) || cIconName == NULL)
		return NULL;
	cd_message (" -> cIconName : %s; bIsDirectory : %d; iVolumeID : %d\n", cIconName, bIsDirectory, iVolumeID);

	if (bIsDirectory)
	{
		int answer = cairo_dock_ask_general_question_and_wait (_("Do you want to monitor the content of the directory ?"));
		if (answer != GTK_RESPONSE_YES)
			bIsDirectory = FALSE;
	}

	//\___________________ On ouvre le patron.
	gchar *cDesktopFileTemplate = cairo_dock_get_launcher_template_conf_file (bIsDirectory ? CAIRO_DOCK_LAUNCHER_FOR_CONTAINER : CAIRO_DOCK_LAUNCHER_FROM_DESKTOP_FILE);

	GKeyFile *pKeyFile = cairo_dock_open_key_file (cDesktopFileTemplate);
	g_free (cDesktopFileTemplate);
	if (pKeyFile == NULL)
		return NULL;

	//\___________________ On renseigne ce qu'on peut.
	g_key_file_set_double (pKeyFile, "Desktop Entry", "Order", fOrder);
	g_key_file_set_string (pKeyFile, "Desktop Entry", "Container", cDockName);
	g_key_file_set_string (pKeyFile, "Desktop Entry", "Base URI", cURI);

	g_key_file_set_string (pKeyFile, "Desktop Entry", "Name", cName);
	g_free (cName);
	g_key_file_set_string (pKeyFile, "Desktop Entry", "Exec", cRealURI);
	g_free (cRealURI);
	g_key_file_set_string (pKeyFile, "Desktop Entry", "Icon", (cIconName != NULL ? cIconName : ""));
	g_free (cIconName);

	g_key_file_set_boolean (pKeyFile, "Desktop Entry", "Is mounting point", (iVolumeID > 0));

	//\___________________ On lui choisit un nom de fichier tel qu'il n'y ait pas de collision.
	gchar *cNewDesktopFileName = cairo_dock_generate_desktop_filename ("file-launcher.desktop", g_cCurrentLaunchersPath);

	//\___________________ On ecrit tout.
	gchar *cNewDesktopFilePath = g_strdup_printf ("%s/%s", g_cCurrentLaunchersPath, cNewDesktopFileName);
	cairo_dock_write_keys_to_file (pKeyFile, cNewDesktopFilePath);
	g_free (cNewDesktopFilePath);
	g_key_file_free (pKeyFile);

	return cNewDesktopFileName;
}
void cairo_dock_add_remove_element_to_key (const gchar *cConfFilePath, const gchar *cGroupName, const gchar *cKeyName, gchar *cElementName, gboolean bAdd)
{
	GKeyFile *pKeyFile = cairo_dock_open_key_file (cConfFilePath);
	if (pKeyFile == NULL)
		return ;
	
	gchar *cElementList = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL), *cNewElementList = NULL;
	if (cElementList != NULL && *cElementList == '\0')
	{
		g_free (cElementList);
		cElementList= NULL;
	}
	
	if (bAdd)
	{
		//g_print ("on rajoute %s\n", cElementName);
		if (cElementList != NULL)
			cNewElementList = g_strdup_printf ("%s;%s", cElementList, cElementName);
		else
			cNewElementList = g_strdup (cElementName);
	}
	else
	{
		//g_print ("on enleve %s\n", cElementName);
		gchar *str = g_strstr_len (cElementList, strlen (cElementList), cElementName);
		g_return_if_fail (str != NULL);
		if (str == cElementList)
		{
			if (str[strlen (cElementName)] == '\0')
				cNewElementList = g_strdup ("");
			else
				cNewElementList = g_strdup (str + strlen (cElementName) + 1);
		}
		else
		{
			*(str-1) = '\0';
			if (str[strlen (cElementName)] == '\0')
				cNewElementList = g_strdup (cElementList);
			else
				cNewElementList = g_strdup_printf ("%s;%s", cElementList, str + strlen (cElementName) + 1);
		}
	}
	g_key_file_set_string (pKeyFile, cGroupName, cKeyName, cNewElementList);
	cairo_dock_write_keys_to_file (pKeyFile, cConfFilePath);
	g_free (cElementList);
	g_free (cNewElementList);
	g_key_file_free (pKeyFile);
}
gchar *gldi_stack_icon_add_conf_file (const gchar *cDockName, double fOrder)
{
	//\__________________ open the template.
	const gchar *cTemplateFile = GLDI_SHARE_DATA_DIR"/"CAIRO_DOCK_CONTAINER_CONF_FILE;	
	GKeyFile *pKeyFile = cairo_dock_open_key_file (cTemplateFile);
	g_return_val_if_fail (pKeyFile != NULL, NULL);
	
	//\__________________ fill the parameters
	g_key_file_set_double (pKeyFile, "Desktop Entry", "Order", fOrder);
	g_key_file_set_string (pKeyFile, "Desktop Entry", "Container", cDockName);
	
	gchar *cNewDesktopFileName = cairo_dock_generate_unique_filename ("container.desktop", g_cCurrentLaunchersPath);
	
	//\__________________ write the keys.
	gchar *cNewDesktopFilePath = g_strdup_printf ("%s/%s", g_cCurrentLaunchersPath, cNewDesktopFileName);
	cairo_dock_write_keys_to_conf_file (pKeyFile, cNewDesktopFilePath);
	g_free (cNewDesktopFilePath);
	g_key_file_free (pKeyFile);
	return cNewDesktopFileName;
}
void cairo_dock_update_launcher_desktop_file (gchar *cDesktopFilePath, CairoDockNewLauncherType iLauncherType)
{
	GError *erreur = NULL;
	GKeyFile *pKeyFile = cairo_dock_open_key_file (cDesktopFilePath);
	if (pKeyFile == NULL)
		return ;

	if (cairo_dock_conf_file_needs_update (pKeyFile, CAIRO_DOCK_VERSION))
	{
		cairo_dock_flush_conf_file_full (pKeyFile,
			cDesktopFilePath,
			CAIRO_DOCK_SHARE_DATA_DIR,
			FALSE,
			(iLauncherType == CAIRO_DOCK_LAUNCHER_FOR_CONTAINER ?
				CAIRO_DOCK_CONTAINER_CONF_FILE :
				(iLauncherType == CAIRO_DOCK_LAUNCHER_FOR_SEPARATOR ?
					CAIRO_DOCK_SEPARATOR_CONF_FILE :
					CAIRO_DOCK_LAUNCHER_CONF_FILE)));
	}
	
	g_key_file_free (pKeyFile);
}
void on_click_normal_apply (GtkButton *button, GtkWidget *pWindow)
{
	//g_print ("%s ()\n", __func__);
	GSList *pWidgetList = g_object_get_data (G_OBJECT (pWindow), "widget-list");
	gchar *cConfFilePath = g_object_get_data (G_OBJECT (pWindow), "conf-file");
	GKeyFile *pKeyFile = cairo_dock_open_key_file (cConfFilePath);
	g_return_if_fail (pKeyFile != NULL);
	
	cairo_dock_update_keyfile_from_widget_list (pKeyFile, pWidgetList);
	cairo_dock_write_keys_to_file (pKeyFile, cConfFilePath);
	g_key_file_free (pKeyFile);
	
	CairoDockApplyConfigFunc pAction = g_object_get_data (G_OBJECT (pWindow), "action");
	gpointer pUserData = g_object_get_data (G_OBJECT (pWindow), "action-data");
	
	if (pAction != NULL)
	{
		gboolean bKeepWindow = pAction (pUserData);
		if (!bKeepWindow)
			on_click_normal_quit (button, pWindow);
	}
	else
		g_object_set_data (G_OBJECT (pWindow), "result", GINT_TO_POINTER (1));
}
static gchar *_cairo_dock_generate_desktop_file_for_edition (CairoDockNewLauncherType iNewLauncherType, const gchar *cDockName, double fOrder, GError **erreur)
{
	//\___________________ On ouvre le patron.
	gchar *cDesktopFileTemplate = cairo_dock_get_launcher_template_conf_file (iNewLauncherType);

	GKeyFile *pKeyFile = cairo_dock_open_key_file (cDesktopFileTemplate);
	g_free (cDesktopFileTemplate);
	if (pKeyFile == NULL)
		return NULL;

	//\___________________ On renseigne ce qu'on peut.
	g_key_file_set_double (pKeyFile, "Desktop Entry", "Order", fOrder);
	g_key_file_set_string (pKeyFile, "Desktop Entry", "Container", cDockName);

	//\___________________ On lui choisit un nom de fichier tel qu'il n'y ait pas de collision, et qu'il soit comprehensible par l'utilisateur, au cas ou il voudrait les modifier a la main.
	gchar *cNewDesktopFileName = cairo_dock_generate_desktop_filename (iNewLauncherType == CAIRO_DOCK_LAUNCHER_FOR_CONTAINER ? "container.desktop" : iNewLauncherType == CAIRO_DOCK_LAUNCHER_FOR_SEPARATOR ? "separator.desktop" : "launcher.desktop", g_cCurrentLaunchersPath);

	//\___________________ On ecrit tout.
	gchar *cNewDesktopFilePath = g_strdup_printf ("%s/%s", g_cCurrentLaunchersPath, cNewDesktopFileName);
	cairo_dock_write_keys_to_file (pKeyFile, cNewDesktopFilePath);
	g_free (cNewDesktopFilePath);
	g_key_file_free (pKeyFile);
	return cNewDesktopFileName;
}
void cairo_dock_apply_filter_on_group_list (gchar **pKeyWords, gboolean bAllWords, gboolean bSearchInToolTip, gboolean bHighLightText, gboolean bHideOther, GList *pGroupDescriptionList)
{
    //g_print ("%s ()\n", __func__);
    if (sBuffer == NULL)
        sBuffer = g_string_new ("");
    CairoDockGroupDescription *pGroupDescription, *pInternalGroupDescription;
    gchar *cKeyWord, *str = NULL, *cModifiedText = NULL, *cDescription, *cToolTip = NULL;
    gboolean bFound, bFrameVisible;
    GtkWidget *pGroupBox, *pLabel, *pCategoryFrame, *pCurrentCategoryFrame = NULL;
    GKeyFile *pKeyFile;
    GKeyFile *pMainKeyFile = cairo_dock_open_key_file (g_cConfFile);

    int i;
    GList *gd;
    const gchar *cGettextDomain;
    for (gd = pGroupDescriptionList; gd != NULL; gd = gd->next)
    {
        pGroupDescription = gd->data;
        pGroupDescription->bMatchFilter = FALSE;
    }
    for (gd = pGroupDescriptionList; gd != NULL; gd = gd->next)
    {
        //g_print ("pGroupDescription:%x\n", gd->data);
        //\_______________ On recupere le group description.
        pGroupDescription = gd->data;

        if (pGroupDescription->cInternalModule)
        {
            g_print ("%s : bouton emprunte a %s\n", pGroupDescription->cGroupName, pGroupDescription->cInternalModule);
            pInternalGroupDescription = cairo_dock_find_module_description (pGroupDescription->cInternalModule);
            if (pInternalGroupDescription != NULL)
                pGroupBox = gtk_widget_get_parent (pInternalGroupDescription->pActivateButton);
            else
                continue;
            pLabel = pInternalGroupDescription->pLabel;
            g_print ("ok, found pGroupBox\n");
        }
        else
        {
            pGroupBox = gtk_widget_get_parent (pGroupDescription->pActivateButton);
            pLabel = pGroupDescription->pLabel;
        }
        //g_print ("  %x\n", pGroupDescription->pActivateButton);
        pCategoryFrame = gtk_widget_get_parent (pGroupBox);
        cGettextDomain = pGroupDescription->cGettextDomain;
        bFound = FALSE;

        cDescription = dgettext (cGettextDomain, pGroupDescription->cGroupName);
        if (bSearchInToolTip)
            cToolTip = dgettext (cGettextDomain, pGroupDescription->cDescription);
        //g_print ("cDescription : %s (%s)(%x,%x)\n", cDescription, cToolTip, cModifiedText, str);

        //\_______________ On change de frame.
        if (pCategoryFrame != pCurrentCategoryFrame)  // on a change de frame.
        {
            if (pCurrentCategoryFrame)
            {
                if (! bFrameVisible && bHideOther)
                {
                    //g_print (" on cache cette categorie\n");
                    gtk_widget_hide (pCurrentCategoryFrame);
                }
                else
                    gtk_widget_show (pCurrentCategoryFrame);
            }
            pCurrentCategoryFrame = pCategoryFrame;
            //g_print (" pCurrentCategoryFrame <- %x\n", pCurrentCategoryFrame);
        }

        //\_______________ On cherche chaque mot dans la description du module.
        for (i = 0; pKeyWords[i] != NULL; i ++)
        {
            cKeyWord = pKeyWords[i];
            _copy_string_to_buffer (cDescription);
            if (bHighLightText)
                cModifiedText = cairo_dock_highlight_key_word (cDescription, cKeyWord, TRUE);
            else
                str = _search_in_buffer (cKeyWord);
            if (cModifiedText == NULL && str == NULL)
            {
                if (cToolTip != NULL)
                {
                    _copy_string_to_buffer (cToolTip);
                    str = _search_in_buffer (cKeyWord);
                }
            }

            if (cModifiedText != NULL || str != NULL)
            {
                //g_print (">>> on a trouve direct %s\n", cKeyWord);
                bFound = TRUE;
                if (cModifiedText != NULL)
                {
                    gtk_label_set_use_markup (GTK_LABEL (pLabel), TRUE);
                    gtk_label_set_markup (GTK_LABEL (pLabel), cModifiedText);
                    g_free (cModifiedText);
                    cModifiedText = NULL;
                }
                else
                {
                    gtk_label_set_text (GTK_LABEL (pLabel), cDescription);
                    str = NULL;
                }
                if (! bAllWords)
                    break ;
            }
            else if (bAllWords)
            {
                bFound = FALSE;
                break ;
            }
        }

        //\_______________ On cherche chaque mot a l'interieur du module.
        if (! bFound && pGroupDescription->cOriginalConfFilePath != NULL)
        {
            //\_______________ On recupere les groupes du module.
            //g_print ("* on cherche dans le fichier de conf %s ...\n", pGroupDescription->cOriginalConfFilePath);
            gchar **pGroupList = NULL;
            CairoDockModule *pModule = cairo_dock_find_module_from_name (pGroupDescription->cGroupName);
            if (pModule != NULL)
            {
                pKeyFile = cairo_dock_open_key_file (pModule->cConfFilePath);
                if (pKeyFile != NULL)
                {
                    gsize length = 0;
                    pGroupList = g_key_file_get_groups (pKeyFile, &length);
                }
            }
            else  // groupe interne, le fichier de conf n'est ouvert qu'une seule fois.
            {
                pKeyFile = pMainKeyFile;
                pGroupList = g_new0 (gchar *, 2);
                pGroupList[0] = g_strdup (pGroupDescription->cGroupName);
            }

            //\_______________ Pour chaque groupe on parcourt toutes les cles.
            if (pGroupList != NULL)
            {
                int iNbWords;
                for (iNbWords = 0; pKeyWords[iNbWords] != NULL; iNbWords ++);
                gboolean *bFoundWords = g_new0 (gboolean , iNbWords);

                gchar *cUsefulComment;
                gchar iElementType;
                int iNbElements;
                gchar **pAuthorizedValuesList;
                gchar *cTipString;
                gboolean bIsAligned;
                gchar **pKeyList;
                gchar *cGroupName, *cKeyName, *cKeyComment;
                int j, k;
                for (k = 0; pGroupList[k] != NULL; k ++)
                {
                    cGroupName = pGroupList[k];
                    pKeyList = g_key_file_get_keys (pKeyFile, cGroupName, NULL, NULL);
                    for (j = 0; pKeyList[j] != NULL; j ++)
                    {
                        cKeyName = pKeyList[j];
                        //\_______________ On recupere la description + bulle d'aide de la cle.
                        cKeyComment =  g_key_file_get_comment (pKeyFile, cGroupName, cKeyName, NULL);
                        cUsefulComment = cairo_dock_parse_key_comment (cKeyComment, &iElementType, &iNbElements, &pAuthorizedValuesList, &bIsAligned, &cTipString);
                        if (cUsefulComment == NULL)
                        {
                            g_free (cKeyComment);
                            continue;
                        }

                        cUsefulComment = dgettext (cGettextDomain, cUsefulComment);
                        if (cTipString != NULL)
                        {
                            if (bSearchInToolTip)
                                cTipString = dgettext (cGettextDomain, cTipString);
                            else
                                cTipString = NULL;
                        }
                        //\_______________ On y cherche les mots-cles.
                        for (i = 0; pKeyWords[i] != NULL; i ++)
                        {
                            if (bFoundWords[i])
                                continue;
                            cKeyWord = pKeyWords[i];
                            str = NULL;
                            if (cUsefulComment)
                            {
                                _copy_string_to_buffer (cUsefulComment);
                                str = _search_in_buffer (cKeyWord);
                            }
                            if (! str && cTipString)
                            {
                                _copy_string_to_buffer (cTipString);
                                str = _search_in_buffer (cKeyWord);
                            }
                            if (! str && pAuthorizedValuesList)
                            {
                                int l;
                                for (l = 0; pAuthorizedValuesList[l] != NULL; l ++)
                                {
                                    _copy_string_to_buffer (dgettext (cGettextDomain, pAuthorizedValuesList[l]));
                                    str = _search_in_buffer (cKeyWord);
                                    if (str != NULL)
                                        break ;
                                }
                            }

                            if (str != NULL)
                            {
                                //g_print (">>>on a trouve %s\n", pKeyWords[i]);
                                bFound = TRUE;
                                str = NULL;
                                if (! bAllWords)
                                {
                                    break ;
                                }
                                bFoundWords[i] = TRUE;
                            }
                        }

                        g_free (cKeyComment);
                        if (! bAllWords && bFound)
                            break ;
                    }  // fin de parcours du groupe.
                    g_strfreev (pKeyList);
                    if (! bAllWords && bFound)
                        break ;
                }  // fin de parcours des groupes.
                g_strfreev (pGroupList);

                if (bAllWords && bFound)
                {
                    for (i = 0; i < iNbWords; i ++)
                    {
                        if (! bFoundWords[i])
                        {
                            //g_print ("par contre il manque %s, dommage\n", pKeyWords[i]);
                            bFound = FALSE;
                            break;
                        }
                    }
                }
                g_free (bFoundWords);
            }  // fin du cas ou on avait des groupes a etudier.
            if (pKeyFile != pMainKeyFile)
                g_key_file_free (pKeyFile);
            //g_print ("bFound : %d\n", bFound);

            if (bHighLightText && bFound)  // on passe le label du groupe en bleu + gras.
            {
                cModifiedText = g_strdup_printf ("<b><span color=\"blue\">%s</span></b>", cDescription);
                //g_print ("cModifiedText : %s\n", cModifiedText);
                gtk_label_set_markup (GTK_LABEL (pLabel), dgettext (cGettextDomain, cModifiedText));
                g_free (cModifiedText);
                cModifiedText = NULL;
            }
        }  // fin du cas ou on devait chercher dans le groupe.

        if (pGroupDescription->cInternalModule)
        {
            pInternalGroupDescription = cairo_dock_find_module_description (pGroupDescription->cInternalModule);
            if (pInternalGroupDescription != NULL)
            {
                pInternalGroupDescription->bMatchFilter |= bFound;
                bFound = pInternalGroupDescription->bMatchFilter;
            }
        }
        else
        {
            pGroupDescription->bMatchFilter |= bFound;
            bFound = pGroupDescription->bMatchFilter;
        }
        if (bFound)
        {
            //g_print ("on montre ce groupe\n");
            gtk_widget_show (pGroupBox);
            if (pCurrentCategoryFrame != NULL)
                bFrameVisible = TRUE;
        }
        else if (bHideOther)
        {
            //g_print ("on cache ce groupe (%s)\n", pGroupDescription->cGroupName);
            gtk_widget_hide (pGroupBox);
        }
        else
            gtk_widget_show (pGroupBox);
        if (! bHighLightText || ! bFound)
        {
            gtk_label_set_markup (GTK_LABEL (pLabel), dgettext (cGettextDomain, cDescription));
        }
    }
void cd_clock_load_theme (CairoDockModuleInstance *myApplet)
{
    cd_message ("%s (%s)", __func__, myConfig.cThemePath);
    //\_______________ On charge le theme choisi (on n'a pas besoin de connaitre les dimmensions de l'icone).
    if (myConfig.cThemePath != NULL)
    {
        GString *sElementPath = g_string_new ("");
        int i;
        for (i = 0; i < CLOCK_ELEMENTS; i ++)
        {
            g_string_printf (sElementPath, "%s/%s", myConfig.cThemePath, s_cFileNames[i]);
            myData.pSvgHandles[i] = rsvg_handle_new_from_file (sElementPath->str, NULL);
        }
        i = 0;
        while (i < CLOCK_FRAME && myData.pSvgHandles[i] == NULL)
        {
            i ++;
            if (i == CLOCK_HOUR_HAND_SHADOW)
                i = CLOCK_FACE_SHADOW;
        }
        if (i != CLOCK_FRAME)
            rsvg_handle_get_dimensions (myData.pSvgHandles[i], &myData.DimensionData);
        if (myData.pSvgHandles[CLOCK_HOUR_HAND] != NULL)
            rsvg_handle_get_dimensions (myData.pSvgHandles[CLOCK_HOUR_HAND], &myData.needleDimension);
        cd_debug ("clock bg dimension : %dx%d", (int) myData.DimensionData.width, (int) myData.DimensionData.height);
        cd_debug ("clock needle dimension : %dx%d", (int) myData.needleDimension.width, (int) myData.needleDimension.height);

        // recuperation des parametres des aiguilles.
        g_string_printf (sElementPath, "%s/%s", myConfig.cThemePath, "theme.conf");
        GKeyFile *pKeyFile = cairo_dock_open_key_file (sElementPath->str);
        if (pKeyFile != NULL)
        {
            GError *erreur = NULL;
            myData.iNeedleRealHeight = g_key_file_get_integer (pKeyFile, "Needle", "height", &erreur);
            if (erreur != NULL)
            {
                cd_warning (erreur->message);
                g_error_free (erreur);
                erreur = NULL;
            }
            myData.iNeedleOffsetX = g_key_file_get_double (pKeyFile, "Needle", "offset x", &erreur);
            if (erreur != NULL)
            {
                cd_warning (erreur->message);
                g_error_free (erreur);
                erreur = NULL;
            }
            g_key_file_free (pKeyFile);
        }
        else  // on prend des valeurs par defaut assez larges.
        {
            g_print ("clock : default needle size\n");
            myData.iNeedleRealHeight = .5 * myData.needleDimension.height;
            myData.iNeedleOffsetX = .5 * myData.needleDimension.width;
        }
        myData.iNeedleRealWidth = myData.needleDimension.width/2 + myData.iNeedleOffsetX;
        myData.iNeedleOffsetY = .5 * myData.iNeedleRealHeight;
        cd_debug ("clock needle : H=%d; dx=%d\n", myData.iNeedleRealHeight, myData.iNeedleOffsetX);

        g_string_free (sElementPath, TRUE);
    }
    else
    {
        myData.DimensionData.width = 48;  // valeurs par defaut si aucun theme trouve.
        myData.DimensionData.height = 48;
        myData.needleDimension.width = 48;
        myData.needleDimension.height = 48;
    }
}
gboolean cd_opengl_load_3D_theme (CairoDockModuleInstance *myApplet, gchar *cThemePath)
{
	gchar *cImageName;
	cairo_surface_t *pSurface;
	gchar *cConfFilePath = g_strdup_printf ("%s/%s", cThemePath, "theme.conf");
	GKeyFile *pKeyFile = cairo_dock_open_key_file (cConfFilePath);
	g_free (cConfFilePath);
	if (pKeyFile == NULL)
		return FALSE;
	
	gchar *cThemePathUpToDate = NULL;
	gint iVersion = g_key_file_get_integer (pKeyFile, "Description", "Version", NULL);
	if (iVersion != 2)
	{
		/// effacer le theme et le recuperer sur le serveur...
		g_print ("theme en version inferieure => sera mis a jour...\n");
		// on ferme la config de l'actuel theme.
		g_key_file_free (pKeyFile);
		pKeyFile = NULL;
		
		// on supprime le theme.
		g_return_val_if_fail (cThemePath && *cThemePath == '/', FALSE);
		gchar *cCommand = g_strdup_printf ("rm -rf '%s'", cThemePath);
		int r = system (cCommand);
		g_free (cCommand);
		
		// on recupere le theme distant.
		pKeyFile = cairo_dock_open_key_file (myApplet->cConfFilePath);
		if (pKeyFile != NULL)
		{
			gboolean bFlushConfFileNeeded = FALSE;
			cThemePathUpToDate = CD_CONFIG_GET_THEME_PATH ("Configuration", "theme", "themes", "cd_box_simple");
			cThemePath = cThemePathUpToDate;
			g_key_file_free (pKeyFile);
			pKeyFile = NULL;
			
			// on ouvre la config du nouveau theme.
			cConfFilePath = g_strdup_printf ("%s/%s", cThemePath, "theme.conf");
			pKeyFile = cairo_dock_open_key_file (cConfFilePath);
			g_free (cConfFilePath);
			if (pKeyFile == NULL)
				return FALSE;
		}
		g_return_val_if_fail (pKeyFile != NULL, FALSE);
	}
	
	GError *erreur = NULL;
	GString *sImagePath = g_string_new ("");	
	
	//\_______________ les images d'avant et arriere plan.
	int iWidth, iHeight;
	CD_APPLET_GET_MY_ICON_EXTENT (&iWidth, &iHeight);
	double fImageWidth, fImageHeight;  // dimensions de la surface generee.
	double fZoomX=1, fZoomY=1;  // facteur de zoom qui lui a ete applique.
	
	cImageName = g_key_file_get_string (pKeyFile, "Pictures", "frame", &erreur);
	_check_error(erreur);
	if (cImageName != NULL)
	{
		g_string_printf (sImagePath, "%s/%s", cThemePath, cImageName);
		pSurface = cairo_dock_create_surface_from_image (sImagePath->str,
			myDrawContext,
			1.,
			iWidth, iHeight,
			CAIRO_DOCK_FILL_SPACE,
			&fImageWidth, &fImageHeight,
			&fZoomX, &fZoomY);
		
		myData.TextureFrame = cairo_dock_create_texture_from_surface (pSurface);
		cairo_surface_destroy (pSurface);
		g_free (cImageName);
	}
	
	cImageName = g_key_file_get_string (pKeyFile, "Pictures", "reflect", &erreur);
	_check_error(erreur);
	if (cImageName != NULL)
	{
		g_string_printf (sImagePath, "%s/%s", cThemePath, cImageName);
		pSurface = cairo_dock_create_surface_from_image (sImagePath->str,
			myDrawContext,
			1.,
			iWidth, iHeight,
			CAIRO_DOCK_FILL_SPACE,
			&fImageWidth, &fImageHeight,
			NULL, NULL);
		
		myData.TextureReflect = cairo_dock_create_texture_from_surface (pSurface);
		cairo_surface_destroy (pSurface);
		g_free (cImageName);
	}
	
	//\_______________ les coordonnees des 4 coins de la pochette
	// dans le referentiel du cadre (directement obtenues avec Gimp) => dans le referentiel de l'icone iWidth x iHeight.
	myData.itopleftX = g_key_file_get_integer (pKeyFile, "Configuration", "topleftX", &erreur) * fZoomX;
	_check_error(erreur);
	myData.itopleftY = g_key_file_get_integer (pKeyFile, "Configuration", "topleftY", &erreur) * fZoomY;
	_check_error(erreur);
	
	myData.ibottomleftX = g_key_file_get_integer (pKeyFile, "Configuration", "bottomleftX", &erreur) * fZoomX;
	_check_error(erreur);
	myData.ibottomleftY = g_key_file_get_integer (pKeyFile, "Configuration", "bottomleftY", &erreur) * fZoomY;
	_check_error(erreur);
	
	myData.ibottomrightX = g_key_file_get_integer (pKeyFile, "Configuration", "bottomrightX", &erreur) * fZoomX;
	_check_error(erreur);
	myData.ibottomrightY = g_key_file_get_integer (pKeyFile, "Configuration", "bottomrightY", &erreur) * fZoomY;
	_check_error(erreur);
	
	myData.itoprightX = g_key_file_get_integer (pKeyFile, "Configuration", "toprightX", &erreur) * fZoomX;
	_check_error(erreur);
	myData.itoprightY = g_key_file_get_integer (pKeyFile, "Configuration", "toprightY", &erreur) * fZoomY;
	_check_error(erreur);			
	
	//\_______________ On definit la calllist qui déforme la pochette.
	myData.draw_cover = glGenLists(1);
	glNewList(myData.draw_cover , GL_COMPILE);
	glBegin(GL_QUADS);
	glTexCoord2d (0,0);
	glVertex3f (-.5 + myData.itopleftX / iWidth,		+.5 - myData.itopleftY / iHeight,		0);
	glTexCoord2d (0,1);
	glVertex3f (-.5 + myData.ibottomleftX / iWidth,		+.5 - myData.ibottomleftY /iHeight,		0.);
	glTexCoord2d (1,1);
	glVertex3f (-.5 + myData.ibottomrightX / iWidth,	+.5 - myData.ibottomrightY / iHeight,	0.);
	glTexCoord2d (1,0);
	glVertex3f (-.5 + myData.itoprightX / iWidth,		+.5 - myData.itoprightY / iHeight,		0.);
	glEnd();
	glEndList();
	
	//\_______________ les zones cliquables et l'OSD.
	myData.numberButtons = g_key_file_get_integer (pKeyFile, "Buttons", "number", NULL);
	if (myData.numberButtons != 0)
	{
		myData.osd = g_key_file_get_boolean (pKeyFile, "Buttons", "osd", &erreur);
		_check_error(erreur);
		
		// Bouton 1
		myData.button1sizeX = g_key_file_get_integer (pKeyFile, "Button1", "sizeX", &erreur) * fZoomX;
		_check_error(erreur);
		myData.button1sizeY = g_key_file_get_integer (pKeyFile, "Button1", "sizeY", &erreur) * fZoomY;
		_check_error(erreur);
		myData.button1coordX = g_key_file_get_integer (pKeyFile, "Button1", "X", &erreur) * fZoomX + myData.button1sizeX/2;  // on se ramene au centre.
		_check_error(erreur);
		myData.button1coordY = g_key_file_get_integer (pKeyFile, "Button1", "Y", &erreur) * fZoomY + myData.button1sizeY/2;  // on se ramene au centre.
		_check_error(erreur);
		
		_make_texture_at_size (myData.TextureButton1, "Button1", "picture", myData.button1sizeX, myData.button1sizeY);
		
		if (myData.osd)
		{
			myData.osdPlaysizeX = g_key_file_get_integer (pKeyFile, "Button1", "osd play sizeX", &erreur) * fZoomX;
			_check_error(erreur);
			myData.osdPlaysizeY = g_key_file_get_integer (pKeyFile, "Button1", "osd play sizeY", &erreur) * fZoomY;
			_check_error(erreur);
			myData.osdPlaycoordX = g_key_file_get_integer (pKeyFile, "Button1", "osd play X", &erreur) * fZoomX + myData.osdPlaysizeX/2;
			_check_error(erreur);
			myData.osdPlaycoordY = g_key_file_get_integer (pKeyFile, "Button1", "osd play Y", &erreur) * fZoomY + myData.osdPlaysizeY/2;
			_check_error(erreur);
			_make_texture_at_size (myData.TextureOsdPlay, "Button1", "osd_play", myData.osdPlaysizeX, myData.osdPlaysizeY);

			myData.osdPausesizeX = g_key_file_get_integer (pKeyFile, "Button1", "osd pause sizeX", &erreur) * fZoomX;
			_check_error(erreur);
			myData.osdPausesizeY = g_key_file_get_integer (pKeyFile, "Button1", "osd pause sizeY", &erreur) * fZoomY;
			_check_error(erreur);
			myData.osdPausecoordX = g_key_file_get_integer (pKeyFile, "Button1", "osd pause X", &erreur) * fZoomX + myData.osdPausesizeX/2;
			_check_error(erreur);
			myData.osdPausecoordY = g_key_file_get_integer (pKeyFile, "Button1", "osd pause Y", &erreur) * fZoomY + myData.osdPausesizeY/2;
			_check_error(erreur);
			_make_texture_at_size (myData.TextureOsdPause, "Button1", "osd_pause", myData.osdPausesizeX, myData.osdPausesizeY);			
		}
		
		// Bouton 4
		if (myData.numberButtons > 3)
		{
			_check_error(erreur);
			myData.button4sizeX = g_key_file_get_integer (pKeyFile, "Button4", "sizeX", &erreur) * fZoomX;
			_check_error(erreur);
			myData.button4sizeY = g_key_file_get_integer (pKeyFile, "Button4", "sizeY", &erreur) * fZoomY;
			_check_error(erreur);
			myData.button4coordX = g_key_file_get_integer (pKeyFile, "Button4", "X", &erreur) * fZoomX + myData.button4sizeX/2;
			_check_error(erreur);
			myData.button4coordY = g_key_file_get_integer (pKeyFile, "Button4", "Y", &erreur) * fZoomY + myData.button4sizeY/2;
			
			_make_texture_at_size (myData.TextureButton4, "Button4", "picture", myData.button4sizeX, myData.button4sizeY);
			
			if (myData.osd)
			{
				myData.osdHomesizeX = g_key_file_get_integer (pKeyFile, "Button4", "osd sizeX", &erreur) * fZoomX;
				_check_error(erreur);
				myData.osdHomesizeY = g_key_file_get_integer (pKeyFile, "Button4", "osd sizeY", &erreur) * fZoomY;
				_check_error(erreur);
				myData.osdHomecoordX = g_key_file_get_integer (pKeyFile, "Button4", "osd X", &erreur) * fZoomX + myData.osdHomesizeX/2;
				_check_error(erreur);
				myData.osdHomecoordY = g_key_file_get_integer (pKeyFile, "Button4", "osd Y", &erreur) * fZoomY + myData.osdHomesizeY/2;
				_check_error(erreur);
				_make_texture_at_size (myData.TextureOsdHome, "Button4", "osd", myData.osdHomesizeX, myData.osdHomesizeY);
			}
		}
		
		// Bouton 3
		if (myData.numberButtons > 2)
		{
			myData.button3sizeX = g_key_file_get_integer (pKeyFile, "Button3", "sizeX", &erreur) * fZoomX;
			_check_error(erreur);
			myData.button3sizeY = g_key_file_get_integer (pKeyFile, "Button3", "sizeY", &erreur) * fZoomY;
			_check_error(erreur);
			myData.button3coordX = g_key_file_get_integer (pKeyFile, "Button3", "X", &erreur) * fZoomX + myData.button3sizeX/2;
			_check_error(erreur);
			myData.button3coordY = g_key_file_get_integer (pKeyFile, "Button3", "Y", &erreur) * fZoomY + myData.button3sizeY/2;
			_check_error(erreur);
			
			_make_texture_at_size (myData.TextureButton3, "Button3", "picture", myData.button3sizeX, myData.button3sizeY);
			
			if (myData.osd)
			{
				myData.osdNextsizeX = g_key_file_get_integer (pKeyFile, "Button3", "osd sizeX", &erreur) * fZoomX;
				_check_error(erreur);
				myData.osdNextsizeY = g_key_file_get_integer (pKeyFile, "Button3", "osd sizeY", &erreur) * fZoomY;
				_check_error(erreur);
				myData.osdNextcoordX = g_key_file_get_integer (pKeyFile, "Button3", "osd X", &erreur) * fZoomX + myData.osdNextsizeX/2;
				_check_error(erreur);
				myData.osdNextcoordY = g_key_file_get_integer (pKeyFile, "Button3", "osd Y", &erreur) * fZoomY + myData.osdNextsizeY/2;
				_check_error(erreur);
				_make_texture_at_size (myData.TextureOsdNext, "Button3", "osd", myData.osdNextsizeX, myData.osdNextsizeY);
			}
		}
		
		// Bouton 2
		if (myData.numberButtons > 1)
		{
			myData.button2sizeX = g_key_file_get_integer (pKeyFile, "Button2", "sizeX", &erreur) * fZoomX;
			_check_error(erreur);
			myData.button2sizeY = g_key_file_get_integer (pKeyFile, "Button2", "sizeY", &erreur) * fZoomY;
			_check_error(erreur);
			myData.button2coordX = g_key_file_get_integer (pKeyFile, "Button2", "X", &erreur) * fZoomX + myData.button2sizeX/2;
			_check_error(erreur);
			myData.button2coordY = g_key_file_get_integer (pKeyFile, "Button2", "Y", &erreur) * fZoomY + myData.button2sizeY/2;
			_check_error(erreur);
			
			_make_texture_at_size (myData.TextureButton2, "Button2", "picture", myData.button2sizeX, myData.button2sizeY);
			
			if (myData.osd)
			{
				myData.osdPrevsizeX = g_key_file_get_integer (pKeyFile, "Button2", "osd sizeX", &erreur) * fZoomX;
				_check_error(erreur);
				myData.osdPrevsizeY = g_key_file_get_integer (pKeyFile, "Button2", "osd sizeY", &erreur) * fZoomY;
				_check_error(erreur);
				myData.osdPrevcoordX = g_key_file_get_integer (pKeyFile, "Button2", "osd X", &erreur) * fZoomX + myData.osdPrevsizeX/2;
				_check_error(erreur);
				myData.osdPrevcoordY = g_key_file_get_integer (pKeyFile, "Button2", "osd Y", &erreur) * fZoomY + myData.osdPrevsizeY/2;
				_check_error(erreur);
				_make_texture_at_size (myData.TextureOsdPrev, "Button2", "osd", myData.osdPrevsizeX, myData.osdPrevsizeY);
			}
		}
	}
	g_key_file_free (pKeyFile);
	g_free (cThemePathUpToDate);
	return TRUE;
}
void cairo_dock_swap_icons (CairoDock *pDock, Icon *icon1, Icon *icon2)
{
	//g_print ("%s (%s, %s) : %.2f <-> %.2f\n", __func__, icon1->acName, icon2->acName, icon1->fOrder, icon2->fOrder);
	if (! ( (CAIRO_DOCK_IS_APPLI (icon1) && CAIRO_DOCK_IS_APPLI (icon2)) || (CAIRO_DOCK_IS_LAUNCHER (icon1) && CAIRO_DOCK_IS_LAUNCHER (icon2)) || (CAIRO_DOCK_IS_APPLET (icon1) && CAIRO_DOCK_IS_APPLET (icon2)) ) )
		return ;

	//\_________________ On intervertit les ordres des 2 lanceurs.
	double fSwap = icon1->fOrder;
	icon1->fOrder = icon2->fOrder;
	icon2->fOrder = fSwap;

	//\_________________ On change l'ordre dans les fichiers des 2 lanceurs.
	if (CAIRO_DOCK_IS_LAUNCHER (icon1))  // ce sont des lanceurs.
	{
		gchar *cDesktopFilePath;
		GKeyFile* pKeyFile;

		if (icon1->acDesktopFileName != NULL)
		{
			cDesktopFilePath = g_strdup_printf ("%s/%s", g_cCurrentLaunchersPath, icon1->acDesktopFileName);
			pKeyFile = cairo_dock_open_key_file (cDesktopFilePath);
			if (pKeyFile == NULL)
				return ;

			g_key_file_set_double (pKeyFile, "Desktop Entry", "Order", icon1->fOrder);
			cairo_dock_write_keys_to_file (pKeyFile, cDesktopFilePath);
			g_key_file_free (pKeyFile);
			g_free (cDesktopFilePath);
		}

		if (icon2->acDesktopFileName != NULL)
		{
			cDesktopFilePath = g_strdup_printf ("%s/%s", g_cCurrentLaunchersPath, icon2->acDesktopFileName);
			pKeyFile = cairo_dock_open_key_file (cDesktopFilePath);
			if (pKeyFile == NULL)
				return ;

			g_key_file_set_double (pKeyFile, "Desktop Entry", "Order", icon2->fOrder);
			cairo_dock_write_keys_to_file (pKeyFile, cDesktopFilePath);
			g_key_file_free (pKeyFile);
			g_free (cDesktopFilePath);
		}
	}

	//\_________________ On les intervertit dans la liste.
	if (pDock->pFirstDrawnElement != NULL && (pDock->pFirstDrawnElement->data == icon1 || pDock->pFirstDrawnElement->data == icon2))
		pDock->pFirstDrawnElement = NULL;
	pDock->icons = g_list_remove (pDock->icons, icon1);
	pDock->icons = g_list_remove (pDock->icons, icon2);
	pDock->icons = g_list_insert_sorted (pDock->icons,
		icon1,
		(GCompareFunc) cairo_dock_compare_icons_order);
	pDock->icons = g_list_insert_sorted (pDock->icons,
		icon2,
		(GCompareFunc) cairo_dock_compare_icons_order);

	//\_________________ On recalcule la largeur max, qui peut avoir ete influencee par le changement d'ordre.
	cairo_dock_update_dock_size (pDock);

	//\_________________ On met a jour l'ordre des applets dans le fichier de conf.
	if (CAIRO_DOCK_IS_APPLET (icon1))
		cairo_dock_update_module_instance_order (icon1->pModuleInstance, icon1->fOrder);
	if (CAIRO_DOCK_IS_APPLET (icon2))
		cairo_dock_update_module_instance_order (icon2->pModuleInstance, icon2->fOrder);
	if (fabs (icon2->fOrder - icon1->fOrder) < 1e-3)
	{
		cairo_dock_normalize_icons_order (pDock->icons, icon1->iType);
	}
}
gchar *gldi_launcher_add_conf_file (const gchar *cOrigin, const gchar *cDockName, double fOrder)
{
	//\__________________ open the template.
	const gchar *cTemplateFile = GLDI_SHARE_DATA_DIR"/"CAIRO_DOCK_LAUNCHER_CONF_FILE;	
	GKeyFile *pKeyFile = cairo_dock_open_key_file (cTemplateFile);
	g_return_val_if_fail (pKeyFile != NULL, NULL);
	
	//\__________________ fill the parameters
	gchar *cFilePath = NULL;
	if (cOrigin != NULL && *cOrigin != '/')  // transform the origin URI into a path or a file name.
	{
		if (strncmp (cOrigin, "application://", 14) == 0)  // Ubuntu >= 11.04: it's now an "app" URI
			cFilePath = g_strdup (cOrigin + 14);  // in this case we don't have the actual path of the .desktop, but that doesn't matter.
		else
			cFilePath = g_filename_from_uri (cOrigin, NULL, NULL);
	}
	else  // no origin or already a path.
		cFilePath = g_strdup (cOrigin);
	g_key_file_set_string (pKeyFile, "Desktop Entry", "Origin", cFilePath?cFilePath:"");
	
	g_key_file_set_double (pKeyFile, "Desktop Entry", "Order", fOrder);
	
	g_key_file_set_string (pKeyFile, "Desktop Entry", "Container", cDockName);
	
	//\__________________ in the case of a script, set ourselves a valid name and command.
	if (cFilePath != NULL && g_str_has_suffix (cFilePath, ".sh"))
	{
		gchar *cName = g_path_get_basename (cFilePath);
		g_key_file_set_string (pKeyFile, "Desktop Entry", "Name", cName);
		g_free (cName);
		g_key_file_set_string (pKeyFile, "Desktop Entry", "Exec", cFilePath);
		g_key_file_set_boolean (pKeyFile, "Desktop Entry", "Terminal", TRUE);
	}
	
	//\__________________ in the case of a custom launcher, set a command (the launcher would be invalid without).
	if (cFilePath == NULL)
	{
		g_key_file_set_string (pKeyFile, "Desktop Entry", "Exec", _("Enter a command"));
		g_key_file_set_string (pKeyFile, "Desktop Entry", "Name", _("New launcher"));
	}
	
	//\__________________ generate a unique and readable filename.
	gchar *cBaseName = (cFilePath ?
		*cFilePath == '/' ?
			g_path_get_basename (cFilePath) :
			g_strdup (cFilePath) :
		g_path_get_basename (cTemplateFile));

	if (! g_str_has_suffix (cBaseName, ".desktop")) // if we have a script (.sh file) => add '.desktop'
	{
		gchar *cTmpBaseName = g_strdup_printf ("%s.desktop", cBaseName);
		g_free (cBaseName);
		cBaseName = cTmpBaseName;
	}

	gchar *cNewDesktopFileName = cairo_dock_generate_unique_filename (cBaseName, g_cCurrentLaunchersPath);
	g_free (cBaseName);
	
	//\__________________ write the keys.
	gchar *cNewDesktopFilePath = g_strdup_printf ("%s/%s", g_cCurrentLaunchersPath, cNewDesktopFileName);
	cairo_dock_write_keys_to_conf_file (pKeyFile, cNewDesktopFilePath);
	g_free (cNewDesktopFilePath);
	
	g_free (cFilePath);
	g_key_file_free (pKeyFile);
	return cNewDesktopFileName;
}
static gchar *_cairo_dock_generate_desktop_file_for_launcher (const gchar *cDesktopURI, const gchar *cDockName, double fOrder, GError **erreur)
{
	g_return_val_if_fail (cDesktopURI != NULL, NULL);
	GError *tmp_erreur = NULL;
	gchar *cFilePath = (*cDesktopURI == '/' ? g_strdup (cDesktopURI) : g_filename_from_uri (cDesktopURI, NULL, &tmp_erreur));
	if (tmp_erreur != NULL)
	{
		g_propagate_error (erreur, tmp_erreur);
		return NULL;
	}

	//\___________________ On supprime a la main les '%20' qui foutent le boxon (rare).
	cairo_dock_remove_html_spaces (cFilePath);

	//\___________________ On ouvre le patron.
	GKeyFile *pKeyFile = cairo_dock_open_key_file (cFilePath);
	if (pKeyFile == NULL)
		return NULL;

	//\___________________ On renseigne nos champs.
	g_key_file_set_double (pKeyFile, "Desktop Entry", "Order", fOrder);
	g_key_file_set_string (pKeyFile, "Desktop Entry", "Container", cDockName);
	
	//\___________________ On elimine les indesirables.
	g_key_file_remove_key (pKeyFile, "Desktop Entry", "X-Ubuntu-Gettext-Domain", NULL);
	gchar *cCommand = g_key_file_get_string (pKeyFile, "Desktop Entry", "Exec", &tmp_erreur);
	if (tmp_erreur != NULL)
	{
		g_propagate_error (erreur, tmp_erreur);
		g_key_file_free (pKeyFile);
		return NULL;
	}
	gchar *str = strchr (cCommand, '%');
	if (str != NULL)
	{
		*str = '\0';
		g_key_file_set_string (pKeyFile, "Desktop Entry", "Exec", cCommand);
	}
	g_free (cCommand);

	gchar *cIconName = g_key_file_get_string (pKeyFile, "Desktop Entry", "Icon", &tmp_erreur);
	if (tmp_erreur != NULL)
	{
		g_propagate_error (erreur, tmp_erreur);
		g_key_file_free (pKeyFile);
		return NULL;
	}
	if (*cIconName != '/' && (g_str_has_suffix (cIconName, ".svg") || g_str_has_suffix (cIconName, ".png") || g_str_has_suffix (cIconName, ".xpm")))
	{
		cIconName[strlen(cIconName) - 4] = '\0';
		g_key_file_set_string (pKeyFile, "Desktop Entry", "Icon", cIconName);
	}
	g_free (cIconName);

	//\___________________ On lui choisit un nom de fichier tel qu'il n'y ait pas de collision.
	gchar *cBaseName = g_path_get_basename (cFilePath);
	gchar *cNewDesktopFileName = cairo_dock_generate_desktop_filename (cBaseName, g_cCurrentLaunchersPath);
	g_free (cBaseName);

	//\___________________ On ecrit tout ca dans un fichier base sur le template.
	gchar *cNewDesktopFilePath = g_strdup_printf ("%s/%s", g_cCurrentLaunchersPath, cNewDesktopFileName);
	cairo_dock_flush_conf_file_full (pKeyFile, cNewDesktopFilePath, CAIRO_DOCK_SHARE_DATA_DIR, FALSE, CAIRO_DOCK_LAUNCHER_CONF_FILE);
	
	g_free (cNewDesktopFilePath);
	g_key_file_free (pKeyFile);
	g_free (cFilePath);

	return cNewDesktopFileName;
}