pidgin: f659186b: When adding custom smiley without a prev...

malu at pidgin.im malu at pidgin.im
Tue Dec 2 13:50:31 EST 2008


-----------------------------------------------------------------
Revision: f659186b896d5b905b4cf31a38eab4638224ca0f
Ancestor: 2f4829edd8475f178a87084a8bb427563233ad66
Author: malu at pidgin.im
Date: 2008-12-02T18:46:21
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/f659186b896d5b905b4cf31a38eab4638224ca0f

Modified files:
        pidgin/gtksmiley.c

ChangeLog: 

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

-------------- next part --------------
============================================================
--- pidgin/gtksmiley.c	09bdcafc0ddd630ebe5f87329a204a474cd438a4
+++ pidgin/gtksmiley.c	2bfcace1f94d80a84a6631685205de2ef9d3f717
@@ -272,11 +272,25 @@ static void do_add(GtkWidget *widget, Pi
 			gchar *buffer = NULL;
 			gsize size = 0;
 			gchar *filename;
+			const gchar *dirname = purple_smileys_get_storing_dir();
+			
+			/* since this may be called before purple_smiley_new_* has ever been
+			 called, we create the storing dir, if it doesn't exist yet, to be
+			 able to save the pixbuf before adding the smiley */
+			if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) {
+				purple_debug_info("gtksmiley", "Creating smileys directory.\n");
 
+				if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) {
+					purple_debug_error("gtksmiley",
+			                   "Unable to create directory %s: %s\n",
+			                   dirname, g_strerror(errno));
+				}
+			}
+			
 			gdk_pixbuf_save_to_buffer(s->custom_pixbuf, &buffer, &size,
 				"png", NULL, "compression", "9", NULL, NULL);
 			filename = purple_util_get_image_filename(buffer, size);
-			s->filename = g_build_filename(purple_smileys_get_storing_dir(), filename, NULL);
+			s->filename = g_build_filename(dirname, filename, NULL);
 			purple_util_write_data_to_file_absolute(s->filename, buffer, size);
 			g_free(filename);
 			g_free(buffer);


More information about the Commits mailing list