1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| void delete_group(GtkComboBox *widget,gpointer data){
GtkTreeModel * p_model = NULL;
GtkTreeIter iter;
gchar* group=NULL;
/* On recupere le modele qu'on a cree. */
p_model = gtk_combo_box_get_model (GTK_COMBO_BOX(widget));
/* On recupere le GtkTreeIter de l'element courant. */
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX(widget), &iter))
{
/*
* On recupere les donnees de l'element courant a savoir
* un entier et une chaine de caracteres.
*/
gtk_tree_model_get (
p_model,&iter,
0,&group,
-1
);
}
GKeyFile * p_key_file;
FILE* error;
GError *pErreur=NULL;
p_key_file = g_key_file_new ();
if (! g_key_file_load_from_file (p_key_file,"config.ini",G_KEY_FILE_KEEP_COMMENTS,&pErreur))
{
error=fopen("error.txt","w");
fprintf("Erreur: %s\n",pErreur->message);
fclose(error);
g_free(pErreur);
}
else{
gsize *size_t;
gchar** groups= g_key_file_get_groups(p_key_file,&size_t);
int k;
FILE* fichier;
for(k=0;k<size_t;k++){
if(!strcmp(groups[k],group))continue;
gchar *pop = g_key_file_get_string (p_key_file, groups[k], "POP", NULL);
gchar *smtp = g_key_file_get_string (p_key_file, groups[k], "SMTP", NULL);
gchar *mail = g_key_file_get_string (p_key_file, groups[k], "Mail", NULL);
gchar *user= g_key_file_get_string (p_key_file, groups[k], "UserName", NULL);
gchar *pass = g_key_file_get_string (p_key_file, groups[k], "Password", NULL);
fichier = fopen("config.ini2.txt","a");
fprintf(fichier,"[%s]\nMail=%s\nPOP=%s\nUserName=%s\nPassword=%s\nSMTP=%s\n\n",groups[k],mail,pop,user,pass,smtp);
fclose(fichier);
}
}
g_key_file_free(p_key_file);
g_rename("config.ini2","config.ini");
gtk_tree_store_clear (GTK_TREE_STORE(data));
loading_tree(GTK_TREE_STORE(data));
} |
Partager