| 235 |
235 |
| 236 } |
236 } |
| 237 |
237 |
| 238 /* Altered from do_colorshift in gnome-panel */ |
238 /* Altered from do_colorshift in gnome-panel */ |
| 239 static void |
239 static void |
| 240 do_alphashift (GdkPixbuf *dest, GdkPixbuf *src, int shift) |
240 do_alphashift (GdkPixbuf *dest, GdkPixbuf *src) |
| 241 { |
241 { |
| 242 gint i, j; |
242 gint i, j; |
| 243 gint width, height, has_alpha, srcrowstride, destrowstride; |
243 gint width, height, has_alpha, srcrowstride, destrowstride; |
| 244 guchar *target_pixels; |
244 guchar *target_pixels; |
| 245 guchar *original_pixels; |
245 guchar *original_pixels; |
| 246 guchar *pixsrc; |
246 guchar *pixsrc; |
| 247 guchar *pixdest; |
247 guchar *pixdest; |
| 248 int val; |
|
| 249 guchar a; |
248 guchar a; |
| 250 |
249 |
| 251 has_alpha = gdk_pixbuf_get_has_alpha (src); |
250 has_alpha = gdk_pixbuf_get_has_alpha (src); |
| 252 if (!has_alpha) |
251 if (!has_alpha) |
| 253 return; |
252 return; |
| 265 for (j = 0; j < width; j++) { |
264 for (j = 0; j < width; j++) { |
| 266 *(pixdest++) = *(pixsrc++); |
265 *(pixdest++) = *(pixsrc++); |
| 267 *(pixdest++) = *(pixsrc++); |
266 *(pixdest++) = *(pixsrc++); |
| 268 *(pixdest++) = *(pixsrc++); |
267 *(pixdest++) = *(pixsrc++); |
| 269 a = *(pixsrc++); |
268 a = *(pixsrc++); |
| 270 val = a - shift; |
269 *(pixdest++) = a / 2; |
| 271 *(pixdest++) = CLAMP(val, 0, 255); |
|
| 272 } |
270 } |
| 273 } |
271 } |
| 274 } |
272 } |
| 275 |
273 |
| 276 /* TODO: This is almost certainly not the best way to do this, but it's late, I'm tired, |
274 /* TODO: This is almost certainly not the best way to do this, but it's late, I'm tired, |
| 284 GtkIconSource *source; |
282 GtkIconSource *source; |
| 285 GdkPixbuf *pixbuf; |
283 GdkPixbuf *pixbuf; |
| 286 |
284 |
| 287 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", dir, size, file, NULL); |
285 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", dir, size, file, NULL); |
| 288 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
286 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
| 289 do_alphashift(pixbuf, pixbuf, 128); |
287 do_alphashift(pixbuf, pixbuf); |
| 290 |
288 |
| 291 source = gtk_icon_source_new(); |
289 source = gtk_icon_source_new(); |
| 292 gtk_icon_source_set_pixbuf(source, pixbuf); |
290 gtk_icon_source_set_pixbuf(source, pixbuf); |
| 293 gtk_icon_source_set_direction(source, GTK_TEXT_DIR_LTR); |
291 gtk_icon_source_set_direction(source, GTK_TEXT_DIR_LTR); |
| 294 gtk_icon_source_set_direction_wildcarded(source, !rtl); |
292 gtk_icon_source_set_direction_wildcarded(source, !rtl); |
| 312 g_object_unref(pixbuf); |
310 g_object_unref(pixbuf); |
| 313 |
311 |
| 314 if (rtl) { |
312 if (rtl) { |
| 315 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", dir, size, "rtl", file, NULL); |
313 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", dir, size, "rtl", file, NULL); |
| 316 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
314 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
| 317 do_alphashift(pixbuf, pixbuf, 128); |
315 do_alphashift(pixbuf, pixbuf); |
| 318 source = gtk_icon_source_new(); |
316 source = gtk_icon_source_new(); |
| 319 gtk_icon_source_set_pixbuf(source, pixbuf); |
317 gtk_icon_source_set_pixbuf(source, pixbuf); |
| 320 gtk_icon_source_set_direction(source, GTK_TEXT_DIR_RTL); |
318 gtk_icon_source_set_direction(source, GTK_TEXT_DIR_RTL); |
| 321 gtk_icon_source_set_size(source, sizeid); |
319 gtk_icon_source_set_size(source, sizeid); |
| 322 gtk_icon_source_set_size_wildcarded(source, FALSE); |
320 gtk_icon_source_set_size_wildcarded(source, FALSE); |