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

1.2
closed-fixed
libfm (241)
3
3 days ago
2013-07-03
alister.hood
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

1 2 > >> (Page 1 of 2)
  • alister.hood
    alister.hood
    2013-07-03

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

     
    • priority: 5 --> 3
    • milestone: --> 2334041
    • labels: --> libfm
     
  • 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);
    }

     
  • 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
     
  • Try master libfm GIT repo, please, and tell me if latest committed workaround fixed the issue. Thank you very much.

     
1 2 > >> (Page 1 of 2)