Menu

#744 Drag-and-drop doesn't work to some applications

1.2
closed-fixed
libfm (316)
3
2014-08-24
2013-07-03
No

Drag-and-drop from pcmanfm into some applications (e.g. dragging a photo into frogr) doesn't work. Dragging into the same applications from rox does work.

Discussion

  • Alister Hood

    Alister Hood - 2013-07-03

    N.B. I'm using the master version, on Arch.

     
  • Lonely Stranger

    Lonely Stranger - 2013-07-06
    • priority: 5 --> 3
    • milestone: --> 2334041
    • labels: --> libfm
     
  • Lonely Stranger

    Lonely Stranger - 2013-07-06

    We support dragging files as URI list and as plain text list. If frogr doesn't support any of those types then I don't know how to help it. I would like you to ask from frogr developers how they expect drag-and-drop to work. Thank you very much.

     
  • Alister Hood

    Alister Hood - 2013-07-24

    Hmmm. The frogr developer said this:

    > Well, I haven't had time to give this much thought, so quick answer is that I
    > have no idea yet on how to fix it in frogr (or whether it's fixable at all,
    > fwiw), and that I was just planning on reproducing the issue and try to find a
    > solution as soon as I have some free time for it.
    >
    > Not sure whether you're meaning there's nothing we can do from frogr side,
    > though. In any case, any advice you can provide on the right direction would be
    > highly appreciated.

    This is way over my head, but this looks like the relevant code in frogr, and I get the impression it's using standard GTK features to receive URIs...:

    _on_icon_view_drag_data_received (GtkWidget *widget,
    GdkDragContext *context,
    gint x, gint y,
    GtkSelectionData *selection_data,
    guint info, guint time,
    gpointer data)
    {
    FrogrMainView *self = NULL;
    FrogrMainViewPrivate *priv = NULL;
    GdkAtom target;
    GSList *fileuris_list = NULL;
    const guchar *files_string = NULL;
    gchar **fileuris_array = NULL;
    gint i;

    self = FROGR_MAIN_VIEW (data);
    priv = FROGR_MAIN_VIEW_GET_PRIVATE (data);

    /* Do nothing when the application is busy doing something else */
    if (FROGR_STATE_IS_BUSY(frogr_controller_get_state (priv->controller)))
    return;

    target = gtk_selection_data_get_target (selection_data);

    if (!gtk_targets_include_uri (&target, 1))
    return;

    /* Get GSList with the list of files */
    files_string = gtk_selection_data_get_data (selection_data);

    fileuris_array = g_strsplit ((const gchar*)files_string, "\r\n", -1);
    for (i = 0; fileuris_array[i]; i++)
    {
    if (fileuris_array[i] && fileuris_array[i][0] != '\0')
    fileuris_list = g_slist_append (fileuris_list, g_strdup (fileuris_array[i]));
    }

    /* Load pictures */
    if (fileuris_list != NULL)
    _load_pictures (FROGR_MAIN_VIEW (self), fileuris_list);

    /* Finish drag and drop */
    gtk_drag_finish (context, TRUE, FALSE, time);

    /* Free */
    g_strfreev (fileuris_array);
    }

     
  • Lonely Stranger

    Lonely Stranger - 2013-07-24

    Oh, I believe I know what is incorrect in their code. They assume that primary target should be always URI but in some cases it might be not. Instead of using gtk_selection_data_get_target() followed by gtk_targets_include_uri() they shoul use gtk_selection_data_targets_include_uri(), and also use gtk_selection_data_get_uris() instead of gtk_selection_data_get_data() followed by g_strsplit(). That will not only simplify their code but also fix problem not only with pcmanfm but also allow drop from other programs which support URI but not as primary target. :)

     
  • Alister Hood

    Alister Hood - 2013-07-29
    • status: open --> closed-rejected
     
  • Alister Hood

    Alister Hood - 2013-07-29

    Thanks,
    It has been fixed in frogr and their developer says thanks for the help
    If I remember which other applications were having problems I'll look into them further - I suspect they don't accept URIs, just image/jpeg or image/png targets (rox seems to provide targets specifically suitable for each file type).

     
  • Alister Hood

    Alister Hood - 2013-08-02

    FWIW, another example of programs which don't accept drag-and-drop from pcmanfm but do from rox is Microsoft Word, Excel, etc, running with Wine :)

     
  • Alister Hood

    Alister Hood - 2013-08-02
    • status: closed-rejected --> open-rejected
     
  • Lonely Stranger

    Lonely Stranger - 2013-08-02

    Try master libfm GIT repo, please, and tell me if latest committed workaround fixed the issue. Thank you very much.

     
  • Lonely Stranger

    Lonely Stranger - 2013-08-02
    • milestone: 2334041 --> 1.2
    • status: open-rejected --> open-fixed
     
  • Alister Hood

    Alister Hood - 2013-08-03

    Oh, I think the issue with Wine applications is some sort of CRLF problem - it can be demonstrated just by trying to drag-and-drop a text file into the built-in Wine notepad. It gives an error message:

    ERROR
    'I:\root\.Xdefaults
    ' could not be found.

    And if you try to drag two files into it:

    ERROR
    'I:\tmp\x_clipboard\paste.cc
    file:\\\tmp\x_clipboard\selection.cc
    ' could not be found.

     
  • Alister Hood

    Alister Hood - 2013-08-03

    Yes, that is what the problem is. A uri list is supposed to be \r\n delimited - see e.g. http://www.lephpfacile.com/manuel-php-gtk/tutorials.filednd.urilist.php

    If I change this in fm-dnd-src.c:

    g_string_append( uri_list, "\n" );

    to this:

    g_string_append( uri_list, "\r\n" );

    then drag-and-drop works to all wine programs, as well as to normal linux programs.

     
  • Lonely Stranger

    Lonely Stranger - 2013-08-03
    • assigned_to: nobody --> lstranger
    • status: open-fixed --> closed-fixed
     
  • Lonely Stranger

    Lonely Stranger - 2013-08-03

    Thank you very much! Applied to master source. :)

     

Anonymous
Anonymous

Add attachments
Cancel