]> git.sesse.net Git - vlc/blobdiff - modules/gui/gtk/open.c
* all: don't use input_OffsetToTime anymore.
[vlc] / modules / gui / gtk / open.c
index c2ca5f3d699a441f4092dd43fe59f6b329dfcc91..6ae7c9497d7b887784e849cebd6ae5532a227307 100644 (file)
@@ -1,17 +1,17 @@
 /*****************************************************************************
  * gtk_open.c : functions to handle file/disc/network open widgets.
  *****************************************************************************
- * Copyright (C) 2000, 2001 VideoLAN
- * $Id: open.c,v 1.10 2003/01/21 17:00:41 fenrir Exp $
+ * Copyright (C) 2000, 2001, 2003 VideoLAN
+ * $Id$
  *
- * Authors: Samuel Hocevar <sam@zoy.org>
+ * Authors: Sam Hocevar <sam@zoy.org>
  *          Stéphane Borel <stef@via.ecp.fr>
- *      
+ *
  * 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
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 #include "playlist.h"
 #include "common.h"
 
-#include "netutils.h"
+#ifdef HAVE_CDDAX
+#define CDDA_MRL "cddax://"
+#else
+#define CDDA_MRL "cdda://"
+#endif
+
+#ifdef HAVE_VCDX
+#define VCD_MRL "vcdx://"
+#else
+#define VCD_MRL "vcdx://"
+#endif
 
 static void GtkOpenShow( intf_thread_t *, int );
 
@@ -143,15 +153,22 @@ void GtkDiscOpenDvd( GtkToggleButton * togglebutton, gpointer user_data )
     intf_thread_t * p_intf = GtkGetIntf( togglebutton );
     char *psz_device;
 
-    if( togglebutton->active
-         && (psz_device = config_GetPsz( p_intf, "dvd" )) )
+    if( togglebutton->active )
     {
-        gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "disc_dvd_use_menu" ) ) , TRUE);
+        if ( (psz_device = config_GetPsz( p_intf, "dvd" )) )
+        {
+           gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "disc_dvd_use_menu" ) ) , TRUE);
 
-        gtk_entry_set_text(
+           gtk_entry_set_text(
             GTK_ENTRY( lookup_widget( GTK_WIDGET(togglebutton),
                                       "disc_name" ) ), psz_device );
-        free( psz_device );
+           free( psz_device );
+        }
+        else
+        {
+          gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "disc_dvd_use_menu" ) ), FALSE );
+        }
+        GtkDiscOpenChanged( (GtkWidget *) togglebutton, user_data );
     }
     else
     {
@@ -164,48 +181,147 @@ void GtkDiscOpenVcd( GtkToggleButton * togglebutton, gpointer user_data )
     intf_thread_t * p_intf = GtkGetIntf( togglebutton );
     char *psz_device;
 
-    if( togglebutton->active
-         && (psz_device = config_GetPsz( p_intf, "vcd" )) )
-    {
-        gtk_entry_set_text(
+    if( togglebutton->active )
+      {
+        if ( (psz_device = config_GetPsz( p_intf, "vcd" )) )
+         {
+           gtk_entry_set_text(
             GTK_ENTRY( lookup_widget( GTK_WIDGET(togglebutton),
                                       "disc_name" ) ), psz_device );
-        free( psz_device );
-    }
+           free( psz_device );
+         } else {
+            gtk_entry_set_text(
+            GTK_ENTRY( lookup_widget( GTK_WIDGET(togglebutton),
+                                      "disc_name" ) ), "" );
+         }
+        GtkDiscOpenChanged( (GtkWidget *) togglebutton, user_data );
+      }
+}
+
+void GtkDiscOpenCDDA( GtkToggleButton * togglebutton, gpointer user_data )
+{
+    intf_thread_t * p_intf = GtkGetIntf( togglebutton );
+    char *psz_device;
+
+    if( togglebutton->active )
+      {
+        if ( (psz_device = config_GetPsz( p_intf, "cd-audio" )) )
+        {
+          gtk_entry_set_text(
+            GTK_ENTRY( lookup_widget( GTK_WIDGET(togglebutton),
+                                      "disc_name" ) ), psz_device );
+          free( psz_device );
+        } else {
+          gtk_entry_set_text(
+            GTK_ENTRY( lookup_widget( GTK_WIDGET(togglebutton),
+                                      "disc_name" ) ), "" );
+        }
+        GtkDiscOpenChanged( (GtkWidget *) togglebutton, user_data );
+      }
 }
 
 static void GtkDiscOpenChanged( GtkWidget * button, gpointer user_data )
 {
+    intf_thread_t * p_intf = GtkGetIntf( button );
     GString * p_target = g_string_new( "" );
+    GtkWidget * p_open = gtk_widget_get_toplevel( GTK_WIDGET (button) );
+    vlc_bool_t b_menus = VLC_FALSE;
+    vlc_bool_t b_chapter_menu = VLC_TRUE;
+    GtkWidget *p_label = gtk_object_get_data( GTK_OBJECT( p_open ),
+                                              "disc_title_label" );
 
-    if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button), 
+    if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
                                           "disc_dvd" ) )->active )
     {
-        if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button), "disc_dvd_use_menu" ) )->active )
+        gtk_label_set_text( GTK_LABEL( p_label ), _("Title") );
+
+        b_menus = GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
+                                               "disc_dvd_use_menu" ) )->active;
+
+        if( b_menus )
         {
             g_string_append( p_target, "dvd://" );
         }
         else
         {
-            g_string_append( p_target, "dvdold://" );
+            g_string_append( p_target, "dvdsimple://" );
         }
+
+        g_string_append( p_target,
+                         gtk_entry_get_text( GTK_ENTRY( lookup_widget(
+                                     GTK_WIDGET(button), "disc_name" ) ) ) );
+
+        if( !b_menus )
+          {
+            g_string_sprintfa( p_target, "@%i:%i",
+                               gtk_spin_button_get_value_as_int(
+                                GTK_SPIN_BUTTON( lookup_widget(
+                                    GTK_WIDGET(button), "disc_title" ) ) ),
+                               gtk_spin_button_get_value_as_int(
+                                GTK_SPIN_BUTTON( lookup_widget(
+                                    GTK_WIDGET(button), "disc_chapter" ) ) ) );
+          }
     }
     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
                                                "disc_vcd" ) )->active )
     {
-        g_string_append( p_target, "vcd://" );
-    }       
+        int i = gtk_spin_button_get_value_as_int(
+                           GTK_SPIN_BUTTON( lookup_widget(
+                           GTK_WIDGET(button), "disc_title" ) ) );
 
-    g_string_append( p_target,
+#ifdef HAVE_VCDX
+        int i_pbc = config_GetInt( p_intf, "vcdx-PBC"  );
+
+        gtk_label_set_text( GTK_LABEL( p_label ),
+                            i_pbc ? _("PBC LID") : _("Entry") );
+
+        g_string_append( p_target, VCD_MRL );
+        g_string_append( p_target,
+                         gtk_entry_get_text( GTK_ENTRY( lookup_widget(
+                         GTK_WIDGET(button), "disc_name" ) ) ) );
+
+        if ( i )
+          g_string_sprintfa( p_target, "@%c%d", i_pbc ? 'P' : 'E', i );
+
+#else
+        gtk_label_set_text( GTK_LABEL( p_label ), _("Track") );
+        g_string_append( p_target, VCD_MRL );
+        g_string_sprintfa( p_target, "@%d", i );
+#endif /* HAVE_VCDX */
+        b_chapter_menu = VLC_FALSE;
+    }
+
+    else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
+                                               "disc_cdda" ) )->active )
+    {
+        int i = gtk_spin_button_get_value_as_int(
+                           GTK_SPIN_BUTTON( lookup_widget(
+                           GTK_WIDGET(button), "disc_title" ) ) );
+
+        gtk_label_set_text( GTK_LABEL( p_label ), _("Track") );
+        b_chapter_menu = VLC_FALSE;
+
+        g_string_append( p_target, CDDA_MRL );
+        g_string_append( p_target,
                      gtk_entry_get_text( GTK_ENTRY( lookup_widget(
                                      GTK_WIDGET(button), "disc_name" ) ) ) );
-    g_string_sprintfa( p_target, "@%i,%i",
-                       gtk_spin_button_get_value_as_int(
-                              GTK_SPIN_BUTTON( lookup_widget(
-                                  GTK_WIDGET(button), "disc_title" ) ) ),
-                       gtk_spin_button_get_value_as_int(
-                              GTK_SPIN_BUTTON( lookup_widget(
-                                  GTK_WIDGET(button), "disc_chapter" ) ) ) );
+#ifdef HAVE_CDDAX
+        if ( i )
+          g_string_sprintfa( p_target, "@T%i", i );
+#else
+        g_string_sprintfa( p_target, "@%i", i );
+
+#endif
+    }
+
+    gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
+                    "disc_title_label" ), !b_menus );
+    gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
+                    "disc_title" ), !b_menus );
+    gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
+                    "disc_chapter_label" ), b_chapter_menu && !b_menus );
+    gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
+                    "disc_chapter" ), b_chapter_menu && !b_menus );
 
     gtk_entry_set_text( GTK_ENTRY( lookup_widget(
                                    GTK_WIDGET(button), "entry_open" ) ),
@@ -228,16 +344,9 @@ gboolean GtkNetworkOpenShow( GtkWidget       *widget,
 
 static void GtkNetworkOpenChanged( GtkWidget *button, gpointer user_data )
 {
-    intf_thread_t * p_intf = GtkGetIntf( button );
     GString *       p_target = g_string_new( "" );
 
     unsigned int    i_port;
-    vlc_bool_t      b_channel;
-
-    /* Manage channel server */
-    b_channel = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(
-            lookup_widget( GTK_WIDGET(button), "network_channel" ) ) );
-    config_PutInt( p_intf, "network-channel", b_channel );
 
 #define SELECTED( s ) GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button), \
                        (s) ) )->active
@@ -267,30 +376,6 @@ static void GtkNetworkOpenChanged( GtkWidget *button, gpointer user_data )
             g_string_sprintfa( p_target, ":%i", i_port );
         }
     }
-    else if( SELECTED( "network_channel" ) )
-    {
-        char *          psz_channel;
-        unsigned int    i_channel_port;
-
-        if( p_intf->p_vlc->p_channel == NULL )
-        {
-            network_ChannelCreate( p_intf );
-        }
-
-        psz_channel = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
-                        GTK_WIDGET(button), "network_channel_address" ) ) );
-        i_channel_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
-            lookup_widget( GTK_WIDGET(button), "network_channel_port" ) ) );
-
-        config_PutPsz( p_intf, "channel-server", psz_channel );
-        if( i_channel_port < 65536 )
-        {
-            config_PutInt( p_intf, "channel-port", i_channel_port );
-        }
-
-        /* FIXME: we should use a playlist server instead */
-        g_string_append( p_target, "udp://" );
-    }
     else if( SELECTED( "network_http" ) )
     {
         g_string_assign( p_target,
@@ -344,33 +429,9 @@ void GtkNetworkOpenMulticast( GtkToggleButton *togglebutton,
     GtkNetworkOpenChanged( GTK_WIDGET( togglebutton ), user_data );
 }
 
-
-void GtkNetworkOpenChannel( GtkToggleButton *togglebutton,
-                                       gpointer user_data )
-{
-    GtkWidget *     p_open;
-
-    p_open = gtk_widget_get_toplevel( GTK_WIDGET (togglebutton) );
-    gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
-                    "network_channel_address_label" ),
-                    gtk_toggle_button_get_active( togglebutton ) );
-    gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
-                    "network_channel_address_combo" ),
-                    gtk_toggle_button_get_active( togglebutton ) );
-
-    gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
-                    "network_channel_port_label" ),
-                    gtk_toggle_button_get_active( togglebutton ) );
-    gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
-                    "network_channel_port" ),
-                    gtk_toggle_button_get_active( togglebutton ) );
-
-    GtkNetworkOpenChanged( GTK_WIDGET( togglebutton ), user_data );
-}
-
 void GtkNetworkOpenHTTP( GtkToggleButton *togglebutton,
                                          gpointer user_data )
-{   
+{
     GtkWidget *     p_open;
 
     p_open = gtk_widget_get_toplevel( GTK_WIDGET (togglebutton) );
@@ -407,7 +468,7 @@ static void GtkSatOpenChanged( GtkWidget * button, gpointer user_data )
                                   GTK_WIDGET(button), "sat_freq" ) ) ),
                        !GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET( button ),
                                                "sat_pol_vert" ) )->active,
-                       strtol( gtk_entry_get_text( GTK_ENTRY( GTK_COMBO( 
+                       strtol( gtk_entry_get_text( GTK_ENTRY( GTK_COMBO(
                                lookup_widget( GTK_WIDGET( button ), "sat_fec" )
                                )->entry ) ), NULL, 10 ),
                        gtk_spin_button_get_value_as_int(
@@ -453,6 +514,28 @@ GtkOpenSubtitleShow                    (GtkButton       *button,
     }
 }
 
+/*****************************************************************************
+ * Open sout callbacks
+ *****************************************************************************
+ * The following callbacks are related to the sout
+ *****************************************************************************/
+
+void GtkOpenSoutShow  ( GtkButton       *button,
+                        gpointer         user_data)
+{
+    intf_thread_t * p_intf = GtkGetIntf( button );
+
+    if( GTK_TOGGLE_BUTTON( button )->active )
+    {
+        gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "sout_settings" ) ), TRUE );
+    }
+    else
+    {
+        gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "sout_settings" ) ), FALSE );
+    }
+
+}
+
 /******************************
   ******************************/
 
@@ -472,7 +555,7 @@ static void GtkOpenShow( intf_thread_t *p_intf, int i_page )
                          "p_intf", p_intf );
 
     /* FileOpen stuff */
-    psz_var = config_GetPsz( p_intf, "search-path" );
+    psz_var = config_GetPsz( p_intf, MODULE_STRING"-search-path" );
     if( psz_var )
     {
         gtk_file_selection_set_filename( GTK_FILE_SELECTION(
@@ -495,27 +578,11 @@ static void GtkOpenShow( intf_thread_t *p_intf, int i_page )
         GTK_OBJECT( p_intf->p_sys->p_open ), "network_udp_port" ) ),
         config_GetInt( p_intf, "server-port" ) );
 
-    psz_var = config_GetPsz( p_intf, "channel-server" );
-    if( psz_var )
-    {
-        gtk_entry_set_text( GTK_ENTRY( gtk_object_get_data(
-            GTK_OBJECT( p_intf->p_sys->p_open ), "network_channel_address" ) ),
-            psz_var );
-        free( psz_var );
-    }
-
     gtk_entry_set_text( GTK_ENTRY( gtk_object_get_data(
         GTK_OBJECT( p_intf->p_sys->p_open ), "network_http_url" ) ),
         "http://" );
 
-    gtk_spin_button_set_value( GTK_SPIN_BUTTON( gtk_object_get_data(
-        GTK_OBJECT( p_intf->p_sys->p_open ), "network_channel_port" ) ),
-        config_GetInt( p_intf, "channel-port" ) );
-
-    gtk_toggle_button_set_active( gtk_object_get_data(
-        GTK_OBJECT( p_intf->p_sys->p_open ), "network_channel" ),
-        config_GetInt( p_intf, "network-channel" ) );
-
+#ifdef HAVE_SATELLITE
     /* Satellite stuff */
     psz_var = config_GetPsz( p_intf, "frequency" );
     if( psz_var )
@@ -534,10 +601,24 @@ static void GtkOpenShow( intf_thread_t *p_intf, int i_page )
             psz_var );
         free( psz_var );
     }
+#endif /*HAVE_SATELITE*/
 
     /* subtitle stuff */
     /* hide hbox_subtitle */
     gtk_widget_hide_all( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "hbox_subtitle" ) ) );
+    /* sout */
+    psz_var = config_GetPsz( p_intf, "sout" );
+    if( psz_var && *psz_var )
+    {
+        gtk_toggle_button_set_active(  gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "show_sout_settings" ), TRUE );
+        gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "sout_settings" ) ), TRUE );
+    }
+    else
+    {
+        gtk_toggle_button_set_active(  gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "show_sout_settings" ), FALSE );
+        gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "sout_settings" ) ), FALSE );
+    }
+    if( psz_var ) free( psz_var );
 
     /* Set the right page */
 setpage:
@@ -569,7 +650,7 @@ void GtkOpenOk( GtkButton * button, gpointer user_data )
 
     psz_target = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
                                        GTK_WIDGET(button), "entry_open" ) ) );
-    playlist_Add( p_playlist, (char*)psz_target,
+    playlist_Add( p_playlist, (char*)psz_target, (char*)psz_target,
                   PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
 
     /* catch the GTK CList */
@@ -601,35 +682,19 @@ void GtkOpenOk( GtkButton * button, gpointer user_data )
     {
         config_PutPsz( p_intf, "sub-file", "" );
     }
-
-    /* Enable the channel box when network channel is selected */
+    /* export sout */
     if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
-                                               "network_channel" ) )->active )
+                           "show_sout_settings" ) )->active )
     {
-        GtkWidget *     p_network_box;
-        GtkWidget *     p_channel;
-        GtkWidget *     p_label;
-
-        p_network_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
-                        p_intf->p_sys->p_window ), "network_box" ) );
-        gtk_widget_show( GTK_WIDGET( p_network_box ) );
-        p_label = gtk_object_get_data( GTK_OBJECT(
-                   p_intf->p_sys->p_window ),
-                   "label_status" );
-        gtk_widget_hide( GTK_WIDGET( p_label ) );
-
-        p_channel = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
-                   p_intf->p_sys->p_window ), "network_channel_box" ) );
-        if( config_GetInt( p_intf, "network-channel" ) )
-        {
-            gtk_widget_show( GTK_WIDGET( p_channel ) );
-        }
-        else
-        {
-            gtk_widget_hide( GTK_WIDGET( p_channel ) );
-        }
+        char    *psz_sout;
+
+        psz_sout = gtk_entry_get_text( GTK_ENTRY( lookup_widget( GTK_WIDGET( p_intf->p_sys->p_sout ), "sout_entry_target" ) ) );
+        config_PutPsz( p_intf, "sout", psz_sout );
+    }
+    else
+    {
+        config_PutPsz( p_intf, "sout", "" );
     }
-    
 }
 
 void GtkOpenCancel( GtkButton * button, gpointer user_data )