2007-11-23 [wwp] 3.1.0cvs25
[claws.git] / src / prefs_common.c
index 0f3f618975aea69a53dd411ee3d68bbd70debed2..a936c7699185bbd8c57a209555b1932ee75706fc 100644 (file)
@@ -4,7 +4,7 @@
  *
  * 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
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #ifdef HAVE_CONFIG_H
@@ -139,6 +139,10 @@ static PrefParam param_os_specific[] = {
  */
 
 static PrefParam param[] = {
+#ifdef MAEMO
+       {"data_root", "", &prefs_common.data_root, P_STRING,
+        NULL, NULL, NULL},
+#endif
        /* Receive */
        {"use_ext_inc", "FALSE", &prefs_common.use_extinc, P_BOOL,
         NULL, NULL, NULL},
@@ -161,6 +165,12 @@ static PrefParam param[] = {
        P_BOOL, NULL, NULL, NULL},
        {"newmail_notify_cmd", "", &SPECIFIC_PREFS.newmail_notify_cmd, P_STRING,
         NULL, NULL, NULL},
+#ifdef MAEMO
+       {"maemo_play_sound", "FALSE", &prefs_common.maemo_play_sound, P_BOOL,
+        NULL, NULL, NULL},
+       {"maemo_show_banner", "FALSE", &prefs_common.maemo_show_banner, P_BOOL,
+        NULL, NULL, NULL},
+#endif
        {"receive_dialog_mode", "2", &prefs_common.recv_dialog_mode, P_ENUM,
         NULL, NULL, NULL},
        {"receivewin_width", "460", &prefs_common.receivewin_width, P_INT,
@@ -177,7 +187,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", "1", &prefs_common.send_dialog_mode, P_ENUM,
+       {"send_dialog_mode", "0", &prefs_common.send_dialog_invisible, P_BOOL,
         NULL, NULL, NULL},
        {"sendwin_width", "460", &prefs_common.sendwin_width, P_INT,
         NULL, NULL, NULL},
@@ -425,12 +435,16 @@ static PrefParam param[] = {
 #endif
        {"toolbar_detachable", "FALSE", &prefs_common.toolbar_detachable, P_BOOL,
         NULL, NULL, NULL},
-       {"show_statusbar", "TRUE", &prefs_common.show_statusbar, P_BOOL,
+       {"show_col_headers", "TRUE", &prefs_common.show_col_headers, P_BOOL,
         NULL, NULL, NULL},
 #ifndef MAEMO
+       {"show_statusbar", "TRUE", &prefs_common.show_statusbar, P_BOOL,
+        NULL, NULL, NULL},
        {"show_searchbar", "TRUE", &prefs_common.show_searchbar, P_BOOL,
         NULL, NULL, NULL},
 #else
+       {"show_statusbar", "FALSE", &prefs_common.show_statusbar, P_BOOL,
+        NULL, NULL, NULL},
        {"show_searchbar", "FALSE", &prefs_common.show_searchbar, P_BOOL,
         NULL, NULL, NULL},
 #endif
@@ -457,6 +471,8 @@ static PrefParam param[] = {
         &prefs_common.summary_col_visible[S_COL_SCORE], P_BOOL, NULL, NULL, NULL},
        {"summary_col_show_locked", "FALSE",
         &prefs_common.summary_col_visible[S_COL_LOCKED], P_BOOL, NULL, NULL, NULL},
+       {"summary_col_show_tags", "FALSE",
+        &prefs_common.summary_col_visible[S_COL_TAGS], P_BOOL, NULL, NULL, NULL},
 
        {"summary_col_pos_mark", "0",
          &prefs_common.summary_col_pos[S_COL_MARK], P_INT, NULL, NULL, NULL},
@@ -480,6 +496,8 @@ static PrefParam param[] = {
         &prefs_common.summary_col_pos[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
        {"summary_col_pos_to", "10",
          &prefs_common.summary_col_pos[S_COL_TO], P_INT, NULL, NULL, NULL},
+       {"summary_col_pos_tags", "11",
+         &prefs_common.summary_col_pos[S_COL_TAGS], P_INT, NULL, NULL, NULL},
 
        {"summary_col_size_mark", "10",
         &prefs_common.summary_col_size[S_COL_MARK], P_INT, NULL, NULL, NULL},
@@ -513,6 +531,8 @@ static PrefParam param[] = {
         &prefs_common.summary_col_size[S_COL_SCORE], P_INT, NULL, NULL, NULL},
        {"summary_col_size_locked", "13",
         &prefs_common.summary_col_size[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
+       {"summary_col_size_tags", "150",
+        &prefs_common.summary_col_size[S_COL_TAGS], P_INT, NULL, NULL, NULL},
 
        /* Widget size */
        {"folderwin_x", "16", &prefs_common.folderwin_x, P_INT,
@@ -650,6 +670,8 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"uri_color", "32512", &prefs_common.uri_col, P_COLOR,
         NULL, NULL, NULL},
+       {"emphasis_color", "207", &prefs_common.emphasis_col, P_COLOR,
+        NULL, NULL, NULL},
        {"target_folder_color", "14294218", &prefs_common.tgt_folder_col, P_COLOR,
         NULL, NULL, NULL},
        {"signature_color", "7960953", &prefs_common.signature_col, P_COLOR,
@@ -714,8 +736,27 @@ 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},
+       {"show_tooltips", "TRUE", &prefs_common.show_tooltips,
+        P_BOOL, NULL, NULL, NULL},
+
+       /* do it SUMMARY_OPEN_ACTIONS-1 times */
+       {"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},
+       {"summary_select_prio7", "0", &prefs_common.summary_select_prio[6], 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},
@@ -754,6 +795,8 @@ static PrefParam param[] = {
         &SPECIFIC_PREFS.print_cmd, P_STRING, NULL, NULL, NULL},
        {"ext_editor_command", DEFAULT_EDITOR_CMD,
         &SPECIFIC_PREFS.ext_editor_cmd, P_STRING, NULL, NULL, NULL},
+       {"cmds_use_system_default", "FALSE",
+        &prefs_common.cmds_use_system_default, P_BOOL, NULL, NULL, NULL},
        {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click,
         P_BOOL, NULL, NULL, NULL},
        {"confirm_on_exit", "FALSE", &prefs_common.confirm_on_exit, P_BOOL,
@@ -783,11 +826,29 @@ static PrefParam param[] = {
        {"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},
-
+#ifndef MAEMO
+       {"enable_log_standard", "TRUE", &prefs_common.enable_log_standard, P_BOOL,
+        NULL, NULL, NULL},
+       {"enable_log_warning", "TRUE", &prefs_common.enable_log_warning, P_BOOL,
+        NULL, NULL, NULL},
+       {"enable_log_error", "TRUE", &prefs_common.enable_log_error, P_BOOL,
+        NULL, NULL, NULL},
+       {"enable_log_status", "TRUE", &prefs_common.enable_log_status, P_BOOL,
+        NULL, NULL, NULL},
+#else
+       {"enable_log_standard", "FALSE", &prefs_common.enable_log_standard, P_BOOL,
+        NULL, NULL, NULL},
+       {"enable_log_warning", "FALSE", &prefs_common.enable_log_warning, P_BOOL,
+        NULL, NULL, NULL},
+       {"enable_log_error", "FALSE", &prefs_common.enable_log_error, P_BOOL,
+        NULL, NULL, NULL},
+       {"enable_log_status", "FALSE", &prefs_common.enable_log_status, P_BOOL,
+        NULL, NULL, NULL},
+#endif
        {"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,
@@ -846,7 +907,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},
@@ -856,6 +917,11 @@ static PrefParam param[] = {
        {"actionswin_height", "-1", &prefs_common.actionswin_height, P_INT,
         NULL, NULL, NULL},
 
+       {"tagswin_width", "486", &prefs_common.tagswin_width, P_INT,
+        NULL, NULL, NULL},
+       {"tagswin_height", "-1", &prefs_common.tagswin_height, P_INT,
+        NULL, NULL, NULL},
+
        {"addressbookwin_width", "520", &prefs_common.addressbookwin_width, P_INT,
         NULL, NULL, NULL},
        {"addressbookwin_height", "-1", &prefs_common.addressbookwin_height, P_INT,
@@ -963,10 +1029,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,
@@ -975,19 +1047,42 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"live_dangerously", "FALSE", &prefs_common.live_dangerously, P_BOOL,
         NULL, NULL, NULL},
+       {"save_parts_readwrite", "FALSE", &prefs_common.save_parts_readwrite, P_BOOL,
+        NULL, NULL, NULL},
        {"hide_quotes", "0", &prefs_common.hide_quotes, P_INT,
         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
+
+       {"print_paper_type", NULL, &prefs_common.print_paper_type, P_STRING,
+        NULL, NULL, NULL},
+       {"print_paper_orientation", "0", &prefs_common.print_paper_orientation, P_INT,
+        NULL, NULL, NULL},
+       {"print_use_color", "0", &prefs_common.print_use_color, P_INT,
+        NULL, NULL, NULL},
+       {"print_use_collate", "0", &prefs_common.print_use_collate, P_INT,
+        NULL, NULL, NULL},
+       {"print_use_reverse", "0", &prefs_common.print_use_reverse, P_INT,
+        NULL, NULL, NULL},
+       {"print_use_duplex", "0", &prefs_common.print_use_duplex, P_INT,
+        NULL, NULL, NULL},
+       {"print_imgs", "1", &prefs_common.print_imgs, P_INT,
+        NULL, NULL, NULL},
+       {"print_previewwin_width", "600", &prefs_common.print_previewwin_width, P_INT,
+        NULL, NULL, NULL},
+       {"print_previewwin_height", "-1", &prefs_common.print_previewwin_height, P_INT,
+        NULL, NULL, NULL},
 
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
 
-PrefsCommon *prefs_common_get(void)
-{
-       return &prefs_common;
-}
-
 /*
  * Read history list from the specified history file
  */
@@ -1223,16 +1318,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);
 
-       gtk_text_buffer_set_text(buffer, out?out:"", -1);
-       g_free(out);
+               pref_get_unescaped_pref(out, txt);
+
+               gtk_text_buffer_set_text(buffer, out?out:"", -1);
+               g_free(out);
+       }
 }
 
 /* set the contents of a gtkentry widget from the internal \-escaped
@@ -1241,15 +1340,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
@@ -1296,3 +1397,81 @@ gboolean prefs_common_unsafe_ssl_certs(void)
 {
        return prefs_common.unsafe_ssl_certs;
 }
+
+gboolean prefs_common_enable_log_standard(void)
+{
+       return prefs_common.enable_log_standard;
+}
+
+gboolean prefs_common_enable_log_warning(void)
+{
+       return prefs_common.enable_log_warning;
+}
+gboolean prefs_common_enable_log_error(void)
+{
+       return prefs_common.enable_log_error;
+}
+gboolean prefs_common_enable_log_status(void)
+{
+       return prefs_common.enable_log_status;
+}
+
+#ifdef MAEMO
+const gchar *prefs_common_get_data_root(void)
+{
+       if (prefs_common.data_root && *prefs_common.data_root)
+               return prefs_common.data_root;
+       else
+               return NULL;
+}
+#endif
+/**
+   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;
+}
+
+const gchar *prefs_common_get_uri_cmd(void)
+{
+       gchar *tmp = NULL;
+       
+       if (!prefs_common.cmds_use_system_default)
+               return prefs_common.uri_cmd;
+       
+       tmp = g_find_program_in_path("xdg-open");
+       if (!tmp) 
+               return prefs_common.uri_cmd;
+       
+       g_free(tmp);
+       return "xdg-open %s";
+}
+
+const gchar *prefs_common_get_ext_editor_cmd(void)
+{
+       return prefs_common.ext_editor_cmd;
+#if 0 /* we should do that, but it detaches the editor and breaks
+        compose.c's external composition. */
+       gchar *tmp = NULL;
+       
+       if (!prefs_common.cmds_use_system_default)
+               return prefs_common.ext_editor_cmd;
+       
+       tmp = g_find_program_in_path("xdg-open");
+       if (!tmp) 
+               return prefs_common.ext_editor_cmd;
+       
+       g_free(tmp);
+       return "xdg-open %s";
+#endif 
+}