167 |
fprintf(Lfic, "manual=%d\n", Ldrive->manual == TRUE ? 1 : 0); |
fprintf(Lfic, "manual=%d\n", Ldrive->manual == TRUE ? 1 : 0); |
168 |
} |
} |
169 |
|
|
170 |
|
gchar *dump_file_list(char *Abuf, gint Asize) |
171 |
|
{ |
172 |
|
GSList *Llistconfig = get_config_path(); |
173 |
|
GSList *Lcurlist; |
174 |
|
|
175 |
|
memset(Abuf, 0, Asize); |
176 |
|
|
177 |
|
for (Lcurlist = Llistconfig; Lcurlist; Lcurlist = g_slist_next(Lcurlist)) { |
178 |
|
if (*Abuf) strncat(Abuf, "\n", Asize-strlen(Abuf)-5); |
179 |
|
strncat(Abuf, Lcurlist->data, Asize-strlen(Abuf)-5); |
180 |
|
} |
181 |
|
|
182 |
|
g_slist_free(Llistconfig); |
183 |
|
|
184 |
|
return Abuf; |
185 |
|
} |
186 |
|
|
187 |
/* ecriture du fichier de configuration */ |
/* ecriture du fichier de configuration */ |
188 |
gboolean write_conf(GError **Aerror) |
gboolean write_conf(GError **Aerror) |
189 |
{ |
{ |
190 |
FILE *Lfic; |
FILE *Lfic; |
191 |
gchar *Ltmp; |
gchar *Ltmp; |
192 |
|
|
193 |
if (!get_config_file(W_OK)) return FALSE; |
if (!get_config_file(W_OK)) return FALSE; |
194 |
g_warning("le conf => %s\n", Gfileconf); |
|
195 |
if (!(Lfic=fopen(Gfileconf, "w"))) { |
if (!(Lfic=fopen(Gfileconf, "w"))) { |
196 |
Ltmp = g_strdup_printf(_("Cannot create %s: %s"), Gfileconf, g_strerror(errno)); |
Ltmp = g_strdup_printf(_("Cannot create %s: %s"), Gfileconf, g_strerror(errno)); |
197 |
g_set_error(Aerror, G_FILE_ERROR, g_file_error_from_errno(errno), Ltmp, g_strerror(errno)); |
g_set_error(Aerror, G_FILE_ERROR, g_file_error_from_errno(errno), Ltmp, g_strerror(errno)); |
488 |
{ |
{ |
489 |
TProgRequis *Lcurprog; |
TProgRequis *Lcurprog; |
490 |
gchar *Lprog; |
gchar *Lprog; |
491 |
|
gboolean Lstatus = TRUE; |
492 |
GtkWidget *Lwindow1 = sc_grave_get_widget(Ag, "topwindow"); |
GtkWidget *Lwindow1 = sc_grave_get_widget(Ag, "topwindow"); |
493 |
|
|
494 |
if (Aop & UPDATE_SAVEONEXIT_VALUE) { |
if (Aop & UPDATE_SAVEONEXIT_VALUE) { |
553 |
} |
} |
554 |
|
|
555 |
if (Aop & WRITE_CONFIG) { |
if (Aop & WRITE_CONFIG) { |
556 |
return write_conf(Aerror); |
Lstatus = write_conf(Aerror); |
557 |
|
if (!Lstatus) { |
558 |
|
gchar Lbuf[_BUF_SIZE]; |
559 |
|
gchar *Lfullmsg = g_strdup_printf(_("Cannot save configuration file !\nI have tried on those files:\n%s"), |
560 |
|
dump_file_list(Lbuf, sizeof(Lbuf)-1)); |
561 |
|
GtkWidget *Ldialog = gtk_message_dialog_new(GTK_IS_WIDGET(Lwindow1) ? GTK_WINDOW(Lwindow1) : NULL, |
562 |
|
GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, |
563 |
|
Lfullmsg); |
564 |
|
|
565 |
|
g_warning(Lfullmsg); |
566 |
|
|
567 |
|
gtk_dialog_run(GTK_DIALOG(Ldialog)); |
568 |
|
gtk_widget_destroy(Ldialog); |
569 |
|
g_free(Lfullmsg); |
570 |
|
} |
571 |
} |
} |
572 |
|
|
573 |
return TRUE; |
return Lstatus; |
574 |
} |
} |
575 |
|
|
576 |
/* renvoi une valeur du fichier de configuration */ |
/* renvoi une valeur du fichier de configuration */ |