changeset 27038:804141095de5

Allow adding received animated custom smileys to locale custom smiley collection. Closes #9066. committer: Sadrul Habib Chowdhury <imadil@gmail.com>
author Andrea Piccinelli <frasten@gmail.com>
date Fri, 05 Jun 2009 08:23:18 +0000
parents f3b0232ef1ea
children 9df57b1a3569
files COPYRIGHT ChangeLog ChangeLog.API pidgin/gtkimhtml.c pidgin/gtksmiley.c pidgin/gtksmiley.h
diffstat 6 files changed, 40 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Fri Jun 05 05:44:44 2009 +0000
+++ b/COPYRIGHT	Fri Jun 05 08:23:18 2009 +0000
@@ -333,6 +333,7 @@
 Diego Petten
 Nathan Peterson
 Sebastián E. Peyrott
+Andrea Piccinelli
 Celso Pinto
 Joao Luís Marques Pinto
 Aleksander Piotrowski
--- a/ChangeLog	Fri Jun 05 05:44:44 2009 +0000
+++ b/ChangeLog	Fri Jun 05 08:23:18 2009 +0000
@@ -87,6 +87,8 @@
 	* Fix a bug in 'Conversation Colors' plugin for RTL messages.
 	* Pressing the Left and Right arrow keys in the buddy list will expand and
 	  collapse buddy groups or contacts. (Peter Ruibal)
+	* Support saving animated custom smileys as animated images or animated
+	  custom smileys. (Andrea Piccinelli)
 
 	Finch:
 	* The hardware cursor is updated correctly. This will be useful
--- a/ChangeLog.API	Fri Jun 05 05:44:44 2009 +0000
+++ b/ChangeLog.API	Fri Jun 05 08:23:18 2009 +0000
@@ -94,6 +94,7 @@
 		* pidgin_blist_set_theme
 		* pidgin_blist_get_theme
 		* pidgin_prefs_labeled_password
+		* pidgin_smiley_editor_set_data
 		* pidgin_sound_is_customized
 		* pidgin_utils_init, pidgin_utils_uninit
 		* pidgin_notify_pounce_add
--- a/pidgin/gtkimhtml.c	Fri Jun 05 05:44:44 2009 +0000
+++ b/pidgin/gtkimhtml.c	Fri Jun 05 08:23:18 2009 +0000
@@ -3867,12 +3867,15 @@
 }
 
 static void
-gtk_imhtml_custom_smiley_save(GtkWidget *w, GtkIMHtmlImage *image)
-{
+gtk_imhtml_custom_smiley_save(GtkWidget *w, GtkIMHtmlImageSave *save)
+{
+	GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image;
+	
 	/* Create an add dialog */
 	PidginSmiley *editor = pidgin_smiley_edit(NULL, NULL);
 	pidgin_smiley_editor_set_shortcut(editor, image->filename);
 	pidgin_smiley_editor_set_image(editor, image->pixbuf);
+	pidgin_smiley_editor_set_data(editor, save->data, save->datasize);
 }
 
 /*
@@ -3907,7 +3910,7 @@
 				item = gtk_image_menu_item_new_with_mnemonic(_("_Add Custom Smiley..."));
 				gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img);
 				g_signal_connect(G_OBJECT(item), "activate",
-								 G_CALLBACK(gtk_imhtml_custom_smiley_save), image);
+								 G_CALLBACK(gtk_imhtml_custom_smiley_save), save);
 				gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 			}
 
--- a/pidgin/gtksmiley.c	Fri Jun 05 05:44:44 2009 +0000
+++ b/pidgin/gtksmiley.c	Fri Jun 05 08:23:18 2009 +0000
@@ -47,6 +47,8 @@
 	GtkWidget *smiley_image;
 	gchar *filename;
 	GdkPixbuf *custom_pixbuf;
+	gpointer data; /** @since 2.6.0 */
+	gsize datasize; /** @since 2.6.0 */
 };
 
 typedef struct
@@ -277,7 +279,6 @@
 		purple_debug_info("gtksmiley", "adding a new smiley\n");
 
 		if (s->filename == NULL) {
-			/* Get the smiley from the custom pixbuf */
 			gchar *buffer = NULL;
 			gsize size = 0;
 			gchar *filename;
@@ -296,8 +297,16 @@
 				}
 			}
 
-			gdk_pixbuf_save_to_buffer(s->custom_pixbuf, &buffer, &size,
-				"png", NULL, "compression", "9", NULL, NULL);
+			if (s->data && s->datasize) {
+				/* Cached data & size in memory */
+				buffer = s->data;
+				size = s->datasize;
+			}
+			else {
+				/* Get the smiley from the custom pixbuf */
+				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(dirname, filename, NULL);
 			purple_util_write_data_to_file_absolute(s->filename, buffer, size);
@@ -465,6 +474,13 @@
 		gtk_image_set_from_pixbuf(GTK_IMAGE(editor->smiley_image), image);
 }
 
+void
+pidgin_smiley_editor_set_data(PidginSmiley *editor, gpointer *data, gsize datasize)
+{
+	editor->data = data;
+	editor->datasize = datasize;
+}
+
 /******************************************************************************
  * Delete smiley
  *****************************************************************************/
--- a/pidgin/gtksmiley.h	Fri Jun 05 05:44:44 2009 +0000
+++ b/pidgin/gtksmiley.h	Fri Jun 05 08:23:18 2009 +0000
@@ -100,4 +100,15 @@
  */
 void pidgin_smiley_editor_set_image(PidginSmiley *editor, GdkPixbuf *image);
 
+/**
+ * Sets the image data in a smiley add dialog
+ *
+ * @param editor A smiley editor dialog
+ * @param data A pointer to smiley's data
+ * @param datasize The size of smiley's data
+ *
+ * @since 2.6.0
+ */
+void pidgin_smiley_editor_set_data(PidginSmiley *editor, gpointer *data, gsize datasize);
+
 #endif /* PIDGIN_GTKSMILEY_H */