changeset 8892:ed62fb44aa30

[gaim-migrate @ 9661] " This patch does two things: 1) Fixes a crash in themes.c if the smiley theme has no smileys and you attempt to get a list of them elsewhere in gaim. 2) Makes the insert smiley dialog have a little text label that says the smiley theme has no available smileys if it would otherwise contain nothing. This solution was suggested as acceptable for letting the user know there's no smileys without disabling the button, blah blah blah. You can ask me for the gory details if you want to know what I would have had to code to make it work the other way." --Kevin Stange committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 06 May 2004 14:02:06 +0000
parents 4f7c365c5c5a
children cd22788db30c
files src/gtkimhtmltoolbar.c src/themes.c
diffstat 2 files changed, 24 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkimhtmltoolbar.c	Thu May 06 12:17:17 2004 +0000
+++ b/src/gtkimhtmltoolbar.c	Thu May 06 14:02:06 2004 +0000
@@ -574,8 +574,8 @@
 
 		if (toolbar->sml)
 			smileys = get_proto_smileys(toolbar->sml);
-		  else
-			  smileys = get_proto_smileys(GAIM_PROTO_DEFAULT);
+		else
+			smileys = get_proto_smileys(GAIM_PROTO_DEFAULT);
 
 		while(smileys) {
 			GtkIMHtmlSmiley *smiley = smileys->data;
@@ -586,28 +586,34 @@
 			smileys = smileys->next;
 		}
 
+		GAIM_DIALOG(dialog);
 
-		width = floor(sqrt(g_slist_length(unique_smileys)));
-
-		GAIM_DIALOG(dialog);
 		gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
 		gtk_window_set_role(GTK_WINDOW(dialog), "smiley_dialog");
 		gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
 
-		smiley_table = gtk_table_new(width, width, TRUE);
+		if(g_slist_length(unique_smileys)) {
+
+			width = floor(sqrt(g_slist_length(unique_smileys)));
 
-		/* pack buttons */
+			smiley_table = gtk_table_new(width, width, TRUE);
+
+			/* pack buttons */
 
-		while(unique_smileys) {
-			GtkIMHtmlSmiley *smiley = unique_smileys->data;
-			if(!smiley->hidden) {
-				add_smiley(toolbar, smiley_table, row, col, smiley->file, smiley->smile);
-				if(++col >= width) {
-					col = 0;
-					row++;
+			while(unique_smileys) {
+				GtkIMHtmlSmiley *smiley = unique_smileys->data;
+				if(!smiley->hidden) {
+					add_smiley(toolbar, smiley_table, row, col, smiley->file, smiley->smile);
+					if(++col >= width) {
+						col = 0;
+						row++;
+					}
 				}
+				unique_smileys = unique_smileys->next;
 			}
-			unique_smileys = unique_smileys->next;
+		}
+		else {
+			smiley_table = gtk_label_new(_("This theme has no available smileys."));
 		}
 
 		gtk_container_add(GTK_CONTAINER(dialog), smiley_table);
--- a/src/themes.c	Thu May 06 12:17:17 2004 +0000
+++ b/src/themes.c	Thu May 06 14:02:06 2004 +0000
@@ -245,6 +245,9 @@
 	if(!current_smiley_theme)
 		return NULL;
 
+	if(!current_smiley_theme->list)
+		return NULL;
+
 	def = list = current_smiley_theme->list;
 
 	while(list) {