2007-06-12 [colin] 2.9.2cvs57
[claws.git] / src / prefs_common.c
index 45c760d88b3ea24a9208664b797a3d81c343ec2e..904f955ea5375e3c58c458c040eceb6d7159602d 100644 (file)
@@ -262,8 +262,13 @@ static PrefParam param[] = {
        {"default_reply_list", "TRUE", &prefs_common.default_reply_list, P_BOOL,
         NULL, NULL, NULL},
 
+#ifndef MAEMO
        {"show_ruler", "TRUE", &prefs_common.show_ruler, P_BOOL,
         NULL, NULL, NULL},
+#else
+       {"show_ruler", "FALSE", &prefs_common.show_ruler, P_BOOL,
+        NULL, NULL, NULL},
+#endif
 
        /* Quote */
        {"reply_quote_mark", "> ", &prefs_common.quotemark, P_STRING,
@@ -709,8 +714,22 @@ static PrefParam param[] = {
        {"always_show_message_when_selected", "FALSE",
         &prefs_common.always_show_msg,
         P_BOOL, NULL, NULL, NULL},
-       {"select_on_entry", "2", &prefs_common.select_on_entry,
+       {"select_on_entry", "3", &prefs_common.select_on_entry,
         P_ENUM, NULL, NULL, NULL},
+
+       {"summary_select_prio1", "0", &prefs_common.summary_select_prio[0], P_ENUM,
+        NULL, NULL, NULL},
+       {"summary_select_prio2", "0", &prefs_common.summary_select_prio[1], P_ENUM,
+        NULL, NULL, NULL},
+       {"summary_select_prio3", "0", &prefs_common.summary_select_prio[2], P_ENUM,
+        NULL, NULL, NULL},
+       {"summary_select_prio4", "0", &prefs_common.summary_select_prio[3], P_ENUM,
+        NULL, NULL, NULL},
+       {"summary_select_prio5", "0", &prefs_common.summary_select_prio[4], P_ENUM,
+        NULL, NULL, NULL},
+       {"summary_select_prio6", "0", &prefs_common.summary_select_prio[5], P_ENUM,
+        NULL, NULL, NULL},
+
        {"mark_as_read_on_new_window", "FALSE",
         &prefs_common.mark_as_read_on_new_window,
         P_BOOL, NULL, NULL, NULL},
@@ -841,7 +860,7 @@ static PrefParam param[] = {
        {"matcherwin_height", "-1", &prefs_common.matcherwin_height, P_INT,
         NULL, NULL, NULL},
 
-       {"templateswin_width", "440", &prefs_common.templateswin_width, P_INT,
+       {"templateswin_width", "480", &prefs_common.templateswin_width, P_INT,
         NULL, NULL, NULL},
        {"templateswin_height", "-1", &prefs_common.templateswin_height, P_INT,
         NULL, NULL, NULL},
@@ -881,6 +900,9 @@ static PrefParam param[] = {
        {"folderitemwin_height", "-1", &prefs_common.folderitemwin_height, P_INT,
         NULL, NULL, NULL},
 
+       {"zero_replacement_char", "0", &prefs_common.zero_replacement, P_STRING,
+        NULL, NULL, NULL},
+
        {"editaccountwin_width", "500", &prefs_common.editaccountwin_width, P_INT,
         NULL, NULL, NULL},
        {"editaccountwin_height", "-1", &prefs_common.editaccountwin_height, P_INT,
@@ -955,10 +977,16 @@ static PrefParam param[] = {
 #endif
        {"thread_by_subject_max_age", "10", &prefs_common.thread_by_subject_max_age,
        P_INT, NULL, NULL, NULL },
+       {"last_opened_folder", "", &prefs_common.last_opened_folder,
+       P_STRING, NULL, NULL, NULL },
+       {"goto_last_folder_on_startup", "FALSE", &prefs_common.goto_last_folder_on_startup,
+       P_BOOL, NULL, NULL, NULL },
        {"summary_quicksearch_sticky", "1", &prefs_common.summary_quicksearch_sticky, P_INT,
         NULL, NULL, NULL},
        {"summary_quicksearch_dynamic", "0", &prefs_common.summary_quicksearch_dynamic, P_INT,
         NULL, NULL, NULL},
+       {"summary_quicksearch_autorun", "0", &prefs_common.summary_quicksearch_autorun, P_INT,
+        NULL, NULL, NULL},
        {"statusbar_update_step", "10", &prefs_common.statusbar_update_step, P_INT,
         NULL, NULL, NULL},
        {"compose_no_markup", "FALSE", &prefs_common.compose_no_markup, P_BOOL,
@@ -971,7 +999,13 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"unsafe_ssl_certs", "FALSE", &prefs_common.unsafe_ssl_certs, P_BOOL,
         NULL, NULL, NULL},
-
+#ifndef MAEMO
+       {"real_time_sync", "FALSE", &prefs_common.real_time_sync, P_BOOL,
+        NULL, NULL, NULL},
+#else
+       {"real_time_sync", "TRUE", &prefs_common.real_time_sync, P_BOOL,
+        NULL, NULL, NULL},
+#endif
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
 
@@ -1059,6 +1093,13 @@ void prefs_common_read_config(void)
        colorlabel_update_colortable_from_prefs();
 }
 
+#define TRY(func) \
+if (!(func)) \
+{ \
+       g_warning("failed to write\n"); \
+       goto out;                       \
+} \
+
 /*
  * Save history list to the specified history file
  */
@@ -1066,25 +1107,45 @@ static void prefs_common_save_history(const gchar *history, GList *list)
 {
        GList *cur;
        FILE *fp;
-       gchar *path;
+       gchar *path, *tmp_path;
 
        path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
                           NULL);
-       if ((fp = g_fopen(path, "wb")) == NULL) {
-               FILE_OP_ERROR(path, "fopen");
-               g_free(path);
-               return;
+       tmp_path = g_strconcat(path, ".tmp", NULL);
+
+       if ((fp = g_fopen(tmp_path, "wb")) == NULL) {
+               FILE_OP_ERROR(tmp_path, "fopen");
+               goto out;
        }
 
        for (cur = list; cur != NULL; cur = cur->next) {
-               fputs((gchar *)cur->data, fp);
-               fputc('\n', fp);
+               TRY(fputs((gchar *)cur->data, fp) != EOF &&
+                   fputc('\n', fp) != EOF);
        }
 
-       fclose(fp);
+       if (fclose(fp) == EOF) {
+               FILE_OP_ERROR(tmp_path, "fclose");
+               fp = NULL;
+               goto out;
+       }
+       fp = NULL;
+#ifdef G_OS_WIN32
+       g_unlink(path);
+#endif
+       if (g_rename(tmp_path, path) < 0) {
+               FILE_OP_ERROR(path, "rename");
+               goto out;
+       }
+
+out:
+       if (fp)
+               fclose(fp);
+       g_free(tmp_path);
        g_free(path);
 }
 
+#undef TRY
+
 void prefs_common_write_config(void)
 {
        prefs_write_config(param, "Common", COMMON_RC);
@@ -1188,16 +1249,20 @@ void pref_set_textview_from_pref(GtkTextView *textview, const gchar *txt)
        GtkTextBuffer *buffer;
        gchar *out = NULL;
 
-       g_return_if_fail( txt != NULL );
        g_return_if_fail( textview != NULL );
 
        buffer = gtk_text_view_get_buffer(textview);
-       out = malloc(strlen(txt)+1);
 
-       pref_get_unescaped_pref(out, txt);
+       if (!txt) {
+               gtk_text_buffer_set_text(buffer, "", -1);
+       } else {
+               out = malloc(strlen(txt)+1);
+
+               pref_get_unescaped_pref(out, txt);
 
-       gtk_text_buffer_set_text(buffer, out?out:"", -1);
-       g_free(out);
+               gtk_text_buffer_set_text(buffer, out?out:"", -1);
+               g_free(out);
+       }
 }
 
 /* set the contents of a gtkentry widget from the internal \-escaped
@@ -1206,15 +1271,17 @@ void pref_set_entry_from_pref(GtkEntry *entry, const gchar *txt)
 {
        gchar *out = NULL;
 
-       g_return_if_fail( txt != NULL );
        g_return_if_fail( entry != NULL );
+       if (!txt) {
+               gtk_entry_set_text(entry, "");
+       } else {
+               out = malloc(strlen(txt)+1);
 
-       out = malloc(strlen(txt)+1);
-
-       pref_get_unescaped_pref(out, txt);
+               pref_get_unescaped_pref(out, txt);
 
-       gtk_entry_set_text(entry, out?out:"");
-       g_free(out);
+               gtk_entry_set_text(entry, out?out:"");
+               g_free(out);
+       }
 }
 
 /* get the \-escaped internal representation of a pref from the contents of
@@ -1261,3 +1328,20 @@ gboolean prefs_common_unsafe_ssl_certs(void)
 {
        return prefs_common.unsafe_ssl_certs;
 }
+
+/**
+   return the translated name of a header, if the translate_header option is
+   set, otherwise return the untranslated header name (header_name itself).
+   this function is provided for convenience, it's an interface to
+   prefs_common.trans_hdr.
+   works with header names either with or without trailing colon, provided
+   that gettext found such header name in the sources (they should all be
+   found in src/gtk/headers.h anyway).
+*/
+const gchar *prefs_common_translated_header_name(const gchar *header_name)
+{
+       if (header_name == NULL || *header_name == '\0')
+               return header_name;
+
+       return prefs_common.trans_hdr ? gettext(header_name) : header_name;
+}