1 /*****************************************************************************
2 * gnome_callbacks.c : Callbacks for the Gnome plugin.
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
5 * $Id: gnome_callbacks.c,v 1.23 2001/04/20 05:40:03 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 );
179 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
181 p_intf->p_sys->b_title_update = 1;
187 on_button_title_next_clicked (GtkButton *button,
190 intf_thread_t * p_intf;
191 input_area_t * p_area;
194 p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
195 i_id = p_intf->p_input->stream.p_selected_area->i_id + 1;
197 if( i_id < p_intf->p_input->stream.i_area_nb )
199 p_area = p_intf->p_input->stream.pp_areas[i_id];
200 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
202 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
204 p_intf->p_sys->b_title_update = 1;
210 on_button_chapter_prev_clicked (GtkButton *button,
213 intf_thread_t * p_intf;
214 input_area_t * p_area;
216 p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
217 p_area = p_intf->p_input->stream.p_selected_area;
219 if( p_area->i_part > 0 )
222 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
224 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
226 p_intf->p_sys->b_chapter_update = 1;
232 on_button_chapter_next_clicked (GtkButton *button,
235 intf_thread_t * p_intf;
236 input_area_t * p_area;
238 p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
239 p_area = p_intf->p_input->stream.p_selected_area;
241 if( p_area->i_part < p_area->i_part_nb )
244 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
246 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
248 p_intf->p_sys->b_chapter_update = 1;
253 /*****************************************************************************
255 *****************************************************************************
256 * The following callbacks are related to the menubar of the main
258 *****************************************************************************/
260 on_menubar_open_activate (GtkMenuItem *menuitem,
263 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
265 /* If we have never used the file selector, open it */
266 if( p_intf->p_sys->p_fileopen == NULL)
268 p_intf->p_sys->p_fileopen = create_intf_fileopen();
269 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
273 gtk_widget_show( p_intf->p_sys->p_fileopen );
274 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
279 on_menubar_disc_activate (GtkMenuItem *menuitem,
282 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
284 gtk_widget_show( p_intf->p_sys->p_disc );
285 gdk_window_raise( p_intf->p_sys->p_disc->window );
290 on_menubar_network_activate (GtkMenuItem *menuitem,
293 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
295 gtk_widget_show( p_intf->p_sys->p_network );
296 gdk_window_raise( p_intf->p_sys->p_network->window );
301 on_menubar_exit_activate (GtkMenuItem *menuitem,
304 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
306 vlc_mutex_lock( &p_intf->change_lock );
308 vlc_mutex_unlock( &p_intf->change_lock );
313 on_menubar_playlist_activate (GtkMenuItem *menuitem,
316 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
318 if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
320 p_intf->p_sys->p_playlist = create_intf_playlist();
321 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
324 gtk_widget_show( p_intf->p_sys->p_playlist );
325 gdk_window_raise( p_intf->p_sys->p_playlist->window );
330 on_menubar_audio_toggle (GtkCheckMenuItem *menuitem,
333 intf_thread_t * p_intf;
334 es_descriptor_t * p_es;
336 p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
338 if( !p_intf->p_sys->b_audio_update )
340 p_es = (es_descriptor_t*)user_data;
342 input_ToggleES( p_intf->p_input, p_es, menuitem->active );
344 p_intf->p_sys->b_audio_update = menuitem->active;
350 on_menubar_subtitle_toggle (GtkCheckMenuItem *menuitem,
353 intf_thread_t * p_intf;
354 es_descriptor_t * p_es;
356 p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
358 if( !p_intf->p_sys->b_spu_update )
360 p_es = (es_descriptor_t*)user_data;
362 input_ToggleES( p_intf->p_input, p_es, menuitem->active );
364 p_intf->p_sys->b_spu_update = menuitem->active;
370 on_menubar_title_toggle (GtkCheckMenuItem *menuitem,
373 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
375 if( menuitem->active && !p_intf->p_sys->b_title_update )
377 p_intf->p_input->pf_set_area( p_intf->p_input,
378 (input_area_t*)user_data );
380 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
382 p_intf->p_sys->b_title_update = 1;
388 on_menubar_chapter_toggle (GtkCheckMenuItem *menuitem,
391 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
392 input_area_t * p_area = p_intf->p_input->stream.p_selected_area;
393 gint i_chapter = (gint)user_data;
396 if( menuitem->active && !p_intf->p_sys->b_chapter_update )
398 p_area->i_part = i_chapter;
399 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
401 snprintf( psz_chapter, 3, "%02d", p_area->i_part );
402 gtk_label_set_text( p_intf->p_sys->p_label_chapter, psz_chapter );
404 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
406 p_intf->p_sys->b_chapter_update = 1;
412 on_menubar_modules_activate (GtkMenuItem *menuitem,
415 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
417 if( !GTK_IS_WIDGET( p_intf->p_sys->p_modules ) )
419 p_intf->p_sys->p_modules = create_intf_modules();
420 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_modules ),
423 gtk_widget_show( p_intf->p_sys->p_modules );
424 gdk_window_raise( p_intf->p_sys->p_modules->window );
429 on_menubar_preferences_activate (GtkMenuItem *menuitem,
437 on_menubar_about_activate (GtkMenuItem *menuitem,
440 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
442 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
444 p_intf->p_sys->p_about = create_intf_about();
445 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
448 gtk_widget_show( p_intf->p_sys->p_about );
449 gdk_window_raise( p_intf->p_sys->p_about->window );
453 /*****************************************************************************
455 *****************************************************************************
456 * The following callbacks are related to the toolbar of the main
458 *****************************************************************************/
460 on_toolbar_open_clicked (GtkButton *button,
463 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
465 /* If we have never used the file selector, open it */
466 if( p_intf->p_sys->p_fileopen == NULL)
468 p_intf->p_sys->p_fileopen = create_intf_fileopen();
469 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
473 gtk_widget_show( p_intf->p_sys->p_fileopen );
474 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
479 on_toolbar_disc_clicked (GtkButton *button,
482 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
484 gtk_widget_show( p_intf->p_sys->p_disc );
485 gdk_window_raise( p_intf->p_sys->p_disc->window );
490 on_toolbar_network_clicked (GtkButton *button,
493 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
495 gtk_widget_show( p_intf->p_sys->p_network );
496 gdk_window_raise( p_intf->p_sys->p_network->window );
501 on_toolbar_back_clicked (GtkButton *button,
509 on_toolbar_stop_clicked (GtkButton *button,
517 on_toolbar_play_clicked (GtkButton *button,
520 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
522 if( p_intf->p_input != NULL )
524 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
530 on_toolbar_pause_clicked (GtkButton *button,
533 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
535 if( p_intf->p_input != NULL )
537 input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
543 on_toolbar_slow_clicked (GtkButton *button,
546 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
548 if( p_intf->p_input != NULL )
550 input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
556 on_toolbar_fast_clicked (GtkButton *button,
559 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
561 if( p_intf->p_input != NULL )
563 input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
569 on_toolbar_playlist_clicked (GtkButton *button,
572 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
574 if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
576 p_intf->p_sys->p_playlist = create_intf_playlist();
577 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
580 gtk_widget_show( p_intf->p_sys->p_playlist );
581 gdk_window_raise( p_intf->p_sys->p_playlist->window );
586 on_toolbar_prev_clicked (GtkButton *button,
589 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
591 if( p_intf->p_input != NULL )
593 /* FIXME: temporary hack */
594 intf_PlaylistPrev( p_main->p_playlist );
595 intf_PlaylistPrev( p_main->p_playlist );
596 p_intf->p_input->b_eof = 1;
599 p_intf->p_sys->b_mode_changed = 1;
604 on_toolbar_next_clicked (GtkButton *button,
607 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
609 if( p_intf->p_input != NULL )
611 /* FIXME: temporary hack */
612 p_intf->p_input->b_eof = 1;
615 p_intf->p_sys->b_mode_changed = 1;
619 /*****************************************************************************
621 *****************************************************************************
622 * The following callbacks are related to the popup menu. The popup
623 * menu is activated when right-clicking on the video output window.
624 *****************************************************************************/
626 on_popup_play_activate (GtkMenuItem *menuitem,
629 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
631 if( p_intf->p_input != NULL )
633 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
639 on_popup_pause_activate (GtkMenuItem *menuitem,
642 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
644 if( p_intf->p_input != NULL )
646 input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
652 on_popup_slow_activate (GtkMenuItem *menuitem,
655 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
657 if( p_intf->p_input != NULL )
659 input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
665 on_popup_fast_activate (GtkMenuItem *menuitem,
668 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
670 if( p_intf->p_input != NULL )
672 input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
678 on_popup_audio_toggle (GtkCheckMenuItem *menuitem,
681 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
682 es_descriptor_t * p_es;
684 p_es = (es_descriptor_t*)user_data;
686 if( !p_intf->p_sys->b_audio_update )
688 input_ToggleES( p_intf->p_input, p_es, menuitem->active );
690 p_intf->p_sys->b_audio_update = menuitem->active;
696 on_popup_subtitle_toggle (GtkCheckMenuItem *menuitem,
699 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
700 es_descriptor_t * p_es;
702 p_es = (es_descriptor_t*)user_data;
704 if( !p_intf->p_sys->b_spu_update )
706 input_ToggleES( p_intf->p_input, p_es, menuitem->active );
708 p_intf->p_sys->b_spu_update = menuitem->active;
714 on_popup_navigation_toggle (GtkCheckMenuItem *menuitem,
717 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
719 if( menuitem->active &&
720 !p_intf->p_sys->b_title_update &&
721 !p_intf->p_sys->b_chapter_update )
723 input_area_t * p_area;
727 i_title = (gint)(user_data) / 100;
728 i_chapter = (gint)(user_data) - ( 100 * i_title );
729 p_area = p_intf->p_input->stream.p_selected_area;
732 if( p_area != p_intf->p_input->stream.pp_areas[i_title] )
734 p_area = p_intf->p_input->stream.pp_areas[i_title];
735 p_intf->p_sys->b_title_update = 1;
738 p_area->i_part = i_chapter;
739 p_intf->p_sys->b_chapter_update = 1;
741 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
743 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
749 on_popup_open_activate (GtkMenuItem *menuitem,
752 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
754 /* If we have never used the file selector, open it */
755 if( p_intf->p_sys->p_fileopen == NULL)
757 p_intf->p_sys->p_fileopen = create_intf_fileopen();
758 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
762 gtk_widget_show( p_intf->p_sys->p_fileopen );
763 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
768 on_popup_disc_activate (GtkMenuItem *menuitem,
771 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
773 gtk_widget_show( p_intf->p_sys->p_disc );
774 gdk_window_raise( p_intf->p_sys->p_disc->window );
779 on_popup_network_activate (GtkMenuItem *menuitem,
782 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
784 gtk_widget_show( p_intf->p_sys->p_network );
785 gdk_window_raise( p_intf->p_sys->p_network->window );
790 on_popup_about_activate (GtkMenuItem *menuitem,
793 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
795 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
797 p_intf->p_sys->p_about = create_intf_about();
798 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
801 gtk_widget_show( p_intf->p_sys->p_about );
802 gdk_window_raise( p_intf->p_sys->p_about->window );
807 on_popup_exit_activate (GtkMenuItem *menuitem,
810 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
812 vlc_mutex_lock( &p_intf->change_lock );
814 vlc_mutex_unlock( &p_intf->change_lock );
818 /*****************************************************************************
820 *****************************************************************************
821 * The following callbacks are related to the file requester.
822 *****************************************************************************/
824 on_intf_fileopen_destroy (GtkObject *object,
827 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_fileopen" );
829 p_intf->p_sys->p_fileopen = NULL;
834 on_fileopen_ok_clicked (GtkButton *button,
837 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_fileopen" );
842 filesel = gtk_widget_get_toplevel (GTK_WIDGET (button));
843 gtk_widget_hide (filesel);
844 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
846 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
848 /* Select added item and switch to file interface */
849 intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
850 if( p_intf->p_input != NULL )
851 p_intf->p_input->b_eof = 1;
852 p_intf->p_sys->i_intf_mode = FILE_MODE;
853 p_intf->p_sys->b_mode_changed = 1;
858 on_fileopen_cancel_clicked (GtkButton *button,
861 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
865 /*****************************************************************************
867 *****************************************************************************
868 * The following callbacks are related to the playlist.
869 *****************************************************************************/
871 on_intf_playlist_destroy (GtkObject *object,
874 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_playlist" );
876 p_intf->p_sys->p_playlist = NULL;
881 on_playlist_ok_clicked (GtkButton *button,
884 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_playlist" );
886 gtk_widget_hide( p_intf->p_sys->p_playlist );
891 on_playlist_close_clicked (GtkButton *button,
894 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
899 /*****************************************************************************
900 * Module manager callbacks
901 *****************************************************************************
902 * The following callbacks are related to the module manager.
903 *****************************************************************************/
905 on_intf_modules_destroy (GtkObject *object,
913 on_modules_ok_clicked (GtkButton *button,
916 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
918 gtk_widget_hide( p_intf->p_sys->p_modules );
923 on_modules_apply_clicked (GtkButton *button,
931 on_modules_cancel_clicked (GtkButton *button,
934 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
938 /*****************************************************************************
939 * Open disc callbacks
940 *****************************************************************************
941 * The following callbacks are related to the disc manager.
942 *****************************************************************************/
944 on_disc_dvd_toggled (GtkToggleButton *togglebutton,
947 if( togglebutton->active )
949 gtk_entry_set_text( GTK_ENTRY( lookup_widget(
950 GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/dvd" );
956 on_disc_vcd_toggled (GtkToggleButton *togglebutton,
959 if( togglebutton->active )
961 gtk_entry_set_text( GTK_ENTRY( lookup_widget(
962 GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/cdrom" );
968 on_disc_ok_clicked (GtkButton *button,
971 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
972 char *psz_device, *psz_source, *psz_method;
974 psz_device = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
975 GTK_WIDGET(button), "disc_name" ) ) );
977 /* "dvd:foo" has size 5 + strlen(foo) */
978 psz_source = malloc( 5 + strlen( psz_device ) );
979 if( psz_source == NULL )
984 /* Check which method was activated */
985 if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
986 "disc_dvd" ) )->active )
989 p_intf->p_sys->i_intf_mode = DVD_MODE;
991 else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
992 "disc_vcd" ) )->active )
998 intf_ErrMsg( "intf error: unknown disc type toggle button position" );
1003 /* Select title and chapter */
1004 main_PutIntVariable( INPUT_TITLE_VAR, gtk_spin_button_get_value_as_int(
1005 GTK_SPIN_BUTTON( lookup_widget(
1006 GTK_WIDGET(button), "disc_title" ) ) ) );
1008 main_PutIntVariable( INPUT_CHAPTER_VAR, gtk_spin_button_get_value_as_int(
1009 GTK_SPIN_BUTTON( lookup_widget(
1010 GTK_WIDGET(button), "disc_chapter" ) ) ) );
1012 /* Build source name and add it to playlist */
1013 sprintf( psz_source, "%s:%s", psz_method, psz_device );
1014 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
1017 /* Select added item and switch to DVD interface */
1018 intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
1019 if( p_intf->p_input != NULL )
1020 p_intf->p_input->b_eof = 1;
1021 p_intf->p_sys->b_mode_changed = 1;
1023 gtk_widget_hide( p_intf->p_sys->p_disc );
1028 on_disc_cancel_clicked (GtkButton *button,
1031 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
1035 /*****************************************************************************
1036 * Network stream callbacks
1037 *****************************************************************************
1038 * The following callbacks are related to the network stream manager.
1039 *****************************************************************************/
1041 on_network_ok_clicked (GtkButton *button,
1044 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_network" );
1045 char *psz_source, *psz_server, *psz_protocol;
1046 unsigned int i_port;
1048 psz_server = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
1049 GTK_WIDGET(button), "network_server" ) ) );
1051 /* Check which protocol was activated */
1052 if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1053 "network_ts" ) )->active )
1055 psz_protocol = "ts";
1057 else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1058 "network_rtp" ) )->active )
1060 psz_protocol = "rtp";
1064 intf_ErrMsg( "intf error: unknown protocol toggle button position" );
1068 /* Get the port number and make sure it will not overflow 5 characters */
1069 i_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
1070 lookup_widget( GTK_WIDGET(button), "network_port" ) ) );
1071 if( i_port > 65535 )
1073 intf_ErrMsg( "intf error: invalid port %i", i_port );
1076 /* Allocate room for "protocol://server:port" */
1077 psz_source = malloc( strlen( psz_protocol ) + strlen( psz_server ) + 10 );
1078 if( psz_source == NULL )
1083 /* Build source name and add it to playlist */
1084 sprintf( psz_source, "%s://%s:%i", psz_protocol, psz_server, i_port );
1085 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
1088 /* Select added item and switch to network interface */
1089 intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
1090 if( p_intf->p_input != NULL )
1091 p_intf->p_input->b_eof = 1;
1092 p_intf->p_sys->b_mode_changed = 1;
1093 p_intf->p_sys->i_intf_mode = NET_MODE;
1095 gtk_widget_hide( p_intf->p_sys->p_network );
1100 on_network_cancel_clicked (GtkButton *button,
1103 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );