aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/table/e-cell-popup.c10
-rw-r--r--widgets/table/e-cell-text.c34
-rw-r--r--widgets/table/e-cell-text.h1
-rw-r--r--widgets/table/e-cell-tree.c38
-rw-r--r--widgets/table/e-cell.c10
-rw-r--r--widgets/table/e-cell.h104
-rw-r--r--widgets/table/e-table-item.c28
7 files changed, 178 insertions, 47 deletions
diff --git a/widgets/table/e-cell-popup.c b/widgets/table/e-cell-popup.c
index 224227e209..96f88dbd3c 100644
--- a/widgets/table/e-cell-popup.c
+++ b/widgets/table/e-cell-popup.c
@@ -105,6 +105,7 @@ static void ecp_show_tooltip (ECellView *ecv,
int row,
int col_width,
ETableTooltip *tooltip);
+static char *ecp_get_bg_color (ECellView *ecell_view, int row);
static gint e_cell_popup_do_popup (ECellPopupView *ecp_view,
GdkEvent *event);
@@ -136,6 +137,7 @@ e_cell_popup_class_init (GtkObjectClass *object_class)
ecc->print_height = ecp_print_height;
ecc->max_width = ecp_max_width;
ecc->show_tooltip = ecp_show_tooltip;
+ ecc->get_bg_color = ecp_get_bg_color;
parent_class = gtk_type_class (e_cell_get_type ());
}
@@ -464,6 +466,14 @@ ecp_show_tooltip (ECellView *ecv,
col_width, tooltip);
}
+static char *
+ecp_get_bg_color (ECellView *ecell_view, int row)
+{
+ ECellPopupView *ecp_view = (ECellPopupView *) ecell_view;
+
+ return e_cell_get_bg_color (ecp_view->child_view, row);
+}
+
ECell*
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index 0de114d2ab..2894ff30d5 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -69,6 +69,7 @@ enum {
ARG_BOLD_COLUMN,
ARG_COLOR_COLUMN,
ARG_EDITABLE,
+ ARG_BG_COLOR_COLUMN
};
@@ -694,6 +695,27 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
gdk_gc_set_clip_rectangle (fg_gc, NULL);
}
+
+/*
+ * Get the background color
+ */
+static gchar *
+ect_get_bg_color(ECellView *ecell_view, int row)
+{
+ ECellText *ect = E_CELL_TEXT (ecell_view->ecell);
+ gchar *color_spec;
+
+ if (ect->bg_color_column == -1)
+ return NULL;
+
+ color_spec = e_table_model_value_at (ecell_view->e_table_model,
+ ect->bg_color_column, row);
+
+ return color_spec;
+}
+
+
+
/*
* Selects the entire string
*/
@@ -1330,6 +1352,10 @@ ect_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
text->editable = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE;
break;
+ case ARG_BG_COLOR_COLUMN:
+ text->bg_color_column = GTK_VALUE_INT (*arg);
+ break;
+
default:
return;
}
@@ -1360,6 +1386,10 @@ ect_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
GTK_VALUE_BOOL (*arg) = text->editable ? TRUE : FALSE;
break;
+ case ARG_BG_COLOR_COLUMN:
+ GTK_VALUE_INT (*arg) = text->bg_color_column;
+ break;
+
default:
arg->type = GTK_TYPE_INVALID;
break;
@@ -1387,6 +1417,7 @@ e_cell_text_class_init (GtkObjectClass *object_class)
ecc->print_height = ect_print_height;
ecc->max_width = ect_max_width;
ecc->show_tooltip = ect_show_tooltip;
+ ecc->get_bg_color = ect_get_bg_color;
ectc->get_text = ect_real_get_text;
ectc->free_text = ect_real_free_text;
@@ -1404,6 +1435,8 @@ e_cell_text_class_init (GtkObjectClass *object_class)
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_COLOR_COLUMN);
gtk_object_add_arg_type ("ECellText::editable",
GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EDITABLE);
+ gtk_object_add_arg_type ("ECellText::bg_color_column",
+ GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_BG_COLOR_COLUMN);
if (!clipboard_atom)
clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
@@ -1417,6 +1450,7 @@ e_cell_text_init (ECellText *ect)
ect->strikeout_column = -1;
ect->bold_column = -1;
ect->color_column = -1;
+ ect->bg_color_column = -1;
ect->editable = TRUE;
}
diff --git a/widgets/table/e-cell-text.h b/widgets/table/e-cell-text.h
index 8ea9c509bd..078f8e7629 100644
--- a/widgets/table/e-cell-text.h
+++ b/widgets/table/e-cell-text.h
@@ -58,6 +58,7 @@ typedef struct {
either a color name like "red" or a color spec like "rgb:F/0/0".
See the XParseColor man page for the formats available. */
int color_column;
+ int bg_color_column;
/* This stores the colors we have allocated. */
GHashTable *colors;
diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c
index 64af817f9b..ebefe5cc84 100644
--- a/widgets/table/e-cell-tree.c
+++ b/widgets/table/e-cell-tree.c
@@ -478,6 +478,17 @@ ect_show_tooltip (ECellView *ecell_view, int model_col, int view_col, int row,
tooltip->x += offset;
e_cell_show_tooltip (tree_view->subcell_view, model_col, view_col, row, col_width - offset, tooltip);
}
+
+/*
+ * ECellView::get_bg_color method
+ */
+static char *
+ect_get_bg_color (ECellView *ecell_view, int row)
+{
+ ECellTreeView *tree_view = (ECellTreeView *) ecell_view;
+
+ return e_cell_get_bg_color (tree_view->subcell_view, row);
+}
/*
* ECellView::enter_edit method
@@ -635,19 +646,20 @@ e_cell_tree_class_init (GtkObjectClass *object_class)
object_class->destroy = ect_destroy;
- ecc->new_view = ect_new_view;
- ecc->kill_view = ect_kill_view;
- ecc->realize = ect_realize;
- ecc->unrealize = ect_unrealize;
- ecc->draw = ect_draw;
- ecc->event = ect_event;
- ecc->height = ect_height;
- ecc->enter_edit = ect_enter_edit;
- ecc->leave_edit = ect_leave_edit;
- ecc->print = ect_print;
- ecc->print_height = ect_print_height;
- ecc->max_width = ect_max_width;
- ecc->show_tooltip = ect_show_tooltip;
+ ecc->new_view = ect_new_view;
+ ecc->kill_view = ect_kill_view;
+ ecc->realize = ect_realize;
+ ecc->unrealize = ect_unrealize;
+ ecc->draw = ect_draw;
+ ecc->event = ect_event;
+ ecc->height = ect_height;
+ ecc->enter_edit = ect_enter_edit;
+ ecc->leave_edit = ect_leave_edit;
+ ecc->print = ect_print;
+ ecc->print_height = ect_print_height;
+ ecc->max_width = ect_max_width;
+ ecc->show_tooltip = ect_show_tooltip;
+ ecc->get_bg_color = ect_get_bg_color;
parent_class = gtk_type_class (PARENT_TYPE);
}
diff --git a/widgets/table/e-cell.c b/widgets/table/e-cell.c
index 79f0a0e9bd..13fef9a04c 100644
--- a/widgets/table/e-cell.c
+++ b/widgets/table/e-cell.c
@@ -352,3 +352,13 @@ e_cell_show_tooltip (ECellView *ecell_view, int model_col, int view_col,
E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->show_tooltip
(ecell_view, model_col, view_col, row, col_width, tooltip);
}
+
+gchar *
+e_cell_get_bg_color(ECellView *ecell_view, int row)
+{
+ if (E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->get_bg_color)
+ return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->get_bg_color (ecell_view, row);
+ else
+ return NULL;
+}
+
diff --git a/widgets/table/e-cell.h b/widgets/table/e-cell.h
index b9927114bb..1d89544440 100644
--- a/widgets/table/e-cell.h
+++ b/widgets/table/e-cell.h
@@ -79,34 +79,86 @@ typedef struct {
int model_col, int view_col, int row, gdouble width);
int (*max_width) (ECellView *ecell_view, int model_col, int view_col);
void (*show_tooltip) (ECellView *ecell_view, int model_col, int view_col, int row, int col_width, ETableTooltip *tooltip);
+ gchar *(*get_bg_color) (ECellView *ecell_view, int row);
} ECellClass;
-GtkType e_cell_get_type (void);
-ECellView *e_cell_new_view (ECell *ecell, ETableModel *table_model, void *e_table_item_view);
-void e_cell_kill_view (ECellView *ecell_view);
-
-gint e_cell_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags, ECellActions *actions);
-
-void e_cell_realize (ECellView *ecell_view);
-void e_cell_unrealize (ECellView *ecell_view);
-
-void e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, ECellFlags flags,
- int x1, int y1, int x2, int y2);
-void e_cell_print (ECellView *ecell_view, GnomePrintContext *context,
- int model_col, int view_col, int row,
- double width, double height);
-gdouble e_cell_print_height (ECellView *ecell_view, GnomePrintContext *context,
- int model_col, int view_col, int row, gdouble width);
-int e_cell_max_width (ECellView *ecell_view, int model_col, int view_col);
-void e_cell_show_tooltip (ECellView *ecell_view, int model_col, int view_col, int row, int col_width, ETableTooltip *tooltip);
-void e_cell_focus (ECellView *ecell_view, int model_col, int view_col, int row,
- int x1, int y1, int x2, int y2);
-void e_cell_unfocus (ECellView *ecell_view);
-int e_cell_height (ECellView *ecell_view, int model_col, int view_col, int row);
-
-void *e_cell_enter_edit (ECellView *ecell_view, int model_col, int view_col, int row);
-void e_cell_leave_edit (ECellView *ecell_view, int model_col, int view_col, int row, void *edit_context);
+
+GtkType e_cell_get_type (void);
+
+/* View creation methods. */
+ECellView *e_cell_new_view (ECell *ecell,
+ ETableModel *table_model,
+ void *e_table_item_view);
+void e_cell_kill_view (ECellView *ecell_view);
+
+/* Cell View methods. */
+gint e_cell_event (ECellView *ecell_view,
+ GdkEvent *event,
+ int model_col,
+ int view_col,
+ int row,
+ ECellFlags flags,
+ ECellActions *actions);
+void e_cell_realize (ECellView *ecell_view);
+void e_cell_unrealize (ECellView *ecell_view);
+void e_cell_draw (ECellView *ecell_view,
+ GdkDrawable *drawable,
+ int model_col,
+ int view_col,
+ int row,
+ ECellFlags flags,
+ int x1,
+ int y1,
+ int x2,
+ int y2);
+void e_cell_print (ECellView *ecell_view,
+ GnomePrintContext *context,
+ int model_col,
+ int view_col,
+ int row,
+ double width,
+ double height);
+gdouble e_cell_print_height (ECellView *ecell_view,
+ GnomePrintContext *context,
+ int model_col,
+ int view_col,
+ int row,
+ gdouble width);
+int e_cell_max_width (ECellView *ecell_view,
+ int model_col,
+ int view_col);
+void e_cell_show_tooltip (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row,
+ int col_width,
+ ETableTooltip *tooltip);
+gchar *e_cell_get_bg_color (ECellView *ecell_view,
+ int row);
+
+void e_cell_focus (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row,
+ int x1,
+ int y1,
+ int x2,
+ int y2);
+void e_cell_unfocus (ECellView *ecell_view);
+int e_cell_height (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row);
+
+void *e_cell_enter_edit (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row);
+void e_cell_leave_edit (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row,
+ void *edit_context);
END_GNOME_DECLS
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index dbf4716c5c..067a5fc60b 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -156,13 +156,13 @@ eti_editing (ETableItem *eti)
}
inline static GdkColor *
-eti_get_cell_background_color (ETableItem *eti, int row, int col, gboolean selected, gboolean *allocated)
+eti_get_cell_background_color (ETableItem *eti, int row, int col, gboolean selected, gboolean *allocatedp)
{
+ ECellView *ecell_view = eti->cell_views [col];
GtkWidget *canvas = GTK_WIDGET(GNOME_CANVAS_ITEM(eti)->canvas);
- GdkColor *background;
-
- if (allocated)
- *allocated = FALSE;
+ GdkColor *background, bg;
+ gchar *color_spec = NULL;
+ gboolean allocated = FALSE;
if (selected){
if (GTK_WIDGET_HAS_FOCUS(canvas))
@@ -173,17 +173,29 @@ eti_get_cell_background_color (ETableItem *eti, int row, int col, gboolean selec
background = &canvas->style->base [GTK_STATE_NORMAL];
}
+ color_spec = e_cell_get_bg_color (ecell_view, row);
+
+ if (color_spec != NULL) {
+ if (gdk_color_parse (color_spec, &bg)) {
+ background = gdk_color_copy (&bg);
+ allocated = TRUE;
+ }
+ }
+
if (eti->alternating_row_colors) {
if (row % 2) {
} else {
- if (allocated)
- *allocated = TRUE;
- background = gdk_color_copy (background);
+ if (!allocated) {
+ background = gdk_color_copy (background);
+ allocated = TRUE;
+ }
e_hsv_tweak (background, 0.0f, 0.0f, -0.05f);
gdk_color_alloc (gtk_widget_get_colormap (GTK_WIDGET (canvas)), background);
}
}
+ if (allocatedp)
+ *allocatedp = allocated;
return background;
}