changeset 830:60284aef22f0

[gaim-migrate @ 840] ctrl-1 = :-) committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sat, 02 Sep 2000 08:42:40 +0000
parents 9a123b171f46
children 97f1ae636ed7
files ChangeLog src/conversation.c src/gaim.h src/prefs.c
diffstat 4 files changed, 94 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Sep 02 02:41:57 2000 +0000
+++ b/ChangeLog	Sat Sep 02 08:42:40 2000 +0000
@@ -8,6 +8,7 @@
 	* Borderless buttons (for that cool pop-up look)
 	* Fixed some resizing bugs
 	* Added Ctrl+{B/I/U/S} hotkeys to conversation windows.
+	* Added Ctrl+(number) hotkeys to insert smileys in conversation windows.
 	* Support for %n, %d, and %t in away messages.  Thanks bmiller!
 	* Background colors
 	* Redesigned preferences dialog
--- a/src/conversation.c	Sat Sep 02 02:41:57 2000 +0000
+++ b/src/conversation.c	Sat Sep 02 08:42:40 2000 +0000
@@ -498,29 +498,96 @@
 			pos=gtk_editable_get_position(GTK_EDITABLE(entry));
 			gtk_editable_insert_text(GTK_EDITABLE(entry), "\n", 1, &pos);
 		}
-	} else if ((event->state & GDK_CONTROL_MASK)
-		   && (general_options & OPT_GEN_CTL_CHARS)) {
-		switch (event->keyval) {
-		case 'i':
-			quiet_set(c->italic, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->italic)));
-			do_italic(c->italic, c->entry);
-			gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event");
-			break;
-		case 'u': /* ctl-u is GDK_Clear, which clears the line */
-			quiet_set(c->underline, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->underline)));
-			do_underline(c->underline, c->entry);
-			gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event");
-			break;
-		case 'b': /* ctl-b is GDK_Left, which moves backwards */
-			quiet_set(c->bold, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->bold)));
-			do_bold(c->bold, c->entry);
-			gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event");
-			break;
-		case 's':
-			quiet_set(c->strike, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->strike)));
-			do_strike(c->strike, c->entry);
-			gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event");
-			break;
+	} else if (event->state & GDK_CONTROL_MASK) {
+		if (general_options & OPT_GEN_CTL_CHARS) {
+			switch (event->keyval) {
+			case 'i':
+				quiet_set(c->italic, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->italic)));
+				do_italic(c->italic, c->entry);
+				gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event");
+				break;
+			case 'u': /* ctl-u is GDK_Clear, which clears the line */
+				quiet_set(c->underline, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->underline)));
+				do_underline(c->underline, c->entry);
+				gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event");
+				break;
+			case 'b': /* ctl-b is GDK_Left, which moves backwards */
+				quiet_set(c->bold, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->bold)));
+				do_bold(c->bold, c->entry);
+				gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event");
+				break;
+			case 's':
+				quiet_set(c->strike, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->strike)));
+				do_strike(c->strike, c->entry);
+				gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event");
+				break;
+			}
+		}
+		if (general_options & OPT_GEN_CTL_SMILEYS) {
+			char buf[7];
+			buf[0] = '\0';
+			switch (event->keyval) {
+				case '1':
+					sprintf(buf, ":-)");
+					break;
+				case '2':
+					sprintf(buf, ":-(");
+					break;
+				case '3':
+					sprintf(buf, ";-)");
+					break;
+				case '4':
+					sprintf(buf, ":-P");
+					break;
+				case '5':
+					sprintf(buf, "=-O");
+					break;
+				case '6':
+					sprintf(buf, ":-*");
+					break;
+				case '7':
+					sprintf(buf, ">:o");
+					break;
+				case '8':
+					sprintf(buf, "8-)");
+					break;
+				case '!':
+					sprintf(buf, ":-$");
+					break;
+				case '@':
+					sprintf(buf, ":-!");
+					break;
+				case '#':
+					sprintf(buf, ":-[");
+					break;
+				case '$':
+					sprintf(buf, "O:-)");
+					break;
+				case '%':
+					sprintf(buf, ":-/");
+					break;
+				case '^':
+					sprintf(buf, ":'(");
+					break;
+				case '&':
+					sprintf(buf, ":-X");
+					break;
+				case '*':
+					sprintf(buf, ":-D");
+					break;
+			}
+			if (buf[0]) {
+				if (GTK_EDITABLE(c->entry)->has_selection) {
+					int finish = GTK_EDITABLE(c->entry)->selection_end_pos;
+					gtk_editable_insert_text(GTK_EDITABLE(c->entry),
+								 buf, strlen(buf), &finish);
+				} else {
+					pos = GTK_EDITABLE(c->entry)->current_pos;
+					gtk_editable_insert_text(GTK_EDITABLE(c->entry),
+								 buf, strlen(buf), &pos);
+				}
+				gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event");
+			}
 		}
 	}
 
--- a/src/gaim.h	Sat Sep 02 02:41:57 2000 +0000
+++ b/src/gaim.h	Sat Sep 02 08:42:40 2000 +0000
@@ -403,7 +403,7 @@
 #define TYPE_SIGNOFF   4
 #define TYPE_KEEPALIVE 5
 
-#define REVISION "gaim:$Revision: 824 $"
+#define REVISION "gaim:$Revision: 840 $"
 #define FLAPON "FLAPON\r\n\r\n"
 
 #define ROAST "Tic/Toc"
@@ -485,6 +485,7 @@
 #define OPT_GEN_USE_OSCAR	0x00040000
 #define OPT_GEN_CTL_CHARS	0x00080000
 #define OPT_GEN_TIK_HACK        0x00100000
+#define OPT_GEN_CTL_SMILEYS     0x00200000
 extern int USE_OSCAR;
 
 extern int display_options;
--- a/src/prefs.c	Sat Sep 02 02:41:57 2000 +0000
+++ b/src/prefs.c	Sat Sep 02 08:42:40 2000 +0000
@@ -623,6 +623,7 @@
 
 	gaim_button(_("Enter sends message"), &general_options, OPT_GEN_ENTER_SENDS, box);
 	gaim_button(_("Control-{B/I/U/S} inserts HTML tags"), &general_options, OPT_GEN_CTL_CHARS, box);
+	gaim_button(_("Control-(number) inserts smileys"), &general_options, OPT_GEN_CTL_SMILEYS, box);
 
 	sep = gtk_hseparator_new();
 	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 5);