Drag files into composer to attach

Bug #684542 reported by Cris Dywan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Postler
Fix Released
Undecided
Unassigned

Bug Description

Dragging files into the composer, specifically the web view and the attachment area, should attach them.

Revision history for this message
Sergio Spinatelli (spinatelli) wrote :

Maybe adding something like

        Gtk.drag_dest_set ( this, Gtk.DestDefaults.ALL, null, Gdk.DragAction.COPY );
     Gtk.drag_dest_add_uri_targets (this);

     this.drag_data_received.connect (on_drag_drop);

and then the function handling

private void on_drag_drop (Gdk.DragContext context, int x, int y, Gtk.SelectionData data, uint info, uint time_){
        string[] uris= data.get_uris();
                //stuff..
               //...
}

should do the job (some string manipulation on the uris and some checks to see if the dropped stuff is actually made of files could also be good).

on_drag_drop could basically do some checks and the call insert_attachment ( string path ) to add the dropped files to the attachments..

What do you think,postler-developers? =)

Revision history for this message
Sergio Spinatelli (spinatelli) wrote :

This works on my machine:

adding this function to the Postler.Composer class

 private void on_drag_drop (Gdk.DragContext context, int x, int y, Gtk.SelectionData data, uint info, uint time_){
        string[] uri= data.get_uris();
  foreach (string s in uri ) {

   File file = File.new_for_uri (s);

   if (file.query_file_type (FileQueryInfoFlags.NOFOLLOW_SYMLINKS) == FileType.REGULAR)
    insert_attachment ( file.get_path ( ) );
  }

  }

and this code to the Composer () constructor:

        Gtk.drag_dest_set ( this, Gtk.DestDefaults.ALL, null, Gdk.DragAction.COPY );
     Gtk.drag_dest_add_uri_targets (this);

     this.drag_data_received.connect (on_drag_drop);

if dropping is allowed in all points of the window.. =)

Revision history for this message
Cris Dywan (kalikiana) wrote :

I made a patch based on this suggestion. I went further and made the web view and attachment area destinations, as I think it is confusing to drag for example onto the toolbar. I also added a drag_finish call, passed {} to avoid warnings and added an is_native () check because only local files are supported.

Changed in postler:
status: New → Fix Committed
Cris Dywan (kalikiana)
Changed in postler:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.