[latexila] Support drag and drop of a list of files



commit 0a663deaf648c515c5c48993e1698bb70a7efb25
Author: Pieter Pareit <pieter pareit gmail com>
Date:   Wed Nov 30 20:54:19 2011 +0100

    Support drag and drop of a list of files
    
    From Nautilus for example, we select a file or a set of files, and we
    drag and drop them into a window of latexila. This will open the files.
    
    But if we drop the files in the TextView, this won't work, instead the
    file paths are pasted.

 src/main_window.vala |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/src/main_window.vala b/src/main_window.vala
index 7485b5f..d7d2560 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -427,6 +427,16 @@ public class MainWindow : Window
         set_file_actions_sensitivity (false);
         set_documents_move_to_new_window_sensitivity (false);
 
+        // drag-n-drop support of files
+        Gtk.drag_dest_set (this, DestDefaults.ALL, {}, Gdk.DragAction.COPY);
+        Gtk.drag_dest_add_uri_targets (this);
+        drag_data_received.connect ((dc, x, y, selection_data, info, time) =>
+        {
+            Application app = Application.get_default ();
+            app.open_documents (selection_data.get_uris ());
+            Gtk.drag_finish (dc, true, true, time);
+        });
+
         // spell checking
         ToggleAction spell_checking_action =
             action_group.get_action ("EditSpellChecking") as ToggleAction;



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