Mercurial > pidgin-twitter
comparison icon.c @ 272:2f053c23ee50
a better way to get an extension for icon image.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Fri, 12 Dec 2008 21:36:38 +0900 |
parents | d3e2b2e58828 |
children | add1e454b87f |
comparison
equal
deleted
inserted
replaced
271:7aad61f56c48 | 272:2f053c23ee50 |
---|---|
1 #include "pidgin-twitter.h" | 1 #include "pidgin-twitter.h" |
2 #include "purple_internal.h" | |
2 | 3 |
3 extern GHashTable *icon_hash[]; | 4 extern GHashTable *icon_hash[]; |
4 extern GRegex *regp[]; | 5 extern GRegex *regp[]; |
5 | 6 |
6 /* prototypes */ | 7 /* prototypes */ |
226 else { | 227 else { |
227 url = g_match_info_fetch(match_info, 1); | 228 url = g_match_info_fetch(match_info, 1); |
228 g_match_info_free(match_info); | 229 g_match_info_free(match_info); |
229 } | 230 } |
230 | 231 |
231 /* find out basename */ | 232 /* find out extension */ |
232 gchar *slash = strrchr(url, '/'); | 233 gchar *slash = strrchr(url, '/'); |
233 *slash = '\0'; | |
234 | |
235 gchar *lower = g_ascii_strdown(slash+1, -1); | 234 gchar *lower = g_ascii_strdown(slash+1, -1); |
236 | 235 |
237 if(strstr(lower, ".png")) | 236 if(strstr(lower, ".png")) |
238 data->img_type = "png"; | 237 data->img_type = "png"; |
239 else if(strstr(lower, ".gif")) | 238 else if(strstr(lower, ".gif")) |
385 | 384 |
386 /* return if user's icon has been downloaded */ | 385 /* return if user's icon has been downloaded */ |
387 if(data->pixbuf) { | 386 if(data->pixbuf) { |
388 twitter_debug("%s's icon has already been downloaded\n", | 387 twitter_debug("%s's icon has already been downloaded\n", |
389 user_name); | 388 user_name); |
390 | |
391 goto fin_got_icon_cb; | 389 goto fin_got_icon_cb; |
392 } | 390 } |
393 | 391 |
394 pixbuf = make_scaled_pixbuf(url_text, len); | 392 pixbuf = make_scaled_pixbuf(url_text, len); |
395 | 393 |
432 gdk_pixbuf_get_rowstride(pixbuf) * | 430 gdk_pixbuf_get_rowstride(pixbuf) * |
433 gdk_pixbuf_get_height(pixbuf)); | 431 gdk_pixbuf_get_height(pixbuf)); |
434 | 432 |
435 if(hash) | 433 if(hash) |
436 g_hash_table_insert(hash, g_strdup(user_name), data); | 434 g_hash_table_insert(hash, g_strdup(user_name), data); |
435 | |
436 /* find out extension */ | |
437 gchar *slash = strrchr(url_data->url, '/'); | |
438 gchar *lower = g_ascii_strdown(slash+1, -1); | |
439 | |
440 if(strstr(lower, ".png")) | |
441 data->img_type = "png"; | |
442 else if(strstr(lower, ".gif")) | |
443 data->img_type = "gif"; | |
444 else if(strstr(lower, ".jpg") || strstr(lower, ".jpeg")) | |
445 data->img_type = "jpg"; | |
446 | |
447 g_free(lower); | |
437 | 448 |
438 dirname = purple_prefs_get_string(OPT_ICON_DIR); | 449 dirname = purple_prefs_get_string(OPT_ICON_DIR); |
439 | 450 |
440 /* store retrieved image to a file in icon dir */ | 451 /* store retrieved image to a file in icon dir */ |
441 if(ensure_path_exists(dirname)) { | 452 if(ensure_path_exists(dirname)) { |