Mercurial > pidgin
changeset 3465:ec437d73b2ee
[gaim-migrate @ 3515]
This looks better.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Thu, 29 Aug 2002 01:43:23 +0000 |
parents | 01af3b8338a2 |
children | 7a3f16a375a5 |
files | src/gtkimhtml.c |
diffstat | 1 files changed, 31 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkimhtml.c Wed Aug 28 18:25:54 2002 +0000 +++ b/src/gtkimhtml.c Thu Aug 29 01:43:23 2002 +0000 @@ -43,13 +43,6 @@ #include "pixmaps/broken.xpm" #endif -#if GTK_CHECK_VERSION(1,3,0) -# define GTK_IMHTML_GET_STYLE_FONT(style) gtk_style_get_font (style) -#else -# define GTK_IMHTML_GET_STYLE_FONT(style) (style)->font -# define GTK_CLASS_TYPE(class) (class)->type -#endif - #include "pixmaps/angel.xpm" #include "pixmaps/bigsmile.xpm" #include "pixmaps/burp.xpm" @@ -91,6 +84,8 @@ #define TYPE_BR 4 #define TYPE_COMMENT 5 +#define GTK_IMHTML_GET_STYLE_FONT(style) gtk_style_get_font (style) + #define DRAW_IMG(x) (((x)->type == TYPE_IMG) || (imhtml->smileys && ((x)->type == TYPE_SMILEY))) typedef struct _GtkIMHtmlBit GtkIMHtmlBit; @@ -1438,32 +1433,29 @@ static gint gtk_imhtml_tip_paint (GtkIMHtml *imhtml) { + int x,y; GtkStyle *style; - GdkFont *font; - gint y, baseline_skip, gap; - + PangoLayout *layout; + if (imhtml->tip_bit->url) + layout = gtk_widget_create_pango_layout (imhtml->tip_window, imhtml->tip_bit->url); + else if (imhtml->tip_bit->img) + layout = gtk_widget_create_pango_layout (imhtml->tip_window, imhtml->tip_bit->img->filename); + else + return FALSE; + style = imhtml->tip_window->style; - font = GTK_IMHTML_GET_STYLE_FONT (style); - - gap = (font->ascent + font->descent) / 4; - if (gap < 2) - gap = 2; - baseline_skip = font->ascent + font->descent + gap; + pango_layout_get_size (layout, &x, &y); if (!imhtml->tip_bit) return FALSE; - + gtk_paint_flat_box (style, imhtml->tip_window->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, imhtml->tip_window, "tooltip", 0, 0, -1, -1); - y = font->ascent + 4; - if (imhtml->tip_bit->url) - gtk_paint_string (style, imhtml->tip_window->window, GTK_STATE_NORMAL, NULL, - imhtml->tip_window, "tooltip", 4, y, imhtml->tip_bit->url); - else if (imhtml->tip_bit->img) - gtk_paint_string (style, imhtml->tip_window->window, GTK_STATE_NORMAL, NULL, - imhtml->tip_window, "tooltip", 4, y, imhtml->tip_bit->img->filename); - + gtk_paint_layout (style, imhtml->tip_window->window, GTK_STATE_NORMAL, TRUE, + NULL, imhtml->tip_window, "tooltip", 4, 4, layout); + + g_object_unref (layout); return FALSE; } @@ -1473,8 +1465,8 @@ GtkIMHtml *imhtml = data; GtkWidget *widget = GTK_WIDGET (imhtml); GtkStyle *style; - GdkFont *font; - gint gap, x, y, w, h, scr_w, scr_h, baseline_skip; + PangoLayout *layout; + gint x, y, w, h, scr_w, scr_h; if (!imhtml->tip_bit || !GTK_WIDGET_DRAWABLE (widget)) { imhtml->tip_timer = 0; @@ -1490,24 +1482,19 @@ gtk_widget_set_name (imhtml->tip_window, "gtk-tooltips"); gtk_signal_connect_object (GTK_OBJECT (imhtml->tip_window), "expose_event", GTK_SIGNAL_FUNC (gtk_imhtml_tip_paint), GTK_OBJECT (imhtml)); - gtk_signal_connect_object (GTK_OBJECT (imhtml->tip_window), "draw", - GTK_SIGNAL_FUNC (gtk_imhtml_tip_paint), GTK_OBJECT (imhtml)); gtk_widget_ensure_style (imhtml->tip_window); style = imhtml->tip_window->style; - font = GTK_IMHTML_GET_STYLE_FONT (style); + layout = gtk_widget_create_pango_layout(imhtml->tip_window, + imhtml->tip_bit->url ? imhtml->tip_bit->url : imhtml->tip_bit->img->filename); scr_w = gdk_screen_width (); scr_h = gdk_screen_height (); - gap = (font->ascent + font->descent) / 4; - if (gap < 2) - gap = 2; - baseline_skip = font->ascent + font->descent + gap; - - w = 8 + gdk_string_width (font, imhtml->tip_bit->img ? imhtml->tip_bit->img->filename : - imhtml->tip_bit->url); - h = 8 - gap + baseline_skip; + pango_layout_get_size(layout, &w, &h); + + w = PANGO_PIXELS(w) + 8; + h = PANGO_PIXELS(h) + 8; gdk_window_get_pointer (NULL, &x, &y, NULL); if (GTK_WIDGET_NO_WINDOW (widget)) @@ -1521,18 +1508,17 @@ x = 0; if ((y + h + + 4) > scr_h) - y = y - imhtml->tip_bit->font->ascent + imhtml->tip_bit->font->descent; + y = y - h; else - if (imhtml->tip_bit->font) - y = y + imhtml->tip_bit->font->ascent + imhtml->tip_bit->font->descent; - else - y = y + font->ascent + font->descent; - + y = y + h - 4; + gtk_widget_set_usize (imhtml->tip_window, w, h); gtk_widget_set_uposition (imhtml->tip_window, x, y); gtk_widget_show (imhtml->tip_window); imhtml->tip_timer = 0; + g_object_unref(layout); + return FALSE; } @@ -1590,7 +1576,7 @@ while (click) { uw = (struct clickable *) click->data; - if ((x > uw->x) && (x < uw->x + uw->width) && + if ((uw->bit->url) && (x > uw->x) && (x < uw->x + uw->width) && (y > uw->y) && (y < uw->y + uw->height) && (uw->bit->url || uw->bit->img)) { if (imhtml->tip_bit != uw->bit) { @@ -2076,12 +2062,7 @@ static const gchar* gtk_imhtml_get_font_name (GdkFont *font) { -#if GTK_CHECK_VERSION(1,3,0) return gdk_x11_font_get_name(font); -#else - GdkFontPrivate *fontpriv = (GdkFontPrivate *) font; - return fontpriv->names->data; -#endif } static GdkFont*