* ./src/video_output/video_output.c: fixed the "picture has invalid status"
[vlc.git] / plugins / gtk / gtk_open.c
1 /*****************************************************************************
2  * gtk_open.c : functions to handle file/disc/network open widgets.
3  *****************************************************************************
4  * Copyright (C) 2000, 2001 VideoLAN
5  * $Id: gtk_open.c,v 1.27 2002/06/02 09:03:54 sam Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *          St├ęphane 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 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include <sys/types.h>                                              /* off_t */
29 #include <stdlib.h>
30
31 #include <vlc/vlc.h>
32 #include <vlc/intf.h>
33
34 #ifdef MODULE_NAME_IS_gnome
35 #   include <gnome.h>
36 #else
37 #   include <gtk/gtk.h>
38 #endif
39
40 #include <string.h>
41
42 #include "gtk_callbacks.h"
43 #include "gtk_interface.h"
44 #include "gtk_support.h"
45 #include "gtk_playlist.h"
46 #include "gtk_common.h"
47
48 #include "netutils.h"
49
50 /*****************************************************************************
51  * Fileopen callbacks
52  *****************************************************************************
53  * The following callbacks are related to the file requester.
54  *****************************************************************************/
55 gboolean GtkFileOpenShow( GtkWidget       *widget,
56                           GdkEventButton  *event,
57                           gpointer         user_data )
58 {
59     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
60
61     /* If we have never used the file selector, open it */
62     if( !GTK_IS_WIDGET( p_intf->p_sys->p_fileopen ) )
63     {
64         char *psz_path;
65
66         p_intf->p_sys->p_fileopen = create_intf_fileopen();
67         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
68                              "p_intf", p_intf );
69
70         if( (psz_path = config_GetPsz( p_intf, "search-path" )) )
71             gtk_file_selection_set_filename( GTK_FILE_SELECTION(
72                 p_intf->p_sys->p_fileopen ), psz_path );
73         if( psz_path ) free( psz_path );
74     }
75
76     gtk_widget_show( p_intf->p_sys->p_fileopen );
77     gdk_window_raise( p_intf->p_sys->p_fileopen->window );
78
79     return TRUE;
80 }
81
82
83 void GtkFileOpenCancel( GtkButton * button, gpointer user_data )
84 {
85     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
86 }
87
88 void GtkFileOpenOk( GtkButton * button, gpointer user_data )
89 {
90     intf_thread_t * p_intf = GetIntf( GTK_WIDGET(button), "intf_fileopen" );
91     playlist_t *    p_playlist;
92     GtkCList *      p_playlist_clist;
93     GtkWidget *     p_filesel;
94     gchar *         psz_filename;
95
96     p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
97     if( p_playlist == NULL )
98     {
99         return;
100     }
101
102     /* hide the file selector */
103     p_filesel = gtk_widget_get_toplevel( GTK_WIDGET(button) );
104     gtk_widget_hide( p_filesel );
105
106     /* add the new file to the interface playlist */
107     psz_filename =
108         gtk_file_selection_get_filename( GTK_FILE_SELECTION( p_filesel ) );
109     playlist_Add( p_playlist, 0, (char*)psz_filename );
110
111     /* catch the GTK CList */
112     p_playlist_clist = GTK_CLIST( gtk_object_get_data(
113         GTK_OBJECT( p_intf->p_sys->p_playlist ), "playlist_clist" ) );
114     /* update the plugin display */
115     GtkRebuildCList( p_playlist_clist, p_playlist );
116
117     vlc_object_release( p_playlist );
118     /* end current item, select added item  */
119 #if 0
120     if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
121     {
122         p_intf->p_vlc->p_input_bank->pp_input[0]->b_eof = 1;
123     }
124
125     intf_PlaylistJumpto( p_intf->p_vlc->p_playlist, i_end - 1 );
126 #endif
127 }
128
129 /*****************************************************************************
130  * Open disc callbacks
131  *****************************************************************************
132  * The following callbacks are related to the disc manager.
133  *****************************************************************************/
134 gboolean GtkDiscOpenShow( GtkWidget       *widget,
135                           GdkEventButton  *event,
136                           gpointer         user_data)
137 {
138     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
139
140     if( !GTK_IS_WIDGET( p_intf->p_sys->p_disc ) )
141     {
142         p_intf->p_sys->p_disc = create_intf_disc();
143         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_disc ),
144                              "p_intf", p_intf );
145     }
146
147     gtk_widget_show( p_intf->p_sys->p_disc );
148     gdk_window_raise( p_intf->p_sys->p_disc->window );
149
150     return TRUE;
151 }
152
153
154 void GtkDiscOpenDvd( GtkToggleButton * togglebutton, gpointer user_data )
155 {
156     intf_thread_t * p_intf = GetIntf( GTK_WIDGET(togglebutton), "intf_disc" );
157
158     if( togglebutton->active )
159     {
160         char *psz_dvd_device;
161
162         if( (psz_dvd_device = config_GetPsz( p_intf, "dvd" )) )
163             gtk_entry_set_text(
164                 GTK_ENTRY( lookup_widget( GTK_WIDGET(togglebutton),
165                                           "disc_name" ) ), psz_dvd_device );
166         if( psz_dvd_device ) free( psz_dvd_device );
167     }
168 }
169
170 void GtkDiscOpenVcd( GtkToggleButton * togglebutton, gpointer user_data )
171 {
172     intf_thread_t * p_intf = GetIntf( GTK_WIDGET(togglebutton), "intf_disc" );
173
174     if( togglebutton->active )
175     {
176         char *psz_vcd_device;
177
178         if( (psz_vcd_device = config_GetPsz( p_intf, "vcd" )) )
179             gtk_entry_set_text(
180                 GTK_ENTRY( lookup_widget( GTK_WIDGET(togglebutton),
181                                           "disc_name" ) ), psz_vcd_device );
182         if( psz_vcd_device ) free( psz_vcd_device );
183     }
184 }
185
186 void GtkDiscOpenOk( GtkButton * button, gpointer user_data )
187 {
188     intf_thread_t * p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
189     playlist_t *    p_playlist;
190     GtkCList *      p_playlist_clist;
191     char *          psz_device, *psz_source, *psz_method;
192     int             i_title, i_chapter;
193
194     p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
195     if( p_playlist == NULL )
196     {
197         return;
198     }
199
200     gtk_widget_hide( p_intf->p_sys->p_disc );
201     psz_device = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
202                                          GTK_WIDGET(button), "disc_name" ) ) );
203
204     /* Check which method was activated */
205     if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
206                                           "disc_dvd" ) )->active )
207     {
208         psz_method = "dvd";
209     }
210     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
211                                                "disc_vcd" ) )->active )
212     {
213         psz_method = "vcd";
214     }
215     else
216     {
217         msg_Err( p_intf, "unknown disc type toggle button position" );
218         return;
219     }
220     
221     /* Select title and chapter */
222     i_title = gtk_spin_button_get_value_as_int(
223                               GTK_SPIN_BUTTON( lookup_widget(
224                                   GTK_WIDGET(button), "disc_title" ) ) );
225
226     i_chapter = gtk_spin_button_get_value_as_int(
227                               GTK_SPIN_BUTTON( lookup_widget(
228                                   GTK_WIDGET(button), "disc_chapter" ) ) );
229     
230     /* "dvd:foo" has size 5 + strlen(foo) */
231     psz_source = malloc( 3 /* "dvd" */ + 1 /* ":" */
232                            + strlen( psz_device ) + 2 /* @, */
233                            + 4 /* i_title & i_chapter < 100 */ + 1 /* "\0" */ );
234     if( psz_source == NULL )
235     {
236         return;
237     }
238
239     /* Build source name and add it to playlist */
240     sprintf( psz_source, "%s:%s@%d,%d",
241              psz_method, psz_device, i_title, i_chapter );
242     playlist_Add( p_playlist, 0, psz_source );
243     free( psz_source );
244
245     /* catch the GTK CList */
246     p_playlist_clist = GTK_CLIST( gtk_object_get_data(
247         GTK_OBJECT( p_intf->p_sys->p_playlist ), "playlist_clist" ) );
248
249     /* update the display */
250     GtkRebuildCList( p_playlist_clist, p_playlist );
251
252     /* stop current item, select added item */
253 #if 0
254     if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
255     {
256         p_intf->p_vlc->p_input_bank->pp_input[0]->b_eof = 1;
257     }
258
259     intf_PlaylistJumpto( p_intf->p_vlc->p_playlist, i_end - 1 );
260 #endif
261
262     vlc_object_release( p_playlist );
263 }
264
265
266 void GtkDiscOpenCancel( GtkButton * button, gpointer user_data )
267 {
268     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
269 }
270
271
272 /*****************************************************************************
273  * Network stream callbacks
274  *****************************************************************************
275  * The following callbacks are related to the network stream manager.
276  *****************************************************************************/
277 gboolean GtkNetworkOpenShow( GtkWidget       *widget,
278                              GdkEventButton  *event,
279                              gpointer         user_data )
280 {
281     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
282
283     if( !GTK_IS_WIDGET( p_intf->p_sys->p_network ) )
284     {
285         char *psz_channel_server;
286
287         p_intf->p_sys->p_network = create_intf_network();
288         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_network ),
289                              "p_intf", p_intf );
290
291         gtk_spin_button_set_value( GTK_SPIN_BUTTON( gtk_object_get_data(
292             GTK_OBJECT( p_intf->p_sys->p_network ), "network_udp_port" ) ),
293             config_GetInt( p_intf, "server-port" ) );
294
295         psz_channel_server = config_GetPsz( p_intf, "channel-server" );
296         if( psz_channel_server )
297             gtk_entry_set_text( GTK_ENTRY( gtk_object_get_data(
298                 GTK_OBJECT( p_intf->p_sys->p_network ), "network_channel_address" ) ),
299                 psz_channel_server );
300         if( psz_channel_server ) free( psz_channel_server );
301
302         gtk_spin_button_set_value( GTK_SPIN_BUTTON( gtk_object_get_data(
303             GTK_OBJECT( p_intf->p_sys->p_network ), "network_channel_port" ) ),
304             config_GetInt( p_intf, "channel-port" ) );
305
306         gtk_toggle_button_set_active( gtk_object_get_data( GTK_OBJECT(
307             p_intf->p_sys->p_network ), "network_channel" ),
308             config_GetInt( p_intf, "network-channel" ) );
309     }
310
311     gtk_widget_show( p_intf->p_sys->p_network );
312     gdk_window_raise( p_intf->p_sys->p_network->window );
313
314     return TRUE;
315 }
316
317
318 void GtkNetworkOpenOk( GtkButton *button, gpointer user_data )
319 {
320     intf_thread_t * p_intf = GetIntf( GTK_WIDGET(button), "intf_network" );
321     playlist_t *    p_playlist;
322     GtkCList *      p_playlist_clist;
323     char *          psz_source, *psz_address;
324     unsigned int    i_port;
325     vlc_bool_t      b_channel;
326
327     p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
328     if( p_playlist == NULL )
329     {
330         return;
331     }
332
333     gtk_widget_hide( p_intf->p_sys->p_network );
334 //    psz_server = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
335 //                                 GTK_WIDGET(button), "network_server" ) ) );
336
337     /* select added item */
338 #if 0
339     if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
340     {
341         p_intf->p_vlc->p_input_bank->pp_input[0]->b_eof = 1;
342     }
343 #endif
344
345     /* Manage channel server */
346     b_channel = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(
347             lookup_widget( GTK_WIDGET(button), "network_channel" ) ) );
348     config_PutInt( p_intf, "network-channel", b_channel );
349
350     /* Check which option was chosen */
351     /* UDP */
352     if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
353                                           "network_udp" ) )->active )
354     {
355         /* No address in UDP mode */
356         psz_address = "";
357
358         /* Get the port number and make sure it will not
359          * overflow 5 characters */
360         i_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
361              lookup_widget( GTK_WIDGET(button), "network_udp_port" ) ) );
362         if( i_port > 65535 )
363         {
364             msg_Err( p_intf, "invalid port %i", i_port );
365         }
366  
367         /* Allocate room for "protocol:@:port" */
368         psz_source = malloc( 5 /* "udp:@" */ + 1 /* ":" */
369                              + 5 /* 0-65535 */ + 1 /* "\0" */ );
370         if( psz_source == NULL )
371         {
372             return;
373         }
374
375         /* Build source name and add it to playlist */
376         sprintf( psz_source, "udp:@:%i", i_port );
377
378         playlist_Add( p_playlist, 0, psz_source );
379         free( psz_source );
380
381         /* catch the GTK CList */
382         p_playlist_clist = GTK_CLIST( gtk_object_get_data(
383             GTK_OBJECT( p_intf->p_sys->p_playlist ), "playlist_clist" ) );
384         /* update the display */
385         GtkRebuildCList( p_playlist_clist, p_playlist );
386
387 #if 0
388         intf_PlaylistJumpto( p_playlist, i_end - 1 );
389 #endif
390     }
391
392     /* UDP Multicast */
393     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
394                                                "network_multicast" ) )->active )
395     {
396         /* get the address */
397         psz_address = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
398                         GTK_WIDGET(button), "network_multicast_address" ) ) );
399  
400         /* Get the port number and make sure it will not
401          * overflow 5 characters */
402         i_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
403              lookup_widget( GTK_WIDGET(button), "network_multicast_port" ) ) );
404         if( i_port > 65535 )
405         {
406             msg_Err( p_intf, "invalid port %i", i_port );
407         }
408  
409         /* Allocate room for "protocol:@address:port" */
410         psz_source = malloc( 5 /* "udp:@" */
411                              + strlen( psz_address ) + 1 /* ":" */
412                              + 5 /* 0-65535 */ + 1 /* "\0" */ );
413         if( psz_source == NULL )
414         {
415             return;
416         }
417
418         /* Build source name and add it to playlist */
419         sprintf( psz_source, "udp:@%s:%i", psz_address, i_port );
420
421         playlist_Add( p_playlist, 0, psz_source );
422         free( psz_source );
423
424         /* catch the GTK CList */
425         p_playlist_clist = GTK_CLIST( gtk_object_get_data(
426             GTK_OBJECT( p_intf->p_sys->p_playlist ), "playlist_clist" ) );
427         /* update the display */
428         GtkRebuildCList( p_playlist_clist, p_playlist );
429
430 #if 0
431         intf_PlaylistJumpto( p_playlist, i_end - 1 );
432 #endif
433     }
434     
435     /* Channel server */
436     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
437                                                "network_channel" ) )->active )
438     {
439         char *          psz_channel;
440         unsigned int    i_channel_port;
441
442         if( p_intf->p_vlc->p_channel == NULL )
443         {
444             network_ChannelCreate( p_intf );
445         }
446
447         psz_channel = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
448                         GTK_WIDGET(button), "network_channel_address" ) ) );
449         i_channel_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
450             lookup_widget( GTK_WIDGET(button), "network_channel_port" ) ) );
451
452         config_PutPsz( p_intf, "channel-server", psz_channel );
453         if( i_channel_port < 65536 )
454         {
455             config_PutInt( p_intf, "channel-port", i_channel_port );
456         }
457
458         p_intf->p_sys->b_playing = 1;
459     }
460     
461     /* HTTP */
462     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
463                                                "network_http" ) )->active )
464     {
465         /* get the url */
466         psz_address = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
467                         GTK_WIDGET(button), "network_http_url" ) ) );
468
469         /* Allocate room for "protocol://url" */
470         psz_source = malloc( 7 /* "http://" */
471                              + strlen( psz_address ) + 1 /* "\0" */ );
472         if( psz_source == NULL )
473         {
474             return;
475         }
476
477         /* Build source name and add it to playlist */
478         sprintf( psz_source, "http://%s", psz_address );
479
480         playlist_Add( p_playlist, 0, psz_source );
481         free( psz_source );
482
483         /* catch the GTK CList */
484         p_playlist_clist = GTK_CLIST( gtk_object_get_data(
485             GTK_OBJECT( p_intf->p_sys->p_playlist ), "playlist_clist" ) );
486         /* update the display */
487         GtkRebuildCList( p_playlist_clist, p_playlist );
488
489 #if 0
490         intf_PlaylistJumpto( p_playlist, i_end - 1 );
491 #endif
492     }
493
494     /* This shouldn't occur */
495     else
496     {
497         msg_Err( p_intf, "unknown protocol toggle button position" );
498         return;
499     }
500
501     /* add the item to the playlist if the channel server wasn't chosen */
502     if( !b_channel )
503     {
504     }
505
506     vlc_object_release( p_playlist );
507 }
508
509 void GtkNetworkOpenCancel( GtkButton * button, gpointer user_data)
510 {
511     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
512 }
513
514
515 void GtkNetworkOpenUDP( GtkToggleButton *togglebutton,
516                                         gpointer user_data )
517 {
518     GtkWidget *     p_network;
519
520     p_network = gtk_widget_get_toplevel( GTK_WIDGET (togglebutton) );
521
522     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_network ),
523                     "network_udp_port_label" ),
524                     gtk_toggle_button_get_active( togglebutton ) );
525     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_network ),
526                     "network_udp_port" ),
527                     gtk_toggle_button_get_active( togglebutton ) );
528 }
529
530
531 void GtkNetworkOpenMulticast( GtkToggleButton *togglebutton,
532                                               gpointer user_data )
533 {
534     GtkWidget *     p_network;
535
536     p_network = gtk_widget_get_toplevel( GTK_WIDGET (togglebutton) );
537     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_network ),
538                     "network_multicast_address_label" ),
539                     gtk_toggle_button_get_active( togglebutton ) );
540     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_network ),
541                     "network_multicast_address_combo" ),
542                     gtk_toggle_button_get_active( togglebutton ) );
543
544     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_network ),
545                     "network_multicast_port_label" ),
546                     gtk_toggle_button_get_active( togglebutton ) );
547     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_network ),
548                     "network_multicast_port" ),
549                     gtk_toggle_button_get_active( togglebutton ) );
550 }
551
552
553 void GtkNetworkOpenChannel( GtkToggleButton *togglebutton,
554                                        gpointer user_data )
555 {
556     GtkWidget *     p_network;
557
558     p_network = gtk_widget_get_toplevel( GTK_WIDGET (togglebutton) );
559     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_network ),
560                     "network_channel_address_label" ),
561                     gtk_toggle_button_get_active( togglebutton ) );
562     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_network ),
563                     "network_channel_address_combo" ),
564                     gtk_toggle_button_get_active( togglebutton ) );
565
566     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_network ),
567                     "network_channel_port_label" ),
568                     gtk_toggle_button_get_active( togglebutton ) );
569     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_network ),
570                     "network_channel_port" ),
571                     gtk_toggle_button_get_active( togglebutton ) );
572 }
573
574
575 void GtkNetworkOpenHTTP( GtkToggleButton *togglebutton,
576                                          gpointer user_data )
577 {   
578     GtkWidget *     p_network;
579
580     p_network = gtk_widget_get_toplevel( GTK_WIDGET (togglebutton) );
581     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_network ),
582                     "network_http_url_label" ),
583                     gtk_toggle_button_get_active( togglebutton ) );
584     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_network ),
585                     "network_http_url" ),
586                     gtk_toggle_button_get_active( togglebutton ) );
587 }
588
589
590 /*****************************************************************************
591  * Open satellite callbacks
592  *****************************************************************************
593  * The following callbacks are related to the satellite card manager.
594  *****************************************************************************/
595 gboolean GtkSatOpenShow( GtkWidget       *widget,
596                           GdkEventButton  *event,
597                           gpointer         user_data)
598 {
599     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
600
601     if( !GTK_IS_WIDGET( p_intf->p_sys->p_sat ) )
602     {
603         p_intf->p_sys->p_sat = create_intf_sat();
604         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_sat ),
605                              "p_intf", p_intf );
606     }
607
608     gtk_widget_show( p_intf->p_sys->p_sat );
609     gdk_window_raise( p_intf->p_sys->p_sat->window );
610
611     return TRUE;
612 }
613
614 void GtkSatOpenOk( GtkButton * button, gpointer user_data )
615 {
616     intf_thread_t * p_intf = GetIntf( GTK_WIDGET(button), "intf_sat" );
617     playlist_t *    p_playlist;
618     GtkCList *      p_playlist_clist;
619     char *          psz_source;
620     int             i_freq, i_srate;
621     int             i_fec;
622     vlc_bool_t      b_pol;
623
624     p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
625     if( p_playlist == NULL )
626     {
627         return;
628     }
629
630     gtk_widget_hide( p_intf->p_sys->p_sat );
631
632     /* Check which polarization was activated */
633     if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET( button ),
634                                         "sat_pol_vert" ) )->active )
635     {
636         b_pol = 0;
637     }
638     else
639     {
640         b_pol = 1;
641     }
642
643     i_fec = strtol( gtk_entry_get_text( GTK_ENTRY( GTK_COMBO( 
644                 lookup_widget( GTK_WIDGET( button ), "sat_fec" )
645                 )->entry ) ), NULL, 10 );
646
647     /* Select frequency and symbol rate */
648     i_freq = gtk_spin_button_get_value_as_int(
649                               GTK_SPIN_BUTTON( lookup_widget(
650                                   GTK_WIDGET(button), "sat_freq" ) ) );
651
652     i_srate = gtk_spin_button_get_value_as_int(
653                               GTK_SPIN_BUTTON( lookup_widget(
654                                   GTK_WIDGET(button), "sat_srate" ) ) );
655     
656     psz_source = malloc( 22 );
657     if( psz_source == NULL )
658     {
659         return;
660     }
661
662     /* Build source name and add it to playlist */
663     sprintf( psz_source, "%s:%d,%d,%d,%d",
664              "satellite", i_freq, b_pol, i_fec, i_srate );
665     playlist_Add( p_playlist, 0, psz_source );
666     free( psz_source );
667
668     /* catch the GTK CList */
669     p_playlist_clist = GTK_CLIST( gtk_object_get_data(
670         GTK_OBJECT( p_intf->p_sys->p_playlist ), "playlist_clist" ) );
671
672     /* update the display */
673     GtkRebuildCList( p_playlist_clist, p_playlist );
674
675     /* stop current item, select added item */
676 #if 0
677     if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
678     {
679         p_intf->p_vlc->p_input_bank->pp_input[0]->b_eof = 1;
680     }
681
682     intf_PlaylistJumpto( p_intf->p_vlc->p_playlist, i_end - 1 );
683 #endif
684
685     vlc_object_release( p_playlist );
686 }
687
688
689 void GtkSatOpenCancel( GtkButton * button, gpointer user_data )
690 {
691     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
692 }
693
694 /****************************************************************************
695  * Callbacks for menuitem
696  ****************************************************************************/
697 void GtkFileOpenActivate( GtkMenuItem * menuitem, gpointer user_data )
698 {
699     GtkFileOpenShow( GTK_WIDGET( menuitem ), NULL, user_data );
700 }
701
702
703 void GtkDiscOpenActivate( GtkMenuItem * menuitem, gpointer user_data )
704 {
705     GtkDiscOpenShow( GTK_WIDGET( menuitem ), NULL, user_data );
706 }
707
708
709 void GtkNetworkOpenActivate( GtkMenuItem * menuitem, gpointer user_data )
710 {
711     GtkNetworkOpenShow( GTK_WIDGET( menuitem ), NULL, user_data );
712 }
713