示例#1
0
void onClearPlaylist(GtkButton *button, gpointer user_data)
{
    intf_thread_t *p_intf = GtkGetIntf( button );
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
    GtkTreeView    *p_tvplaylist;
    int item;

    if( p_playlist == NULL )
    {
        return;
    }

    for(item = p_playlist->i_size - 1; item >= 0 ;item-- )
    {
        playlist_LockDelete( p_playlist, item);
    }
    vlc_object_release( p_playlist );

    // Remove all entries from the Playlist widget.
    p_tvplaylist = (GtkTreeView*) lookup_widget( GTK_WIDGET(button), "tvPlaylist");
    if (p_tvplaylist)
    {
        GtkTreeModel *p_play_model;

        p_play_model = gtk_tree_view_get_model(p_tvplaylist);
        if (p_play_model)
        {
            gtk_list_store_clear(GTK_LIST_STORE(p_play_model));
        }
    }
}
示例#2
0
void Playlist::delSelected()
{
    // Remove the items from the VLC playlist
    int index = 0;
    ConstIterator it;
    for( it = begin(); it != end(); it++ )
    {
        if( (*it).m_selected )
        {
            playlist_item_t *p_item = playlist_LockItemGetByPos( m_pPlaylist,
                                                                 index );
            playlist_LockDelete( m_pPlaylist, p_item->input.i_id );
        }
        else
        {
            index++;
        }
    }

    notify();
}
示例#3
0
void onDeletePlaylist(GtkButton *button, gpointer user_data)
{
    intf_thread_t *p_intf = GtkGetIntf( button );
    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
    GtkTreeView    *p_tvplaylist;

    /* Delete an arbitrary item from the playlist */
    p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvPlaylist" );
    if (p_tvplaylist != NULL)
    {
        GList *p_rows = NULL;
        GList *p_node;
        GtkTreeModel *p_model = NULL;
        GtkListStore *p_store = NULL;
        GtkTreeSelection *p_selection = gtk_tree_view_get_selection(p_tvplaylist);

        p_model = gtk_tree_view_get_model(p_tvplaylist);
        if (p_model)
        {
            p_rows = gtk_tree_selection_get_selected_rows(p_selection, &p_model);

            if( g_list_length( p_rows ) )
            {
                /* reverse-sort so that we can delete from the furthest
                 * to the closest item to delete...
                 */
                p_rows = g_list_reverse( p_rows );
            }

            for (p_node=p_rows; p_node!=NULL; p_node = p_node->next)
            {
                GtkTreeIter iter;
                GtkTreePath *p_path = NULL;

                p_path = (GtkTreePath *)p_node->data;
                if (p_path)
                {
                    if (gtk_tree_model_get_iter(p_model, &iter, p_path))
                    {
                        gint item;

                        gtk_tree_model_get(p_model, &iter, 2, &item, -1);
                        playlist_LockDelete(p_playlist, item);
                    }
                }
            }
#if 0 
            g_list_foreach (p_rows, (GFunc*)gtk_tree_path_free, NULL);
#endif /* Testing the next line */
            g_list_foreach (p_rows, deleteItemFromPlaylist, NULL);
            g_list_free (p_rows);
        }

        /* Rebuild the playlist then. */
        p_store = gtk_list_store_new (3,
                    G_TYPE_STRING, /* Filename */
                    G_TYPE_STRING, /* Time */
                    G_TYPE_UINT);  /* Hidden field */
        if (p_store)
        {
            PlaylistRebuildListStore(p_store, p_playlist);
            gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_store));
            g_object_unref(p_store);
        }
    }
    vlc_object_release( p_playlist );
}