2007-05-03 [wwp] 2.9.1cvs41
[claws.git] / src / prefs_common.c
index f6ba59102ca4fb9efa093851ae48465368226539..3b86b94935bfd7c9c0b40451cf5e3ba1a3decdc8 100644 (file)
@@ -101,7 +101,6 @@ static PrefParam param_os_specific[] = {
          &prefs_common.smallfont,              P_STRING, NULL, NULL, NULL},
        {"normal_font_gtk2",    "Sans 9",
          &prefs_common.normalfont,             P_STRING, NULL, NULL, NULL},
-
        /* Message */
        {"attach_save_directory", NULL,
         &prefs_common.attach_save_dir, P_STRING, NULL, NULL, NULL},
@@ -162,7 +161,7 @@ static PrefParam param[] = {
        P_BOOL, NULL, NULL, NULL},
        {"newmail_notify_cmd", "", &SPECIFIC_PREFS.newmail_notify_cmd, P_STRING,
         NULL, NULL, NULL},
-       {"receive_dialog_mode", "1", &prefs_common.recv_dialog_mode, P_ENUM,
+       {"receive_dialog_mode", "2", &prefs_common.recv_dialog_mode, P_ENUM,
         NULL, NULL, NULL},
        {"receivewin_width", "460", &prefs_common.receivewin_width, P_INT,
         NULL, NULL, NULL},
@@ -178,7 +177,7 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"confirm_send_queued_messages", "FALSE", &prefs_common.confirm_send_queued_messages,
         P_BOOL, NULL, NULL, NULL},
-       {"send_dialog_mode", "0", &prefs_common.send_dialog_mode, P_ENUM,
+       {"send_dialog_mode", "1", &prefs_common.send_dialog_mode, P_ENUM,
         NULL, NULL, NULL},
        {"sendwin_width", "460", &prefs_common.sendwin_width, P_INT,
         NULL, NULL, NULL},
@@ -263,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,
@@ -296,6 +300,7 @@ static PrefParam param[] = {
          &prefs_common.normalfont_gtk1,        P_STRING, NULL, NULL, NULL},
 
        /* new fonts */
+#ifndef MAEMO
        {"widget_font_gtk2",    NULL,
          &SPECIFIC_PREFS.widgetfont,           P_STRING, NULL, NULL, NULL},
        {"message_font_gtk2",   "Monospace 9",
@@ -306,7 +311,18 @@ static PrefParam param[] = {
          &SPECIFIC_PREFS.smallfont,            P_STRING, NULL, NULL, NULL},
        {"normal_font_gtk2",    "Sans 9",
          &SPECIFIC_PREFS.normalfont,           P_STRING, NULL, NULL, NULL},
-
+#else
+       {"widget_font_gtk2",    NULL,
+         &SPECIFIC_PREFS.widgetfont,           P_STRING, NULL, NULL, NULL},
+       {"message_font_gtk2",   "Monospace 8",
+        &SPECIFIC_PREFS.textfont,                      P_STRING, NULL, NULL, NULL},
+        {"print_font_gtk2",     "Monospace 8",
+         &SPECIFIC_PREFS.printfont,             P_STRING, NULL, NULL, NULL},
+       {"small_font_gtk2",     "Sans 8",
+         &SPECIFIC_PREFS.smallfont,            P_STRING, NULL, NULL, NULL},
+       {"normal_font_gtk2",    "Sans 8",
+         &SPECIFIC_PREFS.normalfont,           P_STRING, NULL, NULL, NULL},
+#endif
        /* custom colors */
        {"custom_color1", "#ff9900", &prefs_common.custom_colorlabel[0].color, P_COLOR,
         NULL, NULL, NULL},
@@ -400,22 +416,29 @@ static PrefParam param[] = {
 
        {"enable_thread", "TRUE", &prefs_common.enable_thread, P_BOOL,
         NULL, NULL, NULL},
+#ifndef MAEMO
        {"toolbar_style", "3", &prefs_common.toolbar_style, P_ENUM,
         NULL, NULL, NULL},
+#else
+       {"toolbar_style", "1", &prefs_common.toolbar_style, P_ENUM,
+        NULL, NULL, NULL},
+#endif
        {"toolbar_detachable", "FALSE", &prefs_common.toolbar_detachable, P_BOOL,
         NULL, NULL, NULL},
        {"show_statusbar", "TRUE", &prefs_common.show_statusbar, P_BOOL,
         NULL, NULL, NULL},
+#ifndef MAEMO
        {"show_searchbar", "TRUE", &prefs_common.show_searchbar, P_BOOL,
         NULL, NULL, NULL},
-
+#else
+       {"show_searchbar", "FALSE", &prefs_common.show_searchbar, P_BOOL,
+        NULL, NULL, NULL},
+#endif
 
        {"summary_col_show_mark", "TRUE",
         &prefs_common.summary_col_visible[S_COL_MARK], P_BOOL, NULL, NULL, NULL},
        {"summary_col_show_unread", "TRUE",
         &prefs_common.summary_col_visible[S_COL_STATUS], P_BOOL, NULL, NULL, NULL},
-       {"summary_col_show_mime", "TRUE",
-        &prefs_common.summary_col_visible[S_COL_MIME], P_BOOL, NULL, NULL, NULL},
        {"summary_col_show_subject", "TRUE",
         &prefs_common.summary_col_visible[S_COL_SUBJECT], P_BOOL, NULL, NULL, NULL},
        {"summary_col_show_from", "TRUE",
@@ -424,6 +447,8 @@ static PrefParam param[] = {
         &prefs_common.summary_col_visible[S_COL_TO], P_BOOL, NULL, NULL, NULL},
        {"summary_col_show_date", "TRUE",
         &prefs_common.summary_col_visible[S_COL_DATE], P_BOOL, NULL, NULL, NULL},
+       {"summary_col_show_mime", "TRUE",
+        &prefs_common.summary_col_visible[S_COL_MIME], P_BOOL, NULL, NULL, NULL},
        {"summary_col_show_size", "TRUE",
         &prefs_common.summary_col_visible[S_COL_SIZE], P_BOOL, NULL, NULL, NULL},
        {"summary_col_show_number", "FALSE",
@@ -462,12 +487,22 @@ static PrefParam param[] = {
         &prefs_common.summary_col_size[S_COL_STATUS], P_INT, NULL, NULL, NULL},
        {"summary_col_size_mime", "10",
         &prefs_common.summary_col_size[S_COL_MIME], P_INT, NULL, NULL, NULL},
+#ifndef MAEMO
        {"summary_col_size_subject", "200",
         &prefs_common.summary_col_size[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
        {"summary_col_size_from", "120",
         &prefs_common.summary_col_size[S_COL_FROM], P_INT, NULL, NULL, NULL},
        {"summary_col_size_to", "120",
         &prefs_common.summary_col_size[S_COL_TO], P_INT, NULL, NULL, NULL},
+#else
+       {"summary_col_size_subject", "300",
+        &prefs_common.summary_col_size[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
+       {"summary_col_size_from", "150",
+        &prefs_common.summary_col_size[S_COL_FROM], P_INT, NULL, NULL, NULL},
+       {"summary_col_size_to", "150",
+        &prefs_common.summary_col_size[S_COL_TO], P_INT, NULL, NULL, NULL},
+
+#endif
        {"summary_col_size_date", "118",
         &prefs_common.summary_col_size[S_COL_DATE], P_INT, NULL, NULL, NULL},
        {"summary_col_size_size", "45",
@@ -509,6 +544,7 @@ static PrefParam param[] = {
        {"folder_col_pos_total", "3",
         &prefs_common.folder_col_pos[F_COL_TOTAL], P_INT, NULL, NULL, NULL},
 
+#ifndef MAEMO
        {"folder_col_size_folder", "120",
         &prefs_common.folder_col_size[F_COL_FOLDER], P_INT, NULL, NULL, NULL},
        {"folder_col_size_new", "32",
@@ -517,7 +553,16 @@ static PrefParam param[] = {
         &prefs_common.folder_col_size[F_COL_UNREAD], P_INT, NULL, NULL, NULL},
        {"folder_col_size_total", "32",
         &prefs_common.folder_col_size[F_COL_TOTAL], P_INT, NULL, NULL, NULL},
-
+#else
+       {"folder_col_size_folder", "400",
+        &prefs_common.folder_col_size[F_COL_FOLDER], P_INT, NULL, NULL, NULL},
+       {"folder_col_size_new", "32",
+        &prefs_common.folder_col_size[F_COL_NEW], P_INT, NULL, NULL, NULL},
+       {"folder_col_size_unread", "32",
+        &prefs_common.folder_col_size[F_COL_UNREAD], P_INT, NULL, NULL, NULL},
+       {"folder_col_size_total", "32",
+        &prefs_common.folder_col_size[F_COL_TOTAL], P_INT, NULL, NULL, NULL},
+#endif
        {"summaryview_width", "500", &prefs_common.summaryview_width, P_INT,
         NULL, NULL, NULL},
        {"summaryview_height", "244", &prefs_common.summaryview_height, P_INT,
@@ -546,6 +591,7 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"mainwin_y", "64", &prefs_common.mainwin_y, P_INT,
         NULL, NULL, NULL},
+#ifndef MAEMO
        {"mainwin_width", "800", &prefs_common.mainwin_width, P_INT,
         NULL, NULL, NULL},
        {"mainwin_height", "600", &prefs_common.mainwin_height, P_INT,
@@ -562,6 +608,24 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"compose_height", "560", &prefs_common.compose_height, P_INT,
         NULL, NULL, NULL},
+#else
+       {"mainwin_width", "700", &prefs_common.mainwin_width, P_INT,
+        NULL, NULL, NULL},
+       {"mainwin_height", "470", &prefs_common.mainwin_height, P_INT,
+        NULL, NULL, NULL},
+       {"messagewin_width", "700", &prefs_common.msgwin_width, P_INT,
+        NULL, NULL, NULL},
+       {"messagewin_height", "470", &prefs_common.msgwin_height, P_INT,
+        NULL, NULL, NULL},
+       {"sourcewin_width", "700", &prefs_common.sourcewin_width, P_INT,
+        NULL, NULL, NULL},
+       {"sourcewin_height", "470", &prefs_common.sourcewin_height, P_INT,
+        NULL, NULL, NULL},
+       {"compose_width", "700", &prefs_common.compose_width, P_INT,
+        NULL, NULL, NULL},
+       {"compose_height", "470", &prefs_common.compose_height, P_INT,
+        NULL, NULL, NULL},
+#endif
        {"compose_x", "0", &prefs_common.compose_x, P_INT,
         NULL, NULL, NULL},
        {"compose_y", "0", &prefs_common.compose_y, P_INT,
@@ -638,9 +702,13 @@ static PrefParam param[] = {
         &SPECIFIC_PREFS.mime_open_cmd,     P_STRING, NULL, NULL, NULL},
 
        /* Interface */
+#ifndef MAEMO
        {"layout_mode", "0", &prefs_common.layout_mode, P_INT,
         NULL, NULL, NULL},
-
+#else
+       {"layout_mode", "5", &prefs_common.layout_mode, P_INT,
+        NULL, NULL, NULL},
+#endif
        /* {"emulate_emacs", "FALSE", &prefs_common.emulate_emacs, P_BOOL,
         NULL, NULL, NULL}, */
        {"always_show_message_when_selected", "FALSE",
@@ -700,8 +768,13 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"summary_quicksearch_type", "0", &prefs_common.summary_quicksearch_type, P_INT,
         NULL, NULL, NULL},
+#ifndef MAEMO
        {"summary_quicksearch_recurse", "1", &prefs_common.summary_quicksearch_recurse, P_INT,
         NULL, NULL, NULL},
+#else
+       {"summary_quicksearch_recurse", "0", &prefs_common.summary_quicksearch_recurse, P_INT,
+        NULL, NULL, NULL},
+#endif
 
        {"io_timeout_secs", "60", &prefs_common.io_timeout_secs,
         P_INT, NULL, NULL, NULL},
@@ -709,10 +782,12 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"important_score", "1", &prefs_common.important_score, P_INT,
         NULL, NULL, NULL},
-        {"clip_log", "TRUE", &prefs_common.cliplog, P_BOOL,
+
+    {"clip_log", "TRUE", &prefs_common.cliplog, P_BOOL,
         NULL, NULL, NULL},
        {"log_length", "500", &prefs_common.loglength, P_INT,
         NULL, NULL, NULL},
+
        {"log_msg_color", "#00af00", &prefs_common.log_msg_color, P_COLOR,
         NULL, NULL, NULL},
        {"log_warn_color", "#af0000", &prefs_common.log_warn_color, P_COLOR,
@@ -723,6 +798,31 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"log_out_color", "#0000ef", &prefs_common.log_out_color, P_COLOR,
         NULL, NULL, NULL},
+       {"log_status_ok_color", "#00af00", &prefs_common.log_status_ok_color, P_COLOR,
+        NULL, NULL, NULL},
+       {"log_status_nok_color", "#0000af", &prefs_common.log_status_nok_color, P_COLOR,
+        NULL, NULL, NULL},
+       {"log_status_skip_color", "#aa00aa", &prefs_common.log_status_skip_color, P_COLOR,
+        NULL, NULL, NULL},
+
+    {"enable_filtering_debug", "FALSE", &prefs_common.enable_filtering_debug, P_BOOL,
+        NULL, NULL, NULL},
+    {"filtering_debug_level", "1", &prefs_common.filtering_debug_level, P_INT,
+        NULL, NULL, NULL},
+    {"enable_filtering_debug_inc", "TRUE", &prefs_common.enable_filtering_debug_inc, P_BOOL,
+        NULL, NULL, NULL},
+    {"enable_filtering_debug_manual", "TRUE", &prefs_common.enable_filtering_debug_manual, P_BOOL,
+        NULL, NULL, NULL},
+    {"enable_filtering_debug_folder_proc", "FALSE", &prefs_common.enable_filtering_debug_folder_proc, P_BOOL,
+        NULL, NULL, NULL},
+    {"enable_filtering_debug_pre_proc", "FALSE", &prefs_common.enable_filtering_debug_pre_proc, P_BOOL,
+        NULL, NULL, NULL},
+    {"enable_filtering_debug_post_proc", "FALSE", &prefs_common.enable_filtering_debug_post_proc, P_BOOL,
+        NULL, NULL, NULL},
+    {"filtering_debug_clip_log", "TRUE", &prefs_common.filtering_debug_cliplog, P_BOOL,
+        NULL, NULL, NULL},
+       {"filtering_debug_log_length", "500", &prefs_common.filtering_debug_loglength, P_INT,
+        NULL, NULL, NULL},
 
        {"gtk_can_change_accels", "TRUE", &prefs_common.gtk_can_change_accels, P_BOOL,
         NULL, NULL, NULL},
@@ -746,7 +846,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},
@@ -786,6 +886,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,
@@ -801,6 +904,11 @@ static PrefParam param[] = {
        {"logwin_height", "-1", &prefs_common.logwin_height, P_INT,
         NULL, NULL, NULL},
 
+       {"filtering_debugwin_width", "600", &prefs_common.filtering_debugwin_width, P_INT,
+        NULL, NULL, NULL},
+       {"filtering_debugwin_height", "-1", &prefs_common.filtering_debugwin_height, P_INT,
+        NULL, NULL, NULL},
+
        {"folderselwin_width", "300", &prefs_common.folderselwin_width, P_INT,
         NULL, NULL, NULL},
        {"folderselwin_height", "-1", &prefs_common.folderselwin_height, P_INT,
@@ -842,10 +950,17 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"hover_timeout", "500", &prefs_common.hover_timeout, P_INT,
         NULL, NULL, NULL},
+#ifndef MAEMO
        {"cache_max_mem_usage", "4096", &prefs_common.cache_max_mem_usage, P_INT,
         NULL, NULL, NULL},
        {"cache_min_keep_time", "15", &prefs_common.cache_min_keep_time, P_INT,
         NULL, NULL, NULL},
+#else
+       {"cache_max_mem_usage", "4096", &prefs_common.cache_max_mem_usage, P_INT,
+        NULL, NULL, NULL},
+       {"cache_min_keep_time", "0", &prefs_common.cache_min_keep_time, P_INT,
+        NULL, NULL, NULL},
+#endif
        {"thread_by_subject_max_age", "10", &prefs_common.thread_by_subject_max_age,
        P_INT, NULL, NULL, NULL },
        {"summary_quicksearch_sticky", "1", &prefs_common.summary_quicksearch_sticky, P_INT,
@@ -864,7 +979,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}
 };
 
@@ -952,6 +1073,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
  */
@@ -959,25 +1087,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);
@@ -1154,3 +1302,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;
+}