2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 2004-2021 The Claws Mail Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "claws-features.h"
30 #include <glib/gi18n.h>
32 #include <gdk/gdkkeysyms.h>
34 #include "prefs_common.h"
35 #include "prefs_gtk.h"
37 #include "gtk/gtkutils.h"
38 #include "gtk/prefswindow.h"
40 #include "manage_window.h"
41 #include "mainwindow.h"
42 #include "colorlabel.h"
44 #define SAFE_STRING(str) \
47 static struct MessageColorButtons
{
49 GtkWidget
*color
[COL_LAST_COLOR_INDEX
];
51 GtkWidget
*custom_color
[COLORLABELS
];
54 typedef struct _MsgColorsPage
60 GtkWidget
*checkbtn_enable_colors
;
61 GtkWidget
*checkbtn_enable_bgcolors
;
62 GtkWidget
*checkbtn_recycle_colors
;
65 GtkWidget
*entry_custom_colorlabel
[COLORLABELS
];
68 static void prefs_msg_colors_reset_custom_colors(GtkWidget
*widget
,
71 #define COLOR_BUTTON_PACK_START(gtkbox, colorid, text) \
72 color_buttons.color[colorid] = gtk_color_button_new_with_rgba( \
73 &prefs_common.color[colorid]); \
74 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_buttons.color[colorid]), text); \
75 gtk_widget_show(color_buttons.color[colorid]); \
76 gtk_box_pack_start(GTK_BOX(gtkbox), color_buttons.color[colorid], FALSE, FALSE, 0); \
77 gtk_widget_set_tooltip_text(GTK_WIDGET(color_buttons.color[colorid]), text)
79 #define COLOR_BUTTON_PACK_END(gtkbox, colorid, text) \
80 color_buttons.color[colorid] = gtk_color_button_new_with_rgba( \
81 &prefs_common.color[colorid]); \
82 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_buttons.color[colorid]), text); \
83 gtk_widget_show(color_buttons.color[colorid]); \
84 gtk_box_pack_end(GTK_BOX(gtkbox), color_buttons.color[colorid], FALSE, FALSE, 0); \
85 gtk_widget_set_tooltip_text(GTK_WIDGET(color_buttons.color[colorid]), text)
87 #define COLOR_LABEL_PACK_START(gtkbox, colorid, labeltext) \
88 label[colorid] = gtk_label_new (labeltext); \
89 gtk_widget_show (label[colorid]); \
90 gtk_box_pack_start (GTK_BOX(gtkbox), label[colorid], FALSE, FALSE, 0)
92 #define COLOR_LABEL_PACK_END(gtkbox, colorid, labeltext) \
93 label[colorid] = gtk_label_new (labeltext); \
94 gtk_widget_show (label[colorid]); \
95 gtk_box_pack_end (GTK_BOX(gtkbox), label[colorid], FALSE, FALSE, 0)
97 static void prefs_msg_colors_create_widget(PrefsPage
*_page
, GtkWindow
*window
,
100 MsgColorsPage
*prefs_msg_colors
= (MsgColorsPage
*) _page
;
105 GtkWidget
*checkbtn_enable_colors
;
106 GtkWidget
*label_quote_level1
;
107 GtkWidget
*label_quote_level2
;
108 GtkWidget
*label_quote_level3
;
109 GtkWidget
*checkbtn_enable_bgcolors
;
110 GtkWidget
*checkbtn_recycle_colors
;
112 GtkWidget
*label
[COL_LAST_COLOR_INDEX
];
113 GtkWidget
*frame_msg
;
114 GtkWidget
*frame_folder
;
115 GtkWidget
*frame_quote
;
117 GtkWidget
*hbox_quote
;
118 GtkWidget
*vbox_quotefg
;
119 GtkWidget
*vbox_quotebg
;
120 GtkWidget
*frame_diff
;
123 GtkWidget
*hbox_custom_colors
;
124 GtkWidget
*vbox_custom_colors
;
125 GtkWidget
*vbox_custom_colors1
;
126 GtkWidget
*vbox_custom_colors2
;
127 GtkWidget
*hbox_reset_custom_colors
;
128 GtkWidget
*btn_reset_custom_colors
;
129 GtkWidget
*hbox_custom_color
[COLORLABELS
];
130 GtkWidget
*entry_custom_colorlabel
[COLORLABELS
];
132 gchar
*tooltip_btn_text
= NULL
;
133 gchar
*tooltip_entry_text
= NULL
;
136 notebook
= gtk_notebook_new();
137 gtk_widget_show(notebook
);
139 vbox1
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VBOX_BORDER
);
140 gtk_widget_show (vbox1
);
141 gtk_container_set_border_width (GTK_CONTAINER (vbox1
), VBOX_BORDER
);
142 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
), vbox1
,
143 gtk_label_new(_("Other")));
145 vbox2
= gtkut_get_options_frame(vbox1
, &frame_msg
, _("Message view"));
147 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
148 gtk_widget_show (hbox
);
150 gtk_box_pack_start (GTK_BOX (vbox2
), hbox
, FALSE
, TRUE
, 0);
151 PACK_CHECK_BUTTON (hbox
, checkbtn_enable_colors
,
152 _("Enable coloration of message text"));
154 hbox_quote
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
155 gtk_widget_show (hbox_quote
);
156 vbox_quotefg
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VBOX_BORDER
);
157 gtk_widget_show (vbox_quotefg
);
158 vbox_quotebg
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VBOX_BORDER
);
159 gtk_widget_show (vbox_quotebg
);
160 vbox3
= gtkut_get_options_frame(vbox2
, &frame_quote
, _("Quote"));
161 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, frame_quote
);
163 gtk_box_pack_start (GTK_BOX (vbox3
), hbox_quote
, FALSE
, TRUE
, 0);
164 gtk_box_pack_start (GTK_BOX (hbox_quote
), vbox_quotefg
, FALSE
, TRUE
, 0);
165 gtk_box_pack_start (GTK_BOX (hbox_quote
), vbox_quotebg
, FALSE
, TRUE
, 0);
167 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
168 gtk_widget_show (hbox
);
169 gtk_box_pack_start (GTK_BOX (vbox_quotefg
), hbox
, FALSE
, TRUE
, 0);
171 PACK_CHECK_BUTTON (hbox
, checkbtn_recycle_colors
,
172 _("Cycle quote colors"));
173 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, checkbtn_recycle_colors
);
175 CLAWS_SET_TIP(checkbtn_recycle_colors
,
176 _("If there are more than 3 quote levels, the colors will be reused"));
178 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
179 gtk_widget_show (hbox
);
180 gtk_box_pack_start (GTK_BOX (vbox_quotefg
), hbox
, FALSE
, TRUE
, 0);
182 label_quote_level1
= gtk_label_new (_("1st Level"));
183 gtk_widget_show(label_quote_level1
);
184 gtk_box_pack_start (GTK_BOX(hbox
), label_quote_level1
,
186 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, label_quote_level1
);
188 COLOR_LABEL_PACK_END(hbox
, COL_QUOTE_LEVEL1
, _("Text"));
189 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, label
[COL_QUOTE_LEVEL1
]);
191 COLOR_BUTTON_PACK_END(hbox
, COL_QUOTE_LEVEL1
,
192 C_("Tooltip", "Pick color for 1st level text"));
193 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
,
194 color_buttons
.color
[COL_QUOTE_LEVEL1
]);
196 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
197 gtk_widget_show (hbox
);
198 gtk_box_pack_start (GTK_BOX (vbox_quotefg
), hbox
, FALSE
, TRUE
, 0);
200 label_quote_level2
= gtk_label_new (_("2nd Level"));
201 gtk_widget_show(label_quote_level2
);
202 gtk_box_pack_start (GTK_BOX(hbox
), label_quote_level2
,
204 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, label_quote_level2
);
206 COLOR_LABEL_PACK_END(hbox
, COL_QUOTE_LEVEL2
, _("Text"));
207 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, label
[COL_QUOTE_LEVEL2
]);
209 COLOR_BUTTON_PACK_END(hbox
, COL_QUOTE_LEVEL2
,
210 C_("Tooltip", "Pick color for 2nd level text"));
211 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
,
212 color_buttons
.color
[COL_QUOTE_LEVEL2
]);
214 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
215 gtk_widget_show (hbox
);
216 gtk_box_pack_start (GTK_BOX (vbox_quotefg
), hbox
, FALSE
, TRUE
, 0);
218 label_quote_level3
= gtk_label_new (_("3rd Level"));
219 gtk_widget_show(label_quote_level3
);
220 gtk_box_pack_start (GTK_BOX(hbox
), label_quote_level3
,
222 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, label_quote_level3
);
224 COLOR_LABEL_PACK_END(hbox
, COL_QUOTE_LEVEL3
, _("Text"));
225 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, label
[COL_QUOTE_LEVEL3
]);
227 COLOR_BUTTON_PACK_END(hbox
, COL_QUOTE_LEVEL3
,
228 C_("Tooltip", "Pick color for 3rd level text"));
229 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
,
230 color_buttons
.color
[COL_QUOTE_LEVEL3
]);
232 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
233 gtk_widget_show (hbox
);
234 gtk_box_pack_start (GTK_BOX (vbox_quotebg
), hbox
, FALSE
, TRUE
, 0);
236 PACK_CHECK_BUTTON (hbox
, checkbtn_enable_bgcolors
,
237 _("Enable coloration of text background"));
238 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, checkbtn_enable_bgcolors
);
240 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
241 gtk_widget_show (hbox
);
242 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, hbox
);
243 gtk_box_pack_start (GTK_BOX (vbox_quotebg
), hbox
, FALSE
, TRUE
, 0);
245 COLOR_BUTTON_PACK_START(hbox
, COL_QUOTE_LEVEL1_BG
,
246 C_("Tooltip and Dialog title",
247 "Pick color for 1st level text background"));
248 SET_TOGGLE_SENSITIVITY(checkbtn_enable_bgcolors
,
249 color_buttons
.color
[COL_QUOTE_LEVEL1_BG
]);
251 COLOR_LABEL_PACK_START(hbox
, COL_QUOTE_LEVEL1_BG
, _("Background"));
252 SET_TOGGLE_SENSITIVITY(checkbtn_enable_bgcolors
, label
[COL_QUOTE_LEVEL1_BG
]);
254 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
255 gtk_widget_show (hbox
);
256 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, hbox
);
257 gtk_box_pack_start (GTK_BOX (vbox_quotebg
), hbox
, FALSE
, TRUE
, 0);
259 COLOR_BUTTON_PACK_START(hbox
, COL_QUOTE_LEVEL2_BG
,
260 C_("Tooltip and Dialog title",
261 "Pick color for 2nd level text background"));
262 SET_TOGGLE_SENSITIVITY(checkbtn_enable_bgcolors
,
263 color_buttons
.color
[COL_QUOTE_LEVEL2_BG
]);
265 COLOR_LABEL_PACK_START(hbox
, COL_QUOTE_LEVEL2_BG
, _("Background"));
266 SET_TOGGLE_SENSITIVITY(checkbtn_enable_bgcolors
, label
[COL_QUOTE_LEVEL2_BG
]);
268 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
269 gtk_widget_show (hbox
);
270 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, hbox
);
271 gtk_box_pack_start (GTK_BOX (vbox_quotebg
), hbox
, FALSE
, TRUE
, 0);
273 COLOR_BUTTON_PACK_START(hbox
, COL_QUOTE_LEVEL3_BG
,
274 C_("Tooltip and Dialog title",
275 "Pick color for 3rd level text background"));
276 SET_TOGGLE_SENSITIVITY(checkbtn_enable_bgcolors
,
277 color_buttons
.color
[COL_QUOTE_LEVEL3_BG
]);
279 COLOR_LABEL_PACK_START(hbox
, COL_QUOTE_LEVEL3_BG
, _("Background"));
280 SET_TOGGLE_SENSITIVITY(checkbtn_enable_bgcolors
, label
[COL_QUOTE_LEVEL3_BG
]);
282 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
283 gtk_widget_show (hbox
);
284 gtk_box_pack_start (GTK_BOX (vbox2
), hbox
, FALSE
, TRUE
, 0);
286 COLOR_BUTTON_PACK_START(hbox
, COL_URI
,
287 C_("Tooltip and Dialog title",
288 "Pick color for links"));
289 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
,
290 color_buttons
.color
[COL_URI
]);
292 COLOR_LABEL_PACK_START(hbox
, COL_URI
, _("URI link"));
293 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, label
[COL_URI
]);
295 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
296 gtk_widget_show (hbox
);
297 gtk_box_pack_start (GTK_BOX (vbox2
), hbox
, FALSE
, TRUE
, 0);
299 COLOR_BUTTON_PACK_START(hbox
, COL_SIGNATURE
,
300 C_("Tooltip and Dialog title",
301 "Pick color for signatures"));
302 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
,
303 color_buttons
.color
[COL_SIGNATURE
]);
305 COLOR_LABEL_PACK_START(hbox
, COL_SIGNATURE
, _("Signatures"));
306 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, label
[COL_SIGNATURE
]);
308 vbox4
= gtkut_get_options_frame(vbox2
, &frame_diff
,
309 /* TRANSLATORS: A patch is a text file listing the differences between 2 or more different */
310 /* versions of the same text file */
311 _("Patch messages and attachments"));
312 SET_TOGGLE_SENSITIVITY(checkbtn_enable_colors
, frame_diff
);
314 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
315 gtk_widget_show (hbox
);
316 gtk_box_pack_start (GTK_BOX (vbox4
), hbox
, FALSE
, TRUE
, 0);
318 COLOR_BUTTON_PACK_START(hbox
, COL_DIFF_ADDED
,
319 C_("Tooltip and Dialog title",
320 "Pick color for inserted lines"));
322 COLOR_LABEL_PACK_START(hbox
, COL_DIFF_ADDED
, _("Inserted lines"));
324 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
325 gtk_widget_show (hbox
);
326 gtk_box_pack_start (GTK_BOX (vbox4
), hbox
, FALSE
, FALSE
, 0);
328 COLOR_BUTTON_PACK_START(hbox
, COL_DIFF_DELETED
,
329 C_("Tooltip and Dialog title",
330 "Pick color for removed lines"));
332 COLOR_LABEL_PACK_START(hbox
, COL_DIFF_DELETED
,
335 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
336 gtk_widget_show (hbox
);
337 gtk_box_pack_start (GTK_BOX (vbox4
), hbox
, FALSE
, FALSE
, 0);
339 COLOR_BUTTON_PACK_START(hbox
, COL_DIFF_HUNK
,
340 /* TRANSLATORS: A hunk is a section of the patch indicating how the files differ */
341 C_("Tooltip and Dialog title",
342 "Pick color for hunk lines"));
344 COLOR_LABEL_PACK_START(hbox
, COL_DIFF_HUNK
,
345 /* TRANSLATORS: A hunk is a section of the patch indicating how the files differ */
348 vbox2
= gtkut_get_options_frame(vbox1
, &frame_folder
, _("Folder list"));
350 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
351 gtk_widget_show (hbox
);
352 gtk_box_pack_start (GTK_BOX (vbox2
), hbox
, FALSE
, TRUE
, 0);
354 COLOR_BUTTON_PACK_START(hbox
, COL_TGT_FOLDER
,
355 C_("Tooltip and Dialog title",
356 "Pick color for Target folder."));
357 COLOR_LABEL_PACK_START(hbox
, COL_TGT_FOLDER
, _("Target folder"));
358 gtk_widget_set_tooltip_text(GTK_WIDGET(label
[COL_TGT_FOLDER
]),
359 C_("Tooltip", "Target folder is used when the option "
360 "'Execute immediately when moving or "
361 "deleting messages' is turned off"));
364 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
365 gtk_widget_show (hbox
);
366 gtk_box_pack_start (GTK_BOX (vbox2
), hbox
, FALSE
, FALSE
, 0);
368 COLOR_BUTTON_PACK_START(hbox
, COL_NEW
,
369 C_("Tooltip and Dialog title",
370 "Pick color for folders containing new messages"));
372 COLOR_LABEL_PACK_START(hbox
, COL_NEW
,
373 _("Folder containing new messages"));
376 vbox_custom_colors
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING_NARROW
);
377 gtk_widget_show (vbox_custom_colors
);
378 gtk_container_set_border_width (GTK_CONTAINER (vbox_custom_colors
), VBOX_BORDER
);
379 gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook
), vbox_custom_colors
,
380 gtk_label_new(_("Color labels")));
382 hbox_custom_colors
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
383 gtk_widget_show(hbox_custom_colors
);
384 gtk_box_pack_start(GTK_BOX (vbox_custom_colors
), hbox_custom_colors
,
387 vbox_custom_colors1
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING_NARROW
);
388 gtk_widget_show (vbox_custom_colors1
);
389 gtk_box_pack_start (GTK_BOX (hbox_custom_colors
), vbox_custom_colors1
, FALSE
, FALSE
, 0);
391 vbox_custom_colors2
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, VSPACING_NARROW
);
392 gtk_widget_show (vbox_custom_colors2
);
393 gtk_box_pack_start (GTK_BOX (hbox_custom_colors
), vbox_custom_colors2
, FALSE
, FALSE
, 0);
395 for (c
= 0; c
< (COLORLABELS
>>1)+(COLORLABELS
&1); c
++) {
396 /* TRANSLATORS: 'color %d' refers to the filtering/processing
397 rule name and should not be translated */
398 tooltip_btn_text
= g_strdup_printf(C_("Tooltip", "Pick color for 'color %d'"), c
+1);
400 /* TRANSLATORS: 'color %d' refers to the filtering/processing
401 rule name and should not be translated */
402 tooltip_entry_text
= g_strdup_printf(_("Set label for 'color %d'"), c
+1);
404 hbox_custom_color
[c
] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
405 gtk_widget_show(hbox_custom_color
[c
]);
406 gtk_box_pack_start(GTK_BOX (vbox_custom_colors1
), hbox_custom_color
[c
],
409 color_buttons
.custom_color
[c
] = gtk_color_button_new_with_rgba(
410 &prefs_common
.custom_colorlabel
[c
].color
);
411 title
= g_strdup_printf(C_("Dialog title", "Pick color for 'color %d'"), c
+1);
412 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_buttons
.custom_color
[c
]),
415 gtk_widget_show(color_buttons
.custom_color
[c
]);
416 gtk_box_pack_start(GTK_BOX (hbox_custom_color
[c
]), color_buttons
.custom_color
[c
],
419 CLAWS_SET_TIP(color_buttons
.custom_color
[c
],
421 g_free(tooltip_btn_text
);
423 entry_custom_colorlabel
[c
] = gtk_entry_new();
424 gtk_widget_show (entry_custom_colorlabel
[c
]);
425 gtk_box_pack_start(GTK_BOX (hbox_custom_color
[c
]), entry_custom_colorlabel
[c
],
427 CLAWS_SET_TIP(entry_custom_colorlabel
[c
],
429 g_free(tooltip_entry_text
);
432 for (c
= (COLORLABELS
>>1)+(COLORLABELS
&1); c
< COLORLABELS
; c
++) {
433 /* TRANSLATORS: 'color %d' refers to the filtering/processing
434 rule name and should not be translated */
435 tooltip_btn_text
= g_strdup_printf(C_("Tooltip", "Pick color for 'color %d'"), c
+1);
437 /* TRANSLATORS: 'color %d' refers to the filtering/processing
438 rule name and should not be translated */
439 tooltip_entry_text
= g_strdup_printf(_("Set label for 'color %d'"), c
+1);
441 hbox_custom_color
[c
] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 8);
442 gtk_widget_show(hbox_custom_color
[c
]);
443 gtk_box_pack_start(GTK_BOX (vbox_custom_colors2
), hbox_custom_color
[c
],
446 color_buttons
.custom_color
[c
] = gtk_color_button_new_with_rgba(
447 &prefs_common
.custom_colorlabel
[c
].color
);
448 title
= g_strdup_printf(C_("Dialog title", "Pick color for 'color %d'"), c
+1);
449 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_buttons
.custom_color
[c
]),
452 gtk_widget_show(color_buttons
.custom_color
[c
]);
453 gtk_box_pack_start(GTK_BOX (hbox_custom_color
[c
]), color_buttons
.custom_color
[c
],
455 CLAWS_SET_TIP(color_buttons
.custom_color
[c
],
457 g_free(tooltip_btn_text
);
459 entry_custom_colorlabel
[c
] = gtk_entry_new();
460 gtk_widget_show (entry_custom_colorlabel
[c
]);
461 gtk_box_pack_start(GTK_BOX (hbox_custom_color
[c
]), entry_custom_colorlabel
[c
],
463 CLAWS_SET_TIP(entry_custom_colorlabel
[c
],
466 g_free(tooltip_entry_text
);
469 hbox_reset_custom_colors
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, VBOX_BORDER
);
470 gtk_widget_show (hbox_reset_custom_colors
);
471 gtk_box_pack_start(GTK_BOX (vbox_custom_colors
), hbox_reset_custom_colors
,
474 btn_reset_custom_colors
= gtk_button_new_with_label(_(" Use default "));
475 gtk_widget_show(btn_reset_custom_colors
);
476 gtk_box_pack_start(GTK_BOX(hbox_reset_custom_colors
), btn_reset_custom_colors
,
479 g_signal_connect(G_OBJECT(btn_reset_custom_colors
), "clicked",
480 G_CALLBACK(prefs_msg_colors_reset_custom_colors
), prefs_msg_colors
);
482 for (c
= 0; c
< COLORLABELS
; c
++) {
483 gtk_entry_set_text(GTK_ENTRY (entry_custom_colorlabel
[c
]),
484 gettext(SAFE_STRING (prefs_common
.custom_colorlabel
[c
].label
)));
487 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_colors
),
488 prefs_common
.enable_color
);
489 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_bgcolors
),
490 prefs_common
.enable_bgcolor
);
491 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_recycle_colors
),
492 prefs_common
.recycle_quote_colors
);
494 prefs_msg_colors
->checkbtn_enable_colors
= checkbtn_enable_colors
;
495 prefs_msg_colors
->checkbtn_enable_bgcolors
= checkbtn_enable_bgcolors
;
496 prefs_msg_colors
->checkbtn_recycle_colors
= checkbtn_recycle_colors
;
498 for (c
= 0; c
< COLORLABELS
; c
++) {
499 prefs_msg_colors
->entry_custom_colorlabel
[c
] = entry_custom_colorlabel
[c
];
501 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), 0);
503 prefs_msg_colors
->page
.widget
= notebook
;
506 #undef COLOR_BUTTON_PACK_START
507 #undef COLOR_BUTTON_PACK_END
508 #undef COLOR_LABEL_PACK_START
509 #undef COLOR_LABEL_PACK_END
511 #define COLOR_OTHER_SAVE(colorid) \
512 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(color_buttons.color[colorid]), \
513 &prefs_common.color[colorid])
515 static void prefs_msg_colors_save(PrefsPage
*_page
)
517 MsgColorsPage
*page
= (MsgColorsPage
*) _page
;
520 prefs_common
.enable_color
=
521 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_enable_colors
));
522 prefs_common
.enable_bgcolor
=
523 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_enable_bgcolors
));
524 prefs_common
.recycle_quote_colors
=
525 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page
->checkbtn_recycle_colors
));
528 for (c
= 0; c
< COLORLABELS
; c
++) {
529 g_free(prefs_common
.custom_colorlabel
[c
].label
);
530 prefs_common
.custom_colorlabel
[c
].label
=
531 gtk_editable_get_chars(GTK_EDITABLE(page
->entry_custom_colorlabel
[c
]), 0, -1);
532 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(color_buttons
.custom_color
[c
]),
533 &prefs_common
.custom_colorlabel
[c
].color
);
535 colorlabel_update_colortable_from_prefs();
536 COLOR_OTHER_SAVE(COL_QUOTE_LEVEL1
);
537 COLOR_OTHER_SAVE(COL_QUOTE_LEVEL2
);
538 COLOR_OTHER_SAVE(COL_QUOTE_LEVEL3
);
539 COLOR_OTHER_SAVE(COL_QUOTE_LEVEL1_BG
);
540 COLOR_OTHER_SAVE(COL_QUOTE_LEVEL2_BG
);
541 COLOR_OTHER_SAVE(COL_QUOTE_LEVEL3_BG
);
542 COLOR_OTHER_SAVE(COL_URI
);
543 COLOR_OTHER_SAVE(COL_SIGNATURE
);
544 COLOR_OTHER_SAVE(COL_DIFF_ADDED
);
545 COLOR_OTHER_SAVE(COL_DIFF_DELETED
);
546 COLOR_OTHER_SAVE(COL_DIFF_HUNK
);
547 COLOR_OTHER_SAVE(COL_TGT_FOLDER
);
548 COLOR_OTHER_SAVE(COL_NEW
);
550 main_window_reflect_prefs_all();
551 main_window_reflect_prefs_custom_colors(mainwindow_get_mainwindow());
553 #undef COLOR_OTHER_SAVE
555 static void prefs_msg_colors_reset_custom_colors(GtkWidget
*widget
, gpointer data
)
557 MsgColorsPage
*page
= (MsgColorsPage
*) data
;
561 for (c
= 0; c
< COLORLABELS
; c
++) {
562 rgba
= colorlabel_get_default_color(c
);
563 prefs_common
.custom_colorlabel
[c
].color
= rgba
;
564 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(color_buttons
.custom_color
[c
]), &rgba
);
565 gtk_entry_set_text(GTK_ENTRY(page
->entry_custom_colorlabel
[c
]),
566 gettext(SAFE_STRING (colorlabel_get_color_default_text(c
))));
570 static void prefs_msg_colors_destroy_widget(PrefsPage
*_page
)
574 MsgColorsPage
*prefs_msg_colors
;
576 void prefs_msg_colors_init(void)
579 static gchar
*path
[3];
581 path
[0] = _("Display");
582 path
[1] = _("Colors");
585 page
= g_new0(MsgColorsPage
, 1);
586 page
->page
.path
= path
;
587 page
->page
.create_widget
= prefs_msg_colors_create_widget
;
588 page
->page
.destroy_widget
= prefs_msg_colors_destroy_widget
;
589 page
->page
.save_page
= prefs_msg_colors_save
;
590 page
->page
.weight
= 165.0;
591 prefs_gtk_register_page((PrefsPage
*) page
);
592 prefs_msg_colors
= page
;
595 void prefs_msg_colors_done(void)
597 prefs_gtk_unregister_page((PrefsPage
*) prefs_msg_colors
);
598 g_free(prefs_msg_colors
);