aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table/e-cell-text.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-11-10 00:58:33 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-01-26 21:49:12 +0800
commit310069df2f60e2b2d290d972d231f9021de0e37e (patch)
treef5a7c9cbdf256d442e6669e5e46bd3c4e5a99ddd /widgets/table/e-cell-text.c
parentb4e2a4b0dc885549f5869102dfe9bf714097ee98 (diff)
downloadgsoc2013-evolution-310069df2f60e2b2d290d972d231f9021de0e37e.tar.gz
gsoc2013-evolution-310069df2f60e2b2d290d972d231f9021de0e37e.tar.zst
gsoc2013-evolution-310069df2f60e2b2d290d972d231f9021de0e37e.zip
Adapt ECell classes to latest gtk+-3.0 API.
Diffstat (limited to 'widgets/table/e-cell-text.c')
-rw-r--r--widgets/table/e-cell-text.c82
1 files changed, 6 insertions, 76 deletions
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