comparison src/gtkblist.c @ 10544:bc7352b57a99

[gaim-migrate @ 11910] ugliest. code. ever. but now the buddy icons in the buddy list retain aspect ratio committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Tue, 25 Jan 2005 07:20:09 +0000
parents ef9b6ef0c858
children 54f7939df8e3
comparison
equal deleted inserted replaced
10543:052ef28a0695 10544:bc7352b57a99
2098 g_object_ref(G_OBJECT(buf)); 2098 g_object_ref(G_OBJECT(buf));
2099 gdk_pixbuf_loader_close(loader, NULL); 2099 gdk_pixbuf_loader_close(loader, NULL);
2100 g_object_unref(G_OBJECT(loader)); 2100 g_object_unref(G_OBJECT(loader));
2101 2101
2102 if (buf) { 2102 if (buf) {
2103 GaimAccount *account = gaim_buddy_get_account(buddy);
2104 GaimPluginProtocolInfo *prpl_info = NULL;
2105 int orig_width, orig_height;
2106 int scale_width, scale_height;
2107
2108 if(account && account->gc)
2109 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl);
2110
2103 if (greyed) { 2111 if (greyed) {
2104 GaimPresence *presence = gaim_buddy_get_presence(buddy); 2112 GaimPresence *presence = gaim_buddy_get_presence(buddy);
2105 if (!GAIM_BUDDY_IS_ONLINE(buddy)) 2113 if (!GAIM_BUDDY_IS_ONLINE(buddy))
2106 gdk_pixbuf_saturate_and_pixelate(buf, buf, 0.0, FALSE); 2114 gdk_pixbuf_saturate_and_pixelate(buf, buf, 0.0, FALSE);
2107 if (gaim_presence_is_idle(presence)) 2115 if (gaim_presence_is_idle(presence))
2108 gdk_pixbuf_saturate_and_pixelate(buf, buf, 0.25, FALSE); 2116 gdk_pixbuf_saturate_and_pixelate(buf, buf, 0.25, FALSE);
2109 } 2117 }
2110 2118
2119 /* i'd use the gaim_gtk_buddy_icon_get_scale_size() thing,
2120 * but it won't tell me the original size, which I need for scaling
2121 * purposes */
2122 scale_width = orig_width = gdk_pixbuf_get_width(buf);
2123 scale_height = orig_height = gdk_pixbuf_get_height(buf);
2124
2125 gaim_buddy_icon_get_scale_size(prpl_info ? &prpl_info->icon_spec : NULL, &scale_width, &scale_height);
2126
2111 if (scaled) { 2127 if (scaled) {
2112 ret = gdk_pixbuf_scale_simple(buf,30,30, GDK_INTERP_BILINEAR); 2128 if(scale_height > scale_width) {
2113 g_object_unref(G_OBJECT(buf)); 2129 scale_width = 30.0 * (double)scale_width / (double)scale_height;
2130 scale_height = 30;
2131 } else {
2132 scale_height = 30.0 * (double)scale_height / (double)scale_width;
2133 scale_width = 30;
2134 }
2135
2136 ret = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 30, 30);
2137 gdk_pixbuf_fill(ret, 0x00000000);
2138 gdk_pixbuf_scale(buf, ret, (30-scale_width)/2, (30-scale_height)/2, scale_width, scale_height, (30-scale_width)/2, (30-scale_height)/2, (double)scale_width/(double)orig_width, (double)scale_height/(double)orig_height, GDK_INTERP_BILINEAR);
2114 } else { 2139 } else {
2115 GaimAccount *account = gaim_buddy_get_account(buddy);
2116 int scale_width, scale_height;
2117 GaimPluginProtocolInfo *prpl_info = NULL;
2118
2119 if(account && account->gc)
2120 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl);
2121
2122 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : NULL, &scale_width, &scale_height);
2123
2124 ret = gdk_pixbuf_scale_simple(buf,scale_width,scale_height, GDK_INTERP_BILINEAR); 2140 ret = gdk_pixbuf_scale_simple(buf,scale_width,scale_height, GDK_INTERP_BILINEAR);
2125 g_object_unref(G_OBJECT(buf)); 2141 }
2126 } 2142 g_object_unref(G_OBJECT(buf));
2127 } 2143 }
2128 2144
2129 return ret; 2145 return ret;
2130 } 2146 }
2131 2147
3413 GDK_ACTION_COPY); 3429 GDK_ACTION_COPY);
3414 gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(gtkblist->treeview), 3430 gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(gtkblist->treeview),
3415 dte, 5, 3431 dte, 5,
3416 GDK_ACTION_COPY | GDK_ACTION_MOVE); 3432 GDK_ACTION_COPY | GDK_ACTION_MOVE);
3417 3433
3418 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-received", G_CALLBACK(gaim_gtk_blist_drag_data_rcv_cb), NULL); 3434 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-received", G_CALLBACK(gaim_gtk_blist_drag_data_rcv_cb), NULL);
3419 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-get", G_CALLBACK(gaim_gtk_blist_drag_data_get_cb), NULL); 3435 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-get", G_CALLBACK(gaim_gtk_blist_drag_data_get_cb), NULL);
3420 3436
3421 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-motion", G_CALLBACK(gaim_gtk_blist_drag_motion_cb), NULL); 3437 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-motion", G_CALLBACK(gaim_gtk_blist_drag_motion_cb), NULL);
3422 3438
3423 /* Tooltips */ 3439 /* Tooltips */