예제 #1
0
gboolean on_dnd_dest_files_dropped(FmDndDest* dd, GdkDragAction action,
                               int info_type, FmFileInfoList* files, FmPlacesView* view)
{
    FmPath* dest;
    GList* l;
    gboolean ret = FALSE;

    dest = fm_dnd_dest_get_dest_path(dd);
    /* g_debug("action= %d, %d files-dropped!, info_type: %d", action, fm_list_get_length(files), info_type); */

    if(!dest && action == GDK_ACTION_LINK) /* add bookmarks */
    {
        GtkTreePath* tp = view->dest_row;
        if(tp)
        {
            const GtkTreePath* sep = fm_places_model_get_separator_path(FM_PLACES_MODEL(model));
            int idx = gtk_tree_path_get_indices(tp)[0] - gtk_tree_path_get_indices(sep)[0];

            if(view->dest_pos == GTK_TREE_VIEW_DROP_BEFORE)
                --idx;
            for( l=fm_list_peek_head_link(files); l; l=l->next, ++idx )
            {
                FmBookmarkItem* item;
                FmFileInfo* fi = FM_FILE_INFO(l->data);
                if(fm_file_info_is_dir(fi))
                    item = fm_bookmarks_insert( FM_PLACES_MODEL(model)->bookmarks, fi->path, fi->disp_name, idx);
                /* we don't need to add item to places view. Later the bookmarks will be reloaded. */
            }
        }
        ret = TRUE;
    }

    if(view->dest_row)
    {
        gtk_tree_path_free(view->dest_row);
        view->dest_row = NULL;
    }
    return ret;
}
예제 #2
0
void on_dnd_dest_files_dropped(FmDndDest* dd, GdkDragAction action,
                               int info_type, FmList* files, FmPlacesView* view)
{
	FmPath* dest;
    GList* l;

	dest = fm_dnd_dest_get_dest_path(dd);
    g_debug("action= %d, %d files-dropped!, info_type: %d", action, fm_list_get_length(files), info_type);

    if(action != GDK_ACTION_LINK)
    {
        if(fm_list_is_file_info_list(files))
            files = fm_path_list_new_from_file_info_list(files);
        else
            fm_list_ref(files);
    }

    switch(action)
    {
    case GDK_ACTION_MOVE:
        if(fm_path_is_trash_root(dest))
            fm_trash_files(files);
        else
            fm_move_files(files, dest);
        break;
    case GDK_ACTION_COPY:
        fm_copy_files(files, dest);
        break;
    case GDK_ACTION_LINK:
        {
            GtkTreePath* tp = view->dest_row;
            if(tp)
            {
                GtkTreePath* sep = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &sep_it);
                int idx = gtk_tree_path_get_indices(tp)[0] - gtk_tree_path_get_indices(sep)[0];
                gtk_tree_path_free(sep);
                if(view->dest_pos == GTK_TREE_VIEW_DROP_BEFORE)
                    --idx;
                for( l=fm_list_peek_head_link(files); l; l=l->next, ++idx )
                {
                    FmBookmarkItem* item;
                    if(fm_list_is_file_info_list(files))
                    {
                        FmFileInfo* fi = (FmFileInfo*)l->data;
                        item = fm_bookmarks_insert( bookmarks, fi->path, fi->disp_name, idx);
                    }
                    else
                    {
                        FmPath* path = (FmPath*)l->data;
                        char* disp_name = g_filename_display_name(path->name);
                        item = fm_bookmarks_insert( bookmarks, path, disp_name, idx);
                        g_free(disp_name);
                    }
                    /* we don't need to add item to places view. Later the bookmarks will be reloaded. */
                }
            }
        }
        break;
    }
    fm_list_unref(files);

    if(view->dest_row)
    {
        gtk_tree_path_free(view->dest_row);
        view->dest_row = NULL;
    }
}