[evolution-patches] 40228: partial fix for shortcut-bar font clipping



This is a patch toshok gave me that eliminates the ugly clipping of
multiline labels on shortcuts.  The 1.2 behavior doesn't produce
multiline labels at all, so this isn't a complete fix, but at least it's
less ugly than the current behavior.

Mike
Index: gal/shortcut-bar/ChangeLog
===================================================================
RCS file: /cvs/gnome/gal/gal/shortcut-bar/ChangeLog,v
retrieving revision 1.67
diff -u -p -r1.67 ChangeLog
--- gal/shortcut-bar/ChangeLog	3 Apr 2003 23:32:26 -0000	1.67
+++ gal/shortcut-bar/ChangeLog	14 Apr 2003 15:23:22 -0000
@@ -1,3 +1,9 @@
+2003-04-14  Mike Kestner  <mkestner ximian com>
+
+	* e-icon-bar.c (e_i_b_recalc_item_positions): s/GdkFont/PangoFont
+	(e_i_b_add_item): ditto
+	Patch from Chris Toshok <toshok ximiam com>
+
 2003-04-03  Mike Kestner  <mkestner ximian com>
 
 	* e-icon-bar.c (e_icon_bar_size_allocate): save/restore the
Index: gal/shortcut-bar/e-icon-bar.c
===================================================================
RCS file: /cvs/gnome/gal/gal/shortcut-bar/e-icon-bar.c,v
retrieving revision 1.41
diff -u -p -r1.41 e-icon-bar.c
--- gal/shortcut-bar/e-icon-bar.c	3 Apr 2003 23:32:26 -0000	1.41
+++ gal/shortcut-bar/e-icon-bar.c	14 Apr 2003 15:23:23 -0000
@@ -386,8 +386,16 @@ e_icon_bar_recalc_item_positions (EIconB
 	GtkJustification justify;
 	GtkAnchorType anchor;
 	gint max_lines;
-	GdkFont *font;
 	gboolean line_wrap;
+	PangoContext *context = gtk_widget_get_pango_context (GTK_WIDGET (icon_bar));
+	PangoFontMetrics *metrics;
+
+	metrics = pango_context_get_metrics (context, gtk_widget_get_style (GTK_WIDGET (icon_bar))->font_desc, pango_context_get_language (context));
+
+	text_h = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics)
+			       + pango_font_metrics_get_descent (metrics));
+
+	pango_font_metrics_unref (metrics);
 
 	if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
 		justify = GTK_JUSTIFY_CENTER;
@@ -395,15 +403,11 @@ e_icon_bar_recalc_item_positions (EIconB
 		max_lines = 2;
 		text_x = icon_bar->text_x + (icon_bar->text_w / 2);
 		line_wrap = TRUE;
-		font = gtk_style_get_font (GTK_WIDGET (icon_bar)->style);
-		text_h = font->ascent + font->descent;
 	} else {
 		justify = GTK_JUSTIFY_LEFT;
 		anchor = GTK_ANCHOR_NW;
 		max_lines = 1;
 		text_x = icon_bar->text_x;
-		font = gtk_style_get_font (GTK_WIDGET (icon_bar)->style);
-		text_h = font->ascent + font->descent;
 		line_wrap = FALSE;
 	}
 
@@ -459,7 +463,6 @@ e_icon_bar_recalc_item_positions (EIconB
 	return y;
 }
 
-
 static gint
 e_icon_bar_leave_notify_event (GtkWidget *widget, GdkEventCrossing *event)
 {
@@ -596,7 +599,6 @@ e_icon_bar_style_set (GtkWidget *widget,
 	e_icon_bar_recalc_item_positions (icon_bar);
 }
 
-
 /**
  * e_icon_bar_add_item:
  * @icon_bar: An #EIconBar.
@@ -617,9 +619,10 @@ e_icon_bar_add_item (EIconBar	    *icon_
 	GtkAnchorType anchor;
 	gint max_lines, retval;
 	GtkStyle *style;
-	GdkFont *font;
 	gdouble text_x, clip_height;
 	GdkPixbuf *flattened = NULL;
+	PangoContext *context;
+	PangoFontMetrics *metrics;
 
 	g_return_val_if_fail (E_IS_ICON_BAR (icon_bar), -1);
 	g_return_val_if_fail (text != NULL, -1);
@@ -639,9 +642,14 @@ e_icon_bar_add_item (EIconBar	    *icon_
 	}
 
 	gtk_widget_ensure_style (GTK_WIDGET (icon_bar));
-	style = GTK_WIDGET (icon_bar)->style;
-	font = gtk_style_get_font (style);
-	clip_height = max_lines * (font->ascent + font->descent);
+	
+	context = gtk_widget_get_pango_context (GTK_WIDGET (icon_bar));
+
+	metrics = pango_context_get_metrics (context, gtk_widget_get_style (GTK_WIDGET (icon_bar))->font_desc, pango_context_get_language (context));
+	clip_height = max_lines * PANGO_PIXELS (pango_font_metrics_get_ascent (metrics)
+						+ pango_font_metrics_get_descent (metrics));
+	pango_font_metrics_unref (metrics);
+
 	item.text = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (icon_bar)->root),
 					   e_text_get_type (),
 					   "fill_color_gdk", &style->fg [GTK_STATE_NORMAL],
@@ -653,6 +661,7 @@ e_icon_bar_add_item (EIconBar	    *icon_
 					   "max_lines", max_lines,
 					   "clip", TRUE,
 					   "clip_width", (gdouble) (icon_bar->text_w),
+					   "width", (gdouble) (icon_bar->text_w),
 					   "clip_height", clip_height,
 					   "text", text,
 					   "draw_background", FALSE,
@@ -707,7 +716,6 @@ e_icon_bar_add_item (EIconBar	    *icon_
 
 	return retval;
 }
-
 
 /**
  * e_icon_bar_reorder_item:


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