Mercurial > pidgin.yaz
comparison pidgin/gtksmiley.c @ 24529:c31be282935d
When adding custom smiley without a previous filename (which is the case when
adding a received smiley using the context menu, at which point there is only a
pixbuf) create the storing dir if doesn't yet exists, since we need to dump the
generated image there before calling purpl_smiley_create_from_file
Closes #6623
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Tue, 02 Dec 2008 18:46:21 +0000 |
parents | 305fac6af8f9 |
children | fe5179d40a51 |
comparison
equal
deleted
inserted
replaced
24527:f59b9bfba784 | 24529:c31be282935d |
---|---|
270 if (s->filename == NULL) { | 270 if (s->filename == NULL) { |
271 /* Get the smiley from the custom pixbuf */ | 271 /* Get the smiley from the custom pixbuf */ |
272 gchar *buffer = NULL; | 272 gchar *buffer = NULL; |
273 gsize size = 0; | 273 gsize size = 0; |
274 gchar *filename; | 274 gchar *filename; |
275 | 275 const gchar *dirname = purple_smileys_get_storing_dir(); |
276 | |
277 /* since this may be called before purple_smiley_new_* has ever been | |
278 called, we create the storing dir, if it doesn't exist yet, to be | |
279 able to save the pixbuf before adding the smiley */ | |
280 if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) { | |
281 purple_debug_info("gtksmiley", "Creating smileys directory.\n"); | |
282 | |
283 if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) { | |
284 purple_debug_error("gtksmiley", | |
285 "Unable to create directory %s: %s\n", | |
286 dirname, g_strerror(errno)); | |
287 } | |
288 } | |
289 | |
276 gdk_pixbuf_save_to_buffer(s->custom_pixbuf, &buffer, &size, | 290 gdk_pixbuf_save_to_buffer(s->custom_pixbuf, &buffer, &size, |
277 "png", NULL, "compression", "9", NULL, NULL); | 291 "png", NULL, "compression", "9", NULL, NULL); |
278 filename = purple_util_get_image_filename(buffer, size); | 292 filename = purple_util_get_image_filename(buffer, size); |
279 s->filename = g_build_filename(purple_smileys_get_storing_dir(), filename, NULL); | 293 s->filename = g_build_filename(dirname, filename, NULL); |
280 purple_util_write_data_to_file_absolute(s->filename, buffer, size); | 294 purple_util_write_data_to_file_absolute(s->filename, buffer, size); |
281 g_free(filename); | 295 g_free(filename); |
282 g_free(buffer); | 296 g_free(buffer); |
283 } | 297 } |
284 emoticon = purple_smiley_new_from_file(entry, s->filename); | 298 emoticon = purple_smiley_new_from_file(entry, s->filename); |