1 /*****************************************************************************
2 * gnome_callbacks.c : Callbacks for the Gnome plugin.
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
5 * $Id: gnome_callbacks.c,v 1.21 2001/04/08 07:24:47 stef Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
8 * Stéphane Borel <stef@via.ecp.fr>
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.
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.
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 *****************************************************************************/
25 #define MODULE_NAME gnome
26 #include "modules_inner.h"
28 /*****************************************************************************
30 *****************************************************************************/
40 #include "stream_control.h"
41 #include "input_ext-intf.h"
43 #include "interface.h"
44 #include "intf_playlist.h"
47 #include "gnome_callbacks.h"
48 #include "gnome_interface.h"
49 #include "gnome_support.h"
50 #include "intf_gnome.h"
54 /*****************************************************************************
55 * Inline function to retrieve the interface structure
56 *****************************************************************************/
57 static __inline__ intf_thread_t * GetIntf( GtkWidget *item, char * psz_parent )
59 return( gtk_object_get_data( GTK_OBJECT( lookup_widget(item, psz_parent) ),
64 /*****************************************************************************
66 *****************************************************************************
67 * The following callbacks are related to the main interface window.
68 *****************************************************************************/
70 on_intf_window_destroy (GtkObject *object,
73 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_window" );
75 vlc_mutex_lock( &p_intf->change_lock );
77 vlc_mutex_unlock( &p_intf->change_lock );
82 on_slider_button_press_event (GtkWidget *widget,
83 GdkEventButton *event,
86 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
88 vlc_mutex_lock( &p_intf->change_lock );
89 p_intf->p_sys->b_slider_free = 0;
90 vlc_mutex_unlock( &p_intf->change_lock );
97 on_slider_button_release_event (GtkWidget *widget,
98 GdkEventButton *event,
101 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
103 vlc_mutex_lock( &p_intf->change_lock );
104 p_intf->p_sys->b_slider_free = 1;
105 vlc_mutex_unlock( &p_intf->change_lock );
112 on_intf_window_drag_data_received (GtkWidget *widget,
113 GdkDragContext *drag_context,
116 GtkSelectionData *data,
121 char *psz_text = data->data;
122 int i_len = strlen( psz_text );
126 case DROP_ACCEPT_TEXT_PLAIN: /* FIXME: handle multiple files */
133 /* get rid of ' ' at the end */
134 *( psz_text + i_len - 1 ) = 0;
136 intf_WarnMsg( 1, "intf: dropped text/uri-list data `%s'", psz_text );
137 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_text );
141 case DROP_ACCEPT_TEXT_URI_LIST: /* FIXME: handle multiple files */
148 /* get rid of \r\n at the end */
149 *( psz_text + i_len - 2 ) = 0;
151 intf_WarnMsg( 1, "intf: dropped text/uri-list data `%s'", psz_text );
152 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_text );
157 intf_ErrMsg( "intf error: unknown dropped type");
164 on_button_title_prev_clicked (GtkButton *button,
167 intf_thread_t * p_intf;
168 input_area_t * p_area;
171 p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
172 i_id = p_intf->p_input->stream.p_selected_area->i_id - 1;
176 p_area = p_intf->p_input->stream.pp_areas[i_id];
177 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
178 p_intf->p_sys->b_menus_update = 1;
180 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
182 p_intf->p_sys->b_menus_update = 1;
188 on_button_title_next_clicked (GtkButton *button,
191 intf_thread_t * p_intf;
192 input_area_t * p_area;
195 p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
196 i_id = p_intf->p_input->stream.p_selected_area->i_id + 1;
198 if( i_id < p_intf->p_input->stream.i_area_nb )
200 p_area = p_intf->p_input->stream.pp_areas[i_id];
201 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
202 p_intf->p_sys->b_menus_update = 1;
204 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
206 p_intf->p_sys->b_menus_update = 1;
212 on_button_chapter_prev_clicked (GtkButton *button,
215 intf_thread_t * p_intf;
216 input_area_t * p_area;
218 p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
219 p_area = p_intf->p_input->stream.p_selected_area;
221 if( p_area->i_part > 0 )
224 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
226 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
228 p_intf->p_sys->b_menus_update = 1;
234 on_button_chapter_next_clicked (GtkButton *button,
237 intf_thread_t * p_intf;
238 input_area_t * p_area;
240 p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
241 p_area = p_intf->p_input->stream.p_selected_area;
243 if( p_area->i_part < p_area->i_part_nb )
246 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
248 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
250 p_intf->p_sys->b_menus_update = 1;
255 /*****************************************************************************
257 *****************************************************************************
258 * The following callbacks are related to the menubar of the main
260 *****************************************************************************/
262 on_menubar_open_activate (GtkMenuItem *menuitem,
265 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
267 /* If we have never used the file selector, open it */
268 if( p_intf->p_sys->p_fileopen == NULL)
270 p_intf->p_sys->p_fileopen = create_intf_fileopen();
271 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
275 gtk_widget_show( p_intf->p_sys->p_fileopen );
276 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
281 on_menubar_disc_activate (GtkMenuItem *menuitem,
284 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
286 gtk_widget_show( p_intf->p_sys->p_disc );
287 gdk_window_raise( p_intf->p_sys->p_disc->window );
292 on_menubar_network_activate (GtkMenuItem *menuitem,
295 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
297 gtk_widget_show( p_intf->p_sys->p_network );
298 gdk_window_raise( p_intf->p_sys->p_network->window );
303 on_menubar_exit_activate (GtkMenuItem *menuitem,
306 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
308 vlc_mutex_lock( &p_intf->change_lock );
310 vlc_mutex_unlock( &p_intf->change_lock );
315 on_menubar_playlist_activate (GtkMenuItem *menuitem,
318 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
320 if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
322 p_intf->p_sys->p_playlist = create_intf_playlist();
323 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
326 gtk_widget_show( p_intf->p_sys->p_playlist );
327 gdk_window_raise( p_intf->p_sys->p_playlist->window );
332 on_menubar_audio_toggle (GtkCheckMenuItem *menuitem,
335 intf_thread_t * p_intf;
336 es_descriptor_t * p_es;
338 if( !p_intf->p_sys->b_menus_update )
340 p_es = (es_descriptor_t*)user_data;
342 input_ToggleES( p_intf->p_input, p_es, menuitem->active );
348 on_menubar_subtitle_toggle (GtkCheckMenuItem *menuitem,
351 intf_thread_t * p_intf;
352 es_descriptor_t * p_es;
354 p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
356 if( !p_intf->p_sys->b_menus_update )
358 p_es = (es_descriptor_t*)user_data;
360 input_ToggleES( p_intf->p_input, p_es, menuitem->active );
366 on_menubar_title_toggle (GtkCheckMenuItem *menuitem,
369 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
371 if( menuitem->active && !p_intf->p_sys->b_menus_update )
373 p_intf->p_input->pf_set_area( p_intf->p_input,
374 (input_area_t*)user_data );
376 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
378 p_intf->p_sys->b_menus_update = 1;
384 on_menubar_chapter_toggle (GtkCheckMenuItem *menuitem,
387 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
388 input_area_t * p_area = p_intf->p_input->stream.p_selected_area;
389 gint i_chapter = (gint)user_data;
392 if( menuitem->active && !p_intf->p_sys->b_menus_update )
394 p_area->i_part = i_chapter;
395 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
397 snprintf( psz_chapter, 3, "%02d", p_area->i_part );
398 gtk_label_set_text( p_intf->p_sys->p_label_chapter, psz_chapter );
400 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
402 p_intf->p_sys->b_menus_update = 1;
408 on_menubar_modules_activate (GtkMenuItem *menuitem,
411 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
413 if( !GTK_IS_WIDGET( p_intf->p_sys->p_modules ) )
415 p_intf->p_sys->p_modules = create_intf_modules();
416 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_modules ),
419 gtk_widget_show( p_intf->p_sys->p_modules );
420 gdk_window_raise( p_intf->p_sys->p_modules->window );
425 on_menubar_preferences_activate (GtkMenuItem *menuitem,
433 on_menubar_about_activate (GtkMenuItem *menuitem,
436 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
438 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
440 p_intf->p_sys->p_about = create_intf_about();
441 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
444 gtk_widget_show( p_intf->p_sys->p_about );
445 gdk_window_raise( p_intf->p_sys->p_about->window );
449 /*****************************************************************************
451 *****************************************************************************
452 * The following callbacks are related to the toolbar of the main
454 *****************************************************************************/
456 on_toolbar_open_clicked (GtkButton *button,
459 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
461 /* If we have never used the file selector, open it */
462 if( p_intf->p_sys->p_fileopen == NULL)
464 p_intf->p_sys->p_fileopen = create_intf_fileopen();
465 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
469 gtk_widget_show( p_intf->p_sys->p_fileopen );
470 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
475 on_toolbar_disc_clicked (GtkButton *button,
478 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
480 gtk_widget_show( p_intf->p_sys->p_disc );
481 gdk_window_raise( p_intf->p_sys->p_disc->window );
486 on_toolbar_network_clicked (GtkButton *button,
489 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
491 gtk_widget_show( p_intf->p_sys->p_network );
492 gdk_window_raise( p_intf->p_sys->p_network->window );
497 on_toolbar_back_clicked (GtkButton *button,
505 on_toolbar_stop_clicked (GtkButton *button,
513 on_toolbar_play_clicked (GtkButton *button,
516 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
518 if( p_intf->p_input != NULL )
520 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
526 on_toolbar_pause_clicked (GtkButton *button,
529 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
531 if( p_intf->p_input != NULL )
533 input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
539 on_toolbar_slow_clicked (GtkButton *button,
542 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
544 if( p_intf->p_input != NULL )
546 input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
552 on_toolbar_fast_clicked (GtkButton *button,
555 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
557 if( p_intf->p_input != NULL )
559 input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
565 on_toolbar_playlist_clicked (GtkButton *button,
568 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
570 if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
572 p_intf->p_sys->p_playlist = create_intf_playlist();
573 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
576 gtk_widget_show( p_intf->p_sys->p_playlist );
577 gdk_window_raise( p_intf->p_sys->p_playlist->window );
582 on_toolbar_prev_clicked (GtkButton *button,
585 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
587 if( p_intf->p_input != NULL )
589 /* FIXME: temporary hack */
590 intf_PlaylistPrev( p_main->p_playlist );
591 intf_PlaylistPrev( p_main->p_playlist );
592 p_intf->p_input->b_eof = 1;
595 p_intf->p_sys->b_mode_changed = 1;
600 on_toolbar_next_clicked (GtkButton *button,
603 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
605 if( p_intf->p_input != NULL )
607 /* FIXME: temporary hack */
608 p_intf->p_input->b_eof = 1;
611 p_intf->p_sys->b_mode_changed = 1;
615 /*****************************************************************************
617 *****************************************************************************
618 * The following callbacks are related to the popup menu. The popup
619 * menu is activated when right-clicking on the video output window.
620 *****************************************************************************/
622 on_popup_play_activate (GtkMenuItem *menuitem,
625 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
627 if( p_intf->p_input != NULL )
629 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
635 on_popup_pause_activate (GtkMenuItem *menuitem,
638 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
640 if( p_intf->p_input != NULL )
642 input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
648 on_popup_slow_activate (GtkMenuItem *menuitem,
651 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
653 if( p_intf->p_input != NULL )
655 input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
661 on_popup_fast_activate (GtkMenuItem *menuitem,
664 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
666 if( p_intf->p_input != NULL )
668 input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
674 on_popup_audio_toggle (GtkCheckMenuItem *menuitem,
677 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
678 es_descriptor_t * p_es;
680 p_es = (es_descriptor_t*)user_data;
682 if( !p_intf->p_sys->b_menus_update )
684 input_ToggleES( p_intf->p_input, p_es, menuitem->active );
690 on_popup_subtitle_toggle (GtkCheckMenuItem *menuitem,
693 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
694 es_descriptor_t * p_es;
696 p_es = (es_descriptor_t*)user_data;
698 if( !p_intf->p_sys->b_menus_update )
700 input_ToggleES( p_intf->p_input, p_es, menuitem->active );
706 on_popup_navigation_toggle (GtkCheckMenuItem *menuitem,
709 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
711 if( menuitem->active && !p_intf->p_sys->b_menus_update )
713 input_area_t * p_area;
717 i_title = (gint)(user_data) / 100;
718 i_chapter = (gint)(user_data) - ( 100 * i_title );
720 p_area = p_intf->p_input->stream.pp_areas[i_title];
721 p_area->i_part = i_chapter;
723 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
725 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
727 p_intf->p_sys->b_menus_update = 1;
733 on_popup_open_activate (GtkMenuItem *menuitem,
736 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
738 /* If we have never used the file selector, open it */
739 if( p_intf->p_sys->p_fileopen == NULL)
741 p_intf->p_sys->p_fileopen = create_intf_fileopen();
742 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
746 gtk_widget_show( p_intf->p_sys->p_fileopen );
747 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
752 on_popup_disc_activate (GtkMenuItem *menuitem,
755 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
757 gtk_widget_show( p_intf->p_sys->p_disc );
758 gdk_window_raise( p_intf->p_sys->p_disc->window );
763 on_popup_network_activate (GtkMenuItem *menuitem,
766 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
768 gtk_widget_show( p_intf->p_sys->p_network );
769 gdk_window_raise( p_intf->p_sys->p_network->window );
774 on_popup_about_activate (GtkMenuItem *menuitem,
777 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
779 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
781 p_intf->p_sys->p_about = create_intf_about();
782 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
785 gtk_widget_show( p_intf->p_sys->p_about );
786 gdk_window_raise( p_intf->p_sys->p_about->window );
791 on_popup_exit_activate (GtkMenuItem *menuitem,
794 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
796 vlc_mutex_lock( &p_intf->change_lock );
798 vlc_mutex_unlock( &p_intf->change_lock );
802 /*****************************************************************************
804 *****************************************************************************
805 * The following callbacks are related to the file requester.
806 *****************************************************************************/
808 on_intf_fileopen_destroy (GtkObject *object,
811 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_fileopen" );
813 p_intf->p_sys->p_fileopen = NULL;
818 on_fileopen_ok_clicked (GtkButton *button,
821 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_fileopen" );
826 filesel = gtk_widget_get_toplevel (GTK_WIDGET (button));
827 gtk_widget_hide (filesel);
828 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
830 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
832 /* Select added item and switch to file interface */
833 intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
834 if( p_intf->p_input != NULL )
835 p_intf->p_input->b_eof = 1;
836 p_intf->p_sys->i_intf_mode = FILE_MODE;
837 p_intf->p_sys->b_mode_changed = 1;
842 on_fileopen_cancel_clicked (GtkButton *button,
845 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
849 /*****************************************************************************
851 *****************************************************************************
852 * The following callbacks are related to the playlist.
853 *****************************************************************************/
855 on_intf_playlist_destroy (GtkObject *object,
858 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_playlist" );
860 p_intf->p_sys->p_playlist = NULL;
865 on_playlist_ok_clicked (GtkButton *button,
868 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_playlist" );
870 gtk_widget_hide( p_intf->p_sys->p_playlist );
875 on_playlist_close_clicked (GtkButton *button,
878 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
883 /*****************************************************************************
884 * Module manager callbacks
885 *****************************************************************************
886 * The following callbacks are related to the module manager.
887 *****************************************************************************/
889 on_intf_modules_destroy (GtkObject *object,
897 on_modules_ok_clicked (GtkButton *button,
900 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
902 gtk_widget_hide( p_intf->p_sys->p_modules );
907 on_modules_apply_clicked (GtkButton *button,
915 on_modules_cancel_clicked (GtkButton *button,
918 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
922 /*****************************************************************************
923 * Open disc callbacks
924 *****************************************************************************
925 * The following callbacks are related to the disc manager.
926 *****************************************************************************/
928 on_disc_dvd_toggled (GtkToggleButton *togglebutton,
931 if( togglebutton->active )
933 gtk_entry_set_text( GTK_ENTRY( lookup_widget(
934 GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/dvd" );
940 on_disc_vcd_toggled (GtkToggleButton *togglebutton,
943 if( togglebutton->active )
945 gtk_entry_set_text( GTK_ENTRY( lookup_widget(
946 GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/cdrom" );
952 on_disc_ok_clicked (GtkButton *button,
955 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
956 char *psz_device, *psz_source, *psz_method;
958 psz_device = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
959 GTK_WIDGET(button), "disc_name" ) ) );
961 /* "dvd:foo" has size 5 + strlen(foo) */
962 psz_source = malloc( 5 + strlen( psz_device ) );
963 if( psz_source == NULL )
968 /* Check which method was activated */
969 if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
970 "disc_dvd" ) )->active )
973 p_intf->p_sys->i_intf_mode = DVD_MODE;
975 else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
976 "disc_vcd" ) )->active )
982 intf_ErrMsg( "intf error: unknown disc type toggle button position" );
987 /* Select title and chapter */
988 main_PutIntVariable( INPUT_TITLE_VAR, gtk_spin_button_get_value_as_int(
989 GTK_SPIN_BUTTON( lookup_widget(
990 GTK_WIDGET(button), "disc_title" ) ) ) );
992 main_PutIntVariable( INPUT_CHAPTER_VAR, gtk_spin_button_get_value_as_int(
993 GTK_SPIN_BUTTON( lookup_widget(
994 GTK_WIDGET(button), "disc_chapter" ) ) ) );
996 /* Build source name and add it to playlist */
997 sprintf( psz_source, "%s:%s", psz_method, psz_device );
998 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
1001 /* Select added item and switch to DVD interface */
1002 intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
1003 if( p_intf->p_input != NULL )
1004 p_intf->p_input->b_eof = 1;
1005 p_intf->p_sys->b_mode_changed = 1;
1007 gtk_widget_hide( p_intf->p_sys->p_disc );
1012 on_disc_cancel_clicked (GtkButton *button,
1015 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
1019 /*****************************************************************************
1020 * Network stream callbacks
1021 *****************************************************************************
1022 * The following callbacks are related to the network stream manager.
1023 *****************************************************************************/
1025 on_network_ok_clicked (GtkButton *button,
1028 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_network" );
1029 char *psz_source, *psz_server, *psz_protocol;
1030 unsigned int i_port;
1032 psz_server = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
1033 GTK_WIDGET(button), "network_server" ) ) );
1035 /* Check which protocol was activated */
1036 if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1037 "network_ts" ) )->active )
1039 psz_protocol = "ts";
1041 else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1042 "network_rtp" ) )->active )
1044 psz_protocol = "rtp";
1048 intf_ErrMsg( "intf error: unknown protocol toggle button position" );
1052 /* Get the port number and make sure it will not overflow 5 characters */
1053 i_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
1054 lookup_widget( GTK_WIDGET(button), "network_port" ) ) );
1055 if( i_port > 65535 )
1057 intf_ErrMsg( "intf error: invalid port %i", i_port );
1060 /* Allocate room for "protocol://server:port" */
1061 psz_source = malloc( strlen( psz_protocol ) + strlen( psz_server ) + 10 );
1062 if( psz_source == NULL )
1067 /* Build source name and add it to playlist */
1068 sprintf( psz_source, "%s://%s:%i", psz_protocol, psz_server, i_port );
1069 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
1072 /* Select added item and switch to network interface */
1073 intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
1074 if( p_intf->p_input != NULL )
1075 p_intf->p_input->b_eof = 1;
1076 p_intf->p_sys->b_mode_changed = 1;
1077 p_intf->p_sys->i_intf_mode = NET_MODE;
1079 gtk_widget_hide( p_intf->p_sys->p_network );
1084 on_network_cancel_clicked (GtkButton *button,
1087 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );