1 /*****************************************************************************
2 * gnome_callbacks.c : Callbacks for the Gnome plugin.
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
5 * $Id: gnome_callbacks.c,v 1.22 2001/04/08 07:45: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 );
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 p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
340 if( !p_intf->p_sys->b_menus_update )
342 p_es = (es_descriptor_t*)user_data;
344 input_ToggleES( p_intf->p_input, p_es, 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_menus_update )
360 p_es = (es_descriptor_t*)user_data;
362 input_ToggleES( p_intf->p_input, p_es, menuitem->active );
368 on_menubar_title_toggle (GtkCheckMenuItem *menuitem,
371 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
373 if( menuitem->active && !p_intf->p_sys->b_menus_update )
375 p_intf->p_input->pf_set_area( p_intf->p_input,
376 (input_area_t*)user_data );
378 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
380 p_intf->p_sys->b_menus_update = 1;
386 on_menubar_chapter_toggle (GtkCheckMenuItem *menuitem,
389 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
390 input_area_t * p_area = p_intf->p_input->stream.p_selected_area;
391 gint i_chapter = (gint)user_data;
394 if( menuitem->active && !p_intf->p_sys->b_menus_update )
396 p_area->i_part = i_chapter;
397 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
399 snprintf( psz_chapter, 3, "%02d", p_area->i_part );
400 gtk_label_set_text( p_intf->p_sys->p_label_chapter, psz_chapter );
402 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
404 p_intf->p_sys->b_menus_update = 1;
410 on_menubar_modules_activate (GtkMenuItem *menuitem,
413 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
415 if( !GTK_IS_WIDGET( p_intf->p_sys->p_modules ) )
417 p_intf->p_sys->p_modules = create_intf_modules();
418 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_modules ),
421 gtk_widget_show( p_intf->p_sys->p_modules );
422 gdk_window_raise( p_intf->p_sys->p_modules->window );
427 on_menubar_preferences_activate (GtkMenuItem *menuitem,
435 on_menubar_about_activate (GtkMenuItem *menuitem,
438 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
440 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
442 p_intf->p_sys->p_about = create_intf_about();
443 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
446 gtk_widget_show( p_intf->p_sys->p_about );
447 gdk_window_raise( p_intf->p_sys->p_about->window );
451 /*****************************************************************************
453 *****************************************************************************
454 * The following callbacks are related to the toolbar of the main
456 *****************************************************************************/
458 on_toolbar_open_clicked (GtkButton *button,
461 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
463 /* If we have never used the file selector, open it */
464 if( p_intf->p_sys->p_fileopen == NULL)
466 p_intf->p_sys->p_fileopen = create_intf_fileopen();
467 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
471 gtk_widget_show( p_intf->p_sys->p_fileopen );
472 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
477 on_toolbar_disc_clicked (GtkButton *button,
480 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
482 gtk_widget_show( p_intf->p_sys->p_disc );
483 gdk_window_raise( p_intf->p_sys->p_disc->window );
488 on_toolbar_network_clicked (GtkButton *button,
491 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
493 gtk_widget_show( p_intf->p_sys->p_network );
494 gdk_window_raise( p_intf->p_sys->p_network->window );
499 on_toolbar_back_clicked (GtkButton *button,
507 on_toolbar_stop_clicked (GtkButton *button,
515 on_toolbar_play_clicked (GtkButton *button,
518 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
520 if( p_intf->p_input != NULL )
522 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
528 on_toolbar_pause_clicked (GtkButton *button,
531 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
533 if( p_intf->p_input != NULL )
535 input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
541 on_toolbar_slow_clicked (GtkButton *button,
544 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
546 if( p_intf->p_input != NULL )
548 input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
554 on_toolbar_fast_clicked (GtkButton *button,
557 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
559 if( p_intf->p_input != NULL )
561 input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
567 on_toolbar_playlist_clicked (GtkButton *button,
570 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
572 if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
574 p_intf->p_sys->p_playlist = create_intf_playlist();
575 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
578 gtk_widget_show( p_intf->p_sys->p_playlist );
579 gdk_window_raise( p_intf->p_sys->p_playlist->window );
584 on_toolbar_prev_clicked (GtkButton *button,
587 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
589 if( p_intf->p_input != NULL )
591 /* FIXME: temporary hack */
592 intf_PlaylistPrev( p_main->p_playlist );
593 intf_PlaylistPrev( p_main->p_playlist );
594 p_intf->p_input->b_eof = 1;
597 p_intf->p_sys->b_mode_changed = 1;
602 on_toolbar_next_clicked (GtkButton *button,
605 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
607 if( p_intf->p_input != NULL )
609 /* FIXME: temporary hack */
610 p_intf->p_input->b_eof = 1;
613 p_intf->p_sys->b_mode_changed = 1;
617 /*****************************************************************************
619 *****************************************************************************
620 * The following callbacks are related to the popup menu. The popup
621 * menu is activated when right-clicking on the video output window.
622 *****************************************************************************/
624 on_popup_play_activate (GtkMenuItem *menuitem,
627 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
629 if( p_intf->p_input != NULL )
631 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
637 on_popup_pause_activate (GtkMenuItem *menuitem,
640 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
642 if( p_intf->p_input != NULL )
644 input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
650 on_popup_slow_activate (GtkMenuItem *menuitem,
653 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
655 if( p_intf->p_input != NULL )
657 input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
663 on_popup_fast_activate (GtkMenuItem *menuitem,
666 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
668 if( p_intf->p_input != NULL )
670 input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
676 on_popup_audio_toggle (GtkCheckMenuItem *menuitem,
679 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
680 es_descriptor_t * p_es;
682 p_es = (es_descriptor_t*)user_data;
684 if( !p_intf->p_sys->b_menus_update )
686 input_ToggleES( p_intf->p_input, p_es, menuitem->active );
692 on_popup_subtitle_toggle (GtkCheckMenuItem *menuitem,
695 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
696 es_descriptor_t * p_es;
698 p_es = (es_descriptor_t*)user_data;
700 if( !p_intf->p_sys->b_menus_update )
702 input_ToggleES( p_intf->p_input, p_es, menuitem->active );
708 on_popup_navigation_toggle (GtkCheckMenuItem *menuitem,
711 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
713 if( menuitem->active && !p_intf->p_sys->b_menus_update )
715 input_area_t * p_area;
719 i_title = (gint)(user_data) / 100;
720 i_chapter = (gint)(user_data) - ( 100 * i_title );
722 p_area = p_intf->p_input->stream.pp_areas[i_title];
723 p_area->i_part = i_chapter;
725 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
727 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
729 p_intf->p_sys->b_menus_update = 1;
735 on_popup_open_activate (GtkMenuItem *menuitem,
738 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
740 /* If we have never used the file selector, open it */
741 if( p_intf->p_sys->p_fileopen == NULL)
743 p_intf->p_sys->p_fileopen = create_intf_fileopen();
744 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
748 gtk_widget_show( p_intf->p_sys->p_fileopen );
749 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
754 on_popup_disc_activate (GtkMenuItem *menuitem,
757 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
759 gtk_widget_show( p_intf->p_sys->p_disc );
760 gdk_window_raise( p_intf->p_sys->p_disc->window );
765 on_popup_network_activate (GtkMenuItem *menuitem,
768 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
770 gtk_widget_show( p_intf->p_sys->p_network );
771 gdk_window_raise( p_intf->p_sys->p_network->window );
776 on_popup_about_activate (GtkMenuItem *menuitem,
779 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
781 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
783 p_intf->p_sys->p_about = create_intf_about();
784 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
787 gtk_widget_show( p_intf->p_sys->p_about );
788 gdk_window_raise( p_intf->p_sys->p_about->window );
793 on_popup_exit_activate (GtkMenuItem *menuitem,
796 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
798 vlc_mutex_lock( &p_intf->change_lock );
800 vlc_mutex_unlock( &p_intf->change_lock );
804 /*****************************************************************************
806 *****************************************************************************
807 * The following callbacks are related to the file requester.
808 *****************************************************************************/
810 on_intf_fileopen_destroy (GtkObject *object,
813 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_fileopen" );
815 p_intf->p_sys->p_fileopen = NULL;
820 on_fileopen_ok_clicked (GtkButton *button,
823 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_fileopen" );
828 filesel = gtk_widget_get_toplevel (GTK_WIDGET (button));
829 gtk_widget_hide (filesel);
830 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
832 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
834 /* Select added item and switch to file interface */
835 intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
836 if( p_intf->p_input != NULL )
837 p_intf->p_input->b_eof = 1;
838 p_intf->p_sys->i_intf_mode = FILE_MODE;
839 p_intf->p_sys->b_mode_changed = 1;
844 on_fileopen_cancel_clicked (GtkButton *button,
847 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
851 /*****************************************************************************
853 *****************************************************************************
854 * The following callbacks are related to the playlist.
855 *****************************************************************************/
857 on_intf_playlist_destroy (GtkObject *object,
860 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_playlist" );
862 p_intf->p_sys->p_playlist = NULL;
867 on_playlist_ok_clicked (GtkButton *button,
870 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_playlist" );
872 gtk_widget_hide( p_intf->p_sys->p_playlist );
877 on_playlist_close_clicked (GtkButton *button,
880 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
885 /*****************************************************************************
886 * Module manager callbacks
887 *****************************************************************************
888 * The following callbacks are related to the module manager.
889 *****************************************************************************/
891 on_intf_modules_destroy (GtkObject *object,
899 on_modules_ok_clicked (GtkButton *button,
902 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
904 gtk_widget_hide( p_intf->p_sys->p_modules );
909 on_modules_apply_clicked (GtkButton *button,
917 on_modules_cancel_clicked (GtkButton *button,
920 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
924 /*****************************************************************************
925 * Open disc callbacks
926 *****************************************************************************
927 * The following callbacks are related to the disc manager.
928 *****************************************************************************/
930 on_disc_dvd_toggled (GtkToggleButton *togglebutton,
933 if( togglebutton->active )
935 gtk_entry_set_text( GTK_ENTRY( lookup_widget(
936 GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/dvd" );
942 on_disc_vcd_toggled (GtkToggleButton *togglebutton,
945 if( togglebutton->active )
947 gtk_entry_set_text( GTK_ENTRY( lookup_widget(
948 GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/cdrom" );
954 on_disc_ok_clicked (GtkButton *button,
957 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
958 char *psz_device, *psz_source, *psz_method;
960 psz_device = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
961 GTK_WIDGET(button), "disc_name" ) ) );
963 /* "dvd:foo" has size 5 + strlen(foo) */
964 psz_source = malloc( 5 + strlen( psz_device ) );
965 if( psz_source == NULL )
970 /* Check which method was activated */
971 if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
972 "disc_dvd" ) )->active )
975 p_intf->p_sys->i_intf_mode = DVD_MODE;
977 else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
978 "disc_vcd" ) )->active )
984 intf_ErrMsg( "intf error: unknown disc type toggle button position" );
989 /* Select title and chapter */
990 main_PutIntVariable( INPUT_TITLE_VAR, gtk_spin_button_get_value_as_int(
991 GTK_SPIN_BUTTON( lookup_widget(
992 GTK_WIDGET(button), "disc_title" ) ) ) );
994 main_PutIntVariable( INPUT_CHAPTER_VAR, gtk_spin_button_get_value_as_int(
995 GTK_SPIN_BUTTON( lookup_widget(
996 GTK_WIDGET(button), "disc_chapter" ) ) ) );
998 /* Build source name and add it to playlist */
999 sprintf( psz_source, "%s:%s", psz_method, psz_device );
1000 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
1003 /* Select added item and switch to DVD interface */
1004 intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
1005 if( p_intf->p_input != NULL )
1006 p_intf->p_input->b_eof = 1;
1007 p_intf->p_sys->b_mode_changed = 1;
1009 gtk_widget_hide( p_intf->p_sys->p_disc );
1014 on_disc_cancel_clicked (GtkButton *button,
1017 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
1021 /*****************************************************************************
1022 * Network stream callbacks
1023 *****************************************************************************
1024 * The following callbacks are related to the network stream manager.
1025 *****************************************************************************/
1027 on_network_ok_clicked (GtkButton *button,
1030 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_network" );
1031 char *psz_source, *psz_server, *psz_protocol;
1032 unsigned int i_port;
1034 psz_server = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
1035 GTK_WIDGET(button), "network_server" ) ) );
1037 /* Check which protocol was activated */
1038 if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1039 "network_ts" ) )->active )
1041 psz_protocol = "ts";
1043 else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1044 "network_rtp" ) )->active )
1046 psz_protocol = "rtp";
1050 intf_ErrMsg( "intf error: unknown protocol toggle button position" );
1054 /* Get the port number and make sure it will not overflow 5 characters */
1055 i_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
1056 lookup_widget( GTK_WIDGET(button), "network_port" ) ) );
1057 if( i_port > 65535 )
1059 intf_ErrMsg( "intf error: invalid port %i", i_port );
1062 /* Allocate room for "protocol://server:port" */
1063 psz_source = malloc( strlen( psz_protocol ) + strlen( psz_server ) + 10 );
1064 if( psz_source == NULL )
1069 /* Build source name and add it to playlist */
1070 sprintf( psz_source, "%s://%s:%i", psz_protocol, psz_server, i_port );
1071 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
1074 /* Select added item and switch to network interface */
1075 intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
1076 if( p_intf->p_input != NULL )
1077 p_intf->p_input->b_eof = 1;
1078 p_intf->p_sys->b_mode_changed = 1;
1079 p_intf->p_sys->i_intf_mode = NET_MODE;
1081 gtk_widget_hide( p_intf->p_sys->p_network );
1086 on_network_cancel_clicked (GtkButton *button,
1089 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );