]> git.sesse.net Git - vlc/blobdiff - modules/gui/pda/pda_callbacks.c
Don't include config.h from the headers - refs #297.
[vlc] / modules / gui / pda / pda_callbacks.c
index 5b484a8d64f63f0fd96a57eb9d389e46a7653db2..1685c58411ebf85fc28227ceed075673f88a919f 100644 (file)
@@ -1,10 +1,10 @@
 /*****************************************************************************
  * pda_callbacks.c : Callbacks for the pda Linux Gtk+ plugin.
  *****************************************************************************
- * Copyright (C) 2000, 2001 VideoLAN
+ * Copyright (C) 2000, 2001 the VideoLAN team
  * $Id$
  *
- * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
+ * Authors: Jean-Paul Saman <jpsaman _at_ videolan _dot_ org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 #include <sys/types.h>                                              /* off_t */
-#include <stdlib.h>
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
-#include <vlc/intf.h>
-#include <vlc/vout.h>
+#include <vlc_input.h>
+#include <vlc_interface.h>
+#include <vlc_playlist.h>
+#include <vlc_vout.h>
 
-#include <stdio.h>
-#include <string.h>
 #include <dirent.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <pwd.h>
 #include <grp.h>
 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
 #include <gtk/gtk.h>
 
 #include "pda_callbacks.h"
@@ -87,7 +87,7 @@ void * E_(__GtkGetIntf)( GtkWidget * widget )
     return p_data;
 }
 
-void PlaylistAddItem(GtkWidget *widget, gchar *name, char **ppsz_options, int i_size)
+static void PlaylistAddItem(GtkWidget *widget, gchar *name, char **ppsz_options, int i_size)
 {
     intf_thread_t *p_intf = GtkGetIntf( widget );
     playlist_t    *p_playlist;
@@ -110,7 +110,7 @@ void PlaylistAddItem(GtkWidget *widget, gchar *name, char **ppsz_options, int i_
         GtkTreeIter   p_play_iter;
 
         p_play_model = gtk_tree_view_get_model(p_tvplaylist);
-        
         if (p_play_model)
         {
             int i;
@@ -120,7 +120,7 @@ void PlaylistAddItem(GtkWidget *widget, gchar *name, char **ppsz_options, int i_
             gtk_list_store_set (GTK_LIST_STORE(p_play_model), &p_play_iter,
                                     0, name,   /* Add path to it !!! */
                                     1, "no info",
-                                    2, p_playlist->i_size, /* Hidden index. */
+                                    2, playlist_CurrentSize(p_intf), /* Hidden index. */
                                     -1 );
 
             /* Add to VLC's playlist */
@@ -137,7 +137,8 @@ void PlaylistAddItem(GtkWidget *widget, gchar *name, char **ppsz_options, int i_
                               (const char*)name,
                               PLAYLIST_APPEND, PLAYLIST_END,
                               (mtime_t) 0,
-                              (const char **) ppsz_options, i_pos );
+                              (const char **) ppsz_options, i_pos,
+                              VLC_TRUE, VLC_FALSE );
             }
 
             /* Cleanup memory */
@@ -149,7 +150,8 @@ void PlaylistAddItem(GtkWidget *widget, gchar *name, char **ppsz_options, int i_
     vlc_object_release( p_playlist );
 }
 
-void PlaylistRebuildListStore( GtkListStore * p_list, playlist_t * p_playlist )
+void PlaylistRebuildListStore( intf_thread_t *p_intf,
+    GtkListStore * p_list, playlist_t * p_playlist )
 {
     GtkTreeIter iter;
     int         i_dummy;
@@ -161,16 +163,20 @@ void PlaylistRebuildListStore( GtkListStore * p_list, playlist_t * p_playlist )
     red.green   = 0;
 #endif
     vlc_mutex_lock( &p_playlist->object_lock );
-    for( i_dummy = 0; i_dummy < p_playlist->i_size ; i_dummy++ )
+    for( i_dummy = 0; i_dummy < playlist_CurrentSize(p_intf) ; i_dummy++ )
     {
-        ppsz_text[0] = p_playlist->pp_items[i_dummy]->input.psz_name;
-        ppsz_text[1] = "no info";
-        gtk_list_store_append (p_list, &iter);
-        gtk_list_store_set (p_list, &iter,
-                            0, ppsz_text[0],
-                            1, ppsz_text[1],
-                            2, i_dummy, /* Hidden index */
-                            -1);
+        playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_dummy, VLC_TRUE );
+        if( p_item )
+        {
+            ppsz_text[0] = p_item->p_input->psz_name;
+            ppsz_text[1] = "no info";
+            gtk_list_store_append (p_list, &iter);
+            gtk_list_store_set (p_list, &iter,
+                                0, ppsz_text[0],
+                                1, ppsz_text[1],
+                                2, i_dummy, /* Hidden index */
+                                -1);
+        }
     }
     vlc_mutex_unlock( &p_playlist->object_lock );
 }
@@ -229,7 +235,7 @@ void ReadDirectory(intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
         }
             /* kludge */
         for (i=0; i<n; i++)
-        {           
+        {
             if ((pp_namelist[i]->d_name[0] != '.') &&
                 (lstat(pp_namelist[i]->d_name, &st)==0))
             {
@@ -342,32 +348,30 @@ gboolean onPDADeleteEvent(GtkWidget *widget, GdkEvent *event, gpointer user_data
     intf_thread_t *p_intf = GtkGetIntf( widget );
 
     vlc_mutex_lock( &p_intf->change_lock );
-    p_intf->p_vlc->b_die = VLC_TRUE;
+    vlc_object_kill( p_intf->p_libvlc );
     vlc_mutex_unlock( &p_intf->change_lock );
     msg_Dbg( p_intf, "about to exit vlc ... signaled" );
 
     return TRUE;
 }
 
-
 void onRewind(GtkButton *button, gpointer user_data)
 {
     intf_thread_t *p_intf = GtkGetIntf( button );
 
     if (p_intf->p_sys->p_input != NULL)
     {
-        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );
+        var_SetVoid( p_intf->p_sys->p_input, "rate-slower" );
     }
 }
 
-
 void onPause(GtkButton *button, gpointer user_data)
 {
     intf_thread_t *p_intf = GtkGetIntf( button );
 
     if (p_intf->p_sys->p_input != NULL)
     {
-        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );
+        var_SetInteger( p_intf->p_sys->p_input, "state", PAUSE_S );
     }
 }
 
@@ -380,7 +384,7 @@ void onPlay(GtkButton *button, gpointer user_data)
     if (p_playlist)
     {
         vlc_mutex_lock( &p_playlist->object_lock );
-        if (p_playlist->i_size)
+        if (playlist_CurrentSize(p_intf))
         {
             vlc_mutex_unlock( &p_playlist->object_lock );
             playlist_Play( p_playlist );
@@ -394,7 +398,6 @@ void onPlay(GtkButton *button, gpointer user_data)
     }
 }
 
-
 void onStop(GtkButton *button, gpointer user_data)
 {
     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET( button ) );
@@ -408,14 +411,13 @@ void onStop(GtkButton *button, gpointer user_data)
     }
 }
 
-
 void onForward(GtkButton *button, gpointer user_data)
 {
     intf_thread_t *p_intf = GtkGetIntf( button );
 
     if (p_intf->p_sys->p_input != NULL)
     {
-        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
+        var_SetVoid( p_intf->p_sys->p_input, "rate-faster" );
     }
 }
 
@@ -432,7 +434,6 @@ void onAbout(GtkButton *button, gpointer user_data)
     }
 }
 
-
 gboolean SliderRelease(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 {
     intf_thread_t *p_intf = GtkGetIntf( widget );
@@ -445,7 +446,6 @@ gboolean SliderRelease(GtkWidget *widget, GdkEventButton *event, gpointer user_d
     return TRUE;
 }
 
-
 gboolean SliderPress(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 {
     intf_thread_t *p_intf = GtkGetIntf( widget );
@@ -455,7 +455,7 @@ gboolean SliderPress(GtkWidget *widget, GdkEventButton *event, gpointer user_dat
     p_intf->p_sys->b_slider_free = 0;
     vlc_mutex_unlock( &p_intf->change_lock );
 
-    return TRUE;
+    return FALSE;
 }
 
 void SliderMove(GtkRange *range, GtkScrollType scroll, gpointer user_data)
@@ -465,7 +465,7 @@ void SliderMove(GtkRange *range, GtkScrollType scroll, gpointer user_data)
 }
 
 
-void addSelectedToPlaylist(GtkTreeModel *model, GtkTreePath *path,
+static void addSelectedToPlaylist(GtkTreeModel *model, GtkTreePath *path,
                            GtkTreeIter *iter, gpointer *userdata)
 {
     gchar *psz_filename;
@@ -486,7 +486,7 @@ void onFileListRow(GtkTreeView *treeview, GtkTreePath *path,
         struct stat   st;
         GtkTreeModel *p_model;
         GtkTreeIter   iter;
-        gchar        *psz_filename;
+        char         *psz_filename;
 
         /* This might be a directory selection */
         p_model = gtk_tree_view_get_model(treeview);
@@ -537,7 +537,7 @@ void onAddFileToPlaylist(GtkButton *button, gpointer user_data)
     {
         GtkTreeSelection *p_selection = gtk_tree_view_get_selection(p_treeview);
 
-        gtk_tree_selection_selected_foreach(p_selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) p_treeview);    
+        gtk_tree_selection_selected_foreach(p_selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) p_treeview);
     }
 }
 
@@ -603,7 +603,7 @@ void onAddNetworkPlaylist(GtkButton *button, gpointer user_data)
     if (b_network_transcode)
     {
         msg_Dbg( p_intf, "Network transcode option selected." );
-        onAddTranscodeToPlaylist(GTK_WIDGET(button), (gchar *)psz_mrl_name);
+        onAddTranscodeToPlaylist(button, (gchar *)psz_mrl_name);
     }
     else
     {
@@ -648,7 +648,7 @@ void onAddCameraToPlaylist(GtkButton *button, gpointer user_data)
 
     GtkCheckButton  *p_check_v4l_transcode = NULL;
     gboolean         b_v4l_transcode;
-    
     char **ppsz_options = NULL; /* list of options */
     int  i_options=0;
     char v4l_mrl[6];
@@ -741,7 +741,7 @@ void onAddCameraToPlaylist(GtkButton *button, gpointer user_data)
     if (b_v4l_transcode)
     {
         msg_Dbg( p_intf, "Camera transcode option selected." );
-        onAddTranscodeToPlaylist(GTK_WIDGET(button), (gchar *)v4l_mrl);
+        onAddTranscodeToPlaylist(button, (gchar *)v4l_mrl);
     }
     else
     {
@@ -786,6 +786,7 @@ void onPlaylistRow(GtkTreeView *treeview, GtkTreePath *path,
         GtkTreeModel *p_model;
         GtkTreeIter   iter;
         int           i_row;
+        int           i_skip;
 
         /* This might be a directory selection */
         p_model = gtk_tree_view_get_model(treeview);
@@ -801,7 +802,8 @@ void onPlaylistRow(GtkTreeView *treeview, GtkTreePath *path,
         }
 
         gtk_tree_model_get(p_model, &iter, 2, &i_row, -1);
-        playlist_Goto( p_playlist, i_row );
+        i_skip = i_row - p_playlist->i_current_index;
+        playlist_Skip( p_playlist, i_skip );
     }
     vlc_object_release( p_playlist );
 }
@@ -831,7 +833,7 @@ void onUpdatePlaylist(GtkButton *button, gpointer user_data)
                     G_TYPE_UINT);  /* Hidden field */
         if (p_model)
         {
-            PlaylistRebuildListStore(p_model, p_playlist);
+            PlaylistRebuildListStore(p_intf, p_model, p_playlist);
             gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_model));
             g_object_unref(p_model);
         }
@@ -839,7 +841,7 @@ void onUpdatePlaylist(GtkButton *button, gpointer user_data)
     vlc_object_release( p_playlist );
 }
 
-void deleteItemFromPlaylist(gpointer data, gpointer user_data)
+static void deleteItemFromPlaylist(gpointer data, gpointer user_data)
 {
     gtk_tree_path_free((GtkTreePath*) data); // removing an item.
 }
@@ -873,7 +875,7 @@ void onDeletePlaylist(GtkButton *button, gpointer user_data)
                  */
                 p_rows = g_list_reverse( p_rows );
             }
-    
+
             for (p_node=p_rows; p_node!=NULL; p_node = p_node->next)
             {
                 GtkTreeIter iter;
@@ -887,11 +889,11 @@ void onDeletePlaylist(GtkButton *button, gpointer user_data)
                         gint item;
 
                         gtk_tree_model_get(p_model, &iter, 2, &item, -1);
-                        playlist_Delete(p_playlist, item);
+                        msg_Err( p_playlist, "PDA delete broken");
                     }
                 }
             }
-#if 0 
+#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);
@@ -905,7 +907,7 @@ void onDeletePlaylist(GtkButton *button, gpointer user_data)
                     G_TYPE_UINT);  /* Hidden field */
         if (p_store)
         {
-            PlaylistRebuildListStore(p_store, p_playlist);
+            PlaylistRebuildListStore(p_intf, p_store, p_playlist);
             gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_store));
             g_object_unref(p_store);
         }
@@ -927,9 +929,9 @@ void onClearPlaylist(GtkButton *button, gpointer user_data)
         return;
     }
 
-    for(item = p_playlist->i_size - 1; item >= 0 ;item-- )
+    for(item = playlist_CurrentSize(p_intf) - 1; item >= 0 ;item-- )
     {
-        playlist_Delete( p_playlist, item);
+        msg_Err( p_playlist, "fix pda delete" );
     }
     vlc_object_release( p_playlist );
 
@@ -1057,12 +1059,12 @@ void onAddTranscodeToPlaylist(GtkButton *button, gpointer user_data)
     p_entryVideoBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrate" );
     p_entryVideoBitrateTolerance = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrateTolerance" );
     p_entryVideoKeyFrameInterval = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoKeyFrameInterval" );
-    
     p_video_codec = gtk_entry_get_text(GTK_ENTRY(p_entryVideoCodec));
     i_video_bitrate = gtk_spin_button_get_value_as_int(p_entryVideoBitrate);
     i_video_bitrate_tolerance = gtk_spin_button_get_value_as_int(p_entryVideoBitrateTolerance);
     i_video_keyframe_interval = gtk_spin_button_get_value_as_int(p_entryVideoKeyFrameInterval);
-    
     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vcodec=%s,", (char*)p_video_codec );
     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vb=%d,", (int)i_video_bitrate );
@@ -1114,7 +1116,7 @@ void onAddTranscodeToPlaylist(GtkButton *button, gpointer user_data)
     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "mux=%s,", (char*)p_std_muxer);
     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
-    i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "url=%s", (char*)p_std_url);
+    i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "dst=%s", (char*)p_std_url);
     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
 
     if (strncasecmp( (const char*)p_std_access, "udp", 3)==0)
@@ -1154,7 +1156,7 @@ void onEntryStdAccessChanged(GtkEditable *editable, gpointer user_data)
     GtkCheckButton *p_checkSAP = NULL;
     GtkCheckButton *p_checkSLP = NULL;
     GtkEntry       *p_entryStdAccess = NULL;
-    const gchar    *p_std_access = NULL;    
+    const gchar    *p_std_access = NULL;
     gboolean        b_announce = FALSE;
 
     p_entryStdAccess = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryStdAccess" );