diff src/gtkconv.c @ 7694:6a9acef3b867

[gaim-migrate @ 8339] Committing this now so that I don't accidentally destroy it again. We're going WYSIWYG, folks. This is the beginning of it. Don't bother trying to tell me what doesn't work yet. This is just a sneak-peek. Bold, Italics, and Underline work fairly well. The toggle buttons in the tooltips won't necessarily be accurate yet, and things will get screwed up if you say, start typing, make something bold, then go back to before where you started typing and type there. It'll all be fixed eventually. NOTE: I am not liable for any sexual arousal caused by using this code committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Tue, 02 Dec 2003 07:33:42 +0000
parents 1d0314b99747
children 557f72040bdf
line wrap: on
line diff
--- a/src/gtkconv.c	Tue Dec 02 07:08:02 2003 +0000
+++ b/src/gtkconv.c	Tue Dec 02 07:33:42 2003 +0000
@@ -117,6 +117,15 @@
 
 static GtkWidget *invite_dialog = NULL;
 
+enum {
+	TARGET_XURL=0,
+	TARGET_URI_LIST,
+	TARGET_BLIST_NODE,
+	TARGET_STRING,
+	TARGET_NETSCAPE_URL,
+	TARGET_PLAIN_TEXT 
+};
+
 /* Prototypes. <-- because Paco-Paco hates this comment. */
 static void check_everything(GtkTextBuffer *buffer);
 static void set_toggle(GtkWidget *tb, gboolean active);
@@ -3792,6 +3801,7 @@
 {
 	GaimConvWindow *win = conv->window;
 	GaimConversation *c;
+	gchar* uri;
 
 	if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) {
 		GaimBlistNode *n = NULL;
@@ -3809,6 +3819,64 @@
 
 		gaim_conv_window_add_conversation(win, c);
 	}
+	if (info == TARGET_NETSCAPE_URL)
+	{
+		GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv);
+		gchar* p=(gchar*) sd->data;
+		gchar* q;
+		gchar* link;
+
+		if (p==NULL)
+			return;
+		g_strchomp(p);
+		q = strchr(p,'\n');
+		if (q==NULL)
+		{
+			link=g_strconcat("<a href=\"",p,"\">",p,"</a>",NULL);
+		}
+		else
+		{
+			uri = g_strndup(p,q-p);
+			q++;
+			link=g_strconcat("<a href=\"",uri,"\">",q,"</a>",NULL);
+			g_free(uri);
+		}
+		gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(gtkconv->entry_buffer), link, -1);
+		g_free(link);
+	}
+	if (info == TARGET_XURL)
+	{
+		GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv);
+		gchar* link;
+		uri=g_strdup((gchar*) sd->data);
+		g_strstrip(uri);
+		link=g_strconcat("<a href=\"",uri,"\">",uri,"</a>",NULL);
+		g_free(uri);
+		gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(gtkconv->entry_buffer), link, -1);
+		g_free(link);
+	}
+	if (info == TARGET_URI_LIST && (gchar*)sd->data != NULL 
+	&& g_ascii_strncasecmp((gchar*)sd->data,"file:",5)!=0)
+	{
+		GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv);
+		gchar *p, *q, *link;
+		q=g_strdup((gchar*) sd->data);
+		g_strstrip(q);
+		p=strchr(q,'\n');
+		if (p==NULL)
+		{
+			uri=g_strdup(q);	/* strdup'ing this to make it match the else */
+		}
+		else
+		{
+			uri=g_strndup(q,q-p);
+		}
+		g_free(q);
+		link=g_strconcat("<a href=\"",uri,"\">",uri,"</a>",NULL);
+		g_free(uri);
+		gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(gtkconv->entry_buffer), link, -1);
+		g_free(link);
+	}
 }
 
 /**************************************************************************
@@ -3957,10 +4025,13 @@
 
 static const GtkTargetEntry te[] =
 {
-	{"text/plain", 0, 0},
-	{"text/uri-list", 0, 1},
-	{"GAIM_BLIST_NODE", 0, 2},
-	{"STRING", 0, 3}
+	{"x-url/ftp", 0, TARGET_XURL},
+	{"x-url/http", 0, TARGET_XURL},
+	{"text/uri-list", 0, TARGET_URI_LIST},
+	{"GAIM_BLIST_NODE", 0, TARGET_BLIST_NODE},
+	{"STRING", 0, TARGET_STRING},
+	{"_NETSCAPE_URL", 0, TARGET_NETSCAPE_URL},
+	{"text/plain", 0, TARGET_PLAIN_TEXT}
 };
 
 static void
@@ -4034,20 +4105,15 @@
 				                  GTK_DEST_DEFAULT_DROP,
 						  te, sizeof(te) / sizeof(GtkTargetEntry),
 						  GDK_ACTION_DEFAULT | GDK_ACTION_COPY | GDK_ACTION_MOVE);
-		gtk_drag_dest_set(gtkconv->entry,
-						  GTK_DEST_DEFAULT_MOTION |
-						  GTK_DEST_DEFAULT_DROP,
-						  te, sizeof(te) / sizeof(GtkTargetEntry),
-						  GDK_ACTION_COPY);
-
+		gtk_drag_dest_set(gtkconv->entry, 0,
+                			          te, sizeof(te) / sizeof(GtkTargetEntry),
+                			          GDK_ACTION_COPY);
 		g_signal_connect(G_OBJECT(pane), "drag_data_received",
 						 G_CALLBACK(conv_dnd_recv), conv);
 		g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received",
 						 G_CALLBACK(conv_dnd_recv), conv);
-#if 0
 		g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received",
 						 G_CALLBACK(conv_dnd_recv), conv);
-#endif
 
 		/* Setup the container for the tab. */
 		gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, 5);