open.c
上传用户:riyaled888
上传日期:2009-03-27
资源大小:7338k
文件大小:26k
源码类别:

多媒体

开发平台:

MultiPlatform

  1. /*****************************************************************************
  2.  * gtk_open.c : functions to handle file/disc/network open widgets.
  3.  *****************************************************************************
  4.  * Copyright (C) 2000, 2001, 2003 VideoLAN
  5.  * $Id: open.c 7822 2004-05-30 09:18:59Z gbazin $
  6.  *
  7.  * Authors: Sam Hocevar <sam@zoy.org>
  8.  *          St閜hane Borel <stef@via.ecp.fr>
  9.  *
  10.  * This program is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License as published by
  12.  * the Free Software Foundation; either version 2 of the License, or
  13.  * (at your option) any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to the Free Software
  22.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  23.  *****************************************************************************/
  24. /*****************************************************************************
  25.  * Preamble
  26.  *****************************************************************************/
  27. #include <sys/types.h>                                              /* off_t */
  28. #include <stdlib.h>
  29. #include <vlc/vlc.h>
  30. #include <vlc/intf.h>
  31. #ifdef MODULE_NAME_IS_gnome
  32. #   include <gnome.h>
  33. #else
  34. #   include <gtk/gtk.h>
  35. #endif
  36. #include <string.h>
  37. #include "gtk_callbacks.h"
  38. #include "gtk_interface.h"
  39. #include "gtk_support.h"
  40. #include "playlist.h"
  41. #include "common.h"
  42. #ifdef HAVE_CDDAX
  43. #define CDDA_MRL "cddax://"
  44. #else
  45. #define CDDA_MRL "cdda://"
  46. #endif
  47. #ifdef HAVE_VCDX
  48. #define VCD_MRL "vcdx://"
  49. #else
  50. #define VCD_MRL "vcdx://"
  51. #endif
  52. static void GtkOpenShow( intf_thread_t *, int );
  53. static void GtkFileOpenChanged    ( GtkWidget *, gpointer );
  54. static void GtkDiscOpenChanged    ( GtkWidget *, gpointer );
  55. static void GtkNetworkOpenChanged ( GtkWidget *, gpointer );
  56. static void GtkSatOpenChanged     ( GtkWidget *, gpointer );
  57. /*****************************************************************************
  58.  * File requester callbacks
  59.  *****************************************************************************
  60.  * The following callbacks are related to the file requester.
  61.  *****************************************************************************/
  62. void GtkFileShow( GtkButton * button, gpointer user_data )
  63. {
  64.     GtkWidget * p_file = create_intf_file();
  65.     gtk_object_set_data( GTK_OBJECT(p_file), "p_intf",
  66.                          GtkGetIntf( button ) );
  67.     /* entry <- entry_file or entry_subtitle */
  68.     gtk_object_set_data( GTK_OBJECT(p_file), "entry",
  69.                          user_data );
  70.     gtk_widget_show( p_file );
  71.     gdk_window_raise( p_file->window );
  72. }
  73. void GtkFileOk( GtkButton * button, gpointer user_data )
  74. {
  75.     GtkWidget * p_file = gtk_widget_get_toplevel( GTK_WIDGET (button) );
  76.     char *psz_entry;
  77.     char *psz_filename;
  78.     intf_thread_t * p_intf = GtkGetIntf( button );
  79.     /* add the new file to the dialog box */
  80.     psz_entry = gtk_object_get_data( GTK_OBJECT( p_file ), "entry" );
  81.     psz_filename =
  82.             gtk_file_selection_get_filename( GTK_FILE_SELECTION( p_file ) );
  83.     gtk_entry_set_text( GTK_ENTRY( lookup_widget( p_intf->p_sys->p_open,
  84.                                                   psz_entry ) ),
  85.                         psz_filename );
  86.     gtk_widget_destroy( p_file );
  87. }
  88. void GtkFileCancel( GtkButton * button, gpointer user_data )
  89. {
  90.     gtk_widget_destroy( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
  91. }
  92. /*****************************************************************************
  93.  * Open file callbacks
  94.  *****************************************************************************
  95.  * The following callbacks are related to the file tab.
  96.  *****************************************************************************/
  97. gboolean GtkFileOpenShow( GtkWidget       *widget,
  98.                           gpointer         user_data )
  99. {
  100.     GtkOpenShow( GtkGetIntf( widget ), 0 );
  101.     return TRUE;
  102. }
  103. static void GtkFileOpenChanged( GtkWidget * button, gpointer user_data )
  104. {
  105.     GString *       p_target;
  106.     p_target = g_string_new( "file://" );
  107.     g_string_append( p_target,
  108.                      gtk_entry_get_text( GTK_ENTRY( lookup_widget(
  109.                                      GTK_WIDGET(button), "entry_file" ) ) ) );
  110.     gtk_entry_set_text( GTK_ENTRY( lookup_widget(
  111.                                    GTK_WIDGET(button), "entry_open" ) ),
  112.                         p_target->str );
  113.     g_string_free( p_target, TRUE );
  114. }
  115. /*****************************************************************************
  116.  * Open disc callbacks
  117.  *****************************************************************************
  118.  * The following callbacks are related to the disc manager.
  119.  *****************************************************************************/
  120. gboolean GtkDiscOpenShow( GtkWidget       *widget,
  121.                           gpointer         user_data)
  122. {
  123.     GtkOpenShow( GtkGetIntf( widget ), 1 );
  124.     return TRUE;
  125. }
  126. void GtkDiscOpenDvd( GtkToggleButton * togglebutton, gpointer user_data )
  127. {
  128.     intf_thread_t * p_intf = GtkGetIntf( togglebutton );
  129.     char *psz_device;
  130.     if( togglebutton->active )
  131.     {
  132.         if ( (psz_device = config_GetPsz( p_intf, "dvd" )) )
  133.         {
  134.            gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "disc_dvd_use_menu" ) ) , TRUE);
  135.            gtk_entry_set_text(
  136.             GTK_ENTRY( lookup_widget( GTK_WIDGET(togglebutton),
  137.                                       "disc_name" ) ), psz_device );
  138.            free( psz_device );
  139.         }
  140.         else
  141.         {
  142.           gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "disc_dvd_use_menu" ) ), FALSE );
  143.         }
  144.         GtkDiscOpenChanged( (GtkWidget *) togglebutton, user_data );
  145.     }
  146.     else
  147.     {
  148.         gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "disc_dvd_use_menu" ) ), FALSE );
  149.     }
  150. }
  151. void GtkDiscOpenVcd( GtkToggleButton * togglebutton, gpointer user_data )
  152. {
  153.     intf_thread_t * p_intf = GtkGetIntf( togglebutton );
  154.     char *psz_device;
  155.     if( togglebutton->active )
  156.       {
  157.         if ( (psz_device = config_GetPsz( p_intf, "vcd" )) )
  158.          {
  159.            gtk_entry_set_text(
  160.             GTK_ENTRY( lookup_widget( GTK_WIDGET(togglebutton),
  161.                                       "disc_name" ) ), psz_device );
  162.            free( psz_device );
  163.          } else {
  164.             gtk_entry_set_text(
  165.             GTK_ENTRY( lookup_widget( GTK_WIDGET(togglebutton),
  166.                                       "disc_name" ) ), "" );
  167.          }
  168.         GtkDiscOpenChanged( (GtkWidget *) togglebutton, user_data );
  169.       }
  170. }
  171. void GtkDiscOpenCDDA( GtkToggleButton * togglebutton, gpointer user_data )
  172. {
  173.     intf_thread_t * p_intf = GtkGetIntf( togglebutton );
  174.     char *psz_device;
  175.     if( togglebutton->active )
  176.       {
  177.         if ( (psz_device = config_GetPsz( p_intf, "cd-audio" )) )
  178.         {
  179.           gtk_entry_set_text(
  180.             GTK_ENTRY( lookup_widget( GTK_WIDGET(togglebutton),
  181.                                       "disc_name" ) ), psz_device );
  182.           free( psz_device );
  183.         } else {
  184.           gtk_entry_set_text(
  185.             GTK_ENTRY( lookup_widget( GTK_WIDGET(togglebutton),
  186.                                       "disc_name" ) ), "" );
  187.         }
  188.         GtkDiscOpenChanged( (GtkWidget *) togglebutton, user_data );
  189.       }
  190. }
  191. static void GtkDiscOpenChanged( GtkWidget * button, gpointer user_data )
  192. {
  193.     intf_thread_t * p_intf = GtkGetIntf( button );
  194.     GString * p_target = g_string_new( "" );
  195.     GtkWidget * p_open = gtk_widget_get_toplevel( GTK_WIDGET (button) );
  196.     vlc_bool_t b_menus = VLC_FALSE;
  197.     vlc_bool_t b_chapter_menu = VLC_TRUE;
  198.     GtkWidget *p_label = gtk_object_get_data( GTK_OBJECT( p_open ),
  199.                                               "disc_title_label" );
  200.     if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
  201.                                           "disc_dvd" ) )->active )
  202.     {
  203.         gtk_label_set_text( GTK_LABEL( p_label ), _("Title") );
  204.         b_menus = GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
  205.                                                "disc_dvd_use_menu" ) )->active;
  206.         if( b_menus )
  207.         {
  208.             g_string_append( p_target, "dvd://" );
  209.         }
  210.         else
  211.         {
  212.             g_string_append( p_target, "dvdsimple://" );
  213.         }
  214.         g_string_append( p_target,
  215.                          gtk_entry_get_text( GTK_ENTRY( lookup_widget(
  216.                                      GTK_WIDGET(button), "disc_name" ) ) ) );
  217.         if( !b_menus )
  218.           {
  219.             g_string_sprintfa( p_target, "@%i:%i",
  220.                                gtk_spin_button_get_value_as_int(
  221.                                 GTK_SPIN_BUTTON( lookup_widget(
  222.                                     GTK_WIDGET(button), "disc_title" ) ) ),
  223.                                gtk_spin_button_get_value_as_int(
  224.                                 GTK_SPIN_BUTTON( lookup_widget(
  225.                                     GTK_WIDGET(button), "disc_chapter" ) ) ) );
  226.           }
  227.     }
  228.     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
  229.                                                "disc_vcd" ) )->active )
  230.     {
  231.         int i = gtk_spin_button_get_value_as_int(
  232.                            GTK_SPIN_BUTTON( lookup_widget(
  233.                            GTK_WIDGET(button), "disc_title" ) ) );
  234. #ifdef HAVE_VCDX
  235.         int i_pbc = config_GetInt( p_intf, "vcdx-PBC"  );
  236.         gtk_label_set_text( GTK_LABEL( p_label ),
  237.                             i_pbc ? _("PBC LID") : _("Entry") );
  238.         g_string_append( p_target, VCD_MRL );
  239.         g_string_append( p_target,
  240.                          gtk_entry_get_text( GTK_ENTRY( lookup_widget(
  241.                          GTK_WIDGET(button), "disc_name" ) ) ) );
  242.         if ( i )
  243.           g_string_sprintfa( p_target, "@%c%d", i_pbc ? 'P' : 'E', i );
  244. #else
  245.         gtk_label_set_text( GTK_LABEL( p_label ), _("Track") );
  246.         g_string_append( p_target, VCD_MRL );
  247.         g_string_sprintfa( p_target, "@%d", i );
  248. #endif /* HAVE_VCDX */
  249.         b_chapter_menu = VLC_FALSE;
  250.     }
  251.     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
  252.                                                "disc_cdda" ) )->active )
  253.     {
  254.         int i = gtk_spin_button_get_value_as_int(
  255.                            GTK_SPIN_BUTTON( lookup_widget(
  256.                            GTK_WIDGET(button), "disc_title" ) ) );
  257.         gtk_label_set_text( GTK_LABEL( p_label ), _("Track") );
  258.         b_chapter_menu = VLC_FALSE;
  259.         g_string_append( p_target, CDDA_MRL );
  260.         g_string_append( p_target,
  261.                      gtk_entry_get_text( GTK_ENTRY( lookup_widget(
  262.                                      GTK_WIDGET(button), "disc_name" ) ) ) );
  263. #ifdef HAVE_CDDAX
  264.         if ( i )
  265.           g_string_sprintfa( p_target, "@T%i", i );
  266. #else
  267.         g_string_sprintfa( p_target, "@%i", i );
  268. #endif
  269.     }
  270.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
  271.                     "disc_title_label" ), !b_menus );
  272.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
  273.                     "disc_title" ), !b_menus );
  274.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
  275.                     "disc_chapter_label" ), b_chapter_menu && !b_menus );
  276.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
  277.                     "disc_chapter" ), b_chapter_menu && !b_menus );
  278.     gtk_entry_set_text( GTK_ENTRY( lookup_widget(
  279.                                    GTK_WIDGET(button), "entry_open" ) ),
  280.                         p_target->str );
  281.     g_string_free( p_target, TRUE );
  282. }
  283. /*****************************************************************************
  284.  * Network stream callbacks
  285.  *****************************************************************************
  286.  * The following callbacks are related to the network stream manager.
  287.  *****************************************************************************/
  288. gboolean GtkNetworkOpenShow( GtkWidget       *widget,
  289.                              gpointer         user_data )
  290. {
  291.     GtkOpenShow( GtkGetIntf( widget ), 2 );
  292.     return TRUE;
  293. }
  294. static void GtkNetworkOpenChanged( GtkWidget *button, gpointer user_data )
  295. {
  296.     GString *       p_target = g_string_new( "" );
  297.     unsigned int    i_port;
  298. #define SELECTED( s ) GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button), 
  299.                        (s) ) )->active
  300.     /* Check which option was chosen */
  301.     if( SELECTED( "network_udp" ) )
  302.     {
  303.         g_string_append( p_target, "udp://" );
  304.         i_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
  305.                                lookup_widget( GTK_WIDGET(button),
  306.                                               "network_udp_port" ) ) );
  307.         if( i_port != 1234 )
  308.         {
  309.             g_string_sprintfa( p_target, "@:%i", i_port );
  310.         }
  311.     }
  312.     else if( SELECTED( "network_multicast" ) )
  313.     {
  314.         g_string_sprintfa( p_target, "udp://@%s",
  315.                            gtk_entry_get_text( GTK_ENTRY(
  316.                             lookup_widget( GTK_WIDGET(button),
  317.                                            "network_multicast_address" ) ) ) );
  318.         i_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
  319.                                lookup_widget( GTK_WIDGET(button),
  320.                                               "network_multicast_port" ) ) );
  321.         if( i_port != 1234 )
  322.         {
  323.             g_string_sprintfa( p_target, ":%i", i_port );
  324.         }
  325.     }
  326.     else if( SELECTED( "network_http" ) )
  327.     {
  328.         g_string_assign( p_target,
  329.                          gtk_entry_get_text( GTK_ENTRY( lookup_widget(
  330.                                GTK_WIDGET(button), "network_http_url" ) ) ) );
  331.     }
  332.     gtk_entry_set_text( GTK_ENTRY( lookup_widget(
  333.                                    GTK_WIDGET(button), "entry_open" ) ),
  334.                         p_target->str );
  335.     g_string_free( p_target, TRUE );
  336. }
  337. void GtkNetworkOpenUDP( GtkToggleButton *togglebutton,
  338.                                         gpointer user_data )
  339. {
  340.     GtkWidget *     p_open;
  341.     p_open = gtk_widget_get_toplevel( GTK_WIDGET (togglebutton) );
  342.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
  343.                     "network_udp_port_label" ),
  344.                     gtk_toggle_button_get_active( togglebutton ) );
  345.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
  346.                     "network_udp_port" ),
  347.                     gtk_toggle_button_get_active( togglebutton ) );
  348.     GtkNetworkOpenChanged( GTK_WIDGET( togglebutton ), user_data );
  349. }
  350. void GtkNetworkOpenMulticast( GtkToggleButton *togglebutton,
  351.                                               gpointer user_data )
  352. {
  353.     GtkWidget *     p_open;
  354.     p_open = gtk_widget_get_toplevel( GTK_WIDGET (togglebutton) );
  355.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
  356.                     "network_multicast_address_label" ),
  357.                     gtk_toggle_button_get_active( togglebutton ) );
  358.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
  359.                     "network_multicast_address_combo" ),
  360.                     gtk_toggle_button_get_active( togglebutton ) );
  361.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
  362.                     "network_multicast_port_label" ),
  363.                     gtk_toggle_button_get_active( togglebutton ) );
  364.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
  365.                     "network_multicast_port" ),
  366.                     gtk_toggle_button_get_active( togglebutton ) );
  367.     GtkNetworkOpenChanged( GTK_WIDGET( togglebutton ), user_data );
  368. }
  369. void GtkNetworkOpenHTTP( GtkToggleButton *togglebutton,
  370.                                          gpointer user_data )
  371. {
  372.     GtkWidget *     p_open;
  373.     p_open = gtk_widget_get_toplevel( GTK_WIDGET (togglebutton) );
  374.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
  375.                     "network_http_url_label" ),
  376.                     gtk_toggle_button_get_active( togglebutton ) );
  377.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_open ),
  378.                     "network_http_url" ),
  379.                     gtk_toggle_button_get_active( togglebutton ) );
  380.     GtkNetworkOpenChanged( GTK_WIDGET( togglebutton ), user_data );
  381. }
  382. /*****************************************************************************
  383.  * Open satellite callbacks
  384.  *****************************************************************************
  385.  * The following callbacks are related to the satellite card manager.
  386.  *****************************************************************************/
  387. gboolean GtkSatOpenShow( GtkWidget       *widget,
  388.                          gpointer         user_data)
  389. {
  390.     GtkOpenShow( GtkGetIntf( widget ), 3 );
  391.     return TRUE;
  392. }
  393. static void GtkSatOpenChanged( GtkWidget * button, gpointer user_data )
  394. {
  395.     GString *       p_target = g_string_new( "" );
  396.     g_string_sprintfa( p_target, "%s://%d,%d,%ld,%d", "satellite",
  397.                        gtk_spin_button_get_value_as_int(
  398.                               GTK_SPIN_BUTTON( lookup_widget(
  399.                                   GTK_WIDGET(button), "sat_freq" ) ) ),
  400.                        !GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET( button ),
  401.                                                "sat_pol_vert" ) )->active,
  402.                        strtol( gtk_entry_get_text( GTK_ENTRY( GTK_COMBO(
  403.                                lookup_widget( GTK_WIDGET( button ), "sat_fec" )
  404.                                )->entry ) ), NULL, 10 ),
  405.                        gtk_spin_button_get_value_as_int(
  406.                               GTK_SPIN_BUTTON( lookup_widget(
  407.                                   GTK_WIDGET(button), "sat_srate" ) ) ) );
  408.     gtk_entry_set_text( GTK_ENTRY( lookup_widget(
  409.                                    GTK_WIDGET(button), "entry_open" ) ),
  410.                         p_target->str );
  411.     g_string_free( p_target, TRUE );
  412. }
  413. void
  414. GtkSatOpenToggle                       (GtkToggleButton *togglebutton,
  415.                                         gpointer         user_data)
  416. {
  417.     if( togglebutton->active )
  418.     {
  419.         GtkSatOpenChanged( GTK_WIDGET( togglebutton ), user_data );
  420.     }
  421. }
  422. /*****************************************************************************
  423.  * Open subtitle callbacks
  424.  *****************************************************************************
  425.  * The following callbacks are related to the subtitle
  426.  *****************************************************************************/
  427. void
  428. GtkOpenSubtitleShow                    (GtkButton       *button,
  429.                                         gpointer         user_data)
  430. {
  431.     intf_thread_t * p_intf = GtkGetIntf( button );
  432.     if( GTK_TOGGLE_BUTTON( button )->active )
  433.     {
  434.         /* show hbox_subtitle */
  435.         gtk_widget_show_all( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "hbox_subtitle" ) ) );
  436.     }
  437.     else
  438.     {
  439.         /* hide hbox_subtitle */
  440.         gtk_widget_hide_all( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "hbox_subtitle" ) ) );
  441.     }
  442. }
  443. /*****************************************************************************
  444.  * Open sout callbacks
  445.  *****************************************************************************
  446.  * The following callbacks are related to the sout
  447.  *****************************************************************************/
  448. void GtkOpenSoutShow  ( GtkButton       *button,
  449.                         gpointer         user_data)
  450. {
  451.     intf_thread_t * p_intf = GtkGetIntf( button );
  452.     if( GTK_TOGGLE_BUTTON( button )->active )
  453.     {
  454.         gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "sout_settings" ) ), TRUE );
  455.     }
  456.     else
  457.     {
  458.         gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "sout_settings" ) ), FALSE );
  459.     }
  460. }
  461. /******************************
  462.   ******************************/
  463. static void GtkOpenShow( intf_thread_t *p_intf, int i_page )
  464. {
  465.     char *psz_var;
  466.     GtkWidget *p_notebook;
  467.     /* If we have already created this window, do nothing */
  468.     if( GTK_IS_WIDGET( p_intf->p_sys->p_open ) )
  469.     {
  470.         goto setpage;
  471.     }
  472.     p_intf->p_sys->p_open = create_intf_open();
  473.     gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_open ),
  474.                          "p_intf", p_intf );
  475.     /* FileOpen stuff */
  476.     psz_var = config_GetPsz( p_intf, MODULE_STRING"-search-path" );
  477.     if( psz_var )
  478.     {
  479.         gtk_file_selection_set_filename( GTK_FILE_SELECTION(
  480.             p_intf->p_sys->p_open ), psz_var );
  481.         free( psz_var );
  482.     }
  483.     /* Disc stuff */
  484.     psz_var = config_GetPsz( p_intf, "dvd" );
  485.     if( psz_var )
  486.     {
  487.         gtk_entry_set_text( GTK_ENTRY( gtk_object_get_data(
  488.             GTK_OBJECT( p_intf->p_sys->p_open ), "disc_name" ) ),
  489.             psz_var );
  490.         free( psz_var );
  491.     }
  492.     /* Network stuff */
  493.     gtk_spin_button_set_value( GTK_SPIN_BUTTON( gtk_object_get_data(
  494.         GTK_OBJECT( p_intf->p_sys->p_open ), "network_udp_port" ) ),
  495.         config_GetInt( p_intf, "server-port" ) );
  496.     gtk_entry_set_text( GTK_ENTRY( gtk_object_get_data(
  497.         GTK_OBJECT( p_intf->p_sys->p_open ), "network_http_url" ) ),
  498.         "http://" );
  499. #ifdef HAVE_SATELLITE
  500.     /* Satellite stuff */
  501.     psz_var = config_GetPsz( p_intf, "frequency" );
  502.     if( psz_var )
  503.     {
  504.         gtk_entry_set_text( GTK_ENTRY( gtk_object_get_data(
  505.             GTK_OBJECT( p_intf->p_sys->p_open ), "sat_freq" ) ),
  506.             psz_var );
  507.         free( psz_var );
  508.     }
  509.     psz_var = config_GetPsz( p_intf, "symbol-rate" );
  510.     if( psz_var )
  511.     {
  512.         gtk_entry_set_text( GTK_ENTRY( gtk_object_get_data(
  513.             GTK_OBJECT( p_intf->p_sys->p_open ), "sat_srate" ) ),
  514.             psz_var );
  515.         free( psz_var );
  516.     }
  517. #endif /*HAVE_SATELITE*/
  518.     /* subtitle stuff */
  519.     /* hide hbox_subtitle */
  520.     gtk_widget_hide_all( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "hbox_subtitle" ) ) );
  521.     /* sout */
  522.     psz_var = config_GetPsz( p_intf, "sout" );
  523.     if( psz_var && *psz_var )
  524.     {
  525.         gtk_toggle_button_set_active(  gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "show_sout_settings" ), TRUE );
  526.         gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "sout_settings" ) ), TRUE );
  527.     }
  528.     else
  529.     {
  530.         gtk_toggle_button_set_active(  gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "show_sout_settings" ), FALSE );
  531.         gtk_widget_set_sensitive( GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_open ), "sout_settings" ) ), FALSE );
  532.     }
  533.     if( psz_var ) free( psz_var );
  534.     /* Set the right page */
  535. setpage:
  536.     p_notebook = lookup_widget( GTK_WIDGET( p_intf->p_sys->p_open ),
  537.                                 "open_notebook" );
  538.     gtk_notebook_set_page( GTK_NOTEBOOK( p_notebook ), i_page );
  539.     gtk_widget_show( p_intf->p_sys->p_open );
  540.     gdk_window_raise( p_intf->p_sys->p_open->window );
  541. }
  542. void GtkOpenOk( GtkButton * button, gpointer user_data )
  543. {
  544.     /* Check what was pressed */
  545.     intf_thread_t * p_intf = GtkGetIntf( button );
  546.     playlist_t *    p_playlist;
  547.     GtkCList *      p_playlist_clist;
  548.     gchar *         psz_target;
  549.     /* Hide the dialog box */
  550.     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
  551.     /* Update the playlist */
  552.     p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
  553.     if( p_playlist == NULL )
  554.     {
  555.         return;
  556.     }
  557.     psz_target = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
  558.                                        GTK_WIDGET(button), "entry_open" ) ) );
  559.     playlist_Add( p_playlist, (char*)psz_target, (char*)psz_target,
  560.                   PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
  561.     /* catch the GTK CList */
  562.     p_playlist_clist = GTK_CLIST( gtk_object_get_data(
  563.         GTK_OBJECT( p_intf->p_sys->p_playwin ), "playlist_clist" ) );
  564.     /* update the plugin display */
  565.     GtkRebuildCList( p_playlist_clist, p_playlist );
  566.     vlc_object_release( p_playlist );
  567.     /* export subtitle */
  568.     if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
  569.                            "show_subtitle" ) )->active )
  570.     {
  571.         /* yeah subtitle */
  572.         char    *psz_subtitle;
  573.         gfloat  delay;
  574.         gfloat  fps;
  575.         psz_subtitle = gtk_entry_get_text( GTK_ENTRY( lookup_widget( GTK_WIDGET(button), "entry_subtitle" ) ) );
  576.         delay = gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( lookup_widget( GTK_WIDGET(button), "subtitle_delay" ) ) );
  577.         fps = gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( lookup_widget( GTK_WIDGET(button), "subtitle_fps" ) ) );
  578.         config_PutPsz( p_intf, "sub-file", psz_subtitle );
  579.         config_PutInt( p_intf, "sub-delay", (int)( delay * 10 ) );
  580.         config_PutFloat( p_intf, "sub-fps", fps );
  581.     }
  582.     else
  583.     {
  584.         config_PutPsz( p_intf, "sub-file", "" );
  585.     }
  586.     /* export sout */
  587.     if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
  588.                            "show_sout_settings" ) )->active )
  589.     {
  590.         char    *psz_sout;
  591.         psz_sout = gtk_entry_get_text( GTK_ENTRY( lookup_widget( GTK_WIDGET( p_intf->p_sys->p_sout ), "sout_entry_target" ) ) );
  592.         config_PutPsz( p_intf, "sout", psz_sout );
  593.     }
  594.     else
  595.     {
  596.         config_PutPsz( p_intf, "sout", "" );
  597.     }
  598. }
  599. void GtkOpenCancel( GtkButton * button, gpointer user_data )
  600. {
  601.     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
  602. }
  603. void GtkOpenChanged( GtkWidget * button, gpointer user_data )
  604. {
  605.     intf_thread_t * p_intf = GtkGetIntf( button );
  606.     GtkWidget *p_notebook;
  607.     int i_page;
  608.     p_notebook = lookup_widget( GTK_WIDGET( p_intf->p_sys->p_open ),
  609.                                 "open_notebook" );
  610.     i_page = gtk_notebook_get_current_page( GTK_NOTEBOOK( p_notebook ) );
  611.     switch( i_page )
  612.     {
  613.         case 0:
  614.             GtkFileOpenChanged( button, NULL );
  615.             break;
  616.         case 1:
  617.             GtkDiscOpenChanged( button, NULL );
  618.             break;
  619.         case 2:
  620.             GtkNetworkOpenChanged( button, NULL );
  621.             break;
  622.         case 3:
  623.             GtkSatOpenChanged( button, NULL );
  624.             break;
  625.     }
  626. }