[Commits] [SCM] claws branch, gtk3, updated. 4.0.0-56-gbcb41b69e
paul at claws-mail.org
paul at claws-mail.org
Sun Aug 22 11:58:37 UTC 2021
The branch, gtk3 has been updated
via bcb41b69e5eda3953c1e5d21f2acc908514e3886 (commit)
from 839650c6dd13191109626c51a57144bb9577548b (commit)
Summary of changes:
src/prefs_msg_colors.c | 288 ++++++++++---------------------------------------
1 file changed, 55 insertions(+), 233 deletions(-)
- Log -----------------------------------------------------------------
commit bcb41b69e5eda3953c1e5d21f2acc908514e3886
Author: paul <paul at claws-mail.org>
Date: Sun Aug 22 12:58:34 2021 +0100
use GtkColorChooser in colour prefs page
diff --git a/src/prefs_msg_colors.c b/src/prefs_msg_colors.c
index 2e3966938..48d5706c7 100644
--- a/src/prefs_msg_colors.c
+++ b/src/prefs_msg_colors.c
@@ -1,6 +1,6 @@
/*
* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2004-2019 The Claws Mail Team & Hiroyuki Yamamoto
+ * Copyright (C) 2004-2021 The Claws Mail Team
*
* 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
@@ -65,33 +65,24 @@ typedef struct _MsgColorsPage
GtkWidget *entry_custom_colorlabel[COLORLABELS];
} MsgColorsPage;
-static GtkWidget *color_dialog;
-static const gchar *color_dialog_title[COL_LAST_COLOR_INDEX];
-static gboolean color_dialog_title_init = FALSE;
-
-static void quote_color_set_dialog (GtkWidget *widget,
- gpointer data);
-static void quote_colors_set_dialog_ok (GtkWidget *widget,
- gpointer data);
-static void quote_colors_set_dialog_cancel (GtkWidget *widget,
- gpointer data);
-static gboolean quote_colors_set_dialog_key_pressed (GtkWidget *widget,
- GdkEventKey *event,
- gpointer data);
static void prefs_msg_colors_reset_custom_colors(GtkWidget *widget,
gpointer data);
-#define COLOR_BUTTON_PACK_START(gtkbox, colorid, tooltiptext) \
- color_buttons.color[colorid] = gtk_button_new_with_label ("\x20\xE2\x80\x83\x20"); \
- gtk_widget_show (color_buttons.color[colorid]); \
- gtk_box_pack_start (GTK_BOX(gtkbox), color_buttons.color[colorid], FALSE, FALSE, 0); \
- gtk_widget_set_tooltip_text (GTK_WIDGET(color_buttons.color[colorid]), tooltiptext)
-
-#define COLOR_BUTTON_PACK_END(gtkbox, colorid, tooltiptext) \
- color_buttons.color[colorid] = gtk_button_new_with_label ("\x20\xE2\x80\x83\x20"); \
- gtk_widget_show (color_buttons.color[colorid]); \
- gtk_box_pack_end (GTK_BOX(gtkbox), color_buttons.color[colorid], FALSE, FALSE, 0); \
- gtk_widget_set_tooltip_text (GTK_WIDGET(color_buttons.color[colorid]), tooltiptext)
+#define COLOR_BUTTON_PACK_START(gtkbox, colorid, text) \
+ color_buttons.color[colorid] = gtk_color_button_new_with_rgba( \
+ &prefs_common.color[colorid]); \
+ gtk_color_button_set_title(GTK_COLOR_BUTTON(color_buttons.color[colorid]), text); \
+ gtk_widget_show(color_buttons.color[colorid]); \
+ gtk_box_pack_start(GTK_BOX(gtkbox), color_buttons.color[colorid], FALSE, FALSE, 0); \
+ gtk_widget_set_tooltip_text(GTK_WIDGET(color_buttons.color[colorid]), text)
+
+#define COLOR_BUTTON_PACK_END(gtkbox, colorid, text) \
+ color_buttons.color[colorid] = gtk_color_button_new_with_rgba( \
+ &prefs_common.color[colorid]); \
+ gtk_color_button_set_title(GTK_COLOR_BUTTON(color_buttons.color[colorid]), text); \
+ gtk_widget_show(color_buttons.color[colorid]); \
+ gtk_box_pack_end(GTK_BOX(gtkbox), color_buttons.color[colorid], FALSE, FALSE, 0); \
+ gtk_widget_set_tooltip_text(GTK_WIDGET(color_buttons.color[colorid]), text)
#define COLOR_LABEL_PACK_START(gtkbox, colorid, labeltext) \
label[colorid] = gtk_label_new (labeltext); \
@@ -140,6 +131,7 @@ static void prefs_msg_colors_create_widget(PrefsPage *_page, GtkWindow *window,
gint c;
gchar *tooltip_btn_text = NULL;
gchar *tooltip_entry_text = NULL;
+ gchar *title = NULL;
notebook = gtk_notebook_new();
gtk_widget_show(notebook);
@@ -404,7 +396,12 @@ static void prefs_msg_colors_create_widget(PrefsPage *_page, GtkWindow *window,
gtk_box_pack_start(GTK_BOX (vbox_custom_colors1), hbox_custom_color[c],
FALSE, TRUE, 0);
- color_buttons.custom_color[c] = gtk_button_new_with_label("");
+ color_buttons.custom_color[c] = gtk_color_button_new_with_rgba(
+ &prefs_common.custom_colorlabel[c].color);
+ title = g_strdup_printf(C_("Dialog title", "Pick color for 'color %d'"), c+1);
+ gtk_color_button_set_title(GTK_COLOR_BUTTON(color_buttons.custom_color[c]),
+ title);
+ g_free(title);
gtk_widget_show(color_buttons.custom_color[c]);
gtk_box_pack_start(GTK_BOX (hbox_custom_color[c]), color_buttons.custom_color[c],
FALSE, FALSE, 0);
@@ -436,7 +433,12 @@ static void prefs_msg_colors_create_widget(PrefsPage *_page, GtkWindow *window,
gtk_box_pack_start(GTK_BOX (vbox_custom_colors2), hbox_custom_color[c],
FALSE, TRUE, 0);
- color_buttons.custom_color[c] = gtk_button_new_with_label("");
+ color_buttons.custom_color[c] = gtk_color_button_new_with_rgba(
+ &prefs_common.custom_colorlabel[c].color);
+ title = g_strdup_printf(C_("Dialog title", "Pick color for 'color %d'"), c+1);
+ gtk_color_button_set_title(GTK_COLOR_BUTTON(color_buttons.custom_color[c]),
+ title);
+ g_free(title);
gtk_widget_show(color_buttons.custom_color[c]);
gtk_box_pack_start(GTK_BOX (hbox_custom_color[c]), color_buttons.custom_color[c],
FALSE, FALSE, 0);
@@ -464,35 +466,10 @@ static void prefs_msg_colors_create_widget(PrefsPage *_page, GtkWindow *window,
gtk_box_pack_start(GTK_BOX(hbox_reset_custom_colors), btn_reset_custom_colors,
FALSE, FALSE, 0);
- /* program colors */
- for (c = 0; c < COL_LAST_COLOR_INDEX; c++) {
- if (color_buttons.color[c] != NULL) {
- g_signal_connect(G_OBJECT(color_buttons.color[c]),
- "clicked",
- G_CALLBACK(quote_color_set_dialog),
- GINT_TO_POINTER(COLORLABELS + c));
- }
- }
- /* custom colors */
- for (c = 0; c < COLORLABELS; c++) {
- g_signal_connect(G_OBJECT(color_buttons.custom_color[c]), "clicked",
- G_CALLBACK(quote_color_set_dialog), GINT_TO_POINTER(c));
- }
-
g_signal_connect(G_OBJECT(btn_reset_custom_colors), "clicked",
G_CALLBACK(prefs_msg_colors_reset_custom_colors), prefs_msg_colors);
- /* program colors */
- for (c = 0; c < COL_LAST_COLOR_INDEX; c++) {
- if (color_buttons.color[c] != NULL) {
- gtkut_set_button_color(color_buttons.color[c],
- &prefs_common.color[c]);
- }
- }
- /* custom colors */
for (c = 0; c < COLORLABELS; c++) {
- gtkut_set_button_color(color_buttons.custom_color[c],
- &prefs_common.custom_colorlabel[c].color);
gtk_entry_set_text(GTK_ENTRY (entry_custom_colorlabel[c]),
gettext(SAFE_STRING (prefs_common.custom_colorlabel[c].label)));
}
@@ -507,7 +484,7 @@ static void prefs_msg_colors_create_widget(PrefsPage *_page, GtkWindow *window,
prefs_msg_colors->checkbtn_enable_colors = checkbtn_enable_colors;
prefs_msg_colors->checkbtn_enable_bgcolors = checkbtn_enable_bgcolors;
prefs_msg_colors->checkbtn_recycle_colors = checkbtn_recycle_colors;
- /* custom colors */
+
for (c = 0; c < COLORLABELS; c++) {
prefs_msg_colors->entry_custom_colorlabel[c] = entry_custom_colorlabel[c];
}
@@ -521,185 +498,15 @@ static void prefs_msg_colors_create_widget(PrefsPage *_page, GtkWindow *window,
#undef COLOR_LABEL_PACK_START
#undef COLOR_LABEL_PACK_END
-static void initialize_color_dialog_title()
-{
- color_dialog_title[COL_QUOTE_LEVEL1] =
- C_("Dialog title", "Pick color for 1st level text");
- color_dialog_title[COL_QUOTE_LEVEL2] =
- C_("Dialog title", "Pick color for 2nd level text");
- color_dialog_title[COL_QUOTE_LEVEL3] =
- C_("Dialog title", "Pick color for 3rd level text");
- color_dialog_title[COL_QUOTE_LEVEL1_BG] =
- C_("Dialog title", "Pick color for 1st level text background");
- color_dialog_title[COL_QUOTE_LEVEL2_BG] =
- C_("Dialog title", "Pick color for 2nd level text background");
- color_dialog_title[COL_QUOTE_LEVEL3_BG] =
- C_("Dialog title", "Pick color for 3rd level text background");
- color_dialog_title[COL_URI] =
- C_("Dialog title", "Pick color for links");
- color_dialog_title[COL_TGT_FOLDER] =
- C_("Dialog title", "Pick color for target folder");
- color_dialog_title[COL_SIGNATURE] =
- C_("Dialog title", "Pick color for signatures");
- color_dialog_title[COL_NEW] =
- C_("Dialog title", "Pick color for folder");
- color_dialog_title[COL_DIFF_ADDED] =
- C_("Dialog title", "Pick color for inserted lines");
- color_dialog_title[COL_DIFF_DELETED] =
- C_("Dialog title", "Pick color for removed lines");
- color_dialog_title[COL_DIFF_HUNK] =
- C_("Dialog title", "Pick color for hunk lines");
-
- color_dialog_title_init = TRUE;
-}
-
-static void quote_color_set_dialog(GtkWidget *widget, gpointer data)
-{
- gchar *type = (gchar *)data;
- gchar *title = NULL;
- GdkColor color;
- GdkRGBA rgba;
- GtkColorSelectionDialog *dialog;
- GtkWidget *button_ok;
- GtkWidget *button_cancel;
- gint c, ctype;
-
- ctype = GPOINTER_TO_INT(type);
- /* custom colors */
- /* leave the extra space at the end of the title, this is for translators' convenience */
- for (c = 0; c < COLORLABELS; c++) {
- if (ctype == c) {
- /* TRANSLATORS: 'color %d' refers to the filtering/processing
- rule name and should not be translated */
- title = g_strdup_printf(C_("Dialog title", "Pick color for 'color %d'"), c+1);
- rgba = prefs_common.custom_colorlabel[c].color;
- break;
- }
- }
- /* other colors */
- if (!color_dialog_title_init)
- initialize_color_dialog_title();
-
- if (c == COLORLABELS) {
- ctype -= COLORLABELS;
- if (ctype < COL_LAST_COLOR_INDEX) {
- title = g_strdup(color_dialog_title[ctype]);
- rgba = prefs_common.color[ctype];
- } else {
- g_warning("Unrecognized datatype '%s' in quote_color_set_dialog", type);
- return;
- }
- }
-
- color_dialog = gtk_color_selection_dialog_new(title);
- g_free(title);
- gtk_window_set_position(GTK_WINDOW(color_dialog), GTK_WIN_POS_CENTER);
- gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
- gtk_window_set_resizable(GTK_WINDOW(color_dialog), FALSE);
- manage_window_set_transient(GTK_WINDOW(color_dialog));
-
- g_object_get(color_dialog, "ok-button", &button_ok,
- "cancel-button", &button_cancel,
- NULL);
-
- g_signal_connect(G_OBJECT(button_cancel),
- "clicked", G_CALLBACK(quote_colors_set_dialog_cancel), data);
- g_signal_connect(G_OBJECT(button_ok),
- "clicked", G_CALLBACK(quote_colors_set_dialog_ok), data);
- g_signal_connect(G_OBJECT(color_dialog), "key_press_event",
- G_CALLBACK(quote_colors_set_dialog_key_pressed),data);
-
- /* preselect the previous color in the color selection dialog */
-
- GTKUT_GDKRGBA_TO_GDKCOLOR(rgba, color);
-
- dialog = GTK_COLOR_SELECTION_DIALOG(color_dialog);
- gtk_color_selection_set_current_color
- (GTK_COLOR_SELECTION(gtk_color_selection_dialog_get_color_selection(dialog)), &color);
-
- gtk_widget_show(color_dialog);
-}
-
-static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
-{
- GtkColorSelection *colorsel = GTK_COLOR_SELECTION(
- gtk_color_selection_dialog_get_color_selection
- ((GtkColorSelectionDialog *)color_dialog));
- GdkColor color;
- GdkRGBA rgba;
- gchar *type = (gchar *)data;
- gint c, ctype;
-
- gtk_color_selection_get_current_color(colorsel, &color);
- GTKUT_GDKCOLOR_TO_GDKRGBA(color, rgba);
-
- ctype = GPOINTER_TO_INT(type);
- /* custom colors */
- for (c = 0; c < COLORLABELS; c++) {
- if (ctype == c) {
- prefs_common.custom_colorlabel[c].color = rgba;
- gtkut_set_button_color(color_buttons.custom_color[c], &rgba);
- break;
- }
- }
- /* other colors */
- if (c == COLORLABELS) {
- ctype -= COLORLABELS;
- if (ctype < COL_LAST_COLOR_INDEX) {
- prefs_common.color[ctype] = rgba;
- gtkut_set_button_color(color_buttons.color[ctype], &rgba);
- if (ctype == COL_TGT_FOLDER) {
- folderview_set_target_folder_color(prefs_common.color[ctype]);
- }
- } else {
- g_warning("Unrecognized datatype '%s' in quote_color_set_dialog_ok", type);
- }
- }
-
- gtk_widget_destroy(color_dialog);
-}
-
-static void quote_colors_set_dialog_cancel(GtkWidget *widget, gpointer data)
-{
- gtk_widget_destroy(color_dialog);
-}
-
-static gboolean quote_colors_set_dialog_key_pressed(GtkWidget *widget,
- GdkEventKey *event,
- gpointer data)
-{
- GtkColorSelectionDialog *dialog;
- GtkWidget *button_ok;
- GtkWidget *button_cancel;
-
- dialog = GTK_COLOR_SELECTION_DIALOG(widget);
- g_object_get(dialog, "ok-button", &button_ok,
- "cancel-button", &button_cancel,
- NULL);
-
- if (event) {
- switch (event->keyval) {
- case GDK_KEY_Escape:
- gtk_button_clicked(GTK_BUTTON(button_cancel));
- return TRUE;
- case GDK_KEY_Return:
- case GDK_KEY_KP_Enter:
- /* NOTE: changing focus makes widget accept all currently
- * changed settings! */
- gtk_widget_grab_focus(button_ok);
- /* call ok handler */
- gtk_button_clicked(GTK_BUTTON(button_ok));
- return TRUE;
- default:
- break;
- }
- }
- return FALSE;
-}
+#define COLOR_OTHER_SAVE(colorid) \
+ gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(color_buttons.color[colorid]), \
+ &rgbcolor); \
+ prefs_common.color[colorid] = rgbcolor; \
static void prefs_msg_colors_save(PrefsPage *_page)
{
MsgColorsPage *page = (MsgColorsPage *) _page;
+ GdkRGBA rgbcolor;
gint c;
prefs_common.enable_color =
@@ -714,12 +521,29 @@ static void prefs_msg_colors_save(PrefsPage *_page)
g_free(prefs_common.custom_colorlabel[c].label);
prefs_common.custom_colorlabel[c].label =
gtk_editable_get_chars(GTK_EDITABLE(page->entry_custom_colorlabel[c]), 0, -1);
+ gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(color_buttons.custom_color[c]),
+ &rgbcolor);
+ prefs_common.custom_colorlabel[c].color = rgbcolor;
}
colorlabel_update_colortable_from_prefs();
+ COLOR_OTHER_SAVE(COL_QUOTE_LEVEL1);
+ COLOR_OTHER_SAVE(COL_QUOTE_LEVEL2);
+ COLOR_OTHER_SAVE(COL_QUOTE_LEVEL3);
+ COLOR_OTHER_SAVE(COL_QUOTE_LEVEL1_BG);
+ COLOR_OTHER_SAVE(COL_QUOTE_LEVEL2_BG);
+ COLOR_OTHER_SAVE(COL_QUOTE_LEVEL3_BG);
+ COLOR_OTHER_SAVE(COL_URI);
+ COLOR_OTHER_SAVE(COL_SIGNATURE);
+ COLOR_OTHER_SAVE(COL_DIFF_ADDED);
+ COLOR_OTHER_SAVE(COL_DIFF_DELETED);
+ COLOR_OTHER_SAVE(COL_DIFF_HUNK);
+ COLOR_OTHER_SAVE(COL_TGT_FOLDER);
+ COLOR_OTHER_SAVE(COL_NEW);
main_window_reflect_prefs_all();
main_window_reflect_prefs_custom_colors(mainwindow_get_mainwindow());
}
+#undef COLOR_OTHER_SAVE
static void prefs_msg_colors_reset_custom_colors(GtkWidget *widget, gpointer data)
{
@@ -730,12 +554,10 @@ static void prefs_msg_colors_reset_custom_colors(GtkWidget *widget, gpointer dat
for (c = 0; c < COLORLABELS; c++) {
rgba = colorlabel_get_default_color(c);
prefs_common.custom_colorlabel[c].color = rgba;
- gtkut_set_button_color(color_buttons.custom_color[c],
- &prefs_common.custom_colorlabel[c].color);
- gtk_entry_set_text(GTK_ENTRY (page->entry_custom_colorlabel[c]),
- gettext(SAFE_STRING (colorlabel_get_color_default_text(c))));
+ gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(color_buttons.custom_color[c]), &rgba);
+ gtk_entry_set_text(GTK_ENTRY(page->entry_custom_colorlabel[c]),
+ gettext(SAFE_STRING (colorlabel_get_color_default_text(c))));
}
-
}
static void prefs_msg_colors_destroy_widget(PrefsPage *_page)
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list