[evolution] Inconsistent background color in ETable for Memos, Tasks and List View



commit a0ac630745ad07331c3ac3ad85cf23e77d3b40bc
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jun 26 11:32:53 2019 +0200

    Inconsistent background color in ETable for Memos, Tasks and List View
    
    The background color of some columns in the Memos, Tasks and Calendar's
    List View didn't use the background color of the calendar or component,
    which made the UI look inconsistent. This change makes all columns drawn
    with the same background for each row.

 src/calendar/gui/e-cal-list-view.c      |  3 ++
 src/calendar/gui/e-cal-list-view.etspec |  2 +-
 src/calendar/gui/e-memo-table.c         |  3 ++
 src/calendar/gui/e-memo-table.etspec    |  2 +-
 src/calendar/gui/e-task-table.c         |  9 ++++
 src/calendar/gui/e-task-table.etspec    |  2 +-
 src/e-util/e-cell-toggle.c              | 84 +++++++++++++++++++++++++++++++++
 7 files changed, 102 insertions(+), 3 deletions(-)
---
diff --git a/src/calendar/gui/e-cal-list-view.c b/src/calendar/gui/e-cal-list-view.c
index b7821a95c3..d8574b5d1d 100644
--- a/src/calendar/gui/e-cal-list-view.c
+++ b/src/calendar/gui/e-cal-list-view.c
@@ -184,6 +184,9 @@ setup_e_table (ECalListView *cal_list_view)
        extras = e_table_extras_new ();
 
        cell = e_cell_toggle_new (icon_names, G_N_ELEMENTS (icon_names));
+       g_object_set (cell,
+               "bg-color-column", E_CAL_MODEL_FIELD_COLOR,
+               NULL);
        e_table_extras_add_cell (extras, "icon", cell);
        g_object_unref (cell);
 
diff --git a/src/calendar/gui/e-cal-list-view.etspec b/src/calendar/gui/e-cal-list-view.etspec
index b082a99dea..9901c012d2 100644
--- a/src/calendar/gui/e-cal-list-view.etspec
+++ b/src/calendar/gui/e-cal-list-view.etspec
@@ -7,7 +7,7 @@
   <ETableColumn model_col="0" _title="Categories" cell="calstring" compare="collate" expansion="1.0" 
minimum_width="10" resizable="true" priority="-2"/>
   <ETableColumn model_col="10" _title="Created" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
   <ETableColumn model_col="11" _title="Last modified" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
-  <ETableColumn model_col="12" _title="Source" expansion="1.0" minimum_width="10" resizable="true" 
cell="string" compare="collate" priority="-2"/>
+  <ETableColumn model_col="12" _title="Source" expansion="1.0" minimum_width="10" resizable="true" 
cell="calstring" compare="collate" priority="-2"/>
   <ETableColumn model_col="17" _title="Status" expansion="1.0" minimum_width="10" resizable="true" 
cell="calstatus" compare="status-compare" priority="-1"/>
   <ETableColumn model_col="7" pixbuf="icon" _title="Type" expansion="1.0" minimum_width="16" 
resizable="false" cell="icon" compare="integer" priority="-4"/>
 
diff --git a/src/calendar/gui/e-memo-table.c b/src/calendar/gui/e-memo-table.c
index 7ad45823b1..6fe759d5d5 100644
--- a/src/calendar/gui/e-memo-table.c
+++ b/src/calendar/gui/e-memo-table.c
@@ -416,6 +416,9 @@ memo_table_constructed (GObject *object)
        /* Create pixmaps */
 
        cell = e_cell_toggle_new (icon_names, G_N_ELEMENTS (icon_names));
+       g_object_set (cell,
+               "bg-color-column", E_CAL_MODEL_FIELD_COLOR,
+               NULL);
        e_table_extras_add_cell (extras, "icon", cell);
        g_object_unref (cell);
 
diff --git a/src/calendar/gui/e-memo-table.etspec b/src/calendar/gui/e-memo-table.etspec
index 810830e9cb..1684b5d032 100644
--- a/src/calendar/gui/e-memo-table.etspec
+++ b/src/calendar/gui/e-memo-table.etspec
@@ -5,7 +5,7 @@
   <ETableColumn model_col="5" _title="Start Date" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
   <ETableColumn model_col="10" _title="Created" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
   <ETableColumn model_col="11" _title="Last modified" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
-  <ETableColumn model_col="12" _title="Source" expansion="1.0" minimum_width="10" resizable="true" 
cell="string" compare="collate" priority="-2"/>
+  <ETableColumn model_col="12" _title="Source" expansion="1.0" minimum_width="10" resizable="true" 
cell="calstring" compare="collate" priority="-2"/>
   <ETableColumn model_col="14" _title="Status" expansion="1.0" minimum_width="10" resizable="true" 
cell="calstatus" compare="status-compare" priority="-1"/>
 
   <ETableState>
diff --git a/src/calendar/gui/e-task-table.c b/src/calendar/gui/e-task-table.c
index 4f08347bf0..4717646d5e 100644
--- a/src/calendar/gui/e-task-table.c
+++ b/src/calendar/gui/e-task-table.c
@@ -575,6 +575,9 @@ task_table_constructed (GObject *object)
        /* Create pixmaps */
 
        cell = e_cell_toggle_new (icon_names, G_N_ELEMENTS (icon_names));
+       g_object_set (cell,
+               "bg-color-column", E_CAL_MODEL_FIELD_COLOR,
+               NULL);
        e_table_extras_add_cell (extras, "icon", cell);
        g_object_unref (cell);
 
@@ -582,6 +585,12 @@ task_table_constructed (GObject *object)
 
        e_table_extras_add_icon_name (extras, "complete", "stock_check-filled");
 
+       /* Set background column for the checkbox */
+       cell = e_table_extras_get_cell (extras, "checkbox");
+       g_object_set (cell,
+               "bg-color-column", E_CAL_MODEL_FIELD_COLOR,
+               NULL);
+
        /* set proper format component for a default 'date' cell renderer */
        cell = e_table_extras_get_cell (extras, "date");
        e_cell_date_set_format_component (E_CELL_DATE (cell), "calendar");
diff --git a/src/calendar/gui/e-task-table.etspec b/src/calendar/gui/e-task-table.etspec
index ce06a7ec17..8d3210e0a8 100644
--- a/src/calendar/gui/e-task-table.etspec
+++ b/src/calendar/gui/e-task-table.etspec
@@ -12,7 +12,7 @@
   <ETableColumn model_col="24" _title="Location" expansion="3.0" minimum_width="10" resizable="true" 
cell="calstring" compare="collate" priority="10"/>
   <ETableColumn model_col="10" _title="Created" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
   <ETableColumn model_col="11" _title="Last modified" expansion="2.0" minimum_width="10" resizable="true" 
cell="dateedit" compare="date-compare" priority="-2"/>
-  <ETableColumn model_col="12" _title="Source" expansion="1.0" minimum_width="10" resizable="true" 
cell="string" compare="collate" priority="-2"/>
+  <ETableColumn model_col="12" _title="Source" expansion="1.0" minimum_width="10" resizable="true" 
cell="calstring" compare="collate" priority="-2"/>
 
   <ETableState>
     <column source="1"/>
diff --git a/src/e-util/e-cell-toggle.c b/src/e-util/e-cell-toggle.c
index eeb1135868..4281aed164 100644
--- a/src/e-util/e-cell-toggle.c
+++ b/src/e-util/e-cell-toggle.c
@@ -47,6 +47,13 @@ struct _ECellTogglePrivate {
        GdkPixbuf *empty;
        GPtrArray *pixbufs;
        gint height;
+
+       gint bg_color_column;
+};
+
+enum {
+       PROP_0,
+       PROP_BG_COLOR_COLUMN
 };
 
 G_DEFINE_TYPE (ECellToggle, e_cell_toggle, E_TYPE_CELL)
@@ -366,6 +373,68 @@ cell_toggle_max_width (ECellView *ecell_view,
        return max_width;
 }
 
+static gchar *
+cell_toggle_get_bg_color (ECellView *ecell_view,
+                         gint row)
+{
+       ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell);
+       gchar *color_spec, *bg_color;
+
+       if (toggle->priv->bg_color_column == -1)
+               return NULL;
+
+       color_spec = e_table_model_value_at (
+               ecell_view->e_table_model,
+               toggle->priv->bg_color_column, row);
+
+       bg_color = g_strdup (color_spec);
+
+       if (color_spec)
+               e_table_model_free_value (ecell_view->e_table_model, toggle->priv->bg_color_column, 
color_spec);
+
+       return bg_color;
+}
+
+static void
+cell_toggle_set_property (GObject *object,
+                         guint property_id,
+                         const GValue *value,
+                         GParamSpec *pspec)
+{
+       ECellToggle *toggle;
+
+       toggle = E_CELL_TOGGLE (object);
+
+       switch (property_id) {
+       case PROP_BG_COLOR_COLUMN:
+               toggle->priv->bg_color_column = g_value_get_int (value);
+               break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+               break;
+       }
+}
+
+static void
+cell_toggle_get_property (GObject *object,
+                         guint property_id,
+                         GValue *value,
+                         GParamSpec *pspec)
+{
+       ECellToggle *toggle;
+
+       toggle = E_CELL_TOGGLE (object);
+
+       switch (property_id) {
+       case PROP_BG_COLOR_COLUMN:
+               g_value_set_int (value, toggle->priv->bg_color_column);
+               break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+               break;
+       }
+}
+
 static void
 e_cell_toggle_class_init (ECellToggleClass *class)
 {
@@ -377,6 +446,8 @@ e_cell_toggle_class_init (ECellToggleClass *class)
        object_class = G_OBJECT_CLASS (class);
        object_class->dispose = cell_toggle_dispose;
        object_class->finalize = cell_toggle_finalize;
+       object_class->set_property = cell_toggle_set_property;
+       object_class->get_property = cell_toggle_get_property;
 
        cell_class = E_CELL_CLASS (class);
        cell_class->new_view = cell_toggle_new_view;
@@ -387,6 +458,17 @@ e_cell_toggle_class_init (ECellToggleClass *class)
        cell_class->print = cell_toggle_print;
        cell_class->print_height = cell_toggle_print_height;
        cell_class->max_width = cell_toggle_max_width;
+       cell_class->get_bg_color = cell_toggle_get_bg_color;
+
+       g_object_class_install_property (
+               object_class,
+               PROP_BG_COLOR_COLUMN,
+               g_param_spec_int (
+                       "bg-color-column",
+                       "BG Color Column",
+                       NULL,
+                       -1, G_MAXINT, -1,
+                       G_PARAM_READWRITE));
 
        gal_a11y_e_cell_registry_add_cell_type (
                NULL, E_TYPE_CELL_TOGGLE, gal_a11y_e_cell_toggle_new);
@@ -402,6 +484,8 @@ e_cell_toggle_init (ECellToggle *cell_toggle)
 
        cell_toggle->priv->pixbufs =
                g_ptr_array_new_with_free_func (g_object_unref);
+
+       cell_toggle->priv->bg_color_column = -1;
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]