Esempio n. 1
0
static void confirm_delete (void)
{
    int playlist = aud_playlist_get_active ();
    int entry_count = aud_playlist_entry_count (playlist);

    for (int i = 0; i < entry_count; i ++)
    {
        if (! aud_playlist_entry_get_selected (playlist, i))
            continue;

        char * uri = aud_playlist_entry_get_filename (playlist, i);
        char * filename = uri_to_filename (uri);

        if (filename)
        {
            if (aud_get_bool ("delete_files", "use_trash"))
                move_to_trash (filename);
            else
                really_delete (filename);

            str_unref (filename);
        }
        else
        {
            SPRINTF (error, _("Error deleting %s: not a local file."), uri);
            aud_interface_show_error (error);
        }

        str_unref (uri);
    }

    aud_playlist_delete_selected (playlist);
}
Esempio n. 2
0
static void begin_add (const char * path)
{
    int list = get_playlist (FALSE, FALSE);

    if (list < 0)
        list = create_playlist ();

    aud_set_str ("search-tool", "path", path);

    char * uri = filename_to_uri (path);
    g_return_if_fail (uri);

    if (! g_str_has_suffix (uri, "/"))
    {
        SCONCAT2 (temp, uri, "/");
        str_unref (uri);
        uri = str_get (temp);
    }

    destroy_added_table ();

    added_table = g_hash_table_new_full ((GHashFunc) str_hash, (GEqualFunc)
     str_equal, (GDestroyNotify) str_unref, NULL);

    int entries = aud_playlist_entry_count (list);

    for (int entry = 0; entry < entries; entry ++)
    {
        char * filename = aud_playlist_entry_get_filename (list, entry);

        if (g_str_has_prefix (filename, uri) && ! g_hash_table_contains (added_table, filename))
        {
            aud_playlist_entry_set_selected (list, entry, FALSE);
            g_hash_table_insert (added_table, filename, NULL);
        }
        else
        {
            aud_playlist_entry_set_selected (list, entry, TRUE);
            str_unref (filename);
        }
    }

    aud_playlist_delete_selected (list);
    aud_playlist_remove_failed (list);

    Index * add = index_new ();
    index_insert (add, -1, uri);
    aud_playlist_entry_insert_filtered (list, -1, add, NULL, filter_cb, NULL, FALSE);

    adding = TRUE;
}