diff src/gtkblist.c @ 12519:e63a80be5227

[gaim-migrate @ 14831] better (?) tooltips committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sat, 17 Dec 2005 05:13:45 +0000
parents 53e2dc07d9e2
children 560ddc8d26f3
line wrap: on
line diff
--- a/src/gtkblist.c	Sat Dec 17 05:04:08 2005 +0000
+++ b/src/gtkblist.c	Sat Dec 17 05:13:45 2005 +0000
@@ -2064,19 +2064,26 @@
 	PangoLayout *layout;
 	GdkPixbuf *status_icon;
 	GdkPixbuf *avatar;
+	GaimStatusIconSize size;
 	int avatar_width;
 	int width;
 	int height;
 };
 
-static struct tooltip_data * create_tip_for_node(GaimBlistNode *node)
+static struct tooltip_data * create_tip_for_node(GaimBlistNode *node, GaimStatusIconSize size)
 {
+	char *tooltip_text = NULL;
 	struct tooltip_data *td = g_new0(struct tooltip_data, 1);
-	char *tooltip_text = gaim_get_tooltip_text(node);
-
-	td->status_icon = gaim_gtk_blist_get_status_icon(node, GAIM_STATUS_ICON_LARGE);
-	td->avatar = gaim_gtk_blist_get_buddy_icon(node, FALSE, FALSE);
-
+
+	td->status_icon = gaim_gtk_blist_get_status_icon(node, size);
+	if (size == GAIM_STATUS_ICON_LARGE) {
+		td->avatar = gaim_gtk_blist_get_buddy_icon(node, FALSE, FALSE);
+		tooltip_text = gaim_get_tooltip_text(node);
+	} else if (size == GAIM_STATUS_ICON_SMALL) {
+		td->avatar = NULL;
+		tooltip_text = g_strdup_printf("<b><span size='smaller'>%s</span></b>", GAIM_BLIST_NODE_NAME(node));
+	}
+	td->size = size;
 	td->layout = gtk_widget_create_pango_layout(gtkblist->tipwindow, NULL);
 	pango_layout_set_markup(td->layout, tooltip_text, strlen(tooltip_text));
 	pango_layout_set_wrap(td->layout, PANGO_WRAP_WORD);
@@ -2084,7 +2091,10 @@
 
 	pango_layout_get_size (td->layout, &td->width, &td->height);
 	td->width = PANGO_PIXELS(td->width) + 38 + 8;
-	td->height = MAX(PANGO_PIXELS(td->height) + 8, 38);
+	if (size == GAIM_STATUS_ICON_SMALL)
+		td->height = MAX(PANGO_PIXELS(td->height)+ 4 , 8);
+	else
+		td->height = MAX(PANGO_PIXELS(td->height + 4), 38);
 
 	if(td->avatar) {
 		td->avatar_width = gdk_pixbuf_get_width(td->avatar);
@@ -2115,33 +2125,31 @@
 		max_width = MAX(max_width, td->width);
 	}
 
-	current_height = 0;
+	current_height = 4;
 	for(l = gtkblist->tooltipdata; l; l = l->next)
 	{
 		struct tooltip_data *td = l->data;
 
 #if GTK_CHECK_VERSION(2,2,0)
 		gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->status_icon,
-				0, 0, 4, current_height + 4, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0);
+			0, 0, 	td->size == GAIM_STATUS_ICON_LARGE ? 4 : 19, current_height, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0);
 		if(td->avatar)
 			gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL,
-					td->avatar, 0, 0, max_width - (td->avatar_width + 4), current_height + 4, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0);
+					td->avatar, 0, 0, max_width - (td->avatar_width + 4), current_height, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0);
 #else
-		gdk_pixbuf_render_to_drawable(td->status_icon, GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0, 4, current_height + 4, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
+		gdk_pixbuf_render_to_drawable(td->status_icon, GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0, 4, current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
 		if(td->avatar)
 			gdk_pixbuf_render_to_drawable(td->avatar,
 					GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0,
-					max_width - (td->avatar_width + 4),
-					current_height + 4, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
+					max_width - (td->avatar_width + 4) + (td->size == GAIM_STATUS_ICON_LARGE ? 15 : 0),
+					current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
 #endif
 
 		gtk_paint_layout (style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE,
-				NULL, gtkblist->tipwindow, "tooltip", 38 + 4, current_height + 4, td->layout);
+				NULL, gtkblist->tipwindow, "tooltip", 38 + 4, current_height, td->layout);
 
 		current_height += td->height;
 
-		if(l->next)
-			gtk_paint_hline(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, NULL, NULL, NULL, 4, max_width - 4, current_height-2);
 	}
 }
 
@@ -2255,18 +2263,19 @@
 	gtkblist->tipwindow = gtk_window_new(GTK_WINDOW_POPUP);
 
 	if(GAIM_BLIST_NODE_IS_CHAT(node) || GAIM_BLIST_NODE_IS_BUDDY(node)) {
-		struct tooltip_data *td = create_tip_for_node(node);
+		struct tooltip_data *td = create_tip_for_node(node, GAIM_STATUS_ICON_LARGE);
 		gtkblist->tooltipdata = g_list_append(gtkblist->tooltipdata, td);
 		w = td->width;
 		h = td->height;
 	} else if(GAIM_BLIST_NODE_IS_CONTACT(node)) {
 		GaimBlistNode *child;
+		int count;
 		GaimBuddy *b = gaim_contact_get_priority_buddy((GaimContact *)node);
 		w = h = 0;
-		for(child = node->child; child; child = child->next)
+		for(child = node->child, count = 0; child; child = child->next, count++)
 		{
 			if(GAIM_BLIST_NODE_IS_BUDDY(child) && buddy_is_displayable((GaimBuddy*)child)) {
-				struct tooltip_data *td = create_tip_for_node(child);
+				struct tooltip_data *td = create_tip_for_node(child, b == (GaimBuddy*)child ? GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL);
 				if (b == (GaimBuddy *)child) {
 					gtkblist->tooltipdata = g_list_prepend(gtkblist->tooltipdata, td);
 				} else {
@@ -2276,6 +2285,7 @@
 				h += td->height;
 			}
 		}
+		h += 8;
 	} else {
 		gtk_widget_destroy(gtkblist->tipwindow);
 		gtkblist->tipwindow = NULL;