diff src/gtkimhtml.c @ 8456:5f8d4ab6d375

[gaim-migrate @ 9186] "his patch fixes an issue where the gtkimhtml and the gtkimtoolbar did not know what protocol the conversation was for so they we're either displaying core smileys or white boxes with an x through them. this also make gtkimthml honor the ctrl-{b/u/i} and ctrl-number prefs." --Gary Kramlich who continues: "in the first patch i forgot to adjust the protocol name in the conversation when an item in the send as menu was selected. This fixes that." committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 16 Mar 2004 19:35:17 +0000
parents b08d8874d933
children daeeb96cdf8f
line wrap: on
line diff
--- a/src/gtkimhtml.c	Tue Mar 16 19:19:36 2004 +0000
+++ b/src/gtkimhtml.c	Tue Mar 16 19:35:17 2004 +0000
@@ -388,10 +388,12 @@
 		case 'b':  /* ctrl-b is GDK_Left, which moves backwards. */
 		case 'B':
 			if (imhtml->format_functions & GTK_IMHTML_BOLD) {
-				gtk_imhtml_toggle_bold(imhtml);
-				object = g_object_ref(G_OBJECT(imhtml));
-				g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_BOLD);
-				g_object_unref(object);
+				if(imhtml->html_shortcuts) {
+					gtk_imhtml_toggle_bold(imhtml);
+					object = g_object_ref(G_OBJECT(imhtml));
+					g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_BOLD);
+					g_object_unref(object);
+				}
 			}
 			return TRUE;
 			break;
@@ -408,14 +410,16 @@
 		case 'i':
 		case 'I':
 			if (imhtml->format_functions & GTK_IMHTML_ITALIC)
-				gtk_imhtml_toggle_italic(imhtml);
+				if(imhtml->html_shortcuts)
+					gtk_imhtml_toggle_italic(imhtml);
 			return TRUE;
 			break;
 			
 		case 'u':  /* ctrl-u is GDK_Clear, which clears the line. */
 		case 'U':
 			if (imhtml->format_functions & GTK_IMHTML_UNDERLINE)
-				gtk_imhtml_toggle_underline(imhtml);
+				if(imhtml->html_shortcuts)
+					gtk_imhtml_toggle_underline(imhtml);
 			return TRUE;
 			break;
 			
@@ -449,8 +453,8 @@
 		case '&': strcpy(buf, ":-X");  break;
 		case '*': strcpy(buf, ":-D");  break;
 		}
-	if (*buf) {
-		gtk_imhtml_insert_smiley(imhtml, NULL, buf);//->account->protocol_id, buf);
+	if (*buf && imhtml->smiley_shortcuts) {
+		gtk_imhtml_insert_smiley(imhtml, imhtml->protocol_name, buf);
 		return TRUE;
 	}	
 	return FALSE;
@@ -584,6 +588,7 @@
 	gdk_cursor_unref(imhtml->hand_cursor);
 	gdk_cursor_unref(imhtml->arrow_cursor);
 	gdk_cursor_unref(imhtml->text_cursor);
+	
 	if(imhtml->tip_window){
 		gtk_widget_destroy(imhtml->tip_window);
 	}
@@ -2056,6 +2061,23 @@
 	imhtml->show_comments = show;
 }
 
+void       gtk_imhtml_html_shortcuts   (GtkIMHtml        *imhtml,
+                    gboolean allow)
+{
+	imhtml->html_shortcuts = allow;
+}
+
+void       gtk_imhtml_smiley_shortcuts (GtkIMHtml        *imhtml,
+                    gboolean allow)
+{
+	imhtml->smiley_shortcuts = allow;
+}
+
+void 
+gtk_imhtml_set_protocol_name(GtkIMHtml *imhtml, gchar *protocol_name) {
+	imhtml->protocol_name = protocol_name;
+}
+
 void
 gtk_imhtml_clear (GtkIMHtml *imhtml)
 {
@@ -3018,4 +3040,3 @@
 	return gtk_text_buffer_get_text(imhtml->text_buffer, &start_iter, &end_iter, FALSE);
 
 }
-