2011-10-07 [colin] 3.7.10cvs21
[claws.git] / src / prefs_other.c
index ced063934b2c7c0b7855e0ea32b458cba62f78db..50642d29df2214bb5053b61c304be7b977d5fadf 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2005-2007 Colin Leroy <colin@colino.net> & The Claws Mail Team
+ * Copyright (C) 2005-2011 Colin Leroy <colin@colino.net> & The Claws Mail Team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -59,6 +59,8 @@ typedef struct _OtherPage
        GtkWidget *checkbtn_askonfilter;
        GtkWidget *checkbtn_use_shred;
        GtkWidget *checkbtn_real_time_sync;
+       GtkWidget *flush_metadata_faster_radiobtn;
+       GtkWidget *flush_metadata_safer_radiobtn;
 } OtherPage;
 
 static struct KeybindDialog {
@@ -157,7 +159,7 @@ static void prefs_keybind_select(void)
 static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
                                          gpointer data)
 {
-       if (event && event->keyval == GDK_Escape)
+       if (event && event->keyval == GDK_KEY_Escape)
                prefs_keybind_cancel();
        return FALSE;
 }
@@ -444,7 +446,7 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
 
        GtkWidget *label_iotimeout;
        GtkWidget *spinbtn_iotimeout;
-       GtkObject *spinbtn_iotimeout_adj;
+       GtkAdjustment *spinbtn_iotimeout_adj;
 
        GtkWidget *vbox2;
        GtkWidget *checkbtn_askonclean;
@@ -452,6 +454,12 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
        GtkWidget *checkbtn_use_shred;
        GtkWidget *checkbtn_real_time_sync;
 
+       GtkWidget *frame_metadata;
+       GtkWidget *vbox_metadata;
+       GtkWidget *metadata_label;
+       GtkWidget *flush_metadata_faster_radiobtn;
+       GtkWidget *flush_metadata_safer_radiobtn;
+
        gchar *shred_binary = NULL;
        CLAWS_TIP_DECL();
 
@@ -503,6 +511,28 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
        g_signal_connect (G_OBJECT (button_keybind), "clicked",
                          G_CALLBACK (prefs_keybind_select), NULL);
 
+
+       vbox_metadata = gtkut_get_options_frame(vbox1, &frame_metadata, _("Metadata handling"));
+       metadata_label = gtk_label_new(_("Safer mode asks the OS to write metadata to disk directly;\n"
+                                        "it avoids data loss after crashes but can take some time."));
+       gtk_misc_set_alignment(GTK_MISC(metadata_label), 0, 0);
+       gtk_box_pack_start (GTK_BOX (vbox_metadata), metadata_label, FALSE, FALSE, 0);
+       flush_metadata_safer_radiobtn = gtk_radio_button_new_with_label(NULL, _("Safer"));
+       flush_metadata_faster_radiobtn = gtk_radio_button_new_with_label_from_widget(
+                                          GTK_RADIO_BUTTON(flush_metadata_safer_radiobtn), _("Faster"));
+       hbox1 = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox1);
+       gtk_box_pack_start (GTK_BOX (vbox_metadata), hbox1, FALSE, FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (hbox1), flush_metadata_safer_radiobtn, FALSE, FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (hbox1), flush_metadata_faster_radiobtn, FALSE, FALSE, 0);
+       
+       if (prefs_common.flush_metadata)
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flush_metadata_safer_radiobtn), TRUE);
+       else
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flush_metadata_faster_radiobtn), TRUE);
+
+       gtk_widget_show_all(frame_metadata);
+
        hbox1 = gtk_hbox_new (FALSE, 8);
        gtk_widget_show (hbox1);
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
@@ -511,7 +541,7 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
        gtk_widget_show (label_iotimeout);
        gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
 
-       spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 10);
+       spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 0);
        spinbtn_iotimeout = gtk_spin_button_new
                (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
        gtk_widget_show (spinbtn_iotimeout);
@@ -584,7 +614,8 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
        prefs_other->checkbtn_askonfilter = checkbtn_askonfilter;
        prefs_other->checkbtn_use_shred = checkbtn_use_shred;
        prefs_other->checkbtn_real_time_sync = checkbtn_real_time_sync;
-
+       prefs_other->flush_metadata_safer_radiobtn = flush_metadata_safer_radiobtn;
+       prefs_other->flush_metadata_faster_radiobtn = flush_metadata_faster_radiobtn;
        prefs_other->page.widget = vbox1;
 }
 
@@ -605,6 +636,8 @@ static void prefs_other_save(PrefsPage *_page)
                GTK_TOGGLE_BUTTON(page->checkbtn_warnqueued)); 
        prefs_common.io_timeout_secs = gtk_spin_button_get_value_as_int(
                GTK_SPIN_BUTTON(page->spinbtn_iotimeout));
+       prefs_common.flush_metadata = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->flush_metadata_safer_radiobtn));
        sock_set_io_timeout(prefs_common.io_timeout_secs);
 #ifdef HAVE_LIBETPAN
        imap_main_set_timeout(prefs_common.io_timeout_secs);
@@ -646,10 +679,11 @@ OtherPage *prefs_other;
 void prefs_other_init(void)
 {
        OtherPage *page;
-       static gchar *path[2];
+       static gchar *path[3];
 
        path[0] = _("Other");
-       path[1] = NULL;
+       path[1] = _("Miscellaneous");
+       path[2] = NULL;
 
        page = g_new0(OtherPage, 1);
        page->page.path = path;