Re: Attaching and quoting messages



...and here's drag'n'drop for quoting.  This patch is intended to be 
applied after the previous one (DnD for inline parts), but is actually 
independent of it.  It does depend on Toralf's patch.

Messages dragged from the index tree into the text area of the sendmsg 
window are inserted, quoted, at the cursor position prior to the 
DnD--that is, the location where the icon is actually dropped isn't 
relevant, provided it's within the bounds of the text area.  The cursor 
is *restored to the start* of the inserted material (it would naturally 
go just below the end, but that will often be out of the visible 
window, and then the cursor is left at the foot of the visible window, 
which isn't much use for anything...)

Peter
diff -bNur balsa-include/src/sendmsg-window.c balsa-attach/src/sendmsg-window.c
--- balsa-include/src/sendmsg-window.c	Tue Oct  9 20:23:38 2001
+++ balsa-attach/src/sendmsg-window.c	Tue Oct  9 20:44:56 2001
@@ -1357,6 +1357,35 @@
     }
 }
 
+/* drag_data_quote - text area D&D callback */
+static void
+drag_data_quote(GtkWidget * widget,
+                GdkDragContext * context,
+                gint x,
+                gint y,
+                GtkSelectionData * selection_data,
+                guint info, guint32 time, BalsaSendmsg * bsmsg)
+{
+    if (info == TARGET_MESSAGES) {
+        LibBalsaMessage **message_array =
+            (LibBalsaMessage **) selection_data->data;
+        GString *text = g_string_new(NULL);
+        gint pos = gtk_editable_get_position(GTK_EDITABLE(widget));
+        gint orig_pos = pos;
+
+        while (*message_array) {
+            GString *body = quoteBody(bsmsg, *message_array++, SEND_REPLY);
+
+            text = g_string_append(text, body->str);
+            g_string_free(body, TRUE);
+        }
+        gtk_editable_insert_text(GTK_EDITABLE(widget), text->str,
+                                 strlen(text->str), &pos);
+        gtk_editable_set_position(GTK_EDITABLE(widget), orig_pos);
+        g_string_free(text, TRUE);
+    }
+}
+
 /* create_text_area 
    Creates the text entry part of the compose window.
 */
@@ -1379,6 +1408,11 @@
     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(table),
     				   GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
     gtk_container_add(GTK_CONTAINER(table), msg->text);
+    gtk_signal_connect(GTK_OBJECT(msg->text), "drag_data_received",
+		       GTK_SIGNAL_FUNC(drag_data_quote), msg);
+    gtk_drag_dest_set(GTK_WIDGET(msg->text), GTK_DEST_DEFAULT_ALL,
+		      drop_types, ELEMENTS(drop_types),
+		      GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
 
     gtk_widget_show_all(GTK_WIDGET(table));
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]