1 /*****************************************************************************
2 * gnome_callbacks.c : Callbacks for the Gnome plugin.
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
5 * $Id: gnome_callbacks.c,v 1.24 2001/04/22 00:08:26 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;
413 on_menubar_angle_toggle (GtkCheckMenuItem *menuitem,
416 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
417 input_area_t * p_area = p_intf->p_input->stream.p_selected_area;
418 gint i_angle = (gint)user_data;
420 if( menuitem->active && !p_intf->p_sys->b_angle_update )
422 p_area->i_angle = i_angle;
423 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
425 p_intf->p_sys->b_angle_update = 1;
431 on_menubar_modules_activate (GtkMenuItem *menuitem,
434 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
436 if( !GTK_IS_WIDGET( p_intf->p_sys->p_modules ) )
438 p_intf->p_sys->p_modules = create_intf_modules();
439 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_modules ),
442 gtk_widget_show( p_intf->p_sys->p_modules );
443 gdk_window_raise( p_intf->p_sys->p_modules->window );
448 on_menubar_preferences_activate (GtkMenuItem *menuitem,
456 on_menubar_about_activate (GtkMenuItem *menuitem,
459 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
461 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
463 p_intf->p_sys->p_about = create_intf_about();
464 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
467 gtk_widget_show( p_intf->p_sys->p_about );
468 gdk_window_raise( p_intf->p_sys->p_about->window );
472 /*****************************************************************************
474 *****************************************************************************
475 * The following callbacks are related to the toolbar of the main
477 *****************************************************************************/
479 on_toolbar_open_clicked (GtkButton *button,
482 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
484 /* If we have never used the file selector, open it */
485 if( p_intf->p_sys->p_fileopen == NULL)
487 p_intf->p_sys->p_fileopen = create_intf_fileopen();
488 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
492 gtk_widget_show( p_intf->p_sys->p_fileopen );
493 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
498 on_toolbar_disc_clicked (GtkButton *button,
501 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
503 gtk_widget_show( p_intf->p_sys->p_disc );
504 gdk_window_raise( p_intf->p_sys->p_disc->window );
509 on_toolbar_network_clicked (GtkButton *button,
512 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
514 gtk_widget_show( p_intf->p_sys->p_network );
515 gdk_window_raise( p_intf->p_sys->p_network->window );
520 on_toolbar_back_clicked (GtkButton *button,
528 on_toolbar_stop_clicked (GtkButton *button,
536 on_toolbar_play_clicked (GtkButton *button,
539 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
541 if( p_intf->p_input != NULL )
543 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
549 on_toolbar_pause_clicked (GtkButton *button,
552 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
554 if( p_intf->p_input != NULL )
556 input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
562 on_toolbar_slow_clicked (GtkButton *button,
565 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
567 if( p_intf->p_input != NULL )
569 input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
575 on_toolbar_fast_clicked (GtkButton *button,
578 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
580 if( p_intf->p_input != NULL )
582 input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
588 on_toolbar_playlist_clicked (GtkButton *button,
591 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
593 if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
595 p_intf->p_sys->p_playlist = create_intf_playlist();
596 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
599 gtk_widget_show( p_intf->p_sys->p_playlist );
600 gdk_window_raise( p_intf->p_sys->p_playlist->window );
605 on_toolbar_prev_clicked (GtkButton *button,
608 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
610 if( p_intf->p_input != NULL )
612 /* FIXME: temporary hack */
613 intf_PlaylistPrev( p_main->p_playlist );
614 intf_PlaylistPrev( p_main->p_playlist );
615 p_intf->p_input->b_eof = 1;
618 p_intf->p_sys->b_mode_changed = 1;
623 on_toolbar_next_clicked (GtkButton *button,
626 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
628 if( p_intf->p_input != NULL )
630 /* FIXME: temporary hack */
631 p_intf->p_input->b_eof = 1;
634 p_intf->p_sys->b_mode_changed = 1;
638 /*****************************************************************************
640 *****************************************************************************
641 * The following callbacks are related to the popup menu. The popup
642 * menu is activated when right-clicking on the video output window.
643 *****************************************************************************/
645 on_popup_play_activate (GtkMenuItem *menuitem,
648 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
650 if( p_intf->p_input != NULL )
652 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
658 on_popup_pause_activate (GtkMenuItem *menuitem,
661 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
663 if( p_intf->p_input != NULL )
665 input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
671 on_popup_slow_activate (GtkMenuItem *menuitem,
674 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
676 if( p_intf->p_input != NULL )
678 input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
684 on_popup_fast_activate (GtkMenuItem *menuitem,
687 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
689 if( p_intf->p_input != NULL )
691 input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
697 on_popup_audio_toggle (GtkCheckMenuItem *menuitem,
700 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
701 es_descriptor_t * p_es;
703 p_es = (es_descriptor_t*)user_data;
705 if( !p_intf->p_sys->b_audio_update )
707 input_ToggleES( p_intf->p_input, p_es, menuitem->active );
709 p_intf->p_sys->b_audio_update = menuitem->active;
715 on_popup_subtitle_toggle (GtkCheckMenuItem *menuitem,
718 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
719 es_descriptor_t * p_es;
721 p_es = (es_descriptor_t*)user_data;
723 if( !p_intf->p_sys->b_spu_update )
725 input_ToggleES( p_intf->p_input, p_es, menuitem->active );
727 p_intf->p_sys->b_spu_update = menuitem->active;
733 on_popup_navigation_toggle (GtkCheckMenuItem *menuitem,
736 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
738 if( menuitem->active &&
739 !p_intf->p_sys->b_title_update &&
740 !p_intf->p_sys->b_chapter_update )
742 input_area_t * p_area;
746 i_title = (gint)(user_data) / 100;
747 i_chapter = (gint)(user_data) - ( 100 * i_title );
748 p_area = p_intf->p_input->stream.p_selected_area;
751 if( p_area != p_intf->p_input->stream.pp_areas[i_title] )
753 p_area = p_intf->p_input->stream.pp_areas[i_title];
754 p_intf->p_sys->b_title_update = 1;
757 p_area->i_part = i_chapter;
758 p_intf->p_sys->b_chapter_update = 1;
760 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
762 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
768 on_popup_angle_toggle (GtkCheckMenuItem *menuitem,
771 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
772 input_area_t * p_area = p_intf->p_input->stream.p_selected_area;
773 gint i_angle = (gint)user_data;
775 if( menuitem->active && !p_intf->p_sys->b_angle_update )
777 p_area->i_angle = i_angle;
778 p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
780 p_intf->p_sys->b_angle_update = 1;
786 on_popup_open_activate (GtkMenuItem *menuitem,
789 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
791 /* If we have never used the file selector, open it */
792 if( p_intf->p_sys->p_fileopen == NULL)
794 p_intf->p_sys->p_fileopen = create_intf_fileopen();
795 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
799 gtk_widget_show( p_intf->p_sys->p_fileopen );
800 gdk_window_raise( p_intf->p_sys->p_fileopen->window );
805 on_popup_disc_activate (GtkMenuItem *menuitem,
808 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
810 gtk_widget_show( p_intf->p_sys->p_disc );
811 gdk_window_raise( p_intf->p_sys->p_disc->window );
816 on_popup_network_activate (GtkMenuItem *menuitem,
819 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
821 gtk_widget_show( p_intf->p_sys->p_network );
822 gdk_window_raise( p_intf->p_sys->p_network->window );
827 on_popup_about_activate (GtkMenuItem *menuitem,
830 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
832 if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
834 p_intf->p_sys->p_about = create_intf_about();
835 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
838 gtk_widget_show( p_intf->p_sys->p_about );
839 gdk_window_raise( p_intf->p_sys->p_about->window );
844 on_popup_exit_activate (GtkMenuItem *menuitem,
847 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
849 vlc_mutex_lock( &p_intf->change_lock );
851 vlc_mutex_unlock( &p_intf->change_lock );
855 /*****************************************************************************
857 *****************************************************************************
858 * The following callbacks are related to the file requester.
859 *****************************************************************************/
861 on_intf_fileopen_destroy (GtkObject *object,
864 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_fileopen" );
866 p_intf->p_sys->p_fileopen = NULL;
871 on_fileopen_ok_clicked (GtkButton *button,
874 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_fileopen" );
879 filesel = gtk_widget_get_toplevel (GTK_WIDGET (button));
880 gtk_widget_hide (filesel);
881 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
883 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
885 /* Select added item and switch to file interface */
886 if( p_intf->p_input != NULL )
887 p_intf->p_input->b_eof = 1;
889 // p_intf->p_sys->b_mode_changed = 1;
894 on_fileopen_cancel_clicked (GtkButton *button,
897 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
901 /*****************************************************************************
903 *****************************************************************************
904 * The following callbacks are related to the playlist.
905 *****************************************************************************/
907 on_intf_playlist_destroy (GtkObject *object,
910 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_playlist" );
912 p_intf->p_sys->p_playlist = NULL;
917 on_playlist_ok_clicked (GtkButton *button,
920 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_playlist" );
922 gtk_widget_hide( p_intf->p_sys->p_playlist );
927 on_playlist_close_clicked (GtkButton *button,
930 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
935 /*****************************************************************************
936 * Module manager callbacks
937 *****************************************************************************
938 * The following callbacks are related to the module manager.
939 *****************************************************************************/
941 on_intf_modules_destroy (GtkObject *object,
949 on_modules_ok_clicked (GtkButton *button,
952 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
954 gtk_widget_hide( p_intf->p_sys->p_modules );
959 on_modules_apply_clicked (GtkButton *button,
967 on_modules_cancel_clicked (GtkButton *button,
970 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
974 /*****************************************************************************
975 * Open disc callbacks
976 *****************************************************************************
977 * The following callbacks are related to the disc manager.
978 *****************************************************************************/
980 on_disc_dvd_toggled (GtkToggleButton *togglebutton,
983 if( togglebutton->active )
985 gtk_entry_set_text( GTK_ENTRY( lookup_widget(
986 GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/dvd" );
992 on_disc_vcd_toggled (GtkToggleButton *togglebutton,
995 if( togglebutton->active )
997 gtk_entry_set_text( GTK_ENTRY( lookup_widget(
998 GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/cdrom" );
1004 on_disc_ok_clicked (GtkButton *button,
1007 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
1008 char *psz_device, *psz_source, *psz_method;
1010 psz_device = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
1011 GTK_WIDGET(button), "disc_name" ) ) );
1013 /* "dvd:foo" has size 5 + strlen(foo) */
1014 psz_source = malloc( 5 + strlen( psz_device ) );
1015 if( psz_source == NULL )
1020 /* Check which method was activated */
1021 if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1022 "disc_dvd" ) )->active )
1025 p_intf->p_sys->i_intf_mode = DVD_MODE;
1027 else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1028 "disc_vcd" ) )->active )
1034 intf_ErrMsg( "intf error: unknown disc type toggle button position" );
1039 /* Select title and chapter */
1040 main_PutIntVariable( INPUT_TITLE_VAR, gtk_spin_button_get_value_as_int(
1041 GTK_SPIN_BUTTON( lookup_widget(
1042 GTK_WIDGET(button), "disc_title" ) ) ) );
1044 main_PutIntVariable( INPUT_CHAPTER_VAR, gtk_spin_button_get_value_as_int(
1045 GTK_SPIN_BUTTON( lookup_widget(
1046 GTK_WIDGET(button), "disc_chapter" ) ) ) );
1048 /* Build source name and add it to playlist */
1049 sprintf( psz_source, "%s:%s", psz_method, psz_device );
1050 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
1053 /* Select added item and switch to DVD interface */
1054 intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
1055 if( p_intf->p_input != NULL )
1056 p_intf->p_input->b_eof = 1;
1057 // p_intf->p_sys->b_mode_changed = 1;
1059 gtk_widget_hide( p_intf->p_sys->p_disc );
1064 on_disc_cancel_clicked (GtkButton *button,
1067 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
1071 /*****************************************************************************
1072 * Network stream callbacks
1073 *****************************************************************************
1074 * The following callbacks are related to the network stream manager.
1075 *****************************************************************************/
1077 on_network_ok_clicked (GtkButton *button,
1080 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_network" );
1081 char *psz_source, *psz_server, *psz_protocol;
1082 unsigned int i_port;
1084 psz_server = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
1085 GTK_WIDGET(button), "network_server" ) ) );
1087 /* Check which protocol was activated */
1088 if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1089 "network_ts" ) )->active )
1091 psz_protocol = "ts";
1093 else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1094 "network_rtp" ) )->active )
1096 psz_protocol = "rtp";
1100 intf_ErrMsg( "intf error: unknown protocol toggle button position" );
1104 /* Get the port number and make sure it will not overflow 5 characters */
1105 i_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
1106 lookup_widget( GTK_WIDGET(button), "network_port" ) ) );
1107 if( i_port > 65535 )
1109 intf_ErrMsg( "intf error: invalid port %i", i_port );
1112 /* Allocate room for "protocol://server:port" */
1113 psz_source = malloc( strlen( psz_protocol ) + strlen( psz_server ) + 10 );
1114 if( psz_source == NULL )
1119 /* Build source name and add it to playlist */
1120 sprintf( psz_source, "%s://%s:%i", psz_protocol, psz_server, i_port );
1121 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
1124 /* Select added item and switch to network interface */
1125 intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
1126 if( p_intf->p_input != NULL )
1127 p_intf->p_input->b_eof = 1;
1128 // p_intf->p_sys->b_mode_changed = 1;
1130 gtk_widget_hide( p_intf->p_sys->p_network );
1135 on_network_cancel_clicked (GtkButton *button,
1138 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );