]> git.sesse.net Git - vlc/commitdiff
PDA Interface:
authorJean-Paul Saman <jpsaman@videolan.org>
Tue, 25 Nov 2003 20:41:35 +0000 (20:41 +0000)
committerJean-Paul Saman <jpsaman@videolan.org>
Tue, 25 Nov 2003 20:41:35 +0000 (20:41 +0000)
- Fixed a p_playlist refcount problem
- Clearing VLC playlist and Playlist widget.

modules/gui/pda/pda.c
modules/gui/pda/pda_callbacks.c

index d6e4fda4d614983287f0826fc0d2d06e0350eb22..ec6472dd6a625b5686a4f02c454c9ce72468e17d 100644 (file)
@@ -2,7 +2,7 @@
  * pda.c : PDA Gtk2 plugin for vlc
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: pda.c,v 1.10 2003/11/21 09:23:49 jpsaman Exp $
+ * $Id: pda.c,v 1.11 2003/11/25 20:41:35 jpsaman Exp $
  *
  * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
  *          Marc Ariberti <marcari@videolan.org>
@@ -436,6 +436,7 @@ static int Manage( intf_thread_t *p_intf )
                     PlaylistRebuildListStore(p_liststore, p_playlist);
                     msg_Dbg(p_intf, "Manage: Updating GtkTreeView Playlist" );
                     gtk_tree_view_set_model(p_intf->p_sys->p_tvplaylist, (GtkTreeModel*) p_liststore);
+                    vlc_object_release( p_playlist );
                 }
             }
 
index 01314cd3cd5caf03a15b2c32f4064f2816df14c4..b5d94b0255a596aed1b2d5bad8e7904d2c9691d9 100644 (file)
@@ -2,7 +2,7 @@
  * pda_callbacks.c : Callbacks for the pda Linux Gtk+ plugin.
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: pda_callbacks.c,v 1.16 2003/11/25 20:01:08 jpsaman Exp $
+ * $Id: pda_callbacks.c,v 1.17 2003/11/25 20:41:35 jpsaman Exp $
  *
  * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
  *
@@ -124,19 +124,20 @@ void PlaylistAddItem(GtkWidget *widget, gchar *name)
 #if 0
             if (p_intf->p_sys->b_autoplayfile)
             {
-                playlist_Add( p_playlist, (char*)name, 0, 0,
+                playlist_Add( p_playlist, (const char*)name, 0, 0,
                               PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END);
             }
             else
             {
-                playlist_Add( p_playlist, (char*)name, 0, 0,
+                playlist_Add( p_playlist, (const char*)name, 0, 0,
                               PLAYLIST_APPEND, PLAYLIST_END );
             }
+            
 #endif
+            vlc_object_release( p_playlist );
             msg_Dbg( p_intf, "done");
         }
     }
-    vlc_object_release(  p_playlist );
 }
 
 void PlaylistRebuildListStore( GtkListStore * p_list, playlist_t * p_playlist )
@@ -767,8 +768,39 @@ 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;
+
+    msg_Dbg(p_intf, "Clear VLC playlist" );
 
-    msg_Dbg(p_intf, "Clear playlist" );
+    if( p_playlist == NULL )
+    {
+        return;
+    }
+
+    vlc_mutex_lock( &p_playlist->object_lock );
+    for(item = p_playlist->i_size - 1 ; item >= 0 ; item-- )
+    {
+        playlist_Delete( p_playlist, item);
+    }
+    vlc_mutex_unlock( &p_playlist->object_lock );
+    vlc_object_release( p_playlist );
+
+    // Remove all entries from the Playlist widget.
+    msg_Dbg(p_intf, "Clear 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));
+        }
+    }
 }