[gedit-plugins] terminal: handle drag and drop of files
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins] terminal: handle drag and drop of files
- Date: Fri, 24 May 2013 15:16:21 +0000 (UTC)
commit 8ba90c625f89634d0af48e7c3596404bd830818a
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Fri May 24 17:07:54 2013 +0200
terminal: handle drag and drop of files
https://bugzilla.gnome.org/show_bug.cgi?id=700951
plugins/terminal/terminal.py | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/plugins/terminal/terminal.py b/plugins/terminal/terminal.py
index d82d705..acc014b 100644
--- a/plugins/terminal/terminal.py
+++ b/plugins/terminal/terminal.py
@@ -40,6 +40,8 @@ class GeditTerminal(Vte.Terminal):
'visible_bell' : False,
}
+ TARGET_URI_LIST = 200
+
def __init__(self):
Vte.Terminal.__init__(self)
@@ -48,6 +50,13 @@ class GeditTerminal(Vte.Terminal):
self.set_size(self.get_column_count(), 5)
self.set_size_request(200, 50)
+ tl = Gtk.TargetList.new([])
+ tl.add_uri_targets(self.TARGET_URI_LIST)
+
+ self.drag_dest_set(Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP,
+ [], Gdk.DragAction.DEFAULT | Gdk.DragAction.COPY)
+ self.drag_dest_set_target_list(tl)
+
self.profile_settings = self.get_profile_settings()
self.profile_settings.connect("changed", self.on_profile_settings_changed)
self.system_settings = Gio.Settings.new("org.gnome.desktop.interface")
@@ -62,6 +71,13 @@ class GeditTerminal(Vte.Terminal):
self._vte.fork_command_full(Vte.PtyFlags.DEFAULT, None, [Vte.get_user_shell()], None,
GLib.SpawnFlags.SEARCH_PATH, None, None)
+ def do_drag_data_received(self, drag_context, x, y, data, info, time):
+ if info == self.TARGET_URI_LIST:
+ self.feed_child(' '.join(["'" + item + "'" for item in Gedit.utils_drop_get_uris(data)]), -1)
+ Gtk.drag_finish(drag_context, True, False, time);
+ else:
+ Vte.Terminal.do_drag_data_received(self, drag_context, x, y, data, info, time)
+
def settings_try_new(self, schema):
schemas = Gio.Settings.list_schemas()
if not schemas:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]