| 1294 |
1294 |
| 1295 static void dnd_image_ok_callback(_DndData *data, int choice) |
1295 static void dnd_image_ok_callback(_DndData *data, int choice) |
| 1296 { |
1296 { |
| 1297 char *filedata; |
1297 char *filedata; |
| 1298 size_t size; |
1298 size_t size; |
| |
1299 struct stat st; |
| 1299 GError *err = NULL; |
1300 GError *err = NULL; |
| 1300 GaimConversation *conv; |
1301 GaimConversation *conv; |
| 1301 GaimGtkConversation *gtkconv; |
1302 GaimGtkConversation *gtkconv; |
| 1302 GtkTextIter iter; |
1303 GtkTextIter iter; |
| 1303 int id; |
1304 int id; |
| 1304 switch (choice) { |
1305 switch (choice) { |
| 1305 case DND_BUDDY_ICON: |
1306 case DND_BUDDY_ICON: |
| 1306 if (!g_file_get_contents(data->filename, &filedata, &size, |
1307 if (g_stat(data->filename, &st)) { |
| 1307 &err)) { |
|
| 1308 char *str; |
1308 char *str; |
| 1309 |
1309 |
| 1310 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message); |
1310 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), |
| |
1311 data->filename, strerror(errno)); |
| 1311 gaim_notify_error(NULL, NULL, |
1312 gaim_notify_error(NULL, NULL, |
| 1312 _("Failed to load image"), |
1313 _("Failed to load image"), |
| 1313 str); |
1314 str); |
| 1314 |
|
| 1315 g_error_free(err); |
|
| 1316 g_free(str); |
1315 g_free(str); |
| 1317 |
1316 |
| 1318 return; |
1317 return; |
| 1319 } |
1318 } |
| 1320 |
1319 |
| 1321 gaim_buddy_icons_set_for_user(data->account, data->who, filedata, size); |
1320 gaim_gtk_set_custom_buddy_icon(data->account, data->who, data->filename); |
| 1322 g_free(filedata); |
|
| 1323 break; |
1321 break; |
| 1324 case DND_FILE_TRANSFER: |
1322 case DND_FILE_TRANSFER: |
| 1325 serv_send_file(gaim_account_get_connection(data->account), data->who, data->filename); |
1323 serv_send_file(gaim_account_get_connection(data->account), data->who, data->filename); |
| 1326 break; |
1324 break; |
| 1327 case DND_IM_IMAGE: |
1325 case DND_IM_IMAGE: |
| 2793 |
2791 |
| 2794 return pixbuf; |
2792 return pixbuf; |
| 2795 } |
2793 } |
| 2796 #endif |
2794 #endif |
| 2797 |
2795 |
| |
2796 void gaim_gtk_set_custom_buddy_icon(GaimAccount *account, const char *who, const char *filename) |
| |
2797 { |
| |
2798 GaimConversation *conv; |
| |
2799 GaimBuddy *buddy; |
| |
2800 GaimBlistNode *node; |
| |
2801 char *path = NULL; |
| |
2802 |
| |
2803 buddy = gaim_find_buddy(account, who); |
| |
2804 if (!buddy) { |
| |
2805 gaim_debug_info("custom-icon", "You can only set custom icon for someone in your buddylist.\n"); |
| |
2806 return; |
| |
2807 } |
| |
2808 |
| |
2809 node = (GaimBlistNode*)gaim_buddy_get_contact(buddy); |
| |
2810 path = (char*)gaim_blist_node_get_string(node, "custom_buddy_icon"); |
| |
2811 if (path) { |
| |
2812 struct stat st; |
| |
2813 if (g_stat(path, &st) == 0) |
| |
2814 g_unlink(path); |
| |
2815 path = NULL; |
| |
2816 } |
| |
2817 |
| |
2818 if (filename) { |
| |
2819 char *newfile; |
| |
2820 |
| |
2821 newfile = gaim_gtk_convert_buddy_icon(gaim_find_prpl(gaim_account_get_protocol_id(account)), |
| |
2822 filename); |
| |
2823 path = gaim_buddy_icons_get_full_path(newfile); |
| |
2824 g_free(newfile); |
| |
2825 } |
| |
2826 |
| |
2827 gaim_blist_node_set_string(node, "custom_buddy_icon", path); |
| |
2828 g_free(path); |
| |
2829 |
| |
2830 /* Update the conversation */ |
| |
2831 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, who, account); |
| |
2832 if (conv) |
| |
2833 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ICON); |
| |
2834 |
| |
2835 /* Update the buddylist */ |
| |
2836 if (buddy) |
| |
2837 gaim_blist_update_buddy_icon(buddy); |
| |
2838 } |
| |
2839 |
| |
2840 |