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