]> 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 a3370901224c6d2a1a77005f47af726bb99b577e..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.3 2002/09/30 11:05:39 sam 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 );
 
@@ -67,6 +77,10 @@ void GtkFileShow( GtkButton * button, gpointer user_data )
     gtk_object_set_data( GTK_OBJECT(p_file), "p_intf",
                          GtkGetIntf( button ) );
 
+    /* entry <- entry_file or entry_subtitle */
+    gtk_object_set_data( GTK_OBJECT(p_file), "entry",
+                         user_data );
+
     gtk_widget_show( p_file );
     gdk_window_raise( p_file->window );
 }
@@ -75,14 +89,16 @@ void GtkFileOk( GtkButton * button, gpointer user_data )
 {
     GtkWidget * p_file = gtk_widget_get_toplevel( GTK_WIDGET (button) );
 
+    char *psz_entry;
     char *psz_filename;
     intf_thread_t * p_intf = GtkGetIntf( button );
 
     /* add the new file to the dialog box */
+    psz_entry = gtk_object_get_data( GTK_OBJECT( p_file ), "entry" );
     psz_filename =
             gtk_file_selection_get_filename( GTK_FILE_SELECTION( p_file ) );
     gtk_entry_set_text( GTK_ENTRY( lookup_widget( p_intf->p_sys->p_open,
-                                                  "entry_file" ) ),
+                                                  psz_entry ) ),
                         psz_filename );
     gtk_widget_destroy( p_file );
 }
@@ -137,13 +153,26 @@ 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_entry_set_text(
+        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( 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
+    {
+        gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "disc_dvd_use_menu" ) ), FALSE );
     }
 }
 
@@ -152,41 +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 )
     {
-        g_string_append( p_target, "dvd://" );
+        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, "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" ) ),
@@ -209,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
@@ -248,34 +376,10 @@ 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_sprintfa( p_target, "http://%s",
-                           gtk_entry_get_text( GTK_ENTRY( lookup_widget(
+        g_string_assign( p_target,
+                         gtk_entry_get_text( GTK_ENTRY( lookup_widget(
                                GTK_WIDGET(button), "network_http_url" ) ) ) );
     }
 
@@ -325,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) );
@@ -388,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(
@@ -411,6 +491,51 @@ GtkSatOpenToggle                       (GtkToggleButton *togglebutton,
     }
 }
 
+/*****************************************************************************
+ * Open subtitle callbacks
+ *****************************************************************************
+ * The following callbacks are related to the subtitle
+ *****************************************************************************/
+void
+GtkOpenSubtitleShow                    (GtkButton       *button,
+                                        gpointer         user_data)
+{
+    intf_thread_t * p_intf = GtkGetIntf( button );
+
+    if( GTK_TOGGLE_BUTTON( button )->active )
+    {
+        /* show hbox_subtitle */
+        gtk_widget_show_all( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "hbox_subtitle" ) ) );
+    }
+    else
+    {
+        /* hide hbox_subtitle */
+        gtk_widget_hide_all( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "hbox_subtitle" ) ) );
+    }
+}
+
+/*****************************************************************************
+ * 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 );
+    }
+
+}
+
 /******************************
   ******************************/
 
@@ -430,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(
@@ -453,23 +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_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" ) );
+    gtk_entry_set_text( GTK_ENTRY( gtk_object_get_data(
+        GTK_OBJECT( p_intf->p_sys->p_open ), "network_http_url" ) ),
+        "http://" );
 
+#ifdef HAVE_SATELLITE
     /* Satellite stuff */
     psz_var = config_GetPsz( p_intf, "frequency" );
     if( psz_var )
@@ -488,6 +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:
@@ -519,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 */
@@ -529,6 +660,41 @@ void GtkOpenOk( GtkButton * button, gpointer user_data )
     GtkRebuildCList( p_playlist_clist, p_playlist );
 
     vlc_object_release( p_playlist );
+
+    /* export subtitle */
+    if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
+                           "show_subtitle" ) )->active )
+    {
+        /* yeah subtitle */
+        char    *psz_subtitle;
+        gfloat  delay;
+        gfloat  fps;
+
+        psz_subtitle = gtk_entry_get_text( GTK_ENTRY( lookup_widget( GTK_WIDGET(button), "entry_subtitle" ) ) );
+        delay = gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( lookup_widget( GTK_WIDGET(button), "subtitle_delay" ) ) );
+        fps = gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( lookup_widget( GTK_WIDGET(button), "subtitle_fps" ) ) );
+
+        config_PutPsz( p_intf, "sub-file", psz_subtitle );
+        config_PutInt( p_intf, "sub-delay", (int)( delay * 10 ) );
+        config_PutFloat( p_intf, "sub-fps", fps );
+    }
+    else
+    {
+        config_PutPsz( p_intf, "sub-file", "" );
+    }
+    /* export sout */
+    if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
+                           "show_sout_settings" ) )->active )
+    {
+        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 )