2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2018 Michael Rasmussen and the Claws Mail Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "claws-features.h"
26 #include <glib/gi18n.h>
34 #include "prefs_gtk.h"
35 #include "prefswindow.h"
36 #include "alertpanel.h"
40 #include "archiver_prefs.h"
41 #include "libarchive_archive.h"
43 #define PREFS_BLOCK_NAME "Archiver"
45 ArchiverPrefs archiver_prefs
;
47 struct ArchiverPrefsPage
{
49 GtkWidget
*save_folder
;
51 GtkWidget
*gzip_radiobtn
;
52 GtkWidget
*bzip_radiobtn
;
53 GtkWidget
*compress_radiobtn
;
54 #if ARCHIVE_VERSION_NUMBER >= 2006990
55 GtkWidget
*lzma_radiobtn
;
56 GtkWidget
*xz_radiobtn
;
58 #if ARCHIVE_VERSION_NUMBER >= 3000000
59 GtkWidget
*lzip_radiobtn
;
61 #if ARCHIVE_VERSION_NUMBER >= 3001000
62 GtkWidget
*lrzip_radiobtn
;
63 GtkWidget
*lzop_radiobtn
;
64 GtkWidget
*grzip_radiobtn
;
66 #if ARCHIVE_VERSION_NUMBER >= 3001900
67 GtkWidget
*lz4_radiobtn
;
69 GtkWidget
*none_radiobtn
;
70 GtkWidget
*tar_radiobtn
;
71 GtkWidget
*shar_radiobtn
;
72 GtkWidget
*cpio_radiobtn
;
73 GtkWidget
*pax_radiobtn
;
74 GtkWidget
*recursive_chkbtn
;
75 GtkWidget
*md5sum_chkbtn
;
76 GtkWidget
*rename_chkbtn
;
77 GtkWidget
*unlink_chkbtn
;
80 struct ArchiverPrefsPage archiver_prefs_page
;
82 static void create_archiver_prefs_page (PrefsPage
*page
,
85 static void destroy_archiver_prefs_page (PrefsPage
*page
);
86 static void save_archiver_prefs (PrefsPage
*page
);
88 static PrefParam param
[] = {
89 {"save_folder", NULL
, &archiver_prefs
.save_folder
, P_STRING
, NULL
, NULL
, NULL
},
90 {"compression", "0", &archiver_prefs
.compression
, P_ENUM
, NULL
, NULL
, NULL
},
91 {"format", "0", &archiver_prefs
.format
, P_ENUM
, NULL
, NULL
, NULL
},
92 {"recursive", "TRUE", &archiver_prefs
.recursive
, P_BOOL
, NULL
, NULL
, NULL
},
93 {"md5sum", "FALSE", &archiver_prefs
.md5sum
, P_BOOL
, NULL
, NULL
, NULL
},
94 {"rename", "FALSE", &archiver_prefs
.rename
, P_BOOL
, NULL
, NULL
, NULL
},
95 {"unlink", "FALSE", &archiver_prefs
.unlink
, P_BOOL
, NULL
, NULL
, NULL
},
97 {NULL
, NULL
, NULL
, P_OTHER
, NULL
, NULL
, NULL
}
100 void archiver_prefs_init(void)
102 static gchar
*path
[3];
105 path
[0] = _("Plugins");
106 path
[1] = _("Mail Archiver");
109 prefs_set_default(param
);
110 rcpath
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
, COMMON_RC
, NULL
);
111 prefs_read_config(param
, PREFS_BLOCK_NAME
, rcpath
, NULL
);
114 archiver_prefs_page
.page
.path
= path
;
115 archiver_prefs_page
.page
.create_widget
= create_archiver_prefs_page
;
116 archiver_prefs_page
.page
.destroy_widget
= destroy_archiver_prefs_page
;
117 archiver_prefs_page
.page
.save_page
= save_archiver_prefs
;
118 archiver_prefs_page
.page
.weight
= 30.0;
120 prefs_gtk_register_page((PrefsPage
*) &archiver_prefs_page
);
123 void archiver_prefs_done(void)
125 prefs_gtk_unregister_page((PrefsPage
*) &archiver_prefs_page
);
128 static void foldersel_cb(GtkWidget
*widget
, gpointer data
)
130 struct ArchiverPrefsPage
*page
= (struct ArchiverPrefsPage
*) data
;
131 gchar
*startdir
= NULL
;
135 if (archiver_prefs
.save_folder
&& *archiver_prefs
.save_folder
)
136 startdir
= g_strconcat(archiver_prefs
.save_folder
,
137 G_DIR_SEPARATOR_S
, NULL
);
139 startdir
= g_strdup(get_home_dir());
141 dirname
= filesel_select_file_save_folder(_("Select destination folder"), startdir
);
146 if (!is_dir_exist(dirname
)) {
147 alertpanel_error(_("'%s' is not a directory."),dirname
);
152 if (dirname
[strlen(dirname
)-1] == G_DIR_SEPARATOR
)
153 dirname
[strlen(dirname
)-1] = '\0';
156 tmp
= g_filename_to_utf8(dirname
,-1, NULL
, NULL
, NULL
);
157 gtk_entry_set_text(GTK_ENTRY(page
->save_folder
), tmp
);
163 static void create_archiver_prefs_page(PrefsPage
* _page
,
167 struct ArchiverPrefsPage
*page
= (struct ArchiverPrefsPage
*) _page
;
168 GtkWidget
*vbox1
, *vbox2
;
170 GtkWidget
*save_folder_label
;
171 GtkWidget
*save_folder
;
172 GtkWidget
*save_folder_select
;
174 GSList
*compression_group
= NULL
;
175 GtkWidget
*gzip_radiobtn
;
176 GtkWidget
*bzip_radiobtn
;
177 GtkWidget
*compress_radiobtn
;
178 #if ARCHIVE_VERSION_NUMBER >= 2006990
179 GtkWidget
*lzma_radiobtn
;
180 GtkWidget
*xz_radiobtn
;
182 #if ARCHIVE_VERSION_NUMBER >= 3000000
183 GtkWidget
*lzip_radiobtn
;
185 #if ARCHIVE_VERSION_NUMBER >= 3001000
186 GtkWidget
*lrzip_radiobtn
;
187 GtkWidget
*lzop_radiobtn
;
188 GtkWidget
*grzip_radiobtn
;
190 #if ARCHIVE_VERSION_NUMBER >= 3001900
191 GtkWidget
*lz4_radiobtn
;
193 GtkWidget
*none_radiobtn
;
194 GSList
*format_group
= NULL
;
195 GtkWidget
*tar_radiobtn
;
196 GtkWidget
*shar_radiobtn
;
197 GtkWidget
*cpio_radiobtn
;
198 GtkWidget
*pax_radiobtn
;
199 GtkWidget
*recursive_chkbtn
;
200 GtkWidget
*md5sum_chkbtn
;
201 GtkWidget
*rename_chkbtn
;
202 GtkWidget
*unlink_chkbtn
;
204 vbox1
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING
);
205 gtk_widget_show (vbox1
);
206 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
208 vbox2
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 4);
209 gtk_widget_show (vbox2
);
210 gtk_box_pack_start (GTK_BOX (vbox1
), vbox2
, FALSE
, FALSE
, 0);
212 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
213 gtk_widget_show (hbox1
);
214 gtk_box_pack_start (GTK_BOX (vbox2
), hbox1
, FALSE
, FALSE
, 0);
216 save_folder_label
= gtk_label_new(_("Default save folder"));
217 gtk_widget_show (save_folder_label
);
218 gtk_box_pack_start (GTK_BOX (hbox1
), save_folder_label
, FALSE
, FALSE
, 0);
220 save_folder
= gtk_entry_new ();
221 gtk_widget_show (save_folder
);
222 gtk_box_pack_start (GTK_BOX (hbox1
), save_folder
, TRUE
, TRUE
, 0);
224 save_folder_select
= gtkut_get_browse_directory_btn(_("_Select"));
225 gtk_widget_show (save_folder_select
);
226 gtk_box_pack_start (GTK_BOX (hbox1
), save_folder_select
, FALSE
, FALSE
, 0);
227 CLAWS_SET_TIP(save_folder_select
,
228 _("Click this button to select the default location for saving archives"));
230 g_signal_connect(G_OBJECT(save_folder_select
), "clicked",
231 G_CALLBACK(foldersel_cb
), page
);
233 if (archiver_prefs
.save_folder
!= NULL
)
234 gtk_entry_set_text(GTK_ENTRY(save_folder
),
235 archiver_prefs
.save_folder
);
237 PACK_FRAME (vbox1
, frame
, _("Default compression"));
239 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 4);
240 gtk_widget_show(hbox1
);
241 gtk_container_set_border_width(GTK_CONTAINER(hbox1
), 4);
242 gtk_container_add(GTK_CONTAINER(frame
), hbox1
);
244 gzip_radiobtn
= gtk_radio_button_new_with_label(compression_group
, "GZIP");
245 compression_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(gzip_radiobtn
));
246 gtk_widget_show(gzip_radiobtn
);
247 gtk_box_pack_start(GTK_BOX (hbox1
), gzip_radiobtn
, FALSE
, FALSE
, 0);
248 archiver_set_tooltip(gzip_radiobtn
, g_strdup_printf(_("Choose this option to use %s compression by default"), "GZIP"));
250 bzip_radiobtn
= gtk_radio_button_new_with_label(compression_group
, "BZIP2");
251 compression_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(bzip_radiobtn
));
252 gtk_widget_show(bzip_radiobtn
);
253 gtk_box_pack_start(GTK_BOX (hbox1
), bzip_radiobtn
, FALSE
, FALSE
, 0);
254 archiver_set_tooltip(bzip_radiobtn
, g_strdup_printf(_("Choose this option to use %s compression by default"), "BZIP2"));
256 compress_radiobtn
= gtk_radio_button_new_with_label(compression_group
, "COMPRESS");
257 compression_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(compress_radiobtn
));
258 gtk_widget_show(compress_radiobtn
);
259 gtk_box_pack_start(GTK_BOX (hbox1
), compress_radiobtn
, FALSE
, FALSE
, 0);
260 archiver_set_tooltip(compress_radiobtn
, g_strdup_printf(_("Choose this option to use %s compression by default"), "COMPRESS"));
262 #if ARCHIVE_VERSION_NUMBER >= 2006990
263 lzma_radiobtn
= gtk_radio_button_new_with_label(compression_group
, "LZMA");
264 compression_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(lzma_radiobtn
));
265 gtk_widget_show(lzma_radiobtn
);
266 gtk_box_pack_start(GTK_BOX (hbox1
), lzma_radiobtn
, FALSE
, FALSE
, 0);
267 archiver_set_tooltip(lzma_radiobtn
, g_strdup_printf(_("Choose this option to use %s compression by default"), "LZMA"));
269 xz_radiobtn
= gtk_radio_button_new_with_label(compression_group
, "XZ");
270 compression_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(xz_radiobtn
));
271 gtk_widget_show(xz_radiobtn
);
272 gtk_box_pack_start(GTK_BOX (hbox1
), xz_radiobtn
, FALSE
, FALSE
, 0);
273 archiver_set_tooltip(xz_radiobtn
, g_strdup_printf(_("Choose this option to use %s compression by default"), "XZ"));
276 #if ARCHIVE_VERSION_NUMBER >= 3000000
277 lzip_radiobtn
= gtk_radio_button_new_with_label(compression_group
, "LZIP");
278 compression_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(lzip_radiobtn
));
279 gtk_widget_show(lzip_radiobtn
);
280 gtk_box_pack_start(GTK_BOX (hbox1
), lzip_radiobtn
, FALSE
, FALSE
, 0);
281 archiver_set_tooltip(lzip_radiobtn
, g_strdup_printf(_("Choose this option to use %s compression by default"), "LZIP"));
284 #if ARCHIVE_VERSION_NUMBER >= 3001000
285 lrzip_radiobtn
= gtk_radio_button_new_with_label(compression_group
, "LRZIP");
286 compression_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(lrzip_radiobtn
));
287 gtk_widget_show(lrzip_radiobtn
);
288 gtk_box_pack_start(GTK_BOX (hbox1
), lrzip_radiobtn
, FALSE
, FALSE
, 0);
289 archiver_set_tooltip(lrzip_radiobtn
, g_strdup_printf(_("Choose this option to use %s compression by default"), "LRZIP"));
291 lzop_radiobtn
= gtk_radio_button_new_with_label(compression_group
, "LZOP");
292 compression_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(lzop_radiobtn
));
293 gtk_widget_show(lzop_radiobtn
);
294 gtk_box_pack_start(GTK_BOX (hbox1
), lzop_radiobtn
, FALSE
, FALSE
, 0);
295 archiver_set_tooltip(lzop_radiobtn
, g_strdup_printf(_("Choose this option to use %s compression by default"), "LZOP"));
297 grzip_radiobtn
= gtk_radio_button_new_with_label(compression_group
, "GRZIP");
298 compression_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(grzip_radiobtn
));
299 gtk_widget_show(grzip_radiobtn
);
300 gtk_box_pack_start(GTK_BOX (hbox1
), grzip_radiobtn
, FALSE
, FALSE
, 0);
301 archiver_set_tooltip(grzip_radiobtn
, g_strdup_printf(_("Choose this option to use %s compression by default"), "GRZIP"));
304 #if ARCHIVE_VERSION_NUMBER >= 3001900
305 lz4_radiobtn
= gtk_radio_button_new_with_label(compression_group
, "LZ4");
306 compression_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(lz4_radiobtn
));
307 gtk_widget_show(lz4_radiobtn
);
308 gtk_box_pack_start(GTK_BOX (hbox1
), lz4_radiobtn
, FALSE
, FALSE
, 0);
309 archiver_set_tooltip(lz4_radiobtn
, g_strdup_printf(_("Choose this option to use %s compression by default"), "LZ4"));
312 none_radiobtn
= gtk_radio_button_new_with_label(compression_group
, _("None"));
313 compression_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(none_radiobtn
));
314 gtk_widget_show(none_radiobtn
);
315 gtk_box_pack_start(GTK_BOX (hbox1
), none_radiobtn
, FALSE
, FALSE
, 0);
316 archiver_set_tooltip(none_radiobtn
, g_strdup_printf(_("Choose this option to use %s compression by default"), "NO"));
318 switch (archiver_prefs
.compression
) {
319 case COMPRESSION_GZIP
:
320 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gzip_radiobtn
), TRUE
);
322 case COMPRESSION_BZIP
:
323 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bzip_radiobtn
), TRUE
);
325 case COMPRESSION_COMPRESS
:
326 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compress_radiobtn
), TRUE
);
328 #if ARCHIVE_VERSION_NUMBER >= 2006990
329 case COMPRESSION_LZMA
:
330 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lzma_radiobtn
), TRUE
);
333 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(xz_radiobtn
), TRUE
);
336 #if ARCHIVE_VERSION_NUMBER >= 3000000
337 case COMPRESSION_LZIP
:
338 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lzip_radiobtn
), TRUE
);
341 #if ARCHIVE_VERSION_NUMBER >= 3001000
342 case COMPRESSION_LRZIP
:
343 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lrzip_radiobtn
), TRUE
);
345 case COMPRESSION_LZOP
:
346 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lzop_radiobtn
), TRUE
);
348 case COMPRESSION_GRZIP
:
349 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(grzip_radiobtn
), TRUE
);
352 #if ARCHIVE_VERSION_NUMBER >= 3001900
353 case COMPRESSION_LZ4
:
354 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lz4_radiobtn
), TRUE
);
357 case COMPRESSION_NONE
:
358 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(none_radiobtn
), TRUE
);
362 PACK_FRAME (vbox1
, frame
, _("Default format"));
364 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 4);
365 gtk_widget_show(hbox1
);
366 gtk_container_set_border_width(GTK_CONTAINER(hbox1
), 4);
367 gtk_container_add(GTK_CONTAINER(frame
), hbox1
);
369 tar_radiobtn
= gtk_radio_button_new_with_label(format_group
, "TAR");
370 format_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(tar_radiobtn
));
371 gtk_widget_show(tar_radiobtn
);
372 gtk_box_pack_start(GTK_BOX (hbox1
), tar_radiobtn
, FALSE
, FALSE
, 0);
373 archiver_set_tooltip(tar_radiobtn
, g_strdup_printf(_("Choose this option to use the %s as format by default"), "TAR"));
375 shar_radiobtn
= gtk_radio_button_new_with_label(format_group
, "SHAR");
376 format_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(shar_radiobtn
));
377 gtk_widget_show(shar_radiobtn
);
378 gtk_box_pack_start(GTK_BOX (hbox1
), shar_radiobtn
, FALSE
, FALSE
, 0);
379 archiver_set_tooltip(shar_radiobtn
, g_strdup_printf(_("Choose this option to use the %s as format by default"), "SHAR"));
381 cpio_radiobtn
= gtk_radio_button_new_with_label(format_group
, "CPIO");
382 format_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(cpio_radiobtn
));
383 gtk_widget_show(cpio_radiobtn
);
384 gtk_box_pack_start(GTK_BOX (hbox1
), cpio_radiobtn
, FALSE
, FALSE
, 0);
385 archiver_set_tooltip(cpio_radiobtn
, g_strdup_printf(_("Choose this option to use the %s as format by default"), "CPIO"));
387 pax_radiobtn
= gtk_radio_button_new_with_label(format_group
, "PAX");
388 format_group
= gtk_radio_button_get_group(GTK_RADIO_BUTTON(pax_radiobtn
));
389 gtk_widget_show(pax_radiobtn
);
390 gtk_box_pack_start(GTK_BOX (hbox1
), pax_radiobtn
, FALSE
, FALSE
, 0);
391 archiver_set_tooltip(pax_radiobtn
, g_strdup_printf(_("Choose this option to use the %s as format by default"), "PAX"));
393 switch (archiver_prefs
.format
) {
395 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tar_radiobtn
), TRUE
);
398 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shar_radiobtn
), TRUE
);
401 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cpio_radiobtn
), TRUE
);
404 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pax_radiobtn
), TRUE
);
408 PACK_FRAME (vbox1
, frame
, _("Default miscellaneous options"));
410 hbox1
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 4);
411 gtk_widget_show(hbox1
);
412 gtk_container_set_border_width(GTK_CONTAINER(hbox1
), 4);
413 gtk_container_add(GTK_CONTAINER(frame
), hbox1
);
415 PACK_CHECK_BUTTON(hbox1
, recursive_chkbtn
, _("Recursive"));
416 CLAWS_SET_TIP(recursive_chkbtn
,
417 _("Choose this option to include subfolders in the archives by default"));
418 PACK_CHECK_BUTTON(hbox1
, md5sum_chkbtn
, _("MD5sum"));
419 CLAWS_SET_TIP(md5sum_chkbtn
,
420 _("Choose this option to add MD5 checksums for each file in the archives by default.\n"
421 "Be aware though, that this dramatically increases the time it\n"
422 "will take to create the archives"));
424 PACK_CHECK_BUTTON(hbox1
, rename_chkbtn
, _("Rename"));
425 CLAWS_SET_TIP(rename_chkbtn
,
426 _("Choose this option to use descriptive names for each file in the archive.\n"
427 "The naming scheme: date_from@to@subject.\n"
428 "Names will be truncated to max 96 characters"));
430 PACK_CHECK_BUTTON(hbox1
, unlink_chkbtn
, _("Delete"));
431 CLAWS_SET_TIP(unlink_chkbtn
,
432 _("Choose this option to delete mails after archiving"));
434 if (archiver_prefs
.recursive
)
435 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(recursive_chkbtn
), TRUE
);
436 if (archiver_prefs
.md5sum
)
437 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(md5sum_chkbtn
), TRUE
);
438 if (archiver_prefs
.rename
)
439 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rename_chkbtn
), TRUE
);
440 if (archiver_prefs
.unlink
)
441 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(unlink_chkbtn
), TRUE
);
444 page
->save_folder
= save_folder
;
445 page
->gzip_radiobtn
= gzip_radiobtn
;
446 page
->bzip_radiobtn
= bzip_radiobtn
;
447 page
->compress_radiobtn
= compress_radiobtn
;
448 #if ARCHIVE_VERSION_NUMBER >= 2006990
449 page
->lzma_radiobtn
= lzma_radiobtn
;
450 page
->xz_radiobtn
= xz_radiobtn
;
452 #if ARCHIVE_VERSION_NUMBER >= 3000000
453 page
->lzip_radiobtn
= lzip_radiobtn
;
455 #if ARCHIVE_VERSION_NUMBER >= 3001000
456 page
->lrzip_radiobtn
= lrzip_radiobtn
;
457 page
->lzop_radiobtn
= lzop_radiobtn
;
458 page
->grzip_radiobtn
= grzip_radiobtn
;
460 #if ARCHIVE_VERSION_NUMBER >= 3001900
461 page
->lz4_radiobtn
= lz4_radiobtn
;
463 page
->none_radiobtn
= none_radiobtn
;
464 page
->tar_radiobtn
= tar_radiobtn
;
465 page
->shar_radiobtn
= shar_radiobtn
;
466 page
->cpio_radiobtn
= cpio_radiobtn
;
467 page
->pax_radiobtn
= pax_radiobtn
;
468 page
->recursive_chkbtn
= recursive_chkbtn
;
469 page
->md5sum_chkbtn
= md5sum_chkbtn
;
470 page
->rename_chkbtn
= rename_chkbtn
;
471 page
->unlink_chkbtn
= unlink_chkbtn
;
473 page
->page
.widget
= vbox1
;
476 static void destroy_archiver_prefs_page(PrefsPage
*page
)
481 static void save_archiver_prefs(PrefsPage
* _page
)
483 struct ArchiverPrefsPage
*page
= (struct ArchiverPrefsPage
*) _page
;
485 gchar
*rc_file_path
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
,
488 archiver_prefs
.save_folder
= gtk_editable_get_chars(GTK_EDITABLE(page
->save_folder
), 0, -1);
489 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->gzip_radiobtn
)))
490 archiver_prefs
.compression
= COMPRESSION_GZIP
;
491 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->bzip_radiobtn
)))
492 archiver_prefs
.compression
= COMPRESSION_BZIP
;
493 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->compress_radiobtn
)))
494 archiver_prefs
.compression
= COMPRESSION_COMPRESS
;
495 #if ARCHIVE_VERSION_NUMBER >= 2006990
496 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->lzma_radiobtn
)))
497 archiver_prefs
.compression
= COMPRESSION_LZMA
;
498 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->xz_radiobtn
)))
499 archiver_prefs
.compression
= COMPRESSION_XZ
;
501 #if ARCHIVE_VERSION_NUMBER >= 3000000
502 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->lzip_radiobtn
)))
503 archiver_prefs
.compression
= COMPRESSION_LZIP
;
505 #if ARCHIVE_VERSION_NUMBER >= 3001000
506 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->lrzip_radiobtn
)))
507 archiver_prefs
.compression
= COMPRESSION_LRZIP
;
508 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->lzop_radiobtn
)))
509 archiver_prefs
.compression
= COMPRESSION_LZOP
;
510 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->grzip_radiobtn
)))
511 archiver_prefs
.compression
= COMPRESSION_GRZIP
;
513 #if ARCHIVE_VERSION_NUMBER >= 3001900
514 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->lz4_radiobtn
)))
515 archiver_prefs
.compression
= COMPRESSION_LZ4
;
517 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->none_radiobtn
)))
518 archiver_prefs
.compression
= COMPRESSION_NONE
;
520 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->tar_radiobtn
)))
521 archiver_prefs
.format
= FORMAT_TAR
;
522 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->shar_radiobtn
)))
523 archiver_prefs
.format
= FORMAT_SHAR
;
524 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->cpio_radiobtn
)))
525 archiver_prefs
.format
= FORMAT_CPIO
;
526 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->pax_radiobtn
)))
527 archiver_prefs
.format
= FORMAT_PAX
;
529 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->recursive_chkbtn
)))
530 archiver_prefs
.recursive
= TRUE
;
532 archiver_prefs
.recursive
= FALSE
;
533 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->md5sum_chkbtn
)))
534 archiver_prefs
.md5sum
= TRUE
;
536 archiver_prefs
.md5sum
= FALSE
;
537 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->rename_chkbtn
)))
538 archiver_prefs
.rename
= TRUE
;
540 archiver_prefs
.rename
= FALSE
;
541 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->unlink_chkbtn
)))
542 archiver_prefs
.unlink
= TRUE
;
544 archiver_prefs
.unlink
= FALSE
;
547 pref_file
= prefs_write_open(rc_file_path
);
548 g_free(rc_file_path
);
551 (prefs_set_block_label(pref_file
, PREFS_BLOCK_NAME
) < 0))
554 if (prefs_write_param(param
, pref_file
->fp
) < 0) {
555 g_warning("failed to write Archiver plugin configuration");
556 prefs_file_close_revert(pref_file
);
559 if (fprintf(pref_file
->fp
, "\n") < 0) {
560 FILE_OP_ERROR(rc_file_path
, "fprintf");
561 prefs_file_close_revert(pref_file
);
563 prefs_file_close(pref_file
);