changeset 9909:ebca3bbc6719

[gaim-migrate @ 10801] (12:58:49) nosnilmot: LSchiere: I've got a few patches :) 1) Avoids a g_log when closing conversations on disconnected accounts http://nosnilmot.com/patches/gaim-0.83cvs-gtkconv-glog-quieter.patch (12:59:20) nosnilmot: 2) Some conversation signal fix-lets, which reduces g_log warnings when closing gaim with conversations open http://nosnilmot.com/patches/gaim-0.83cvs-conv-signal-fixes.patch (12:59:45) nosnilmot: 3) Drag-and-drop buddy support for the Invite dialog : http://nosnilmot.com/patches/gaim-0.83cvs-invite-dnd.patch committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sun, 29 Aug 2004 16:59:47 +0000
parents e46e63a96f07
children 0cb20555b3ab
files ChangeLog src/conversation.c src/gtkconv.c
diffstat 3 files changed, 102 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Aug 29 16:30:59 2004 +0000
+++ b/ChangeLog	Sun Aug 29 16:59:47 2004 +0000
@@ -1,5 +1,8 @@
 Gaim: The Pimpin' Penguin IM Client that's good for the soul!
 version 0.83:
+	New Features:
+	* Drag-and-drop buddy support for the Invite dialog (Stu Tomlinson)
+
 	Bug Fixes:
 	* Compile with gtk 2.5.x (Gary Kramlich)
 
--- a/src/conversation.c	Sun Aug 29 16:30:59 2004 +0000
+++ b/src/conversation.c	Sun Aug 29 16:59:47 2004 +0000
@@ -2900,7 +2900,7 @@
 										GAIM_SUBTYPE_CONVERSATION));
 
 	gaim_signal_register(handle, "conversation-updated",
-						 gaim_marshal_VOID__POINTER_UINT, NULL, 1,
+						 gaim_marshal_VOID__POINTER_UINT, NULL, 2,
 						 gaim_value_new(GAIM_TYPE_SUBTYPE,
 										GAIM_SUBTYPE_CONVERSATION),
 						 gaim_value_new(GAIM_TYPE_UINT));
@@ -3003,8 +3003,7 @@
 void
 gaim_conversations_uninit(void)
 {
-	
+	while (conversations)
+		gaim_conversation_destroy((GaimConversation*)conversations->data);
 	gaim_signals_unregister_by_instance(gaim_conversations_get_handle());
-	while (conversations) 
-		gaim_conversation_destroy((GaimConversation*)conversations->data);
 }
--- a/src/gtkconv.c	Sun Aug 29 16:30:59 2004 +0000
+++ b/src/gtkconv.c	Sun Aug 29 16:59:47 2004 +0000
@@ -679,6 +679,80 @@
 }
 
 static void
+invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y,
+				GtkSelectionData *sd, guint inf, guint t, gpointer data)
+{
+	InviteBuddyInfo *info = (InviteBuddyInfo *)data;
+	const char *convprotocol;
+
+	convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv));
+
+	if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE))
+	{
+		GaimBlistNode *node = NULL;
+		GaimBuddy *buddy;
+
+		memcpy(&node, sd->data, sizeof(node));
+
+		if (GAIM_BLIST_NODE_IS_CONTACT(node))
+			buddy = gaim_contact_get_priority_buddy((GaimContact *)node);
+		else if (GAIM_BLIST_NODE_IS_BUDDY(node))
+			buddy = (GaimBuddy *)node;
+		else
+			return;
+
+		if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account)))
+		{
+			gaim_notify_error(NULL, NULL,
+							  _("That buddy is not on the same protocol as this "
+								"chat"), NULL);
+		}
+		else
+			gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name);
+
+		gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t);
+	}
+	else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE))
+	{
+		char *protocol = NULL;
+		char *username = NULL;
+		GaimAccount *account;
+
+		if (gaim_gtk_parse_x_im_contact(sd->data, FALSE, &account,
+										&protocol, &username, NULL))
+		{
+			if (account == NULL)
+			{
+				gaim_notify_error(NULL, NULL,
+					_("You are not currently signed on with an account that "
+					  "can invite that buddy."), NULL);
+			}
+			else if (strcmp(convprotocol, gaim_account_get_protocol_id(account)))
+			{
+				gaim_notify_error(NULL, NULL,
+								  _("That buddy is not on the same protocol as this "
+									"chat"), NULL);
+			}
+			else
+			{
+				gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username);
+			}
+		}
+
+		if (username != NULL) g_free(username);
+		if (protocol != NULL) g_free(protocol);
+
+		gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t);
+	}
+}
+
+static const GtkTargetEntry dnd_targets[] =
+{
+	{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0},
+	{"application/x-im-contact", 0, 1}
+};
+
+static void
 invite_cb(GtkWidget *widget, GaimConversation *conv)
 {
 	InviteBuddyInfo *info = NULL;
@@ -715,6 +789,8 @@
 		gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE);
 		gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE);
 
+		info->window = GTK_WIDGET(invite_dialog);
+
 		/* Setup the outside spacing. */
 		vbox = GTK_DIALOG(invite_dialog)->vbox;
 
@@ -788,6 +864,25 @@
 		/* Connect the signals. */
 		g_signal_connect(G_OBJECT(invite_dialog), "response",
 						 G_CALLBACK(do_invite), info);
+		/* Setup drag-and-drop */
+		gtk_drag_dest_set(info->window,
+						  GTK_DEST_DEFAULT_MOTION |
+						  GTK_DEST_DEFAULT_DROP,
+						  dnd_targets,
+						  sizeof(dnd_targets) / sizeof(GtkTargetEntry),
+						  GDK_ACTION_COPY);
+		gtk_drag_dest_set(info->entry,
+						  GTK_DEST_DEFAULT_MOTION |
+						  GTK_DEST_DEFAULT_DROP,
+						  dnd_targets,
+						  sizeof(dnd_targets) / sizeof(GtkTargetEntry),
+						  GDK_ACTION_COPY);
+
+		g_signal_connect(G_OBJECT(info->window), "drag_data_received",
+						 G_CALLBACK(invite_dnd_recv), info);
+		g_signal_connect(G_OBJECT(info->entry), "drag_data_received",
+						 G_CALLBACK(invite_dnd_recv), info);
+
 	}
 
 	gtk_widget_show_all(invite_dialog);
@@ -2598,7 +2693,7 @@
 	gtkwin  = GAIM_GTK_WINDOW(win);
 	gtkconv = GAIM_GTK_CONVERSATION(conv);
 	gc      = gaim_conversation_get_gc(conv);
-	account = gaim_connection_get_account(gc);
+	account = gaim_conversation_get_account(conv);
 
 	if (gc != NULL)
 		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);