95
95
UriList uri_list = new UriList (selection_data);
96
StringBuilder insert = new StringBuilder ();
96
bool more_than_one = false;
98
// Place the cursor in the position where the uri was
99
// dropped, adjusting x,y by the TextView's VisibleRect.
100
Gdk.Rectangle rect = VisibleRect;
101
int adjustedX = x + rect.X;
102
int adjustedY = y + rect.Y;
103
Gtk.TextIter cursor = GetIterAtLocation (adjustedX, adjustedY);
104
Buffer.PlaceCursor (cursor);
106
Gtk.TextTag link_tag = Buffer.TagTable.Lookup ("link:url");
98
108
foreach (Uri uri in uri_list) {
99
109
Logger.Log ("Got Dropped URI: {0}", uri);
101
// FIXME: The space here is a hack
102
// around a bug in the URL Regex which
103
// matches across newlines.
104
if (insert.Length > 0)
105
insert.Append (" \n");
108
insert.Append (uri.LocalPath);
112
insert = uri.LocalPath;
110
insert.Append (uri.ToString ());
113
if (insert.Length > 0) {
114
Gtk.TextIter insert_iter =
115
Buffer.GetIterAtMark (Buffer.InsertMark);
116
Buffer.InsertWithTags (ref insert_iter,
118
Buffer.TagTable.Lookup ("link:url"));
121
Gtk.Drag.Finish (context, insert.Length > 0, false, time);
114
insert = uri.ToString ();
116
if (insert == null || insert.Trim () == String.Empty)
120
cursor = Buffer.GetIterAtMark (Buffer.InsertMark);
122
// FIXME: The space here is a hack
123
// around a bug in the URL Regex which
124
// matches across newlines.
125
if (cursor.LineOffset == 0)
126
Buffer.Insert (ref cursor, " \n");
128
Buffer.Insert (ref cursor, ", ");
131
Buffer.InsertWithTags (ref cursor, insert, link_tag);
132
more_than_one = true;
135
Gtk.Drag.Finish (context, more_than_one, false, time);
123
137
base.OnDragDataReceived (context, x, y, selection_data, info, time);