From c2b2e863cb97b6203b1be955a52096166462da8e Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 2 Nov 2010 11:16:48 +0100 Subject: Add forgotten cairo_destroy() calls --- widgets/table/e-table-header-utils.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'widgets/table/e-table-header-utils.c') diff --git a/widgets/table/e-table-header-utils.c b/widgets/table/e-table-header-utils.c index 16e0a1948c..19a493b0f4 100644 --- a/widgets/table/e-table-header-utils.c +++ b/widgets/table/e-table-header-utils.c @@ -290,8 +290,10 @@ e_table_header_draw_button (GdkDrawable *drawable, ETableCol *ecol, inner_width = button_width - 2 * (xthick + HEADER_PADDING); inner_height = button_height - 2 * (ythick + HEADER_PADDING); - if (inner_width < 1 || inner_height < 1) + if (inner_width < 1 || inner_height < 1) { + cairo_destroy (cr); return; /* nothing fits */ + } inner_x = x + xthick + HEADER_PADDING; inner_y = y + ythick + HEADER_PADDING; @@ -314,8 +316,10 @@ e_table_header_draw_button (GdkDrawable *drawable, ETableCol *ecol, g_return_if_reached (); } - if (inner_width < 1) + if (inner_width < 1) { + cairo_destroy (cr); return; /* nothing else fits */ + } layout = build_header_layout (widget, ecol->text); pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END); -- cgit v1.2.3 From a891b81cfb3430a764dab0d5644114c4dab22297 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 7 Nov 2010 21:13:03 -0500 Subject: Coding style and whitespace cleanup. --- widgets/table/e-table-header-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'widgets/table/e-table-header-utils.c') diff --git a/widgets/table/e-table-header-utils.c b/widgets/table/e-table-header-utils.c index 19a493b0f4..56fa44a3c6 100644 --- a/widgets/table/e-table-header-utils.c +++ b/widgets/table/e-table-header-utils.c @@ -379,7 +379,7 @@ e_table_header_draw_button (GdkDrawable *drawable, ETableCol *ecol, } #endif gdk_cairo_set_source_pixbuf (cr, ecol->pixbuf, - xpos, inner_y + (inner_height - clip_height) / 2); + xpos, inner_y + (inner_height - clip_height) / 2); cairo_paint (cr); } else { pango_layout_set_width (layout, inner_width * PANGO_SCALE); -- cgit v1.2.3 From b4e2a4b0dc885549f5869102dfe9bf714097ee98 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 15 Jan 2011 10:12:53 -0500 Subject: Adapt ETableHeaderItem to latest gtk+-3.0 API. --- widgets/table/e-table-header-utils.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'widgets/table/e-table-header-utils.c') diff --git a/widgets/table/e-table-header-utils.c b/widgets/table/e-table-header-utils.c index 56fa44a3c6..da60ce03d9 100644 --- a/widgets/table/e-table-header-utils.c +++ b/widgets/table/e-table-header-utils.c @@ -237,7 +237,7 @@ make_composite_pixmap (GdkDrawable *drawable, GdkGC *gc, * Draws a button suitable for a table header. **/ void -e_table_header_draw_button (GdkDrawable *drawable, ETableCol *ecol, +e_table_header_draw_button (cairo_t *cr, ETableCol *ecol, GtkStyle *style, GtkStateType state, GtkWidget *widget, gint x, gint y, gint width, gint height, @@ -249,10 +249,9 @@ e_table_header_draw_button (GdkDrawable *drawable, ETableCol *ecol, gint inner_width, inner_height; gint arrow_width = 0, arrow_height = 0; PangoLayout *layout; - cairo_t *cr; static gpointer g_label = NULL; - g_return_if_fail (drawable != NULL); + g_return_if_fail (cr != NULL); g_return_if_fail (ecol != NULL); g_return_if_fail (E_IS_TABLE_COL (ecol)); g_return_if_fail (style != NULL); @@ -272,8 +271,7 @@ e_table_header_draw_button (GdkDrawable *drawable, ETableCol *ecol, gtk_widget_realize (g_label); } - cr = gdk_cairo_create (drawable); - + cairo_save (cr); gdk_cairo_set_source_color (cr, >k_widget_get_style (GTK_WIDGET (g_label))->fg[state]); xthick = style->xthickness; @@ -281,8 +279,8 @@ e_table_header_draw_button (GdkDrawable *drawable, ETableCol *ecol, /* Button bevel */ - gtk_paint_box (style, drawable, state, GTK_SHADOW_OUT, - NULL, widget, "button", + gtk_paint_box (style, cr, state, GTK_SHADOW_OUT, + widget, "button", x, y, button_width, button_height); /* Inside area */ @@ -291,7 +289,7 @@ e_table_header_draw_button (GdkDrawable *drawable, ETableCol *ecol, inner_height = button_height - 2 * (ythick + HEADER_PADDING); if (inner_width < 1 || inner_height < 1) { - cairo_destroy (cr); + cairo_restore (cr); return; /* nothing fits */ } @@ -313,11 +311,12 @@ e_table_header_draw_button (GdkDrawable *drawable, ETableCol *ecol, inner_width -= arrow_width + HEADER_PADDING; break; default: + cairo_restore (cr); g_return_if_reached (); } if (inner_width < 1) { - cairo_destroy (cr); + cairo_restore (cr); return; /* nothing else fits */ } @@ -397,8 +396,8 @@ e_table_header_draw_button (GdkDrawable *drawable, ETableCol *ecol, if (ecol->icon_name == NULL) inner_width += arrow_width + HEADER_PADDING; - gtk_paint_arrow (style, drawable, state, - GTK_SHADOW_NONE, NULL, widget, "header", + gtk_paint_arrow (style, cr, state, + GTK_SHADOW_NONE, widget, "header", (arrow == E_TABLE_COL_ARROW_UP) ? GTK_ARROW_UP : GTK_ARROW_DOWN, (ecol->icon_name == NULL), inner_x + inner_width - arrow_width, @@ -408,10 +407,10 @@ e_table_header_draw_button (GdkDrawable *drawable, ETableCol *ecol, } default: + cairo_restore (cr); g_return_if_reached (); } g_object_unref (layout); - - cairo_destroy (cr); + cairo_restore (cr); } -- cgit v1.2.3 From 21ab8044dab93b6367463593628ec42befda4f67 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 29 Jan 2011 10:50:53 -0500 Subject: Coding style and whitespace cleanup. --- widgets/table/e-table-header-utils.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'widgets/table/e-table-header-utils.c') diff --git a/widgets/table/e-table-header-utils.c b/widgets/table/e-table-header-utils.c index da60ce03d9..55e90159c6 100644 --- a/widgets/table/e-table-header-utils.c +++ b/widgets/table/e-table-header-utils.c @@ -272,7 +272,8 @@ e_table_header_draw_button (cairo_t *cr, ETableCol *ecol, } cairo_save (cr); - gdk_cairo_set_source_color (cr, >k_widget_get_style (GTK_WIDGET (g_label))->fg[state]); + gdk_cairo_set_source_color ( + cr, >k_widget_get_style (GTK_WIDGET (g_label))->fg[state]); xthick = style->xthickness; ythick = style->ythickness; @@ -321,7 +322,7 @@ e_table_header_draw_button (cairo_t *cr, ETableCol *ecol, } layout = build_header_layout (widget, ecol->text); - pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END); + pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END); /* Pixbuf or label */ if (ecol->icon_name != NULL) { @@ -351,10 +352,12 @@ e_table_header_draw_button (cairo_t *cr, ETableCol *ecol, ypos = inner_y; - pango_layout_set_width (layout, (inner_width - (xpos - inner_x)) * PANGO_SCALE); + pango_layout_set_width ( + layout, (inner_width - (xpos - inner_x)) * + PANGO_SCALE); - cairo_move_to (cr, xpos + pwidth + 1, ypos); - pango_cairo_show_layout (cr, layout); + cairo_move_to (cr, xpos + pwidth + 1, ypos); + pango_cairo_show_layout (cr, layout); } /* FIXME: For some reason, under clutter gdk_draw_rgb_image_dithalign crashes @@ -377,14 +380,14 @@ e_table_header_draw_button (cairo_t *cr, ETableCol *ecol, g_object_unref (pixmap); } #endif - gdk_cairo_set_source_pixbuf (cr, ecol->pixbuf, + gdk_cairo_set_source_pixbuf (cr, ecol->pixbuf, xpos, inner_y + (inner_height - clip_height) / 2); - cairo_paint (cr); + cairo_paint (cr); } else { - pango_layout_set_width (layout, inner_width * PANGO_SCALE); + pango_layout_set_width (layout, inner_width * PANGO_SCALE); - cairo_move_to (cr, inner_x, inner_y); - pango_cairo_show_layout (cr, layout); + cairo_move_to (cr, inner_x, inner_y); + pango_cairo_show_layout (cr, layout); } switch (arrow) { -- cgit v1.2.3 From 2c31a5bc23cf5a092c0621bf34554ffb2b6ae2ec Mon Sep 17 00:00:00 2001 From: Kjartan Maraas Date: Tue, 8 Feb 2011 11:57:50 -0500 Subject: Bug 641756 - Fix warnings from GCC 4.6 GCC learned how to find dead assignments. --- widgets/table/e-table-header-utils.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'widgets/table/e-table-header-utils.c') diff --git a/widgets/table/e-table-header-utils.c b/widgets/table/e-table-header-utils.c index 55e90159c6..2fe6a56089 100644 --- a/widgets/table/e-table-header-utils.c +++ b/widgets/table/e-table-header-utils.c @@ -327,16 +327,14 @@ e_table_header_draw_button (cairo_t *cr, ETableCol *ecol, /* Pixbuf or label */ if (ecol->icon_name != NULL) { gint pwidth, pheight; - gint clip_width, clip_height; + gint clip_height; gint xpos; - /* GdkPixmap *pixmap; */ g_return_if_fail (ecol->pixbuf != NULL); pwidth = gdk_pixbuf_get_width (ecol->pixbuf); pheight = gdk_pixbuf_get_height (ecol->pixbuf); - clip_width = MIN (pwidth, inner_width); clip_height = MIN (pheight, inner_height); xpos = inner_x; @@ -360,26 +358,6 @@ e_table_header_draw_button (cairo_t *cr, ETableCol *ecol, pango_cairo_show_layout (cr, layout); } - /* FIXME: For some reason, under clutter gdk_draw_rgb_image_dithalign crashes - * Debug that later */ -#if 0 - pixmap = make_composite_pixmap (drawable, gc, - ecol->pixbuf, &style->bg[state], - clip_width, clip_height, - xpos, - inner_y + (inner_height - clip_height) / 2); - - gdk_gc_set_clip_rectangle (gc, NULL); - - if (pixmap) { - gdk_draw_drawable (drawable, gc, pixmap, - 0, 0, - xpos, - inner_y + (inner_height - clip_height) / 2, - clip_width, clip_height); - g_object_unref (pixmap); - } -#endif gdk_cairo_set_source_pixbuf (cr, ecol->pixbuf, xpos, inner_y + (inner_height - clip_height) / 2); cairo_paint (cr); -- cgit v1.2.3 From 4cfb84c573f21ca7519e24cff1c5742b715355c4 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 7 May 2011 12:22:36 -0400 Subject: Whitespace and coding style cleanups. --- widgets/table/e-table-header-utils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'widgets/table/e-table-header-utils.c') diff --git a/widgets/table/e-table-header-utils.c b/widgets/table/e-table-header-utils.c index 2fe6a56089..8911867652 100644 --- a/widgets/table/e-table-header-utils.c +++ b/widgets/table/e-table-header-utils.c @@ -124,7 +124,9 @@ make_composite_pixmap (GdkDrawable *drawable, GdkGC *gc, pheight = gdk_pixbuf_get_height (pixbuf); g_return_val_if_fail (width <= pwidth && height <= pheight, NULL); - color = ((bg->red & 0xff00) << 8) | (bg->green & 0xff00) | ((bg->blue & 0xff00) >> 8); + color = ((bg->red & 0xff00) << 8) | + (bg->green & 0xff00) | + ((bg->blue & 0xff00) >> 8); if (width >= pwidth && height >= pheight) { tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height); -- cgit v1.2.3 From 756c8abcb840b8da588031f4a0d7e1fc979fab70 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 27 May 2011 15:23:07 +0200 Subject: Bug #646109 - Fix use of include to make sure translations work --- widgets/table/e-table-header-utils.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'widgets/table/e-table-header-utils.c') diff --git a/widgets/table/e-table-header-utils.c b/widgets/table/e-table-header-utils.c index 8911867652..174d20a1de 100644 --- a/widgets/table/e-table-header-utils.c +++ b/widgets/table/e-table-header-utils.c @@ -22,7 +22,9 @@ * */ +#ifdef HAVE_CONFIG_H #include +#endif #include /* strlen() */ #include -- cgit v1.2.3 From 394e580dfdb04342c2e457ced400908e4dd5c88e Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 28 May 2011 10:18:56 -0400 Subject: Including directly is rarely needed. --- widgets/table/e-table-header-utils.c | 1 - 1 file changed, 1 deletion(-) (limited to 'widgets/table/e-table-header-utils.c') diff --git a/widgets/table/e-table-header-utils.c b/widgets/table/e-table-header-utils.c index 174d20a1de..659677eceb 100644 --- a/widgets/table/e-table-header-utils.c +++ b/widgets/table/e-table-header-utils.c @@ -27,7 +27,6 @@ #endif #include /* strlen() */ -#include #include -- cgit v1.2.3 From fcbbdfbd18e15b4ee8322a0217cf03a689a5e033 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 16 Aug 2011 11:25:56 -0400 Subject: Coding style and whitespace cleanup. --- widgets/table/e-table-header-utils.c | 37 ++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'widgets/table/e-table-header-utils.c') diff --git a/widgets/table/e-table-header-utils.c b/widgets/table/e-table-header-utils.c index 659677eceb..34f93a701b 100644 --- a/widgets/table/e-table-header-utils.c +++ b/widgets/table/e-table-header-utils.c @@ -35,8 +35,9 @@ #include "e-table-defines.h" #include "e-table-header-utils.h" -static PangoLayout* -build_header_layout (GtkWidget *widget, const gchar *str) +static PangoLayout * +build_header_layout (GtkWidget *widget, + const gchar *str) { PangoLayout *layout; @@ -69,7 +70,8 @@ build_header_layout (GtkWidget *widget, const gchar *str) * Return value: The height of the button, in pixels. **/ gdouble -e_table_header_compute_height (ETableCol *ecol, GtkWidget *widget) +e_table_header_compute_height (ETableCol *ecol, + GtkWidget *widget) { gint ythick; gint height; @@ -112,9 +114,14 @@ e_table_header_width_extras (GtkStyle *style) */ #if 0 static GdkPixmap * -make_composite_pixmap (GdkDrawable *drawable, GdkGC *gc, - GdkPixbuf *pixbuf, GdkColor *bg, gint width, gint height, - gint dither_xofs, gint dither_yofs) +make_composite_pixmap (GdkDrawable *drawable, + GdkGC *gc, + GdkPixbuf *pixbuf, + GdkColor *bg, + gint width, + gint height, + gint dither_xofs, + gint dither_yofs) { gint pwidth, pheight; GdkPixmap *pixmap; @@ -240,12 +247,18 @@ make_composite_pixmap (GdkDrawable *drawable, GdkGC *gc, * Draws a button suitable for a table header. **/ void -e_table_header_draw_button (cairo_t *cr, ETableCol *ecol, - GtkStyle *style, GtkStateType state, - GtkWidget *widget, - gint x, gint y, gint width, gint height, - gint button_width, gint button_height, - ETableColArrow arrow) +e_table_header_draw_button (cairo_t *cr, + ETableCol *ecol, + GtkStyle *style, + GtkStateType state, + GtkWidget *widget, + gint x, + gint y, + gint width, + gint height, + gint button_width, + gint button_height, + ETableColArrow arrow) { gint xthick, ythick; gint inner_x, inner_y; -- cgit v1.2.3 From b73a8f243ea4446f39012d7a64c107c25ff6d854 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Fri, 30 Sep 2011 11:34:38 -0400 Subject: ETableHeader: Rework the header button drawing code for GTK+ 3 The code in ETable that draws the button headers is outdated, and uses deprecated gtk_paint_* functions mixed with cairo. Port the code to use the GtkStyleContext API, which allows themes to give the header the same appearance of a regular GtkTreeView header. --- widgets/table/e-table-header-utils.c | 119 ++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 58 deletions(-) (limited to 'widgets/table/e-table-header-utils.c') diff --git a/widgets/table/e-table-header-utils.c b/widgets/table/e-table-header-utils.c index 34f93a701b..431009016f 100644 --- a/widgets/table/e-table-header-utils.c +++ b/widgets/table/e-table-header-utils.c @@ -60,6 +60,23 @@ build_header_layout (GtkWidget *widget, return layout; } +static void +get_button_padding (GtkWidget *widget, + GtkBorder *padding) +{ + GtkStyleContext *context; + GtkStateFlags state_flags; + + context = gtk_widget_get_style_context (widget); + state_flags = gtk_widget_get_state_flags (widget); + + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON); + gtk_style_context_get_padding (context, state_flags, padding); + + gtk_style_context_restore (context); +} + /** * e_table_header_compute_height: * @ecol: Table column description. @@ -73,15 +90,15 @@ gdouble e_table_header_compute_height (ETableCol *ecol, GtkWidget *widget) { - gint ythick; gint height; PangoLayout *layout; + GtkBorder padding; g_return_val_if_fail (ecol != NULL, -1); g_return_val_if_fail (E_IS_TABLE_COL (ecol), -1); g_return_val_if_fail (GTK_IS_WIDGET (widget), -1); - ythick = gtk_widget_get_style (widget)->ythickness; + get_button_padding (widget, &padding); layout = build_header_layout (widget, ecol->text); @@ -93,8 +110,7 @@ e_table_header_compute_height (ETableCol *ecol, } height = MAX (height, MIN_ARROW_SIZE); - - height += 2 * (ythick + HEADER_PADDING); + height += padding.top + padding.bottom + 2 * HEADER_PADDING; g_object_unref (layout); @@ -102,11 +118,12 @@ e_table_header_compute_height (ETableCol *ecol, } gdouble -e_table_header_width_extras (GtkStyle *style) +e_table_header_width_extras (GtkWidget *widget) { - g_return_val_if_fail (style != NULL, -1); + GtkBorder padding; - return 2 * (style->xthickness + HEADER_PADDING); + get_button_padding (widget, &padding); + return padding.left + padding.right + 2 * HEADER_PADDING; } /* Creates a pixmap that is a composite of a background color and the upper-left @@ -233,8 +250,6 @@ make_composite_pixmap (GdkDrawable *drawable, * e_table_header_draw_button: * @drawable: Destination drawable. * @ecol: Table column for the header information. - * @style: Style to use for drawing the button. - * @state: State of the table widget. * @widget: The table widget. * @x: Leftmost coordinate of the button. * @y: Topmost coordinate of the button. @@ -249,8 +264,6 @@ make_composite_pixmap (GdkDrawable *drawable, void e_table_header_draw_button (cairo_t *cr, ETableCol *ecol, - GtkStyle *style, - GtkStateType state, GtkWidget *widget, gint x, gint y, @@ -260,58 +273,49 @@ e_table_header_draw_button (cairo_t *cr, gint button_height, ETableColArrow arrow) { - gint xthick, ythick; gint inner_x, inner_y; gint inner_width, inner_height; gint arrow_width = 0, arrow_height = 0; PangoLayout *layout; - static gpointer g_label = NULL; + GtkStyleContext *context; + GtkBorder padding; + GtkStateFlags state_flags; g_return_if_fail (cr != NULL); g_return_if_fail (ecol != NULL); g_return_if_fail (E_IS_TABLE_COL (ecol)); - g_return_if_fail (style != NULL); g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (button_width > 0 && button_height > 0); - if (g_label == NULL) { - GtkWidget *button = gtk_button_new_with_label("Hi"); - GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_container_add (GTK_CONTAINER (window), button); - gtk_widget_ensure_style (window); - gtk_widget_ensure_style (button); - g_label = gtk_bin_get_child (GTK_BIN (button)); - g_object_add_weak_pointer (G_OBJECT (g_label), &g_label); - gtk_widget_ensure_style (g_label); - gtk_widget_realize (g_label); - } - - cairo_save (cr); - gdk_cairo_set_source_color ( - cr, >k_widget_get_style (GTK_WIDGET (g_label))->fg[state]); + /* Button bevel */ + context = gtk_widget_get_style_context (widget); + state_flags = gtk_widget_get_state_flags (widget); - xthick = style->xthickness; - ythick = style->ythickness; + gtk_style_context_save (context); + gtk_style_context_set_state (context, state_flags); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON); - /* Button bevel */ + gtk_style_context_get_padding (context, state_flags, &padding); - gtk_paint_box (style, cr, state, GTK_SHADOW_OUT, - widget, "button", - x, y, button_width, button_height); + gtk_render_background ( + context, cr, x, y, + button_width, button_height); + gtk_render_frame ( + context, cr, x, y, + button_width, button_height); /* Inside area */ - inner_width = button_width - 2 * (xthick + HEADER_PADDING); - inner_height = button_height - 2 * (ythick + HEADER_PADDING); + inner_width = button_width - (padding.left + padding.right + 2 * HEADER_PADDING); + inner_height = button_height - (padding.top + padding.bottom + 2 * HEADER_PADDING); if (inner_width < 1 || inner_height < 1) { - cairo_restore (cr); return; /* nothing fits */ } - inner_x = x + xthick + HEADER_PADDING; - inner_y = y + ythick + HEADER_PADDING; + inner_x = x + padding.left + HEADER_PADDING; + inner_y = y + padding.top + HEADER_PADDING; /* Arrow space */ @@ -328,12 +332,11 @@ e_table_header_draw_button (cairo_t *cr, inner_width -= arrow_width + HEADER_PADDING; break; default: - cairo_restore (cr); g_return_if_reached (); } if (inner_width < 1) { - cairo_restore (cr); + gtk_style_context_restore (context); return; /* nothing else fits */ } @@ -370,18 +373,19 @@ e_table_header_draw_button (cairo_t *cr, layout, (inner_width - (xpos - inner_x)) * PANGO_SCALE); - cairo_move_to (cr, xpos + pwidth + 1, ypos); - pango_cairo_show_layout (cr, layout); + gtk_render_layout ( + context, cr, xpos + pwidth + 1, + ypos, layout); } - gdk_cairo_set_source_pixbuf (cr, ecol->pixbuf, - xpos, inner_y + (inner_height - clip_height) / 2); - cairo_paint (cr); + gtk_render_icon ( + context, cr, ecol->pixbuf, xpos, + inner_y + (inner_height - clip_height) / 2); + } else { pango_layout_set_width (layout, inner_width * PANGO_SCALE); - cairo_move_to (cr, inner_x, inner_y); - pango_cairo_show_layout (cr, layout); + gtk_render_layout (context, cr, inner_x, inner_y, layout); } switch (arrow) { @@ -393,21 +397,20 @@ e_table_header_draw_button (cairo_t *cr, if (ecol->icon_name == NULL) inner_width += arrow_width + HEADER_PADDING; - gtk_paint_arrow (style, cr, state, - GTK_SHADOW_NONE, widget, "header", - (arrow == E_TABLE_COL_ARROW_UP) ? GTK_ARROW_UP : GTK_ARROW_DOWN, - (ecol->icon_name == NULL), - inner_x + inner_width - arrow_width, - inner_y + (inner_height - arrow_height) / 2, - arrow_width, arrow_height); + gtk_render_arrow ( + context, cr, + (arrow == E_TABLE_COL_ARROW_UP) ? 0 : G_PI, + inner_x + inner_width - arrow_width, + inner_y + (inner_height - arrow_height) / 2, + MAX (arrow_width, arrow_height)); + break; } default: - cairo_restore (cr); g_return_if_reached (); } g_object_unref (layout); - cairo_restore (cr); + gtk_style_context_restore (context); } -- cgit v1.2.3 From 4674fb54872a093b9e116de91e7122c42be735fa Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Fri, 30 Sep 2011 11:48:06 -0400 Subject: ETableHeader: Nuke unused code. --- widgets/table/e-table-header-utils.c | 149 +---------------------------------- 1 file changed, 2 insertions(+), 147 deletions(-) (limited to 'widgets/table/e-table-header-utils.c') diff --git a/widgets/table/e-table-header-utils.c b/widgets/table/e-table-header-utils.c index 431009016f..0150ff02a6 100644 --- a/widgets/table/e-table-header-utils.c +++ b/widgets/table/e-table-header-utils.c @@ -35,31 +35,6 @@ #include "e-table-defines.h" #include "e-table-header-utils.h" -static PangoLayout * -build_header_layout (GtkWidget *widget, - const gchar *str) -{ - PangoLayout *layout; - - layout = gtk_widget_create_pango_layout (widget, str); - -#ifdef FROB_FONT_DESC - { - PangoFontDescription *desc; - desc = pango_font_description_copy (gtk_widget_get_style (widget)->font_desc); - pango_font_description_set_size (desc, - pango_font_description_get_size (desc) * 1.2); - - pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD); - pango_layout_set_font_description (layout, desc); - - pango_font_description_free (desc); - } -#endif - - return layout; -} - static void get_button_padding (GtkWidget *widget, GtkBorder *padding) @@ -100,7 +75,7 @@ e_table_header_compute_height (ETableCol *ecol, get_button_padding (widget, &padding); - layout = build_header_layout (widget, ecol->text); + layout = gtk_widget_create_pango_layout (widget, ecol->text); pango_layout_get_pixel_size (layout, NULL, &height); @@ -126,126 +101,6 @@ e_table_header_width_extras (GtkWidget *widget) return padding.left + padding.right + 2 * HEADER_PADDING; } -/* Creates a pixmap that is a composite of a background color and the upper-left - * corner rectangle of a pixbuf. - */ -#if 0 -static GdkPixmap * -make_composite_pixmap (GdkDrawable *drawable, - GdkGC *gc, - GdkPixbuf *pixbuf, - GdkColor *bg, - gint width, - gint height, - gint dither_xofs, - gint dither_yofs) -{ - gint pwidth, pheight; - GdkPixmap *pixmap; - GdkPixbuf *tmp; - gint color; - - pwidth = gdk_pixbuf_get_width (pixbuf); - pheight = gdk_pixbuf_get_height (pixbuf); - g_return_val_if_fail (width <= pwidth && height <= pheight, NULL); - - color = ((bg->red & 0xff00) << 8) | - (bg->green & 0xff00) | - ((bg->blue & 0xff00) >> 8); - - if (width >= pwidth && height >= pheight) { - tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height); - if (!tmp) - return NULL; - - gdk_pixbuf_composite_color (pixbuf, tmp, - 0, 0, - width, height, - 0, 0, - 1.0, 1.0, - GDK_INTERP_NEAREST, - 255, - 0, 0, - 16, - color, color); - } else { - gint x, y, rowstride; - GdkPixbuf *fade; - guchar *pixels; - - /* Do a nice fade of the pixbuf down and to the right */ - - fade = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height); - if (!fade) - return NULL; - - gdk_pixbuf_copy_area (pixbuf, - 0, 0, - width, height, - fade, - 0, 0); - - rowstride = gdk_pixbuf_get_rowstride (fade); - pixels = gdk_pixbuf_get_pixels (fade); - - for (y = 0; y < height; y++) { - guchar *p; - gint yfactor; - - p = pixels + y * rowstride; - - if (height < pheight) - yfactor = height - y; - else - yfactor = height; - - for (x = 0; x < width; x++) { - gint xfactor; - - if (width < pwidth) - xfactor = width - x; - else - xfactor = width; - - p[3] = ((gint) p[3] * xfactor * yfactor / (width * height)); - p += 4; - } - } - - tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height); - if (!tmp) { - g_object_unref (fade); - return NULL; - } - - gdk_pixbuf_composite_color (fade, tmp, - 0, 0, - width, height, - 0, 0, - 1.0, 1.0, - GDK_INTERP_NEAREST, - 255, - 0, 0, - 16, - color, color); - - g_object_unref (fade); - } - - pixmap = gdk_pixmap_new (drawable, width, height, -1); - gdk_draw_rgb_image_dithalign (pixmap, gc, - 0, 0, - width, height, - GDK_RGB_DITHER_NORMAL, - gdk_pixbuf_get_pixels (tmp), - gdk_pixbuf_get_rowstride (tmp), - dither_xofs, dither_yofs); - g_object_unref (tmp); - - return pixmap; -} -#endif - /** * e_table_header_draw_button: * @drawable: Destination drawable. @@ -340,7 +195,7 @@ e_table_header_draw_button (cairo_t *cr, return; /* nothing else fits */ } - layout = build_header_layout (widget, ecol->text); + layout = gtk_widget_create_pango_layout (widget, ecol->text); pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END); /* Pixbuf or label */ -- cgit v1.2.3