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