[evolution] Bug 640994 - Email label colour disappears in message list pane when selected
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 640994 - Email label colour disappears in message list pane when selected
- Date: Tue, 2 Oct 2018 10:49:31 +0000 (UTC)
commit 5ac881ff3677847bca5c8b022b70a65e3dbe1b22
Author: Milan Crha <mcrha redhat com>
Date: Tue Oct 2 12:49:42 2018 +0200
Bug 640994 - Email label colour disappears in message list pane when selected
Closes https://bugzilla.gnome.org/show_bug.cgi?id=640994
src/e-util/e-cell-text.c | 90 +++++++++++++++++++++------------------
src/e-util/e-table-item.c | 40 +++++++++++-------
src/mail/message-list.c | 104 +++++++++++++++++++++++++++++++++++++++-------
3 files changed, 163 insertions(+), 71 deletions(-)
---
diff --git a/src/e-util/e-cell-text.c b/src/e-util/e-cell-text.c
index 6366fc1088..de1b147187 100644
--- a/src/e-util/e-cell-text.c
+++ b/src/e-util/e-cell-text.c
@@ -733,62 +733,65 @@ ect_draw (ECellView *ecell_view,
ECellTextView *text_view = (ECellTextView *) ecell_view;
ECellText *ect = E_CELL_TEXT (ecell_view->ecell);
CellEdit *edit = text_view->edit;
+ gboolean color_overwritten = FALSE;
gboolean selected;
GtkWidget *canvas = GTK_WIDGET (text_view->canvas);
- GdkRGBA fg_rgba, bg_rgba;
+ GdkRGBA fg_rgba, bg_rgba, overwritten_rgba;
gint x_origin, y_origin, vspacing;
cairo_save (cr);
selected = flags & E_CELL_SELECTED;
- if (selected) {
- if (gtk_widget_has_focus (canvas))
- e_utils_get_theme_color (canvas, "theme_selected_fg_color",
E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR, &fg_rgba);
- else
- e_utils_get_theme_color (canvas,
"theme_unfocused_selected_fg_color,theme_selected_fg_color",
E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_FG_COLOR, &fg_rgba);
- gdk_cairo_set_source_rgba (cr, &fg_rgba);
- } else {
- gboolean color_overwritten = FALSE;
+ e_utils_get_theme_color (canvas, "theme_text_color,theme_fg_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR,
&fg_rgba);
+ gdk_cairo_set_source_rgba (cr, &fg_rgba);
- e_utils_get_theme_color (canvas, "theme_text_color,theme_fg_color",
E_UTILS_DEFAULT_THEME_TEXT_COLOR, &fg_rgba);
- gdk_cairo_set_source_rgba (cr, &fg_rgba);
-
- if (ect->color_column != -1) {
- gchar *color_spec;
- GdkColor color;
+ if (ect->color_column != -1) {
+ gchar *color_spec;
- color_spec = e_table_model_value_at (
- ecell_view->e_table_model,
- ect->color_column, row);
- if (color_spec && gdk_color_parse (color_spec, &color)) {
- gdk_cairo_set_source_color (cr, &color);
- color_overwritten = TRUE;
+ color_spec = e_table_model_value_at (
+ ecell_view->e_table_model,
+ ect->color_column, row);
+ if (color_spec && gdk_rgba_parse (&overwritten_rgba, color_spec)) {
+ if (selected) {
+ fg_rgba = e_utils_get_text_color_for_background (&overwritten_rgba);
+ gdk_cairo_set_source_rgba (cr, &fg_rgba);
+ } else {
+ gdk_cairo_set_source_rgba (cr, &overwritten_rgba);
}
-
- if (color_spec)
- e_table_model_free_value (ecell_view->e_table_model, ect->color_column,
color_spec);
+ color_overwritten = TRUE;
}
- if (!color_overwritten && ect->bg_color_column != -1) {
- GdkRGBA bg_rgba;
- gchar *color_spec;
+ if (color_spec)
+ e_table_model_free_value (ecell_view->e_table_model, ect->color_column, color_spec);
+ }
- /* if the background color is overwritten and the text color is not, then
- pick either black or white text color, because the theme text color might
- be hard to read on the overwritten background */
- color_spec = e_table_model_value_at (
- ecell_view->e_table_model,
- ect->bg_color_column, row);
+ if (!color_overwritten && !selected && ect->bg_color_column != -1) {
+ gchar *color_spec;
- if (color_spec && gdk_rgba_parse (&bg_rgba, color_spec)) {
- bg_rgba = e_utils_get_text_color_for_background (&bg_rgba);
- gdk_cairo_set_source_rgba (cr, &bg_rgba);
- }
+ /* if the background color is overwritten and the text color is not, then
+ pick either black or white text color, because the theme text color might
+ be hard to read on the overwritten background */
+ color_spec = e_table_model_value_at (
+ ecell_view->e_table_model,
+ ect->bg_color_column, row);
- if (color_spec)
- e_table_model_free_value (ecell_view->e_table_model, ect->bg_color_column,
color_spec);
+ if (color_spec && gdk_rgba_parse (&bg_rgba, color_spec)) {
+ color_overwritten = TRUE;
+ bg_rgba = e_utils_get_text_color_for_background (&bg_rgba);
+ gdk_cairo_set_source_rgba (cr, &bg_rgba);
}
+
+ if (color_spec)
+ e_table_model_free_value (ecell_view->e_table_model, ect->bg_color_column,
color_spec);
+ }
+
+ if (!color_overwritten && selected) {
+ if (gtk_widget_has_focus (canvas))
+ e_utils_get_theme_color (canvas, "theme_selected_fg_color",
E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR, &fg_rgba);
+ else
+ e_utils_get_theme_color (canvas,
"theme_unfocused_selected_fg_color,theme_selected_fg_color",
E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_FG_COLOR, &fg_rgba);
+ gdk_cairo_set_source_rgba (cr, &fg_rgba);
}
vspacing = get_vertical_spacing (canvas);
@@ -873,7 +876,7 @@ ect_get_bg_color (ECellView *ecell_view,
gint row)
{
ECellText *ect = E_CELL_TEXT (ecell_view->ecell);
- gchar *color_spec;
+ gchar *color_spec, *bg_color;
if (ect->bg_color_column == -1)
return NULL;
@@ -882,7 +885,12 @@ ect_get_bg_color (ECellView *ecell_view,
ecell_view->e_table_model,
ect->bg_color_column, row);
- return color_spec;
+ bg_color = g_strdup (color_spec);
+
+ if (color_spec)
+ e_table_model_free_value (ecell_view->e_table_model, ect->bg_color_column, color_spec);
+
+ return bg_color;
}
/*
diff --git a/src/e-util/e-table-item.c b/src/e-util/e-table-item.c
index 61b2dd6c13..0e96fac7f4 100644
--- a/src/e-util/e-table-item.c
+++ b/src/e-util/e-table-item.c
@@ -42,6 +42,7 @@
#include "e-canvas-utils.h"
#include "e-canvas.h"
#include "e-cell.h"
+#include "e-cell-text.h"
#include "e-marshal.h"
#include "e-table-subset.h"
#include "gal-a11y-e-table-item-factory.h"
@@ -333,28 +334,37 @@ eti_get_cell_background_color (ETableItem *eti,
{
ECellView *ecell_view = eti->cell_views[col];
GtkWidget *canvas;
+ gboolean was_set = FALSE;
gchar *color_spec = NULL;
canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (eti)->canvas);
- if (selected) {
- if (gtk_widget_has_focus (canvas))
- e_utils_get_theme_color (canvas, "theme_selected_bg_color",
E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, background);
- else
- e_utils_get_theme_color (canvas,
"theme_unfocused_selected_bg_color,theme_selected_bg_color",
E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_BG_COLOR, background);
- } else {
- e_utils_get_theme_color (canvas, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR,
background);
+ g_signal_emit (eti, eti_signals[GET_BG_COLOR], 0, row, col, background, &was_set);
- g_signal_emit (eti, eti_signals[GET_BG_COLOR], 0, row, col, background);
- }
+ if (!was_set) {
+ color_spec = e_cell_get_bg_color (ecell_view, row);
- color_spec = e_cell_get_bg_color (ecell_view, row);
+ if (color_spec != NULL) {
+ GdkRGBA bg;
- if (color_spec != NULL) {
- GdkRGBA bg;
+ if (gdk_rgba_parse (&bg, color_spec)) {
+ *background = bg;
+ was_set = TRUE;
+ }
+ }
- if (gdk_rgba_parse (&bg, color_spec))
- *background = bg;
+ g_free (color_spec);
+ }
+
+ if (!was_set) {
+ if (selected) {
+ if (gtk_widget_has_focus (canvas))
+ e_utils_get_theme_color (canvas, "theme_selected_bg_color",
E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, background);
+ else
+ e_utils_get_theme_color (canvas,
"theme_unfocused_selected_bg_color,theme_selected_bg_color",
E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_BG_COLOR, background);
+ } else {
+ e_utils_get_theme_color (canvas, "theme_base_color",
E_UTILS_DEFAULT_THEME_BASE_COLOR, background);
+ }
}
if (eti->alternating_row_colors) {
@@ -3414,7 +3424,7 @@ e_table_item_class_init (ETableItemClass *class)
G_STRUCT_OFFSET (ETableItemClass, get_bg_color),
NULL, NULL,
NULL,
- G_TYPE_NONE, 3,
+ G_TYPE_BOOLEAN, 3, /* return TRUE when set */
G_TYPE_INT, /* row */
G_TYPE_INT, /* col */
G_TYPE_POINTER /* GdkRGBA *background, but cannot be passed as
diff --git a/src/mail/message-list.c b/src/mail/message-list.c
index f889046389..e364b2d97b 100644
--- a/src/mail/message-list.c
+++ b/src/mail/message-list.c
@@ -2001,7 +2001,43 @@ ml_tree_value_at_ex (ETreeModel *etm,
colour = g_intern_string (colour_alloced);
g_free (colour_alloced);
}
- } else if (camel_message_info_get_flags (msg_info) & CAMEL_MESSAGE_FLAGGED) {
+ } else if (g_hash_table_size (ld.labels_tag2iter) > 1) {
+ /* When there is more than one label set, then pick the color of the first
+ found, in order of the EMailLabelListStore */
+ GtkTreeIter titer;
+ GtkTreeModel *model = GTK_TREE_MODEL (ld.store);
+
+ if (gtk_tree_model_get_iter_first (model, &titer)) {
+ do {
+ gchar *tag;
+
+ tag = e_mail_label_list_store_get_tag (ld.store, &titer);
+ if (tag && g_hash_table_contains (ld.labels_tag2iter, tag)) {
+ GdkColor colour_val;
+
+ g_free (tag);
+
+ if (e_mail_label_list_store_get_color (ld.store,
&titer, &colour_val)) {
+ gchar *colour_alloced;
+
+ /* XXX Hack to avoid returning an allocated
string. */
+ colour_alloced = gdk_color_to_string
(&colour_val);
+ colour = g_intern_string (colour_alloced);
+ g_free (colour_alloced);
+ }
+ break;
+ }
+
+ g_free (tag);
+ } while (gtk_tree_model_iter_next (model, &titer));
+ }
+ }
+
+ g_hash_table_destroy (ld.labels_tag2iter);
+ }
+
+ if (!colour) {
+ if (camel_message_info_get_flags (msg_info) & CAMEL_MESSAGE_FLAGGED) {
/* FIXME: extract from the important.xpm somehow. */
colour = "#A7453E";
} else if (((followup && *followup) || (due_by && *due_by)) && !(completed &&
*completed)) {
@@ -2010,8 +2046,6 @@ ml_tree_value_at_ex (ETreeModel *etm,
if ((followup && *followup) || now >= camel_header_decode_date (due_by, NULL))
colour = "#A7453E";
}
-
- g_hash_table_destroy (ld.labels_tag2iter);
}
if (!colour)
@@ -2852,32 +2886,72 @@ ml_tree_sorting_changed (ETreeTableAdapter *adapter,
return FALSE;
}
-static void
-ml_get_bg_color_cb (ETableItem *item,
- gint row,
- gint col,
- GdkRGBA *inout_background,
- MessageList *message_list)
+static gboolean
+ml_get_new_mail_bg_color (ETableItem *item,
+ gint row,
+ gint col,
+ GdkRGBA *inout_background,
+ MessageList *message_list)
{
CamelMessageInfo *msg_info;
ETreePath path;
- g_return_if_fail (IS_MESSAGE_LIST (message_list));
- g_return_if_fail (inout_background != NULL);
+ g_return_val_if_fail (IS_MESSAGE_LIST (message_list), FALSE);
+ g_return_val_if_fail (inout_background != NULL, FALSE);
if (!message_list->priv->new_mail_bg_color || row < 0)
- return;
+ return FALSE;
path = e_tree_table_adapter_node_at_row (e_tree_get_table_adapter (E_TREE (message_list)), row);
if (!path || G_NODE_IS_ROOT ((GNode *) path))
- return;
+ return FALSE;
/* retrieve the message information array */
msg_info = ((GNode *) path)->data;
- g_return_if_fail (msg_info != NULL);
+ g_return_val_if_fail (msg_info != NULL, FALSE);
- if (!(camel_message_info_get_flags (msg_info) & CAMEL_MESSAGE_SEEN))
+ if (!(camel_message_info_get_flags (msg_info) & CAMEL_MESSAGE_SEEN)) {
*inout_background = *(message_list->priv->new_mail_bg_color);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+ml_get_bg_color_cb (ETableItem *item,
+ gint row,
+ gint col,
+ GdkRGBA *inout_background,
+ MessageList *message_list)
+{
+ gboolean was_set = FALSE;
+
+ g_return_val_if_fail (IS_MESSAGE_LIST (message_list), FALSE);
+ g_return_val_if_fail (inout_background != NULL, FALSE);
+
+ if (row < 0)
+ return FALSE;
+
+ if (e_selection_model_is_row_selected (e_tree_get_selection_model (E_TREE (message_list)), row)) {
+ ETableModel *table_model;
+ gchar *color_spec;
+
+ table_model = E_TABLE_MODEL (e_tree_get_table_adapter (E_TREE (message_list)));
+
+ color_spec = e_table_model_value_at (table_model, COL_COLOUR, row);
+ if (color_spec && gdk_rgba_parse (inout_background, color_spec)) {
+ was_set = TRUE;
+ }
+
+ if (color_spec)
+ e_table_model_free_value (table_model, COL_COLOUR, color_spec);
+ }
+
+ if (!was_set)
+ was_set = ml_get_new_mail_bg_color (item, row, col, inout_background, message_list);
+
+ return was_set;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]