]> git.sesse.net Git - vlc/blob - plugins/gnome/gnome_callbacks.c
* Header cleaning: filled all empty authors fields, added CVS $Id stuff.
[vlc] / plugins / gnome / gnome_callbacks.c
1 /*****************************************************************************
2  * gnome_callbacks.c : Callbacks for the Gnome plugin.
3  *****************************************************************************
4  * Copyright (C) 2000, 2001 VideoLAN
5  * $Id: gnome_callbacks.c,v 1.18 2001/03/21 13:42:34 sam Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *      
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  * 
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #define MODULE_NAME gnome
25 #include "modules_inner.h"
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30 #include "defs.h"
31
32 #include <gnome.h>
33
34 #include "config.h"
35 #include "common.h"
36 #include "threads.h"
37 #include "mtime.h"
38
39 #include "stream_control.h"
40 #include "input_ext-intf.h"
41
42 #include "interface.h"
43 #include "intf_playlist.h"
44 #include "intf_msg.h"
45
46 #include "gnome_callbacks.h"
47 #include "gnome_interface.h"
48 #include "gnome_support.h"
49 #include "intf_gnome.h"
50
51 #include "main.h"
52
53 /*****************************************************************************
54  * Inline function to retrieve the interface structure
55  *****************************************************************************/
56 static __inline__ intf_thread_t * GetIntf( GtkWidget *item, char * psz_parent )
57 {
58     return( gtk_object_get_data( GTK_OBJECT( lookup_widget(item, psz_parent) ),
59                                  "p_intf" ) );
60 }
61
62
63 /*****************************************************************************
64  * Interface callbacks
65  *****************************************************************************
66  * The following callbacks are related to the main interface window.
67  *****************************************************************************/
68 void
69 on_intf_window_destroy                 (GtkObject       *object,
70                                         gpointer         user_data)
71 {
72     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_window" );
73
74     vlc_mutex_lock( &p_intf->change_lock );
75     p_intf->b_die = 1;
76     vlc_mutex_unlock( &p_intf->change_lock );
77 }
78
79
80 gboolean
81 on_slider_button_press_event           (GtkWidget       *widget,
82                                         GdkEventButton  *event,
83                                         gpointer         user_data)
84 {
85     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
86
87     vlc_mutex_lock( &p_intf->change_lock );
88     p_intf->p_sys->b_slider_free = 0;
89     vlc_mutex_unlock( &p_intf->change_lock );
90
91     return FALSE;
92 }
93
94
95 gboolean
96 on_slider_button_release_event         (GtkWidget       *widget,
97                                         GdkEventButton  *event,
98                                         gpointer         user_data)
99 {
100     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
101
102     vlc_mutex_lock( &p_intf->change_lock );
103     p_intf->p_sys->b_slider_free = 1;
104     vlc_mutex_unlock( &p_intf->change_lock );
105
106     return FALSE;
107 }
108
109
110 void
111 on_intf_window_drag_data_received      (GtkWidget       *widget,
112                                         GdkDragContext  *drag_context,
113                                         gint             x,
114                                         gint             y,
115                                         GtkSelectionData *data,
116                                         guint            info,
117                                         guint            time,
118                                         gpointer         user_data)
119 {
120     char *psz_text = data->data;
121     int i_len      = strlen( psz_text );
122
123     switch( info )
124     {
125     case DROP_ACCEPT_TEXT_PLAIN: /* FIXME: handle multiple files */
126
127         if( i_len < 1 )
128         {
129             return;
130         }
131
132         /* get rid of ' ' at the end */
133         *( psz_text + i_len - 1 ) = 0;
134
135         intf_WarnMsg( 1, "intf: dropped text/uri-list data `%s'", psz_text );
136         intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_text );
137
138         break;
139
140     case DROP_ACCEPT_TEXT_URI_LIST: /* FIXME: handle multiple files */
141
142         if( i_len < 2 )
143         {
144             return;
145         }
146
147         /* get rid of \r\n at the end */
148         *( psz_text + i_len - 2 ) = 0;
149
150         intf_WarnMsg( 1, "intf: dropped text/uri-list data `%s'", psz_text );
151         intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_text );
152         break;
153
154     default:
155
156         intf_ErrMsg( "intf error: unknown dropped type");
157         break;
158     }
159 }
160
161
162 /*****************************************************************************
163  * Menubar callbacks
164  *****************************************************************************
165  * The following callbacks are related to the menubar of the main
166  * interface window.
167  *****************************************************************************/
168 void
169 on_menubar_open_activate               (GtkMenuItem     *menuitem,
170                                         gpointer         user_data)
171 {
172     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
173
174     /* If we have never used the file selector, open it */
175     if( p_intf->p_sys->p_fileopen == NULL)
176     {
177         p_intf->p_sys->p_fileopen = create_intf_fileopen();
178         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
179                              "p_intf", p_intf );
180     }
181
182     gtk_widget_show( p_intf->p_sys->p_fileopen );
183     gdk_window_raise( p_intf->p_sys->p_fileopen->window );
184 }
185
186
187 void
188 on_menubar_disc_activate               (GtkMenuItem     *menuitem,
189                                         gpointer         user_data)
190 {
191     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
192
193     gtk_widget_show( p_intf->p_sys->p_disc );
194     gdk_window_raise( p_intf->p_sys->p_disc->window );
195 }
196
197
198 void
199 on_menubar_network_activate            (GtkMenuItem     *menuitem,
200                                         gpointer         user_data)
201 {
202     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
203
204     gtk_widget_show( p_intf->p_sys->p_network );
205     gdk_window_raise( p_intf->p_sys->p_network->window );
206 }
207
208
209 void
210 on_menubar_exit_activate               (GtkMenuItem     *menuitem,
211                                         gpointer         user_data)
212 {
213     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
214
215     vlc_mutex_lock( &p_intf->change_lock );
216     p_intf->b_die = 1;
217     vlc_mutex_unlock( &p_intf->change_lock );
218 }
219
220
221 void
222 on_menubar_playlist_activate           (GtkMenuItem     *menuitem,
223                                         gpointer         user_data)
224 {
225     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
226
227     if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
228     {
229         p_intf->p_sys->p_playlist = create_intf_playlist();
230         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
231                              "p_intf", p_intf );
232     }
233     gtk_widget_show( p_intf->p_sys->p_playlist );
234     gdk_window_raise( p_intf->p_sys->p_playlist->window );
235 }
236
237
238 void
239 on_menubar_audio_toggle                (GtkCheckMenuItem     *menuitem,
240                                         gpointer              user_data)
241 {
242     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
243     es_descriptor_t *       p_es;
244
245     p_es = (es_descriptor_t*)user_data;
246
247     input_ChangeES( p_intf->p_input, p_es, 1 );
248 }
249
250
251 void
252 on_menubar_subtitle_toggle             (GtkCheckMenuItem     *menuitem,
253                                         gpointer              user_data)
254 {
255     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
256     es_descriptor_t *       p_es;
257
258     p_es = (es_descriptor_t*)user_data;
259
260     input_ChangeES( p_intf->p_input, p_es, 2 );
261 }
262
263
264 void
265 on_menubar_title_toggle                (GtkCheckMenuItem     *menuitem,
266                                         gpointer              user_data)
267 {
268     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
269
270     p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)user_data );
271     p_intf->p_sys->b_menus_update = 1;
272     input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
273 }
274
275
276 void
277 on_menubar_chapter_toggle              (GtkCheckMenuItem     *menuitem,
278                                         gpointer              user_data)
279 {
280     intf_thread_t * p_intf    = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
281     input_area_t *  p_area    = p_intf->p_input->stream.p_selected_area;
282     gint            i_chapter = (gint)user_data;
283
284     p_area->i_part = i_chapter;
285
286     p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
287     input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
288 }
289
290 void
291 on_menubar_modules_activate            (GtkMenuItem     *menuitem,
292                                         gpointer         user_data)
293 {
294     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
295
296     if( !GTK_IS_WIDGET( p_intf->p_sys->p_modules ) )
297     {
298         p_intf->p_sys->p_modules = create_intf_modules();
299         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_modules ),
300                              "p_intf", p_intf );
301     }
302     gtk_widget_show( p_intf->p_sys->p_modules );
303     gdk_window_raise( p_intf->p_sys->p_modules->window );
304 }
305
306
307 void
308 on_menubar_preferences_activate        (GtkMenuItem     *menuitem,
309                                         gpointer         user_data)
310 {
311
312 }
313
314
315 void
316 on_menubar_about_activate              (GtkMenuItem     *menuitem,
317                                         gpointer         user_data)
318 {
319     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
320
321     if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
322     {
323         p_intf->p_sys->p_about = create_intf_about();
324         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
325                              "p_intf", p_intf );
326     }
327     gtk_widget_show( p_intf->p_sys->p_about );
328     gdk_window_raise( p_intf->p_sys->p_about->window );
329 }
330
331
332 /*****************************************************************************
333  * Toolbar callbacks
334  *****************************************************************************
335  * The following callbacks are related to the toolbar of the main
336  * interface window.
337  *****************************************************************************/
338 void
339 on_toolbar_open_clicked                (GtkButton       *button,
340                                         gpointer         user_data)
341 {
342     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
343
344     /* If we have never used the file selector, open it */
345     if( p_intf->p_sys->p_fileopen == NULL)
346     {
347         p_intf->p_sys->p_fileopen = create_intf_fileopen();
348         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
349                              "p_intf", p_intf );
350     }
351
352     gtk_widget_show( p_intf->p_sys->p_fileopen );
353     gdk_window_raise( p_intf->p_sys->p_fileopen->window );
354 }
355
356
357 void
358 on_toolbar_disc_clicked                (GtkButton       *button,
359                                         gpointer         user_data)
360 {
361     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
362
363     gtk_widget_show( p_intf->p_sys->p_disc );
364     gdk_window_raise( p_intf->p_sys->p_disc->window );
365 }
366
367
368 void
369 on_toolbar_network_clicked             (GtkButton       *button,
370                                         gpointer         user_data)
371 {
372     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
373
374     gtk_widget_show( p_intf->p_sys->p_network );
375     gdk_window_raise( p_intf->p_sys->p_network->window );
376 }
377
378
379 void
380 on_toolbar_back_clicked                (GtkButton       *button,
381                                         gpointer         user_data)
382 {
383
384 }
385
386
387 void
388 on_toolbar_stop_clicked                (GtkButton       *button,
389                                         gpointer         user_data)
390 {
391
392 }
393
394
395 void
396 on_toolbar_play_clicked                (GtkButton       *button,
397                                         gpointer         user_data)
398 {
399     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
400
401     if( p_intf->p_input != NULL )
402     {
403         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
404     }
405 }
406
407
408 void
409 on_toolbar_pause_clicked               (GtkButton       *button,
410                                         gpointer         user_data)
411 {
412     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
413
414     if( p_intf->p_input != NULL )
415     {
416         input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
417     }
418 }
419
420
421 void
422 on_toolbar_slow_clicked                (GtkButton       *button,
423                                         gpointer         user_data)
424 {
425     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
426
427     if( p_intf->p_input != NULL )
428     {
429         input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
430     }
431 }
432
433
434 void
435 on_toolbar_fast_clicked                (GtkButton       *button,
436                                         gpointer         user_data)
437 {
438     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
439
440     if( p_intf->p_input != NULL )
441     {
442         input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
443     }
444 }
445
446
447 void
448 on_toolbar_playlist_clicked            (GtkButton       *button,
449                                         gpointer         user_data)
450 {
451     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
452
453     if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
454     {
455         p_intf->p_sys->p_playlist = create_intf_playlist();
456         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
457                              "p_intf", p_intf );
458     }
459     gtk_widget_show( p_intf->p_sys->p_playlist );
460     gdk_window_raise( p_intf->p_sys->p_playlist->window );
461 }
462
463
464 void
465 on_toolbar_prev_clicked                (GtkButton       *button,
466                                         gpointer         user_data)
467 {
468     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
469
470     if( p_intf->p_input != NULL )
471     {
472         /* FIXME: temporary hack */
473         intf_PlaylistPrev( p_main->p_playlist );
474         intf_PlaylistPrev( p_main->p_playlist );
475         p_intf->p_input->b_eof = 1;
476     }
477 }
478
479
480 void
481 on_toolbar_next_clicked                (GtkButton       *button,
482                                         gpointer         user_data)
483 {
484     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
485
486     if( p_intf->p_input != NULL )
487     {
488         /* FIXME: temporary hack */
489         p_intf->p_input->b_eof = 1;
490     }
491 }
492
493
494 /*****************************************************************************
495  * Popup callbacks
496  *****************************************************************************
497  * The following callbacks are related to the popup menu. The popup
498  * menu is activated when right-clicking on the video output window.
499  *****************************************************************************/
500 void
501 on_popup_play_activate                 (GtkMenuItem     *menuitem,
502                                         gpointer         user_data)
503 {
504     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
505
506     if( p_intf->p_input != NULL )
507     {
508         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
509     }
510 }
511
512
513 void
514 on_popup_pause_activate                (GtkMenuItem     *menuitem,
515                                         gpointer         user_data)
516 {
517     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
518
519     if( p_intf->p_input != NULL )
520     {
521         input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
522     }
523 }
524
525
526 void
527 on_popup_slow_activate                 (GtkMenuItem     *menuitem,
528                                         gpointer         user_data)
529 {
530     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
531
532     if( p_intf->p_input != NULL )
533     {
534         input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
535     }
536 }
537
538
539 void
540 on_popup_fast_activate                 (GtkMenuItem     *menuitem,
541                                         gpointer         user_data)
542 {
543     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
544
545     if( p_intf->p_input != NULL )
546     {
547         input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
548     }
549 }
550
551
552 void
553 on_popup_audio_toggle                  (GtkCheckMenuItem     *menuitem,
554                                         gpointer              user_data)
555 {
556     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
557     es_descriptor_t *       p_es;
558
559     p_es = (es_descriptor_t*)user_data;
560
561     input_ChangeES( p_intf->p_input, p_es, 1 );
562 }
563
564
565 void
566 on_popup_subtitle_toggle            (GtkCheckMenuItem     *menuitem,
567                                      gpointer              user_data)
568 {
569     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
570     es_descriptor_t *       p_es;
571
572     p_es = (es_descriptor_t*)user_data;
573
574     input_ChangeES( p_intf->p_input, p_es, 2 );
575 }
576
577
578 void
579 on_popup_navigation_toggle             (GtkCheckMenuItem     *menuitem,
580                                         gpointer             user_data)
581 {
582     if( menuitem->active )
583     {
584         intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
585         input_area_t *  p_area;
586         gint            i_title;
587         gint            i_chapter;
588
589         i_title   = (gint)(user_data) / 100 ;
590         i_chapter = (gint)(user_data) - ( 100 * i_title );
591
592         if( i_title != p_intf->p_input->stream.p_selected_area->i_id )
593         {
594             p_intf->p_sys->b_menus_update = 1;
595         }
596
597         p_area = p_intf->p_input->stream.pp_areas[i_title];
598         p_area->i_part = i_chapter;
599
600         p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
601                 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
602     }
603 }
604
605
606 void
607 on_popup_open_activate                 (GtkMenuItem     *menuitem,
608                                         gpointer         user_data)
609 {
610     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
611
612     /* If we have never used the file selector, open it */
613     if( p_intf->p_sys->p_fileopen == NULL)
614     {
615         p_intf->p_sys->p_fileopen = create_intf_fileopen();
616         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
617                              "p_intf", p_intf );
618     }
619
620     gtk_widget_show( p_intf->p_sys->p_fileopen );
621     gdk_window_raise( p_intf->p_sys->p_fileopen->window );
622 }
623
624
625 void
626 on_popup_disc_activate                 (GtkMenuItem     *menuitem,
627                                         gpointer         user_data)
628 {
629     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
630
631     gtk_widget_show( p_intf->p_sys->p_disc );
632     gdk_window_raise( p_intf->p_sys->p_disc->window );
633 }
634
635
636 void
637 on_popup_network_activate              (GtkMenuItem     *menuitem,
638                                         gpointer         user_data)
639 {
640     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
641
642     gtk_widget_show( p_intf->p_sys->p_network );
643     gdk_window_raise( p_intf->p_sys->p_network->window );
644 }
645
646
647 void
648 on_popup_about_activate                (GtkMenuItem     *menuitem,
649                                         gpointer         user_data)
650 {
651     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
652
653     if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
654     {
655         p_intf->p_sys->p_about = create_intf_about();
656         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
657                              "p_intf", p_intf );
658     }
659     gtk_widget_show( p_intf->p_sys->p_about );
660     gdk_window_raise( p_intf->p_sys->p_about->window );
661 }
662
663
664 void
665 on_popup_exit_activate                 (GtkMenuItem     *menuitem,
666                                         gpointer         user_data)
667 {
668     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
669
670     vlc_mutex_lock( &p_intf->change_lock );
671     p_intf->b_die = 1;
672     vlc_mutex_unlock( &p_intf->change_lock );
673 }
674
675
676 /*****************************************************************************
677  * Fileopen callbacks
678  *****************************************************************************
679  * The following callbacks are related to the file requester.
680  *****************************************************************************/
681 void
682 on_intf_fileopen_destroy               (GtkObject       *object,
683                                         gpointer         user_data)
684 {
685     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_fileopen" );
686
687     p_intf->p_sys->p_fileopen = NULL;
688 }
689
690
691 void
692 on_fileopen_ok_clicked                 (GtkButton       *button,
693                                         gpointer         user_data)
694 {
695     GtkWidget *filesel;
696     gchar *filename;
697
698     filesel = gtk_widget_get_toplevel (GTK_WIDGET (button));
699     gtk_widget_hide (filesel);
700     filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
701
702     intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
703 }
704
705
706 void
707 on_fileopen_cancel_clicked             (GtkButton       *button,
708                                         gpointer         user_data)
709 {
710     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
711 }
712
713
714 /*****************************************************************************
715  * Playlist callbacks
716  *****************************************************************************
717  * The following callbacks are related to the playlist.
718  *****************************************************************************/
719 void
720 on_intf_playlist_destroy               (GtkObject       *object,
721                                         gpointer         user_data)
722 {
723     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_playlist" );
724
725     p_intf->p_sys->p_playlist = NULL;
726 }
727
728
729 void
730 on_playlist_ok_clicked                 (GtkButton       *button,
731                                         gpointer         user_data)
732 {
733     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_playlist" );
734
735     gtk_widget_hide( p_intf->p_sys->p_playlist );
736 }
737
738
739 void
740 on_playlist_close_clicked              (GtkButton       *button,
741                                         gpointer         user_data)
742 {
743     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
744 }
745
746
747
748 /*****************************************************************************
749  * Module manager callbacks
750  *****************************************************************************
751  * The following callbacks are related to the module manager.
752  *****************************************************************************/
753 void
754 on_intf_modules_destroy                (GtkObject       *object,
755                                         gpointer         user_data)
756 {
757
758 }
759
760
761 void
762 on_modules_ok_clicked                  (GtkButton       *button,
763                                         gpointer         user_data)
764 {
765     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
766
767     gtk_widget_hide( p_intf->p_sys->p_modules );
768 }
769
770
771 void
772 on_modules_apply_clicked               (GtkButton       *button,
773                                         gpointer         user_data)
774 {
775
776 }
777
778
779 void
780 on_modules_cancel_clicked              (GtkButton       *button,
781                                         gpointer         user_data)
782 {
783     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
784 }
785
786
787 /*****************************************************************************
788  * Open disc callbacks
789  *****************************************************************************
790  * The following callbacks are related to the disc manager.
791  *****************************************************************************/
792 void
793 on_disc_dvd_toggled                    (GtkToggleButton *togglebutton,
794                                         gpointer         user_data)
795 {
796     if( togglebutton->active )
797     {
798         gtk_entry_set_text( GTK_ENTRY( lookup_widget(
799             GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/dvd" );
800     }
801 }
802
803
804 void
805 on_disc_vcd_toggled                    (GtkToggleButton *togglebutton,
806                                         gpointer         user_data)
807 {
808     if( togglebutton->active )
809     {
810         gtk_entry_set_text( GTK_ENTRY( lookup_widget(
811             GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/cdrom" );
812     }
813 }
814
815
816 void
817 on_disc_ok_clicked                     (GtkButton       *button,
818                                         gpointer         user_data)
819 {
820     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
821     char *psz_device, *psz_source, *psz_method;
822
823     psz_device = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
824                                          GTK_WIDGET(button), "disc_name" ) ) );
825
826     /* "dvd:foo" has size 5 + strlen(foo) */
827     psz_source = malloc( 5 + strlen( psz_device ) );
828     if( psz_source == NULL )
829     {
830         return;
831     }
832
833     /* Check which method was activated */
834     if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
835                                           "disc_dvd" ) )->active )
836     {
837         psz_method = "dvd";
838     }
839     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
840                                                "disc_vcd" ) )->active )
841     {
842         psz_method = "vcd";
843     }
844     else
845     {
846         intf_ErrMsg( "intf error: unknown disc type toggle button position" );
847         free( psz_source );
848         return;
849     }
850     
851     /* Select title and chapter */
852     main_PutIntVariable( INPUT_TITLE_VAR, gtk_spin_button_get_value_as_int(
853                               GTK_SPIN_BUTTON( lookup_widget(
854                                   GTK_WIDGET(button), "disc_title" ) ) ) );
855
856     main_PutIntVariable( INPUT_CHAPTER_VAR, gtk_spin_button_get_value_as_int(
857                               GTK_SPIN_BUTTON( lookup_widget(
858                                   GTK_WIDGET(button), "disc_chapter" ) ) ) );
859
860     /* Build source name and add it to playlist */
861     sprintf( psz_source, "%s:%s", psz_method, psz_device );
862     intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
863     free( psz_source );
864
865     gtk_widget_hide( p_intf->p_sys->p_disc );
866 }
867
868
869 void
870 on_disc_cancel_clicked                 (GtkButton       *button,
871                                         gpointer         user_data)
872 {
873     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
874 }
875
876
877 /*****************************************************************************
878  * Network stream callbacks
879  *****************************************************************************
880  * The following callbacks are related to the network stream manager.
881  *****************************************************************************/
882 void
883 on_network_ok_clicked                  (GtkButton       *button,
884                                         gpointer         user_data)
885 {
886     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_network" );
887     char *psz_source, *psz_server, *psz_protocol;
888     unsigned int i_port;
889
890     psz_server = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
891                                  GTK_WIDGET(button), "network_server" ) ) );
892
893     /* Check which protocol was activated */
894     if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
895                                           "network_ts" ) )->active )
896     {
897         psz_protocol = "ts";
898     }
899     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
900                                                "network_rtp" ) )->active )
901     {
902         psz_protocol = "rtp";
903     }
904     else
905     {
906         intf_ErrMsg( "intf error: unknown protocol toggle button position" );
907         return;
908     }
909
910     /* Get the port number and make sure it will not overflow 5 characters */
911     i_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
912                  lookup_widget( GTK_WIDGET(button), "network_port" ) ) );
913     if( i_port > 65535 )
914     {
915         intf_ErrMsg( "intf error: invalid port %i", i_port );
916     }
917
918     /* Allocate room for "protocol://server:port" */
919     psz_source = malloc( strlen( psz_protocol ) + strlen( psz_server ) + 10 );
920     if( psz_source == NULL )
921     {
922         return;
923     }
924    
925     /* Build source name and add it to playlist */
926     sprintf( psz_source, "%s://%s:%i", psz_protocol, psz_server, i_port );
927     intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
928     free( psz_source );
929
930     gtk_widget_hide( p_intf->p_sys->p_network );
931 }
932
933
934 void
935 on_network_cancel_clicked              (GtkButton       *button,
936                                         gpointer         user_data)
937 {
938     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
939 }
940