aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--widgets/table/e-cell-hbox.c4
-rw-r--r--widgets/table/e-cell-pixbuf.c5
-rw-r--r--widgets/table/e-cell-popup.c20
-rw-r--r--widgets/table/e-cell-text.c82
-rw-r--r--widgets/table/e-cell-text.h3
-rw-r--r--widgets/table/e-cell-toggle.c6
-rw-r--r--widgets/table/e-cell-tree.c46
-rw-r--r--widgets/table/e-cell-vbox.c4
-rw-r--r--widgets/table/e-cell.c16
-rw-r--r--widgets/table/e-cell.h4
10 files changed, 69 insertions, 121 deletions
diff --git a/widgets/table/e-cell-hbox.c b/widgets/table/e-cell-hbox.c
index 4053452705..48547e037b 100644
--- a/widgets/table/e-cell-hbox.c
+++ b/widgets/table/e-cell-hbox.c
@@ -139,7 +139,7 @@ ecv_unrealize (ECellView *ecv)
*/
static void
ecv_draw (ECellView *ecell_view,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint model_col,
gint view_col,
gint row,
@@ -165,7 +165,7 @@ ecv_draw (ECellView *ecell_view,
printf("width of %d %d of %d\n", width,hbox_view->def_size_cols[i], allotted_width ); */
e_cell_draw (
- hbox_view->subcell_views[i], drawable,
+ hbox_view->subcell_views[i], cr,
hbox_view->model_cols[i], view_col, row, flags,
x1 + subcell_offset , y1,
x1 + subcell_offset + width, y2);
diff --git a/widgets/table/e-cell-pixbuf.c b/widgets/table/e-cell-pixbuf.c
index b8662b9182..e25cb2dc63 100644
--- a/widgets/table/e-cell-pixbuf.c
+++ b/widgets/table/e-cell-pixbuf.c
@@ -97,14 +97,13 @@ pixbuf_kill_view (ECellView *ecell_view)
}
static void
-pixbuf_draw (ECellView *ecell_view, GdkDrawable *drawable,
+pixbuf_draw (ECellView *ecell_view, cairo_t *cr,
gint model_col, gint view_col, gint row, ECellFlags flags,
gint x1, gint y1, gint x2, gint y2)
{
GdkPixbuf *cell_pixbuf;
gint real_x, real_y;
gint pix_w, pix_h;
- cairo_t *cr;
cell_pixbuf = e_table_model_value_at (ecell_view->e_table_model,
1, row);
@@ -135,12 +134,10 @@ pixbuf_draw (ECellView *ecell_view, GdkDrawable *drawable,
real_y = y1;
}
- cr = gdk_cairo_create (drawable);
cairo_save (cr);
gdk_cairo_set_source_pixbuf (cr, cell_pixbuf, real_x, real_y);
cairo_paint_with_alpha (cr, 1);
cairo_restore (cr);
- cairo_destroy (cr);
}
static gint
diff --git a/widgets/table/e-cell-popup.c b/widgets/table/e-cell-popup.c
index dfc9526885..abfe61e206 100644
--- a/widgets/table/e-cell-popup.c
+++ b/widgets/table/e-cell-popup.c
@@ -54,7 +54,7 @@ static void ecp_kill_view (ECellView *ecv);
static void ecp_realize (ECellView *ecv);
static void ecp_unrealize (ECellView *ecv);
static void ecp_draw (ECellView *ecv,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint model_col,
gint view_col,
gint row,
@@ -245,7 +245,7 @@ ecp_unrealize (ECellView *ecv)
* ECell::draw method
*/
static void
-ecp_draw (ECellView *ecv, GdkDrawable *drawable,
+ecp_draw (ECellView *ecv, cairo_t *cr,
gint model_col, gint view_col, gint row, ECellFlags flags,
gint x1, gint y1, gint x2, gint y2)
{
@@ -256,6 +256,8 @@ ecp_draw (ECellView *ecv, GdkDrawable *drawable,
GdkRectangle rect;
gboolean show_popup_arrow;
+ cairo_save (cr);
+
canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (ecv->e_table_item_view)->canvas);
/* Display the popup arrow if we are the cursor cell, or the popup
@@ -274,7 +276,7 @@ ecp_draw (ECellView *ecv, GdkDrawable *drawable,
if (show_popup_arrow) {
GtkStyle *style;
- e_cell_draw (ecp_view->child_view, drawable, model_col,
+ e_cell_draw (ecp_view->child_view, cr, model_col,
view_col, row, flags,
x1, y1, x2 - E_CELL_POPUP_ARROW_WIDTH, y2);
@@ -290,22 +292,24 @@ ecp_draw (ECellView *ecv, GdkDrawable *drawable,
style = gtk_widget_get_style (canvas);
- gtk_paint_box (style, drawable,
+ gtk_paint_box (style, cr,
GTK_STATE_NORMAL, shadow,
- &rect, canvas, "ecellpopup",
+ canvas, "ecellpopup",
rect.x, rect.y, rect.width, rect.height);
- gtk_paint_arrow (style, drawable,
+ gtk_paint_arrow (style, cr,
GTK_STATE_NORMAL, GTK_SHADOW_NONE,
- &rect, canvas, NULL,
+ canvas, NULL,
GTK_ARROW_DOWN, TRUE,
rect.x + E_CELL_POPUP_ARROW_XPAD,
rect.y + E_CELL_POPUP_ARROW_YPAD,
rect.width - E_CELL_POPUP_ARROW_XPAD * 2,
rect.height - E_CELL_POPUP_ARROW_YPAD * 2);
} else {
- e_cell_draw (ecp_view->child_view, drawable, model_col,
+ e_cell_draw (ecp_view->child_view, cr, model_col,
view_col, row, flags, x1, y1, x2, y2);
}
+
+ cairo_restore (cr);
}
/*
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index 2e260d7135..245f894067 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -197,8 +197,6 @@ static void _get_tep (CellEdit *edit);
static gint get_position_from_xy (CellEdit *edit, gint x, gint y);
static gboolean _blink_scroll_timeout (gpointer data);
-static void ect_free_color (gchar *color_spec, GdkColor *color, GdkColormap *colormap);
-static GdkColor* e_cell_text_get_color (ECellTextView *cell_view, gchar *color_spec);
static void e_cell_text_preedit_changed_cb (GtkIMContext *context, ECellTextView *text_view);
static void e_cell_text_commit_cb (GtkIMContext *context, const gchar *str, ECellTextView *text_view);
static gboolean e_cell_text_retrieve_surrounding_cb (GtkIMContext *context, ECellTextView *text_view);
@@ -379,8 +377,6 @@ static void
ect_unrealize (ECellView *ecv)
{
ECellTextView *text_view = (ECellTextView *) ecv;
- ECellText *ect = (ECellText*) ecv->ecell;
- GdkColormap *colormap;
if (text_view->edit) {
ect_cancel_edit (text_view);
@@ -388,34 +384,11 @@ ect_unrealize (ECellView *ecv)
g_object_unref (text_view->i_cursor);
- if (ect->colors) {
- colormap = gtk_widget_get_colormap (GTK_WIDGET (text_view->canvas));
- g_hash_table_foreach (ect->colors, (GHFunc) ect_free_color,
- colormap);
- g_hash_table_destroy (ect->colors);
- ect->colors = NULL;
- }
-
if (E_CELL_CLASS (e_cell_text_parent_class)->unrealize)
(* E_CELL_CLASS (e_cell_text_parent_class)->unrealize) (ecv);
}
-static void
-ect_free_color (gchar *color_spec, GdkColor *color, GdkColormap *colormap)
-{
- g_free (color_spec);
-
- /* This frees the color. Note we don't free it if it is the special
- value. */
- if (color != (GdkColor*) 1) {
- gdk_colormap_free_colors (colormap, color, 1);
-
- /* This frees the memory for the GdkColor. */
- gdk_color_free (color);
- }
-}
-
static PangoAttrList*
build_attr_list (ECellTextView *text_view, gint row, gint text_length)
{
@@ -701,7 +674,7 @@ get_vertical_spacing (GtkWidget *canvas)
* ECell::draw method
*/
static void
-ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
+ect_draw (ECellView *ecell_view, cairo_t *cr,
gint model_col, gint view_col, gint row, ECellFlags flags,
gint x1, gint y1, gint x2, gint y2)
{
@@ -713,14 +686,12 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
GtkWidget *canvas = GTK_WIDGET (text_view->canvas);
GtkStyle *style;
gint x_origin, y_origin, vspacing;
- cairo_t *cr;
+ cairo_save (cr);
style = gtk_widget_get_style (canvas);
selected = flags & E_CELL_SELECTED;
- cr = gdk_cairo_create (drawable);
-
if (selected) {
if (gtk_widget_has_focus (canvas))
gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_SELECTED]);
@@ -731,15 +702,13 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
if (ect->color_column != -1) {
gchar *color_spec;
- GdkColor *cell_foreground;
+ GdkColor color;
color_spec = e_table_model_value_at (
ecell_view->e_table_model,
ect->color_column, row);
- cell_foreground = e_cell_text_get_color (text_view,
- color_spec);
- if (cell_foreground)
- gdk_cairo_set_source_color (cr, cell_foreground);
+ if (color_spec && gdk_color_parse (color_spec, &color))
+ gdk_cairo_set_source_color (cr, &color);
}
}
@@ -805,7 +774,7 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
}
g_object_unref (layout);
- cairo_destroy (cr);
+ cairo_restore (cr);
}
/*
@@ -2474,45 +2443,6 @@ _get_tep (CellEdit *edit)
}
}
-static GdkColor*
-e_cell_text_get_color (ECellTextView *cell_view, gchar *color_spec)
-{
- ECellText *ect = E_CELL_TEXT (((ECellView*) cell_view)->ecell);
- GdkColormap *colormap;
- GdkColor *color, tmp_color;
-
- /* If the color spec is NULL we use the default color. */
- if (color_spec == NULL)
- return NULL;
-
- /* Create the hash table if we haven't already. */
- if (!ect->colors)
- ect->colors = g_hash_table_new (g_str_hash, g_str_equal);
-
- /* See if we've already allocated the color. Note that we use a
- special value of (GdkColor*) 1 in the hash to indicate that we've
- already tried and failed to allocate the color, so we don't keep
- trying to allocate it. */
- color = g_hash_table_lookup (ect->colors, color_spec);
- if (color == (GdkColor*) 1)
- return NULL;
- if (color)
- return color;
-
- /* Try to parse the color. */
- if (gdk_color_parse (color_spec, &tmp_color)) {
- colormap = gtk_widget_get_colormap (GTK_WIDGET (cell_view->canvas));
-
- /* Try to allocate the color. */
- if (gdk_colormap_alloc_color (colormap, &tmp_color, FALSE, TRUE))
- color = gdk_color_copy (&tmp_color);
- }
-
- g_hash_table_insert (ect->colors, g_strdup (color_spec),
- color ? color : (GdkColor*) 1);
- return color;
-}
-
/**
* e_cell_text_set_selection:
* @cell_view: the given cell view
diff --git a/widgets/table/e-cell-text.h b/widgets/table/e-cell-text.h
index ee3e1f5202..7645a0064b 100644
--- a/widgets/table/e-cell-text.h
+++ b/widgets/table/e-cell-text.h
@@ -91,9 +91,6 @@ struct _ECellText {
See the XParseColor man page for the formats available. */
gint color_column;
gint bg_color_column;
-
- /* This stores the colors we have allocated. */
- GHashTable *colors;
};
struct _ECellTextClass {
diff --git a/widgets/table/e-cell-toggle.c b/widgets/table/e-cell-toggle.c
index d988f801ae..ae7fcc703b 100644
--- a/widgets/table/e-cell-toggle.c
+++ b/widgets/table/e-cell-toggle.c
@@ -170,7 +170,7 @@ cell_toggle_kill_view (ECellView *ecell_view)
static void
cell_toggle_draw (ECellView *ecell_view,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint model_col,
gint view_col,
gint row,
@@ -183,7 +183,6 @@ cell_toggle_draw (ECellView *ecell_view,
ECellTogglePrivate *priv;
GdkPixbuf *image;
gint x, y;
- cairo_t *cr;
const gint value = GPOINTER_TO_INT (
e_table_model_value_at (ecell_view->e_table_model, model_col, row));
@@ -208,13 +207,10 @@ cell_toggle_draw (ECellView *ecell_view,
else
y = y1 + ((y2 - y1) - gdk_pixbuf_get_height (image)) / 2;
- cr = gdk_cairo_create (drawable);
cairo_save (cr);
gdk_cairo_set_source_pixbuf (cr, image, x, y);
cairo_paint_with_alpha (cr, 1);
cairo_restore (cr);
- cairo_destroy (cr);
-
}
static void
diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c
index 3793652524..1a4b00bb4c 100644
--- a/widgets/table/e-cell-tree.c
+++ b/widgets/table/e-cell-tree.c
@@ -189,7 +189,7 @@ ect_unrealize (ECellView *ecv)
static void
draw_expander (ECellTreeView *ectv,
- GdkDrawable *drawable,
+ cairo_t *cr,
GtkExpanderStyle expander_style,
GtkStateType state,
GdkRectangle *rect)
@@ -204,7 +204,7 @@ draw_expander (ECellTreeView *ectv,
gtk_widget_style_get (tree, "expander_size", &exp_size, NULL);
gtk_paint_expander (
- style, drawable, state, rect, tree, "treeview",
+ style, cr, state, tree, "treeview",
rect->x + rect->width - exp_size / 2,
rect->y + rect->height / 2, expander_style);
}
@@ -214,7 +214,7 @@ draw_expander (ECellTreeView *ectv,
*/
static void
ect_draw (ECellView *ecell_view,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint model_col,
gint view_col,
gint row,
@@ -232,15 +232,14 @@ ect_draw (ECellView *ecell_view,
GtkWidget *canvas = GTK_WIDGET (tree_view->canvas);
GtkStyle *style;
gboolean selected;
- cairo_t *cr;
gint offset, subcell_offset;
- cr = gdk_cairo_create (drawable);
-
style = gtk_widget_get_style (canvas);
selected = flags & E_CELL_SELECTED;
+ cairo_save (cr);
+
/* only draw the tree effects if we're the active sort */
if (/* XXX */ TRUE) {
GdkPixbuf *node_image;
@@ -278,7 +277,7 @@ ect_draw (ECellView *ecell_view,
r = rect;
r.width -= node_image_width + 2;
- draw_expander (tree_view, drawable, expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED, GTK_STATE_NORMAL, &r);
+ draw_expander (tree_view, cr, expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED, GTK_STATE_NORMAL, &r);
}
if (node_image) {
@@ -293,11 +292,11 @@ ect_draw (ECellView *ecell_view,
/* Now cause our subcell to draw its contents, shifted by
subcell_offset pixels */
- e_cell_draw (tree_view->subcell_view, drawable,
+ e_cell_draw (tree_view->subcell_view, cr,
model_col, view_col, row, flags,
x1 + subcell_offset, y1, x2, y2);
- cairo_destroy (cr);
+ cairo_restore (cr);
}
static void
@@ -360,6 +359,7 @@ animate_expander (gpointer data)
GtkLayout *layout;
GdkWindow *window;
animate_closure_t *closure = (animate_closure_t *) data;
+ cairo_t *cr;
if (closure->finish) {
e_tree_table_adapter_node_set_expanded (closure->etta, closure->node, !closure->expanded);
@@ -371,13 +371,17 @@ animate_expander (gpointer data)
layout = GTK_LAYOUT (closure->ectv->canvas);
window = gtk_layout_get_bin_window (layout);
+ cr = gdk_cairo_create (window);
+
draw_expander (
- closure->ectv, window, closure->expanded ?
+ closure->ectv, cr, closure->expanded ?
GTK_EXPANDER_SEMI_COLLAPSED :
GTK_EXPANDER_SEMI_EXPANDED,
GTK_STATE_NORMAL, &closure->area);
closure->finish = TRUE;
+ cairo_destroy (cr);
+
return TRUE;
}
@@ -408,6 +412,7 @@ ect_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col
gint tmp_row = row;
GdkRectangle area;
animate_closure_t *closure = g_new0 (animate_closure_t, 1);
+ cairo_t *cr;
gint hgt;
e_table_item_get_cell_geometry (tree_view->cell_view.e_table_item_view,
@@ -418,11 +423,14 @@ ect_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col
if (hgt != area.height) /* Composite cells */
area.height += hgt;
+ cr = gdk_cairo_create (window);
draw_expander (
- tree_view, window, expanded ?
+ tree_view, cr, expanded ?
GTK_EXPANDER_SEMI_EXPANDED :
GTK_EXPANDER_SEMI_COLLAPSED,
GTK_STATE_NORMAL, &area);
+ cairo_destroy (cr);
+
closure->ectv = tree_view;
closure->etta = etta;
closure->node = node;
@@ -445,14 +453,20 @@ ect_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col
if (tree_view->prelit ^ in_expander) {
gint tmp_row = row;
+ cairo_t *cr;
+
e_table_item_get_cell_geometry (tree_view->cell_view.e_table_item_view,
&tmp_row, &view_col, &area.x, &area.y, NULL, &area.height);
area.width = offset - 2;
+
+ cr = gdk_cairo_create (window);
draw_expander (
- tree_view, window,
+ tree_view, cr,
e_tree_table_adapter_node_is_expanded (etta, node) ?
GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED,
in_expander ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL, &area);
+ cairo_destroy (cr);
+
tree_view->prelit = in_expander;
return TRUE;
}
@@ -465,14 +479,20 @@ ect_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col
if (tree_view->prelit) {
gint tmp_row = row;
GdkRectangle area;
+ cairo_t *cr;
+
e_table_item_get_cell_geometry (tree_view->cell_view.e_table_item_view,
&tmp_row, &view_col, &area.x, &area.y, NULL, &area.height);
area.width = offset - 2;
+
+ cr = gdk_cairo_create (window);
draw_expander (
- tree_view, window,
+ tree_view, cr,
e_tree_table_adapter_node_is_expanded (etta, node) ?
GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED,
GTK_STATE_NORMAL, &area);
+ cairo_destroy (cr);
+
tree_view->prelit = FALSE;
}
return TRUE;
diff --git a/widgets/table/e-cell-vbox.c b/widgets/table/e-cell-vbox.c
index f57cd0e113..1e5875b2b1 100644
--- a/widgets/table/e-cell-vbox.c
+++ b/widgets/table/e-cell-vbox.c
@@ -132,7 +132,7 @@ ecv_unrealize (ECellView *ecv)
*/
static void
ecv_draw (ECellView *ecell_view,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint model_col,
gint view_col,
gint row,
@@ -156,7 +156,7 @@ ecv_draw (ECellView *ecell_view,
vbox_view->subcell_views[i],
vbox_view->model_cols[i], view_col, row);
e_cell_draw (
- vbox_view->subcell_views[i], drawable,
+ vbox_view->subcell_views[i], cr,
vbox_view->model_cols[i], view_col, row, flags,
x1, y1 + subcell_offset, x2,
y1 + subcell_offset + height);
diff --git a/widgets/table/e-cell.c b/widgets/table/e-cell.c
index f54b644045..19c5e37848 100644
--- a/widgets/table/e-cell.c
+++ b/widgets/table/e-cell.c
@@ -54,7 +54,7 @@ ec_unrealize (ECellView *e_cell)
}
static void
-ec_draw (ECellView *ecell_view, GdkDrawable *drawable,
+ec_draw (ECellView *ecell_view, cairo_t *cr,
gint model_col, gint view_col, gint row, ECellFlags flags,
gint x1, gint y1, gint x2, gint y2)
{
@@ -240,7 +240,7 @@ e_cell_unrealize (ECellView *ecell_view)
/**
* e_cell_draw:
* @ecell_view: the ECellView to redraw
- * @drawable: draw desination
+ * @cr: a Cairo context
* @model_col: the column in the model being drawn.
* @view_col: the column in the view being drawn (what the model maps to).
* @row: the row being drawn
@@ -250,14 +250,14 @@ e_cell_unrealize (ECellView *ecell_view)
* @x2: boudary for the rendering
* @y2: boudary for the rendering
*
- * This instructs the ECellView to render itself into the drawable. The
- * region to be drawn in given by (x1,y1)-(x2,y2).
+ * This instructs the ECellView to render itself into the Cairo context.
+ * The region to be drawn in given by (x1,y1)-(x2,y2).
*
* The most important flags are %E_CELL_SELECTED and %E_CELL_FOCUSED, other
* flags include alignments and justifications.
*/
void
-e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable,
+e_cell_draw (ECellView *ecell_view, cairo_t *cr,
gint model_col, gint view_col, gint row, ECellFlags flags,
gint x1, gint y1, gint x2, gint y2)
{
@@ -265,7 +265,11 @@ e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable,
g_return_if_fail (row >= 0);
g_return_if_fail (row < e_table_model_row_count (ecell_view->e_table_model));
- ECVIEW_EC_CLASS (ecell_view)->draw (ecell_view, drawable, model_col, view_col, row, flags, x1, y1, x2, y2);
+ cairo_save (cr);
+
+ ECVIEW_EC_CLASS (ecell_view)->draw (ecell_view, cr, model_col, view_col, row, flags, x1, y1, x2, y2);
+
+ cairo_restore (cr);
}
/**
diff --git a/widgets/table/e-cell.h b/widgets/table/e-cell.h
index 111736f41c..3a41db0afe 100644
--- a/widgets/table/e-cell.h
+++ b/widgets/table/e-cell.h
@@ -114,7 +114,7 @@ struct _ECellClass {
void (*unrealize) (ECellView *ecell_view);
void (*draw) (ECellView *ecell_view,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint model_col,
gint view_col, gint row,
ECellFlags flags,
@@ -214,7 +214,7 @@ gint e_cell_event (ECellView *ecell_view,
void e_cell_realize (ECellView *ecell_view);
void e_cell_unrealize (ECellView *ecell_view);
void e_cell_draw (ECellView *ecell_view,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint model_col,
gint view_col,
gint row,