diff src/gtkimhtml.c @ 8317:6f549c1d0829

[gaim-migrate @ 9041] Because I won't be able to work on this until late this week at the earliest, here's GtkIMHtmlToolbar. It's a composite widget that attaches to an editable gtkimhtml and controls all the formatting with ease. All one has to do to get a formattable, editable, gtkimhtml now is to replace a gtktextview with a gtkimhtml (you can even leave all the other calls that control it as gtkimhtml descends from gtktextview) throw one of these toolbars in there and gtk_imhtml_toolbar_attach it to the gtkimhtml. That's what I did in the New Away Message dialog. This would also be nice in gtkrequest.c and gtkpounce.c. Of course, this isn't done and there's a ton of hacky commented out old code in there. Things like keyboard shortcut preferences don't currently work and there's a lot of things I want to move around yet. However, if anyone feels inspired to work on it before I get back to it feel free. Maybe you can IM me beforehand or something. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Mon, 23 Feb 2004 21:18:27 +0000
parents f694277e8341
children 0d1e5870d328
line wrap: on
line diff
--- a/src/gtkimhtml.c	Sun Feb 22 22:10:47 2004 +0000
+++ b/src/gtkimhtml.c	Mon Feb 23 21:18:27 2004 +0000
@@ -351,23 +351,101 @@
  * It's supposed to be fixed in gtk2.2.  You can view the bug report at
  * http://bugzilla.gnome.org/show_bug.cgi?id=107939
  */
-gboolean gtk_key_pressed_cb(GtkWidget *imhtml, GdkEventKey *event, gpointer data)
-{
+
+/*
+ * I'm adding some keyboard shortcuts too.
+ */
+
+gboolean gtk_key_pressed_cb(GtkIMHtml *imhtml, GdkEventKey *event, gpointer data)
+{	
+	char buf[7];
+	buf[0] = '\0';
+
 	if (event->state & GDK_CONTROL_MASK)
 		switch (event->keyval) {
-			case 'a':
-				return TRUE;
-				break;
-
-			case GDK_Home:
-				return TRUE;
-				break;
-
-			case GDK_End:
-				return TRUE;
-				break;
+		case 'a':
+			return TRUE;
+			break;
+			
+		case GDK_Home:
+			return TRUE;
+			break;
+
+		case GDK_End:
+			return TRUE;
+			break;
+		
+		case 'b':  /* ctrl-b is GDK_Left, which moves backwards. */
+		case 'B':
+			gtk_imhtml_toggle_bold(imhtml);
+			return TRUE;
+			break;
+			
+		case 'f':
+		case 'F':
+			/*set_toggle(gtkconv->toolbar.font,
+			  !gtk_toggle_button_get_active(
+			  GTK_TOGGLE_BUTTON(gtkconv->toolbar.font)));*/
+			
+			return TRUE;
+			break;
+			
+		case 'i':
+		case 'I':
+			/*set_toggle(gtkconv->toolbar.italic,
+			  !gtk_toggle_button_get_active(
+			  GTK_TOGGLE_BUTTON(gtkconv->toolbar.italic)));*/
+			gtk_imhtml_toggle_italic(imhtml);
+			return TRUE;
+			break;
+			
+		case 'u':  /* ctrl-u is GDK_Clear, which clears the line. */
+		case 'U':
+			/*set_toggle(gtkconv->toolbar.underline,
+			  !gtk_toggle_button_get_active(
+			  GTK_TOGGLE_BUTTON(gtkconv->toolbar.underline)));*/
+			gtk_imhtml_toggle_underline(imhtml);
+			return TRUE;
+			break;
+			
+		case '-':
+			/*set_toggle(gtkconv->toolbar.smaller_size,
+			  !gtk_toggle_button_get_active(
+			  GTK_TOGGLE_BUTTON(gtkconv->toolbar.smaller_size)));*/
+			gtk_imhtml_font_shrink(imhtml);
+			return TRUE;
+			break;
+			
+		case '=':
+		case '+':
+			/*set_toggle(gtkconv->toolbar.larger_size,
+			  !gtk_toggle_button_get_active(
+			  GTK_TOGGLE_BUTTON(gtkconv->toolbar.larger_size)));*/
+			gtk_imhtml_font_grow(imhtml);
+			return TRUE;
+			break;
+			
+		case '1': strcpy(buf, ":-)");  break;
+		case '2': strcpy(buf, ":-(");  break;
+		case '3': strcpy(buf, ";-)");  break;
+		case '4': strcpy(buf, ":-P");  break;
+		case '5': strcpy(buf, "=-O");  break;
+		case '6': strcpy(buf, ":-*");  break;
+		case '7': strcpy(buf, ">:o");  break;
+		case '8': strcpy(buf, "8-)");  break;
+		case '!': strcpy(buf, ":-$");  break;
+		case '@': strcpy(buf, ":-!");  break;
+		case '#': strcpy(buf, ":-[");  break;
+		case '$': strcpy(buf, "O:-)"); break;
+		case '%': strcpy(buf, ":-/");  break;
+		case '^': strcpy(buf, ":'(");  break;
+		case '&': strcpy(buf, ":-X");  break;
+		case '*': strcpy(buf, ":-D");  break;
 		}
-
+	if (*buf) {
+		gtk_imhtml_insert_smiley(imhtml, NULL, buf);//->account->protocol_id, buf);
+		return TRUE;
+	}	
 	return FALSE;
 }
 
@@ -1757,6 +1835,11 @@
 					break;
 				case 62:	/* comment */
 					/* NEW_BIT (NEW_TEXT_BIT); */
+					ws[wpos] = '\0';
+					if (url)
+						gtk_imhtml_insert_link(imhtml, url, ws);
+					else
+						gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos);
 					if (imhtml->show_comments)
 						wpos = g_snprintf (ws, len, "%s", tag);
 					/* NEW_BIT (NEW_COMMENT_BIT); */