changeset 337:f5b199e20d12

[gaim-migrate @ 347] Cheese first look at graphical smileys. These are subject to change quite a bit :0 committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Tue, 06 Jun 2000 09:36:12 +0000
parents 5a88018cc555
children 9d258a0aa560
files ChangeLog pixmaps/smile_happy.xpm pixmaps/smile_sad.xpm pixmaps/smile_wink.xpm src/conversation.c src/dialogs.c src/gaim.h src/gtkhtml.c src/gtkhtml.h src/prefs.c
diffstat 10 files changed, 181 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Jun 05 17:25:16 2000 +0000
+++ b/ChangeLog	Tue Jun 06 09:36:12 2000 +0000
@@ -2,6 +2,7 @@
 
 version 0.9.19:
 	* Oscar can sign in to ICQ now
+	* Graphical Smiley Faces
 
 version 0.9.18 (06/02/2000):
 	* Logging in works better for oscar
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pixmaps/smile_happy.xpm	Tue Jun 06 09:36:12 2000 +0000
@@ -0,0 +1,21 @@
+/* XPM */
+static char * smile_happy_xpm[] = {
+"20 15 3 1",
+" 	c None",
+".	c #000000",
+"+	c #FFFF00",
+"       ......       ",
+"      ..++++..      ",
+"     ..++++++..     ",
+"    ..++++++++..    ",
+"   ..+++.++.+++..   ",
+"   .++++.++.++++.   ",
+"   .++++++++++++.   ",
+"   .++++++++++++.   ",
+"   .+++.++++.+++.   ",
+"   ..+++....+++..   ",
+"    ..++++++++..    ",
+"     ..++++++..     ",
+"      ..++++..      ",
+"       ......       ",
+"                    "};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pixmaps/smile_sad.xpm	Tue Jun 06 09:36:12 2000 +0000
@@ -0,0 +1,21 @@
+/* XPM */
+static char * smile_sad_xpm[] = {
+"20 15 3 1",
+" 	c None",
+".	c #000000",
+"+	c #FFFF00",
+"       ......       ",
+"      ..++++..      ",
+"     ..++++++..     ",
+"    ..++++++++..    ",
+"   ..+++.++.+++..   ",
+"   .++++.++.++++.   ",
+"   .++++++++++++.   ",
+"   .++++++++++++.   ",
+"   .++++++++++++.   ",
+"   ..+++....+++..   ",
+"    ..+.++++.+..    ",
+"     ..++++++..     ",
+"      ..++++..      ",
+"       ......       ",
+"                    "};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pixmaps/smile_wink.xpm	Tue Jun 06 09:36:12 2000 +0000
@@ -0,0 +1,21 @@
+/* XPM */
+static char * smile_wink_xpm[] = {
+"20 15 3 1",
+" 	c None",
+".	c #000000",
+"+	c #FFFF00",
+"       ......       ",
+"      ..++++..      ",
+"     ..++++++..     ",
+"    ..++++++++..    ",
+"   ..+++.++.+++..   ",
+"   .+++++++.++++.   ",
+"   .++++++++++++.   ",
+"   .++++++++.+++.   ",
+"   .++++++++.+++.   ",
+"   ..+++....+++..   ",
+"    ..++++++++..    ",
+"     ..++++++..     ",
+"      ..++++..      ",
+"       ......       ",
+"                    "};
--- a/src/conversation.c	Mon Jun 05 17:25:16 2000 +0000
+++ b/src/conversation.c	Tue Jun 06 09:36:12 2000 +0000
@@ -45,6 +45,10 @@
 #include "pixmaps/link.xpm"
 #include "pixmaps/strike.xpm"
 
+#include "pixmaps/smile_happy.xpm"
+#include "pixmaps/smile_sad.xpm"
+#include "pixmaps/smile_wink.xpm"
+
 int state_lock=0;
 
 GdkPixmap *dark_icon_pm = NULL;
@@ -837,18 +841,23 @@
         char *who = NULL;
         FILE *fd;
         char colour[10];
-
+	GdkBitmap *mask;
+	GdkPixmap *face;
+	int state;
+	int y;
+	int i;
+	char *smiley = g_malloc(5);
+	
         if (flags & WFLAG_SYSTEM) {
 
                 gtk_html_freeze(GTK_HTML(c->text));
         
                 gtk_html_append_text(GTK_HTML(c->text), what, 0);
-
-                gtk_html_append_text(GTK_HTML(c->text), "<BR>", 0);
+		
+		gtk_html_append_text(GTK_HTML(c->text), "<BR>", 0);
 
                 gtk_html_thaw(GTK_HTML(c->text));
 
-
                 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) {
                         char *t1;
 
@@ -887,8 +896,98 @@
 
                 gtk_html_freeze(GTK_HTML(c->text));
 
-                gtk_html_append_text(GTK_HTML(c->text), buf, 0);
-                gtk_html_append_text(GTK_HTML(c->text), what, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0);
+		y = 0;
+		state = 0;
+		buf2[0] = 0;
+
+
+		gtk_html_append_text(GTK_HTML(c->text), buf, 0);
+	
+		if (display_options & OPT_DISP_SHOW_SMILEY)
+		{
+			for (i = 0; i < strlen(what); i++)
+        		{
+               			buf2[y] = what[i];
+               			y++;
+
+		                if ((what[i] == ':') || (what[i] == ';'))
+               			{
+                       			if (state == 0)
+                        	  	{
+                                		smiley[state] = what[i];
+                                		state = 1;
+                        		}
+                        		else
+                                		state = 0;
+                		}
+                		else if ((what[i] == '-'))
+                		{
+                        		if (state == 1)
+                        		{
+                                		smiley[state] = what[i];
+                                		state = 2;
+                        		}
+                        		else
+                                		state = 0;
+                		}
+                		else if ((what[i] == ')') || (what[i] == '*') || (what[i] == '(') ||
+                         		(what[i] == 'p') || (what[i] == 'P') || (what[i] == '$') ||
+                         		(what[i] == '!') || (what[i] == 'D') || (what[i] == 'X') )
+                		{
+                        		if ( (state == 1) && (what[i] == ')') )
+                        		{
+                                		smiley[state] = what[i];
+                                		smiley[state+1] = 0;
+                                		buf2[y - state - 1] = 0;
+                                		y = 0;
+						face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile_happy_xpm);	
+						gtk_html_append_text(GTK_HTML(c->text), buf2, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0);
+						gtk_html_add_pixmap(GTK_HTML(c->text), face, 0);			
+                                		state = 0;
+                        		}
+                        		else if (state == 2)
+                        		{
+                                		smiley[state] = what[i];
+                                		smiley[state+1] = 0;
+                                		buf2[y - state - 1] = 0;
+                                		y = 0;
+
+						if (!strcasecmp(smiley, ":-("))
+						{
+							face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile_sad_xpm);
+						}
+						else if (!strcasecmp(smiley, ";-)"))
+						{
+							face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile_wink_xpm);
+						}
+						else
+						{
+							face = gdk_pixmap_create_from_xpm_d(c->window->window, &mask, &c->window->style->white, smile_happy_xpm);
+						}
+
+						gtk_html_append_text(GTK_HTML(c->text), buf2, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0);
+						gtk_html_add_pixmap(GTK_HTML(c->text), face, 0);
+                                		state = 0;
+                        		}
+                        		else
+                                		state = 0;
+                		}
+               		 	else
+                		{
+                        		state = 0;
+                		}
+        		}
+
+			if (buf2)
+			{
+				buf2[y] = 0;
+				gtk_html_append_text(GTK_HTML(c->text), buf2, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0);
+			}				
+		}
+		else
+		{
+			gtk_html_append_text(GTK_HTML(c->text), what, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0);
+		}
 
                 gtk_html_append_text(GTK_HTML(c->text), "<BR>", 0);
 
@@ -927,7 +1026,7 @@
         if (general_options & OPT_GEN_POPUP_WINDOWS)
                 gdk_window_show(c->window->window);
 
-        
+	g_free(smiley);        
 	g_free(buf);
         g_free(buf2);
 }
--- a/src/dialogs.c	Mon Jun 05 17:25:16 2000 +0000
+++ b/src/dialogs.c	Tue Jun 06 09:36:12 2000 +0000
@@ -1345,6 +1345,9 @@
 	GtkWidget *text;
         GtkWidget *bbox;
         GtkWidget *sw;
+	GdkBitmap *mask;
+	GdkPixmap *face;
+	GtkWidget *face_p;
 
         struct info_dlg *b = g_new0(struct info_dlg, 1);
 
@@ -1383,6 +1386,7 @@
 	gtk_widget_show_all(b->window);
 
 	gtk_html_append_text(GTK_HTML(b->text), info, 0);
+
 }
 
 void g_show_info(char *url) {
--- a/src/gaim.h	Mon Jun 05 17:25:16 2000 +0000
+++ b/src/gaim.h	Tue Jun 06 09:36:12 2000 +0000
@@ -350,7 +350,7 @@
 #define TYPE_SIGNOFF   4
 #define TYPE_KEEPALIVE 5
 
-#define REVISION "gaim:$Revision: 323 $"
+#define REVISION "gaim:$Revision: 347 $"
 #define FLAPON "FLAPON\r\n\r\n"
 
 #define ROAST "Tic/Toc"
@@ -438,7 +438,8 @@
 #define OPT_DISP_IGNORE_COLOUR   0x00000020
 #define OPT_DISP_SHOW_LOGON      0x00000040
 #define OPT_DISP_DEVIL_PIXMAPS   0x00000080
-
+#define OPT_DISP_SHOW_SMILEY	 0x00000100
+ 
 extern int sound_options;
 #define OPT_SOUND_LOGIN          0x00000001
 #define OPT_SOUND_LOGOUT         0x00000002
--- a/src/gtkhtml.c	Mon Jun 05 17:25:16 2000 +0000
+++ b/src/gtkhtml.c	Tue Jun 06 09:36:12 2000 +0000
@@ -119,7 +119,7 @@
 static void gtk_html_adjustment(GtkAdjustment * adjustment, GtkHtml * html);
 static void gtk_html_disconnect(GtkAdjustment * adjustment, GtkHtml * html);
 static void gtk_html_add_seperator(GtkHtml * html);
-static void gtk_html_add_pixmap(GtkHtml * html, GdkPixmap * pm, gint fit);
+// static void gtk_html_add_pixmap(GtkHtml * html, GdkPixmap * pm, gint fit);
 static void gtk_html_add_text(GtkHtml * html,
 							  GdkFont * font,
 							  GdkColor * fore,
@@ -2685,10 +2685,7 @@
 }
 
 
-
-
-
-static void gtk_html_add_pixmap(GtkHtml * html, GdkPixmap * pm, int fit)
+void gtk_html_add_pixmap(GtkHtml * html, GdkPixmap * pm, int fit)
 {
 	GtkHtmlBit *last_hb;
 	GtkHtmlBit *hb = g_new0(GtkHtmlBit, 1);
--- a/src/gtkhtml.h	Mon Jun 05 17:25:16 2000 +0000
+++ b/src/gtkhtml.h	Tue Jun 06 09:36:12 2000 +0000
@@ -148,7 +148,7 @@
 void       gtk_html_freeze           (GtkHtml      *html);
 void       gtk_html_thaw             (GtkHtml      *html);
 
-
+void	gtk_html_add_pixmap	(GtkHtml * html, GdkPixmap *pm, gint fint);
 
 
 #ifdef __cplusplus
--- a/src/prefs.c	Mon Jun 05 17:25:16 2000 +0000
+++ b/src/prefs.c	Tue Jun 06 09:36:12 2000 +0000
@@ -789,7 +789,7 @@
 #endif
 	gaim_button("Show logon/logoffs in conversation windows", &display_options, OPT_DISP_SHOW_LOGON, appbox );
 	gaim_button("Use devil icons", &display_options, OPT_DISP_DEVIL_PIXMAPS, appbox );
-	
+	gaim_button("Show graphical smileys", &display_options, OPT_DISP_SHOW_SMILEY, appbox );
 	
 	
 	gaim_button("Bold Text", &font_options, OPT_FONT_BOLD, fontbox);