Move all colors into an array
authorRicardo Mones <ricardo@mones.org>
Mon, 5 Feb 2018 20:12:55 +0000 (21:12 +0100)
committerRicardo Mones <ricardo@mones.org>
Mon, 5 Feb 2018 20:18:03 +0000 (21:18 +0100)
15 files changed:
src/compose.c
src/foldersel.c
src/folderview.c
src/gtk/about.c
src/gtk/gtkutils.c
src/gtk/logwindow.c
src/gtk/quicksearch.c
src/gtk/spell_entry.c
src/mainwindow.c
src/plugins/vcalendar/vcalendar.c
src/prefs_common.c
src/prefs_common.h
src/prefs_msg_colors.c
src/prefs_spelling.c
src/textview.c

index 878e88c..ec66385 100644 (file)
@@ -849,21 +849,21 @@ static void compose_create_tags(GtkTextView *text, Compose *compose)
 
        if (prefs_common.enable_color) {
                /* grab the quote colors, converting from an int to a GdkColor */
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level1_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL1],
                                               &quote_color1);
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level2_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL2],
                                               &quote_color2);
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level3_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL3],
                                               &quote_color3);
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level1_bgcol,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL1_BG],
                                               &quote_bgcolor1);
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level2_bgcol,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL2_BG],
                                               &quote_bgcolor2);
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level3_bgcol,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL3_BG],
                                               &quote_bgcolor3);
-               gtkut_convert_int_to_gdk_color(prefs_common.signature_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_SIGNATURE],
                                               &signature_color);
-               gtkut_convert_int_to_gdk_color(prefs_common.uri_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_URI],
                                               &uri_color);
        } else {
                signature_color = quote_color1 = quote_color2 = quote_color3 = 
@@ -7757,9 +7757,9 @@ static Compose *compose_create(PrefsAccount *account,
 
        cm_return_val_if_fail(account != NULL, NULL);
 
-       gtkut_convert_int_to_gdk_color(prefs_common.default_header_bgcolor,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_DEFAULT_HEADER_BG],
                                           &default_header_bgcolor);
-       gtkut_convert_int_to_gdk_color(prefs_common.default_header_color,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_DEFAULT_HEADER],
                                           &default_header_color);
 
        debug_print("Creating compose window...\n");
@@ -8273,7 +8273,7 @@ static Compose *compose_create(PrefsAccount *account,
                        gtkaspell = gtkaspell_new(prefs_common.dictionary,
                                                  prefs_common.alt_dictionary,
                                                  conv_get_locale_charset_str(),
-                                                 prefs_common.misspelled_col,
+                                                 prefs_common.color[COL_MISSPELLED],
                                                  prefs_common.check_while_typing,
                                                  prefs_common.recheck_when_changing_dict,
                                                  prefs_common.use_alternate,
index 8435cbf..1953cf3 100644 (file)
@@ -402,7 +402,7 @@ static void foldersel_append_item(GtkTreeStore *store, FolderItem *item,
        static GdkColor color_noselect = {0, COLOR_DIM, COLOR_DIM, COLOR_DIM};
        static GdkColor color_new;
 
-       gtkut_convert_int_to_gdk_color(prefs_common.color_new, &color_new);
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_NEW], &color_new);
 
        name = folder_item_get_name(item);
 
index ff84755..db17902 100644 (file)
@@ -708,13 +708,13 @@ void folderview_init(FolderView *folderview)
                                        (normal_style->font_desc);
                        normal_style->font_desc = font_desc;
                }
-               gtkut_convert_int_to_gdk_color(prefs_common.color_new, &gdk_color);
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_NEW], &gdk_color);
                normal_color_style = gtk_style_copy(normal_style);
                normal_color_style->fg[GTK_STATE_NORMAL] = gdk_color;
        }
 
        if (!bold_style) {
-               gtkut_convert_int_to_gdk_color(prefs_common.color_new, &gdk_color);
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_NEW], &gdk_color);
                bold_style = gtk_style_copy(gtk_widget_get_style(ctree));
                if (prefs_common.derive_from_normal_font || !BOLD_FONT) {
                        PangoFontDescription *font_desc;
index 890e2d7..d7dfbd1 100644 (file)
@@ -118,7 +118,7 @@ static GtkWidget *about_create_child_page_info(void)
        gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
 
        /* textview link style (based upon main prefs) */
-       gtkut_convert_int_to_gdk_color(prefs_common.uri_col,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_URI],
                                (GdkColor*)&uri_color);
        tag = gtk_text_buffer_create_tag(buffer, "link",
                                "foreground-gdk", &uri_color,
@@ -569,7 +569,7 @@ static GtkWidget *about_create_child_page_license(void)
        ADD_TEXT("\n\n");
 
        /* textview link style (based upon main prefs) */
-       gtkut_convert_int_to_gdk_color(prefs_common.uri_col,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_URI],
                        (GdkColor*)&uri_color);
 
        tag = gtk_text_buffer_create_tag(buffer, "link",
index 14fa92e..1669191 100644 (file)
@@ -1234,9 +1234,9 @@ GtkWidget *gtkut_get_link_btn(GtkWidget *window, const gchar *url, const gchar *
        if (!url)
                return NULL;
 
-       gtkut_convert_int_to_gdk_color(prefs_common.uri_col,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_URI],
                                               &uri_color[0]);
-       gtkut_convert_int_to_gdk_color(prefs_common.uri_col,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_URI],
                                               &uri_color[1]);
 
        btn = gtk_button_new_with_label(label?label:url);
index 07d9534..56b151f 100644 (file)
@@ -162,14 +162,14 @@ void log_window_init(LogWindow *logwin)
        GdkColor color[LOG_COLORS];
        gint i;
 
-       gtkut_convert_int_to_gdk_color(prefs_common.log_msg_color, &color[0]);
-       gtkut_convert_int_to_gdk_color(prefs_common.log_warn_color, &color[1]);
-       gtkut_convert_int_to_gdk_color(prefs_common.log_error_color, &color[2]);
-       gtkut_convert_int_to_gdk_color(prefs_common.log_in_color, &color[3]);
-       gtkut_convert_int_to_gdk_color(prefs_common.log_out_color, &color[4]);
-       gtkut_convert_int_to_gdk_color(prefs_common.log_status_ok_color, &color[5]);
-       gtkut_convert_int_to_gdk_color(prefs_common.log_status_nok_color, &color[6]);
-       gtkut_convert_int_to_gdk_color(prefs_common.log_status_skip_color, &color[7]);
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_LOG_MSG], &color[0]);
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_LOG_WARN], &color[1]);
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_LOG_ERROR], &color[2]);
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_LOG_IN], &color[3]);
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_LOG_OUT], &color[4]);
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_LOG_STATUS_OK], &color[5]);
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_LOG_STATUS_NOK], &color[6]);
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_LOG_STATUS_SKIP], &color[7]);
 
        logwin->msg_color = color[0];
        logwin->warn_color = color[1];
index 0e79a66..1c22e59 100644 (file)
@@ -848,13 +848,13 @@ QuickSearch *quicksearch_new()
        
        update_extended_buttons(quicksearch);
 
-       gtkut_convert_int_to_gdk_color(prefs_common.qs_active_bgcolor,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QS_ACTIVE_BG],
                                           &qs_active_bgcolor);
-       gtkut_convert_int_to_gdk_color(prefs_common.qs_active_color,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QS_ACTIVE],
                                           &qs_active_color);
-       gtkut_convert_int_to_gdk_color(prefs_common.qs_error_bgcolor,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QS_ERROR_BG],
                                           &qs_error_bgcolor);
-       gtkut_convert_int_to_gdk_color(prefs_common.qs_error_color,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QS_ERROR],
                                           &qs_error_color);
 
        return quicksearch;
index 0578a6a..f49b259 100644 (file)
@@ -354,15 +354,15 @@ static void entry_strsplit_utf8(GtkEntry *entry, gchar ***set, gint **starts, gi
 
 static void insert_misspelled_marker(ClawsSpellEntry *entry, guint start, guint end)
 {
-       guint16 red   = (guint16) (((gdouble)((prefs_common.misspelled_col & 
+       guint16 red   = (guint16) (((gdouble)((prefs_common.color[COL_MISSPELLED] &
                                        0xff0000) >> 16) / 255.0) * 65535.0);
-       guint16 green = (guint16) (((gdouble)((prefs_common.misspelled_col & 
+       guint16 green = (guint16) (((gdouble)((prefs_common.color[COL_MISSPELLED] &
                                        0x00ff00) >> 8) / 255.0) * 65535.0);
-       guint16 blue  = (guint16) (((gdouble) (prefs_common.misspelled_col & 
+       guint16 blue  = (guint16) (((gdouble) (prefs_common.color[COL_MISSPELLED] &
                                        0x0000ff) / 255.0) * 65535.0);
        PangoAttribute *fcolor, *ucolor, *unline;
        
-       if(prefs_common.misspelled_col != 0) {
+       if(prefs_common.color[COL_MISSPELLED] != 0) {
                fcolor = pango_attr_foreground_new(red, green, blue);
                fcolor->start_index = start;
                fcolor->end_index = end;
index 04e4c45..73b0097 100644 (file)
@@ -2095,10 +2095,10 @@ MainWindow *main_window_create()
        summaryview->color_dim.red = summaryview->color_dim.green =
                summaryview->color_dim.blue = COLOR_DIM;
 
-       gtkut_convert_int_to_gdk_color(prefs_common.color_new,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_NEW],
                                       &folderview->color_new);
 
-       gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_TGT_FOLDER],
                                       &folderview->color_op);
 
        summaryview->color_important.red = 0;
index 3b7e2f4..c8f1af1 100644 (file)
@@ -1356,7 +1356,7 @@ void vcalendar_init(void)
                                (GSourceFunc)vcal_webcal_check, 
                                (gpointer)NULL);
        if (prefs_common_get_prefs()->enable_color) {
-               gtkut_convert_int_to_gdk_color(prefs_common_get_prefs()->uri_col,
+               gtkut_convert_int_to_gdk_color(prefs_common_get_prefs()->color[COL_URI],
                                       &uri_color);
        }
 
index 4b42e65..f9754bf 100644 (file)
@@ -276,8 +276,8 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"recheck_when_changing_dict", "TRUE", &prefs_common.recheck_when_changing_dict,
         P_BOOL, NULL, NULL, NULL},
-       {"misspelled_color", "#ff0000", &prefs_common.misspelled_col, P_COLOR,
-        NULL, NULL, NULL},
+       {"misspelled_color", "#ff0000", &prefs_common.color[COL_MISSPELLED],
+        P_COLOR, NULL, NULL, NULL},
        {"use_both_dicts", "FALSE", &prefs_common.use_both_dicts, P_BOOL,
         NULL, NULL, NULL},
 
@@ -696,47 +696,47 @@ static PrefParam param[] = {
        {"enable_color", "TRUE", &prefs_common.enable_color, P_BOOL,
         NULL, NULL, NULL},
 
-       {"quote_level1_color", "#0000b3", &prefs_common.quote_level1_col, P_COLOR,
-        NULL, NULL, NULL},
-       {"quote_level2_color", "#0000b3", &prefs_common.quote_level2_col, P_COLOR,
-        NULL, NULL, NULL},
-       {"quote_level3_color", "#0000b3", &prefs_common.quote_level3_col, P_COLOR,
-        NULL, NULL, NULL},
+       {"quote_level1_color", "#0000b3", &prefs_common.color[COL_QUOTE_LEVEL1],
+        P_COLOR, NULL, NULL, NULL},
+       {"quote_level2_color", "#0000b3", &prefs_common.color[COL_QUOTE_LEVEL2],
+        P_COLOR, NULL, NULL, NULL},
+       {"quote_level3_color", "#0000b3", &prefs_common.color[COL_QUOTE_LEVEL3],
+        P_COLOR, NULL, NULL, NULL},
        {"enable_bgcolor", "FALSE", &prefs_common.enable_bgcolor, P_BOOL,
         NULL, NULL, NULL},
-       {"quote_level1_bgcolor", "#cccccc", &prefs_common.quote_level1_bgcol, P_COLOR,
-        NULL, NULL, NULL},
-       {"quote_level2_bgcolor", "#d4d4d4", &prefs_common.quote_level2_bgcol, P_COLOR,
-        NULL, NULL, NULL},
-       {"quote_level3_bgcolor", "#dddddd", &prefs_common.quote_level3_bgcol, P_COLOR,
-        NULL, NULL, NULL},
-       {"uri_color", "#007f00", &prefs_common.uri_col, P_COLOR,
-        NULL, NULL, NULL},
-       {"emphasis_color", "#0000cf", &prefs_common.emphasis_col, P_COLOR,
-        NULL, NULL, NULL},
-       {"target_folder_color", "#da1cca", &prefs_common.tgt_folder_col, P_COLOR,
-        NULL, NULL, NULL},
-       {"signature_color", "#797979", &prefs_common.signature_col, P_COLOR,
-        NULL, NULL, NULL},
+       {"quote_level1_bgcolor", "#cccccc", &prefs_common.color[COL_QUOTE_LEVEL1_BG],
+        P_COLOR, NULL, NULL, NULL},
+       {"quote_level2_bgcolor", "#d4d4d4", &prefs_common.color[COL_QUOTE_LEVEL2_BG],
+        P_COLOR, NULL, NULL, NULL},
+       {"quote_level3_bgcolor", "#dddddd", &prefs_common.color[COL_QUOTE_LEVEL3_BG],
+        P_COLOR, NULL, NULL, NULL},
+       {"uri_color", "#007f00", &prefs_common.color[COL_URI],
+        P_COLOR, NULL, NULL, NULL},
+       {"emphasis_color", "#0000cf", &prefs_common.color[COL_EMPHASIS],
+        P_COLOR, NULL, NULL, NULL},
+       {"target_folder_color", "#da1cca", &prefs_common.color[COL_TGT_FOLDER],
+        P_COLOR, NULL, NULL, NULL},
+       {"signature_color", "#797979", &prefs_common.color[COL_SIGNATURE],
+        P_COLOR, NULL, NULL, NULL},
        {"recycle_quote_colors", "FALSE", &prefs_common.recycle_quote_colors,
         P_BOOL, NULL, NULL, NULL},
 
-       {"default_header_color", "#000000", &prefs_common.default_header_color, P_COLOR,
-        NULL, NULL, NULL},
-       {"default_header_bgcolor", "#f5f6be", &prefs_common.default_header_bgcolor, P_COLOR,
-        NULL, NULL, NULL},
-       {"tags_color", "#000000", &prefs_common.tags_color, P_COLOR,
-        NULL, NULL, NULL},
-       {"tags_bgcolor", "#f5f6be", &prefs_common.tags_bgcolor, P_COLOR,
-        NULL, NULL, NULL},
-       {"qs_active_color", "#000000", &prefs_common.qs_active_color, P_COLOR,
-        NULL, NULL, NULL},
-       {"qs_active_bgcolor", "#f5f6be", &prefs_common.qs_active_bgcolor, P_COLOR,
-        NULL, NULL, NULL},
-       {"qs_error_color", "#000000", &prefs_common.qs_error_color, P_COLOR,
-        NULL, NULL, NULL},
-       {"qs_error_bgcolor", "#ff7070", &prefs_common.qs_error_bgcolor, P_COLOR,
-        NULL, NULL, NULL},
+       {"default_header_color", "#000000", &prefs_common.color[COL_DEFAULT_HEADER],
+        P_COLOR, NULL, NULL, NULL},
+       {"default_header_bgcolor", "#f5f6be", &prefs_common.color[COL_DEFAULT_HEADER_BG],
+        P_COLOR, NULL, NULL, NULL},
+       {"tags_color", "#000000", &prefs_common.color[COL_TAGS],
+        P_COLOR, NULL, NULL, NULL},
+       {"tags_bgcolor", "#f5f6be", &prefs_common.color[COL_TAGS_BG],
+        P_COLOR, NULL, NULL, NULL},
+       {"qs_active_color", "#000000", &prefs_common.color[COL_QS_ACTIVE],
+        P_COLOR, NULL, NULL, NULL},
+       {"qs_active_bgcolor", "#f5f6be", &prefs_common.color[COL_QS_ACTIVE_BG],
+        P_COLOR, NULL, NULL, NULL},
+       {"qs_error_color", "#000000", &prefs_common.color[COL_QS_ERROR],
+        P_COLOR, NULL, NULL, NULL},
+       {"qs_error_bgcolor", "#ff7070", &prefs_common.color[COL_QS_ERROR_BG],
+        P_COLOR, NULL, NULL, NULL},
 
        {"display_header_pane", "FALSE", &prefs_common.display_header_pane,
         P_BOOL, NULL, NULL, NULL},
@@ -961,22 +961,22 @@ static PrefParam param[] = {
        {"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,
-        NULL, NULL, NULL},
-       {"log_error_color", "#af0000", &prefs_common.log_error_color, P_COLOR,
-        NULL, NULL, NULL},
-       {"log_in_color", "#000000", &prefs_common.log_in_color, P_COLOR,
-        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},
+       {"log_msg_color", "#00af00", &prefs_common.color[COL_LOG_MSG],
+        P_COLOR, NULL, NULL, NULL},
+       {"log_warn_color", "#af0000", &prefs_common.color[COL_LOG_WARN],
+        P_COLOR, NULL, NULL, NULL},
+       {"log_error_color", "#af0000", &prefs_common.color[COL_LOG_ERROR],
+        P_COLOR, NULL, NULL, NULL},
+       {"log_in_color", "#000000", &prefs_common.color[COL_LOG_IN],
+        P_COLOR, NULL, NULL, NULL},
+       {"log_out_color", "#0000ef", &prefs_common.color[COL_LOG_OUT],
+        P_COLOR, NULL, NULL, NULL},
+       {"log_status_ok_color", "#00af00", &prefs_common.color[COL_LOG_STATUS_OK],
+        P_COLOR, NULL, NULL, NULL},
+       {"log_status_nok_color", "#0000af", &prefs_common.color[COL_LOG_STATUS_NOK],
+        P_COLOR, NULL, NULL, NULL},
+       {"log_status_skip_color", "#aa00aa", &prefs_common.color[COL_LOG_STATUS_SKIP],
+        P_COLOR, NULL, NULL, NULL},
 
     {"enable_filtering_debug", "FALSE", &prefs_common.enable_filtering_debug, P_BOOL,
         NULL, NULL, NULL},
@@ -1000,8 +1000,8 @@ static PrefParam param[] = {
        {"gtk_can_change_accels", "FALSE", &prefs_common.gtk_can_change_accels, P_BOOL,
         NULL, NULL, NULL},
 
-       {"color_new", "#0000b3", &prefs_common.color_new, P_COLOR,
-        NULL, NULL, NULL},
+       {"color_new", "#0000b3", &prefs_common.color[COL_NEW],
+        P_COLOR, NULL, NULL, NULL},
 
        /* Some windows' sizes */
        {"filteringwin_width", "500", &prefs_common.filteringwin_width, P_INT,
@@ -1229,12 +1229,12 @@ static PrefParam param[] = {
        {"nav_history_length", "50", &prefs_common.nav_history_length, P_INT,
         NULL, NULL, NULL},
 
-       {"diff_added_color", "#008b8b", &prefs_common.diff_added_color, P_COLOR,
-        NULL, NULL, NULL},
-       {"diff_deleted_color", "#6a5acd", &prefs_common.diff_deleted_color, P_COLOR,
-        NULL, NULL, NULL},
-       {"diff_hunk_color", "#a52a2a", &prefs_common.diff_hunk_color, P_COLOR,
-        NULL, NULL, NULL},
+       {"diff_added_color", "#008b8b", &prefs_common.color[COL_DIFF_ADDED],
+        P_COLOR, NULL, NULL, NULL},
+       {"diff_deleted_color", "#6a5acd", &prefs_common.color[COL_DIFF_DELETED],
+        P_COLOR, NULL, NULL, NULL},
+       {"diff_hunk_color", "#a52a2a", &prefs_common.color[COL_DIFF_HUNK],
+        P_COLOR, NULL, NULL, NULL},
 
        {"folder_search_wildcard", "TRUE", &prefs_common.folder_search_wildcard, P_BOOL,
         NULL, NULL, NULL},
index 702db3d..e4b38a8 100644 (file)
@@ -108,6 +108,42 @@ typedef enum
        AVATARS_ENABLE_BOTH = 3
 } EnableAvatars;
 
+typedef enum
+{
+       COL_MISSPELLED,
+       COL_QUOTE_LEVEL1,
+       COL_QUOTE_LEVEL2,
+       COL_QUOTE_LEVEL3,
+       COL_QUOTE_LEVEL1_BG,
+       COL_QUOTE_LEVEL2_BG,
+       COL_QUOTE_LEVEL3_BG,
+       COL_URI,
+       COL_TGT_FOLDER,
+       COL_SIGNATURE,
+       COL_EMPHASIS,
+       COL_DEFAULT_HEADER,
+       COL_DEFAULT_HEADER_BG,
+       COL_TAGS,
+       COL_TAGS_BG,
+       COL_QS_ACTIVE,
+       COL_QS_ACTIVE_BG,
+       COL_QS_ERROR,
+       COL_QS_ERROR_BG,
+       COL_LOG_MSG,
+       COL_LOG_WARN,
+       COL_LOG_ERROR,
+       COL_LOG_IN,
+       COL_LOG_OUT,
+       COL_LOG_STATUS_OK,
+       COL_LOG_STATUS_NOK,
+       COL_LOG_STATUS_SKIP,
+       COL_NEW,
+       COL_DIFF_ADDED,
+       COL_DIFF_DELETED,
+       COL_DIFF_HUNK,
+       COL_LAST_COLOR_INDEX
+} ColorIndex;
+
 struct _PrefsCommon
 {
        gint config_version;
@@ -184,7 +220,6 @@ struct _PrefsCommon
        gboolean enable_aspell;
        gchar *dictionary;
        gchar *alt_dictionary;
-       gulong misspelled_col;
        gboolean check_while_typing;
        gboolean recheck_when_changing_dict;
        gboolean use_alternate;
@@ -204,6 +239,9 @@ struct _PrefsCommon
        /* custom colors */
        ColorlabelPrefs custom_colorlabel[COLORLABELS];
 
+       /* program colors */
+       gulong color[COL_LAST_COLOR_INDEX];
+
        /* image viewer */
        gboolean display_img;
        gboolean resize_img;
@@ -306,25 +344,7 @@ struct _PrefsCommon
        /* Message */
        gboolean enable_color;
        gboolean enable_bgcolor;
-       gulong quote_level1_col;
-       gulong quote_level2_col;
-       gulong quote_level3_col;
-       gulong quote_level1_bgcol;
-       gulong quote_level2_bgcol;
-       gulong quote_level3_bgcol;
-       gulong uri_col;
-       gulong tgt_folder_col;
-       gulong signature_col;
-       gulong emphasis_col;
        gboolean recycle_quote_colors;
-       gulong default_header_bgcolor;
-       gulong default_header_color;
-       gulong tags_bgcolor;
-       gulong tags_color;
-       gulong qs_active_bgcolor;
-       gulong qs_active_color;
-       gulong qs_error_bgcolor;
-       gulong qs_error_color;
        gboolean display_header_pane;
        gboolean display_header;
        gboolean display_xface;
@@ -412,15 +432,6 @@ struct _PrefsCommon
        gboolean enable_log_error;
        gboolean enable_log_status;
 
-       gulong log_msg_color;
-       gulong log_warn_color;
-       gulong log_error_color;
-       gulong log_in_color;
-       gulong log_out_color;
-       gulong log_status_ok_color;
-       gulong log_status_nok_color;
-       gulong log_status_skip_color;
-
        gboolean enable_filtering_debug;
        gint filtering_debug_level;
        gboolean enable_filtering_debug_inc;
@@ -454,8 +465,7 @@ struct _PrefsCommon
        gint summary_quicksearch_recurse;
        gint summary_quicksearch_dynamic;
        gint summary_quicksearch_autorun;
-       gulong color_new;
-       
+
        GList *summary_quicksearch_history;
        GList *summary_search_from_history;
        GList *summary_search_to_history;
@@ -544,10 +554,6 @@ struct _PrefsCommon
 
        gint nav_history_length;
 
-       gulong diff_added_color;
-       gulong diff_deleted_color;
-       gulong diff_hunk_color;
-       
        gboolean folder_search_wildcard;
        gboolean address_search_wildcard;
 
index 4b56eb0..4d6223e 100644 (file)
@@ -516,25 +516,25 @@ static void prefs_msg_colors_create_widget(PrefsPage *_page, GtkWindow *window,
                         G_CALLBACK(prefs_msg_colors_reset_custom_colors), prefs_msg_colors);
 
        set_button_bg_color(color_buttons.btn_quote_level1,
-                           prefs_common.quote_level1_col);
+                           prefs_common.color[COL_QUOTE_LEVEL1]);
        set_button_bg_color(color_buttons.btn_quote_level2,
-                           prefs_common.quote_level2_col);
+                           prefs_common.color[COL_QUOTE_LEVEL2]);
        set_button_bg_color(color_buttons.btn_quote_level3,
-                           prefs_common.quote_level3_col);
+                           prefs_common.color[COL_QUOTE_LEVEL3]);
        set_button_bg_color(color_buttons.btn_quote_level1_bg,
-                           prefs_common.quote_level1_bgcol);
+                           prefs_common.color[COL_QUOTE_LEVEL1_BG]);
        set_button_bg_color(color_buttons.btn_quote_level2_bg,
-                           prefs_common.quote_level2_bgcol);
+                           prefs_common.color[COL_QUOTE_LEVEL2_BG]);
        set_button_bg_color(color_buttons.btn_quote_level3_bg,
-                           prefs_common.quote_level3_bgcol);
+                           prefs_common.color[COL_QUOTE_LEVEL3_BG]);
        set_button_bg_color(color_buttons.btn_uri,
-                           prefs_common.uri_col);
+                           prefs_common.color[COL_URI]);
        set_button_bg_color(color_buttons.btn_tgt_folder,
-                           prefs_common.tgt_folder_col);
+                           prefs_common.color[COL_TGT_FOLDER]);
        set_button_bg_color(color_buttons.btn_signature,
-                           prefs_common.signature_col);
+                           prefs_common.color[COL_SIGNATURE]);
        set_button_bg_color(color_buttons.btn_color_new,
-                           prefs_common.color_new);
+                           prefs_common.color[COL_NEW]);
        /* custom colors */
        for (c = 0; c < COLORLABELS; c++) {
                set_button_bg_color(color_buttons.custom_color[c],
@@ -588,34 +588,34 @@ static void quote_color_set_dialog(GtkWidget *widget, gpointer data)
        if (c == COLORLABELS) {
                if(g_ascii_strcasecmp(type, "LEVEL1") == 0) {
                        title = g_strdup(C_("Dialog title", "Pick color for 1st level text"));
-                       rgbvalue = prefs_common.quote_level1_col;
+                       rgbvalue = prefs_common.color[COL_QUOTE_LEVEL1];
                } else if(g_ascii_strcasecmp(type, "LEVEL2") == 0) {
                        title = g_strdup(C_("Dialog title", "Pick color for 2nd level text"));
-                       rgbvalue = prefs_common.quote_level2_col;
+                       rgbvalue = prefs_common.color[COL_QUOTE_LEVEL2];
                } else if(g_ascii_strcasecmp(type, "LEVEL3") == 0) {
                        title = g_strdup(C_("Dialog title", "Pick color for 3rd level text"));
-                       rgbvalue = prefs_common.quote_level3_col;
+                       rgbvalue = prefs_common.color[COL_QUOTE_LEVEL3];
                } else if(g_ascii_strcasecmp(type, "LEVEL1BG") == 0) {
                        title = g_strdup(C_("Dialog title", "Pick color for 1st level text background"));
-                       rgbvalue = prefs_common.quote_level1_bgcol;
+                       rgbvalue = prefs_common.color[COL_QUOTE_LEVEL1_BG];
                } else if(g_ascii_strcasecmp(type, "LEVEL2BG") == 0) {
                        title = g_strdup(C_("Dialog title", "Pick color for 2nd level text background"));
-                       rgbvalue = prefs_common.quote_level2_bgcol;
+                       rgbvalue = prefs_common.color[COL_QUOTE_LEVEL2_BG];
                } else if(g_ascii_strcasecmp(type, "LEVEL3BG") == 0) {
                        title = g_strdup(C_("Dialog title", "Pick color for 3rd level text background"));
-                       rgbvalue = prefs_common.quote_level3_bgcol;
+                       rgbvalue = prefs_common.color[COL_QUOTE_LEVEL3_BG];
                } else if(g_ascii_strcasecmp(type, "URI") == 0) {
                        title = g_strdup(C_("Dialog title", "Pick color for links"));
-                       rgbvalue = prefs_common.uri_col;
+                       rgbvalue = prefs_common.color[COL_URI];
                } else if(g_ascii_strcasecmp(type, "TGTFLD") == 0) {
                        title = g_strdup(C_("Dialog title", "Pick color for target folder"));
-                       rgbvalue = prefs_common.tgt_folder_col;
+                       rgbvalue = prefs_common.color[COL_TGT_FOLDER];
                } else if(g_ascii_strcasecmp(type, "SIGNATURE") == 0) {
                        title = g_strdup(C_("Dialog title", "Pick color for signatures"));
-                       rgbvalue = prefs_common.signature_col;
+                       rgbvalue = prefs_common.color[COL_SIGNATURE];
                } else if(g_ascii_strcasecmp(type, "NEW") == 0) {
                        title = g_strdup(C_("Dialog title", "Pick color for folder"));
-                       rgbvalue = prefs_common.color_new;
+                       rgbvalue = prefs_common.color[COL_NEW];
                } else {
                        /* Should never be called */
                        g_warning("Unrecognized datatype '%s' in quote_color_set_dialog", type);
@@ -677,35 +677,35 @@ static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
        /* other colors */
        if (c == COLORLABELS) {
                if (g_ascii_strcasecmp(type, "LEVEL1") == 0) {
-                       prefs_common.quote_level1_col = rgbvalue;
+                       prefs_common.color[COL_QUOTE_LEVEL1] = rgbvalue;
                        set_button_bg_color(color_buttons.btn_quote_level1, rgbvalue);
                } else if (g_ascii_strcasecmp(type, "LEVEL2") == 0) {
-                       prefs_common.quote_level2_col = rgbvalue;
+                       prefs_common.color[COL_QUOTE_LEVEL2] = rgbvalue;
                        set_button_bg_color(color_buttons.btn_quote_level2, rgbvalue);
                } else if (g_ascii_strcasecmp(type, "LEVEL3") == 0) {
-                       prefs_common.quote_level3_col = rgbvalue;
+                       prefs_common.color[COL_QUOTE_LEVEL3] = rgbvalue;
                        set_button_bg_color(color_buttons.btn_quote_level3, rgbvalue);
                } else if (g_ascii_strcasecmp(type, "LEVEL1BG") == 0) {
-                       prefs_common.quote_level1_bgcol = rgbvalue;
+                       prefs_common.color[COL_QUOTE_LEVEL1_BG] = rgbvalue;
                        set_button_bg_color(color_buttons.btn_quote_level1_bg, rgbvalue);
                } else if (g_ascii_strcasecmp(type, "LEVEL2BG") == 0) {
-                       prefs_common.quote_level2_bgcol = rgbvalue;
+                       prefs_common.color[COL_QUOTE_LEVEL2_BG] = rgbvalue;
                        set_button_bg_color(color_buttons.btn_quote_level2_bg, rgbvalue);
                } else if (g_ascii_strcasecmp(type, "LEVEL3BG") == 0) {
-                       prefs_common.quote_level3_bgcol = rgbvalue;
+                       prefs_common.color[COL_QUOTE_LEVEL3_BG] = rgbvalue;
                        set_button_bg_color(color_buttons.btn_quote_level3_bg, rgbvalue);
                } else if (g_ascii_strcasecmp(type, "URI") == 0) {
-                       prefs_common.uri_col = rgbvalue;
+                       prefs_common.color[COL_URI] = rgbvalue;
                        set_button_bg_color(color_buttons.btn_uri, rgbvalue);
                } else if (g_ascii_strcasecmp(type, "TGTFLD") == 0) {
-                       prefs_common.tgt_folder_col = rgbvalue;
+                       prefs_common.color[COL_TGT_FOLDER] = rgbvalue;
                        set_button_bg_color(color_buttons.btn_tgt_folder, rgbvalue);
-                       folderview_set_target_folder_color(prefs_common.tgt_folder_col);
+                       folderview_set_target_folder_color(prefs_common.color[COL_TGT_FOLDER]);
                } else if (g_ascii_strcasecmp(type, "SIGNATURE") == 0) {
-                       prefs_common.signature_col = rgbvalue;
+                       prefs_common.color[COL_SIGNATURE] = rgbvalue;
                        set_button_bg_color(color_buttons.btn_signature, rgbvalue);
                } else if (g_ascii_strcasecmp(type, "NEW") == 0) {
-                       prefs_common.color_new = rgbvalue;
+                       prefs_common.color[COL_NEW] = rgbvalue;
                        set_button_bg_color(color_buttons.btn_color_new, rgbvalue);
                } else {
                        g_printerr("Unrecognized datatype '%s' in quote_color_set_dialog_ok\n", type);
index 09cc94c..39f6533 100644 (file)
@@ -264,7 +264,7 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp
        g_signal_connect(G_OBJECT(misspelled_colorbtn), "clicked",
                         G_CALLBACK(prefs_spelling_colorsel), prefs_spelling);
 
-       prefs_spelling->misspell_col = prefs_common.misspelled_col;
+       prefs_spelling->misspell_col = prefs_common.color[COL_MISSPELLED];
        gtkut_set_widget_bgcolor_rgb(misspelled_colorbtn, prefs_spelling->misspell_col);
 
        prefs_spelling->window                  = GTK_WIDGET(window);
@@ -312,7 +312,7 @@ static void prefs_spelling_save(PrefsPage *_page)
                gtkaspell_get_dictionary_menu_active_item(
                                GTK_COMBO_BOX(spelling->default_alt_dict_combo));
 
-       prefs_common.misspelled_col = spelling->misspell_col;
+       prefs_common.color[COL_MISSPELLED] = spelling->misspell_col;
 }
 
 static void prefs_spelling_destroy_widget(PrefsPage *_page)
index c9be5d8..1a48788 100644 (file)
@@ -565,31 +565,31 @@ static void textview_update_message_colors(TextView *textview)
 
        if (prefs_common.enable_color) {
                /* grab the quote colors, converting from an int to a GdkColor */
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level1_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL1],
                                               &quote_colors[0]);
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level2_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL2],
                                               &quote_colors[1]);
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level3_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL3],
                                               &quote_colors[2]);
-               gtkut_convert_int_to_gdk_color(prefs_common.uri_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_URI],
                                               &uri_color);
-               gtkut_convert_int_to_gdk_color(prefs_common.signature_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_SIGNATURE],
                                               &signature_color);
-               gtkut_convert_int_to_gdk_color(prefs_common.emphasis_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_EMPHASIS],
                                               &emphasis_color);
-               gtkut_convert_int_to_gdk_color(prefs_common.diff_added_color,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_DIFF_ADDED],
                                               &diff_added_color);
-               gtkut_convert_int_to_gdk_color(prefs_common.diff_deleted_color,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_DIFF_DELETED],
                                               &diff_deleted_color);
-               gtkut_convert_int_to_gdk_color(prefs_common.diff_hunk_color,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_DIFF_HUNK],
                                               &diff_hunk_color);
        }
        if (prefs_common.enable_color && prefs_common.enable_bgcolor) {
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level1_bgcol,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL1_BG],
                                                   &quote_bgcolors[0]);
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level2_bgcol,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL2_BG],
                                                   &quote_bgcolors[1]);
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level3_bgcol,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL3_BG],
                                                   &quote_bgcolors[2]);
                CHANGE_TAG_COLOR("quote0", &quote_colors[0], &quote_bgcolors[0]);
                CHANGE_TAG_COLOR("quote1", &quote_colors[1], &quote_bgcolors[1]);
@@ -610,9 +610,9 @@ static void textview_update_message_colors(TextView *textview)
        CHANGE_TAG_COLOR("diff-del-file", &diff_deleted_color, NULL);
        CHANGE_TAG_COLOR("diff-hunk", &diff_hunk_color, NULL);
 
-       gtkut_convert_int_to_gdk_color(prefs_common.tags_bgcolor,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_TAGS_BG],
                                           &tags_bgcolor);
-       gtkut_convert_int_to_gdk_color(prefs_common.tags_color,
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_TAGS],
                                           &tags_color);
 }
 #undef CHANGE_TAG_COLOR