]> git.sesse.net Git - vlc/blob - plugins/gnome/gnome_callbacks.c
64d89d4c05ff6426ab1c53217af8573603d4eef8
[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.24 2001/04/22 00:08:26 stef Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *          Stéphane Borel <stef@via.ecp.fr>
9  *      
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.
14  * 
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.
19  *
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  *****************************************************************************/
24
25 #define MODULE_NAME gnome
26 #include "modules_inner.h"
27
28 /*****************************************************************************
29  * Preamble
30  *****************************************************************************/
31 #include "defs.h"
32
33 #include <gnome.h>
34
35 #include "config.h"
36 #include "common.h"
37 #include "threads.h"
38 #include "mtime.h"
39
40 #include "stream_control.h"
41 #include "input_ext-intf.h"
42
43 #include "interface.h"
44 #include "intf_playlist.h"
45 #include "intf_msg.h"
46
47 #include "gnome_callbacks.h"
48 #include "gnome_interface.h"
49 #include "gnome_support.h"
50 #include "intf_gnome.h"
51
52 #include "main.h"
53
54 /*****************************************************************************
55  * Inline function to retrieve the interface structure
56  *****************************************************************************/
57 static __inline__ intf_thread_t * GetIntf( GtkWidget *item, char * psz_parent )
58 {
59     return( gtk_object_get_data( GTK_OBJECT( lookup_widget(item, psz_parent) ),
60                                  "p_intf" ) );
61 }
62
63
64 /*****************************************************************************
65  * Interface callbacks
66  *****************************************************************************
67  * The following callbacks are related to the main interface window.
68  *****************************************************************************/
69 void
70 on_intf_window_destroy                 (GtkObject       *object,
71                                         gpointer         user_data)
72 {
73     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_window" );
74
75     vlc_mutex_lock( &p_intf->change_lock );
76     p_intf->b_die = 1;
77     vlc_mutex_unlock( &p_intf->change_lock );
78 }
79
80
81 gboolean
82 on_slider_button_press_event           (GtkWidget       *widget,
83                                         GdkEventButton  *event,
84                                         gpointer         user_data)
85 {
86     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
87
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 );
91
92     return FALSE;
93 }
94
95
96 gboolean
97 on_slider_button_release_event         (GtkWidget       *widget,
98                                         GdkEventButton  *event,
99                                         gpointer         user_data)
100 {
101     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
102
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 );
106
107     return FALSE;
108 }
109
110
111 void
112 on_intf_window_drag_data_received      (GtkWidget       *widget,
113                                         GdkDragContext  *drag_context,
114                                         gint             x,
115                                         gint             y,
116                                         GtkSelectionData *data,
117                                         guint            info,
118                                         guint            time,
119                                         gpointer         user_data)
120 {
121     char *psz_text = data->data;
122     int i_len      = strlen( psz_text );
123
124     switch( info )
125     {
126     case DROP_ACCEPT_TEXT_PLAIN: /* FIXME: handle multiple files */
127
128         if( i_len < 1 )
129         {
130             return;
131         }
132
133         /* get rid of ' ' at the end */
134         *( psz_text + i_len - 1 ) = 0;
135
136         intf_WarnMsg( 1, "intf: dropped text/uri-list data `%s'", psz_text );
137         intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_text );
138
139         break;
140
141     case DROP_ACCEPT_TEXT_URI_LIST: /* FIXME: handle multiple files */
142
143         if( i_len < 2 )
144         {
145             return;
146         }
147
148         /* get rid of \r\n at the end */
149         *( psz_text + i_len - 2 ) = 0;
150
151         intf_WarnMsg( 1, "intf: dropped text/uri-list data `%s'", psz_text );
152         intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_text );
153         break;
154
155     default:
156
157         intf_ErrMsg( "intf error: unknown dropped type");
158         break;
159     }
160 }
161
162
163 void
164 on_button_title_prev_clicked           (GtkButton       *button,
165                                         gpointer         user_data)
166 {
167     intf_thread_t * p_intf;
168     input_area_t *  p_area;
169     int             i_id;
170
171     p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
172     i_id = p_intf->p_input->stream.p_selected_area->i_id - 1;
173
174     if( i_id >= 0 )
175     {
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
179         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
180
181         p_intf->p_sys->b_title_update = 1;
182     }
183 }
184
185
186 void
187 on_button_title_next_clicked           (GtkButton       *button,
188                                         gpointer         user_data)
189 {
190     intf_thread_t * p_intf;
191     input_area_t *  p_area;
192     int             i_id;
193
194     p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
195     i_id = p_intf->p_input->stream.p_selected_area->i_id + 1;
196
197     if( i_id < p_intf->p_input->stream.i_area_nb )
198     {
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 );
201
202         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
203
204         p_intf->p_sys->b_title_update = 1;
205     }
206 }
207
208
209 void
210 on_button_chapter_prev_clicked         (GtkButton       *button,
211                                         gpointer         user_data)
212 {
213     intf_thread_t * p_intf;
214     input_area_t *  p_area;
215
216     p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
217     p_area = p_intf->p_input->stream.p_selected_area;
218
219     if( p_area->i_part > 0 )
220     {
221         p_area->i_part--;
222         p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
223
224         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
225
226         p_intf->p_sys->b_chapter_update = 1;
227     }
228 }
229
230
231 void
232 on_button_chapter_next_clicked         (GtkButton       *button,
233                                         gpointer         user_data)
234 {
235     intf_thread_t * p_intf;
236     input_area_t *  p_area;
237
238     p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
239     p_area = p_intf->p_input->stream.p_selected_area;
240
241     if( p_area->i_part < p_area->i_part_nb )
242     {
243         p_area->i_part++;
244         p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
245
246         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
247
248         p_intf->p_sys->b_chapter_update = 1;
249     }
250 }
251
252
253 /*****************************************************************************
254  * Menubar callbacks
255  *****************************************************************************
256  * The following callbacks are related to the menubar of the main
257  * interface window.
258  *****************************************************************************/
259 void
260 on_menubar_open_activate               (GtkMenuItem     *menuitem,
261                                         gpointer         user_data)
262 {
263     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
264
265     /* If we have never used the file selector, open it */
266     if( p_intf->p_sys->p_fileopen == NULL)
267     {
268         p_intf->p_sys->p_fileopen = create_intf_fileopen();
269         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
270                              "p_intf", p_intf );
271     }
272
273     gtk_widget_show( p_intf->p_sys->p_fileopen );
274     gdk_window_raise( p_intf->p_sys->p_fileopen->window );
275 }
276
277
278 void
279 on_menubar_disc_activate               (GtkMenuItem     *menuitem,
280                                         gpointer         user_data)
281 {
282     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
283
284     gtk_widget_show( p_intf->p_sys->p_disc );
285     gdk_window_raise( p_intf->p_sys->p_disc->window );
286 }
287
288
289 void
290 on_menubar_network_activate            (GtkMenuItem     *menuitem,
291                                         gpointer         user_data)
292 {
293     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
294
295     gtk_widget_show( p_intf->p_sys->p_network );
296     gdk_window_raise( p_intf->p_sys->p_network->window );
297 }
298
299
300 void
301 on_menubar_exit_activate               (GtkMenuItem     *menuitem,
302                                         gpointer         user_data)
303 {
304     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
305
306     vlc_mutex_lock( &p_intf->change_lock );
307     p_intf->b_die = 1;
308     vlc_mutex_unlock( &p_intf->change_lock );
309 }
310
311
312 void
313 on_menubar_playlist_activate           (GtkMenuItem     *menuitem,
314                                         gpointer         user_data)
315 {
316     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
317
318     if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
319     {
320         p_intf->p_sys->p_playlist = create_intf_playlist();
321         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
322                              "p_intf", p_intf );
323     }
324     gtk_widget_show( p_intf->p_sys->p_playlist );
325     gdk_window_raise( p_intf->p_sys->p_playlist->window );
326 }
327
328
329 void
330 on_menubar_audio_toggle                (GtkCheckMenuItem     *menuitem,
331                                         gpointer              user_data)
332 {
333     intf_thread_t *         p_intf;
334     es_descriptor_t *       p_es;
335
336     p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
337
338     if( !p_intf->p_sys->b_audio_update )
339     {
340         p_es = (es_descriptor_t*)user_data;
341
342         input_ToggleES( p_intf->p_input, p_es, menuitem->active );
343
344         p_intf->p_sys->b_audio_update = menuitem->active;
345     }
346 }
347
348
349 void
350 on_menubar_subtitle_toggle             (GtkCheckMenuItem     *menuitem,
351                                         gpointer              user_data)
352 {
353     intf_thread_t *         p_intf;
354     es_descriptor_t *       p_es;
355
356     p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
357
358     if( !p_intf->p_sys->b_spu_update )
359     {
360         p_es = (es_descriptor_t*)user_data;
361
362         input_ToggleES( p_intf->p_input, p_es, menuitem->active );
363
364         p_intf->p_sys->b_spu_update = menuitem->active;
365     }
366 }
367
368
369 void
370 on_menubar_title_toggle                (GtkCheckMenuItem     *menuitem,
371                                         gpointer              user_data)
372 {
373     intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
374
375     if( menuitem->active && !p_intf->p_sys->b_title_update )
376     {
377         p_intf->p_input->pf_set_area( p_intf->p_input,
378                                      (input_area_t*)user_data );
379
380         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
381
382         p_intf->p_sys->b_title_update = 1;
383     }
384 }
385
386
387 void
388 on_menubar_chapter_toggle              (GtkCheckMenuItem     *menuitem,
389                                         gpointer              user_data)
390 {
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;
394     char            psz_chapter[3];
395
396     if( menuitem->active && !p_intf->p_sys->b_chapter_update )
397     {
398         p_area->i_part = i_chapter;
399         p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
400
401         snprintf( psz_chapter, 3, "%02d", p_area->i_part );
402         gtk_label_set_text( p_intf->p_sys->p_label_chapter, psz_chapter );
403
404         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
405
406         p_intf->p_sys->b_chapter_update = 1;
407     }
408
409 }
410
411
412 void
413 on_menubar_angle_toggle                (GtkCheckMenuItem     *menuitem,
414                                         gpointer             user_data)
415 {
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;
419
420     if( menuitem->active && !p_intf->p_sys->b_angle_update )
421     {
422         p_area->i_angle = i_angle;
423         p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
424
425         p_intf->p_sys->b_angle_update = 1;
426     }
427 }
428
429
430 void
431 on_menubar_modules_activate            (GtkMenuItem     *menuitem,
432                                         gpointer         user_data)
433 {
434     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
435
436     if( !GTK_IS_WIDGET( p_intf->p_sys->p_modules ) )
437     {
438         p_intf->p_sys->p_modules = create_intf_modules();
439         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_modules ),
440                              "p_intf", p_intf );
441     }
442     gtk_widget_show( p_intf->p_sys->p_modules );
443     gdk_window_raise( p_intf->p_sys->p_modules->window );
444 }
445
446
447 void
448 on_menubar_preferences_activate        (GtkMenuItem     *menuitem,
449                                         gpointer         user_data)
450 {
451
452 }
453
454
455 void
456 on_menubar_about_activate              (GtkMenuItem     *menuitem,
457                                         gpointer         user_data)
458 {
459     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
460
461     if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
462     {
463         p_intf->p_sys->p_about = create_intf_about();
464         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
465                              "p_intf", p_intf );
466     }
467     gtk_widget_show( p_intf->p_sys->p_about );
468     gdk_window_raise( p_intf->p_sys->p_about->window );
469 }
470
471
472 /*****************************************************************************
473  * Toolbar callbacks
474  *****************************************************************************
475  * The following callbacks are related to the toolbar of the main
476  * interface window.
477  *****************************************************************************/
478 void
479 on_toolbar_open_clicked                (GtkButton       *button,
480                                         gpointer         user_data)
481 {
482     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
483
484     /* If we have never used the file selector, open it */
485     if( p_intf->p_sys->p_fileopen == NULL)
486     {
487         p_intf->p_sys->p_fileopen = create_intf_fileopen();
488         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
489                              "p_intf", p_intf );
490     }
491
492     gtk_widget_show( p_intf->p_sys->p_fileopen );
493     gdk_window_raise( p_intf->p_sys->p_fileopen->window );
494 }
495
496
497 void
498 on_toolbar_disc_clicked                (GtkButton       *button,
499                                         gpointer         user_data)
500 {
501     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
502
503     gtk_widget_show( p_intf->p_sys->p_disc );
504     gdk_window_raise( p_intf->p_sys->p_disc->window );
505 }
506
507
508 void
509 on_toolbar_network_clicked             (GtkButton       *button,
510                                         gpointer         user_data)
511 {
512     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
513
514     gtk_widget_show( p_intf->p_sys->p_network );
515     gdk_window_raise( p_intf->p_sys->p_network->window );
516 }
517
518
519 void
520 on_toolbar_back_clicked                (GtkButton       *button,
521                                         gpointer         user_data)
522 {
523
524 }
525
526
527 void
528 on_toolbar_stop_clicked                (GtkButton       *button,
529                                         gpointer         user_data)
530 {
531
532 }
533
534
535 void
536 on_toolbar_play_clicked                (GtkButton       *button,
537                                         gpointer         user_data)
538 {
539     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
540
541     if( p_intf->p_input != NULL )
542     {
543         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
544     }
545 }
546
547
548 void
549 on_toolbar_pause_clicked               (GtkButton       *button,
550                                         gpointer         user_data)
551 {
552     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
553
554     if( p_intf->p_input != NULL )
555     {
556         input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
557     }
558 }
559
560
561 void
562 on_toolbar_slow_clicked                (GtkButton       *button,
563                                         gpointer         user_data)
564 {
565     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
566
567     if( p_intf->p_input != NULL )
568     {
569         input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
570     }
571 }
572
573
574 void
575 on_toolbar_fast_clicked                (GtkButton       *button,
576                                         gpointer         user_data)
577 {
578     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
579
580     if( p_intf->p_input != NULL )
581     {
582         input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
583     }
584 }
585
586
587 void
588 on_toolbar_playlist_clicked            (GtkButton       *button,
589                                         gpointer         user_data)
590 {
591     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
592
593     if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
594     {
595         p_intf->p_sys->p_playlist = create_intf_playlist();
596         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
597                              "p_intf", p_intf );
598     }
599     gtk_widget_show( p_intf->p_sys->p_playlist );
600     gdk_window_raise( p_intf->p_sys->p_playlist->window );
601 }
602
603
604 void
605 on_toolbar_prev_clicked                (GtkButton       *button,
606                                         gpointer         user_data)
607 {
608     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
609
610     if( p_intf->p_input != NULL )
611     {
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;
616     }
617
618     p_intf->p_sys->b_mode_changed = 1;
619 }
620
621
622 void
623 on_toolbar_next_clicked                (GtkButton       *button,
624                                         gpointer         user_data)
625 {
626     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
627
628     if( p_intf->p_input != NULL )
629     {
630         /* FIXME: temporary hack */
631         p_intf->p_input->b_eof = 1;
632     }
633
634     p_intf->p_sys->b_mode_changed = 1;
635 }
636
637
638 /*****************************************************************************
639  * Popup callbacks
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  *****************************************************************************/
644 void
645 on_popup_play_activate                 (GtkMenuItem     *menuitem,
646                                         gpointer         user_data)
647 {
648     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
649
650     if( p_intf->p_input != NULL )
651     {
652         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
653     }
654 }
655
656
657 void
658 on_popup_pause_activate                (GtkMenuItem     *menuitem,
659                                         gpointer         user_data)
660 {
661     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
662
663     if( p_intf->p_input != NULL )
664     {
665         input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
666     }
667 }
668
669
670 void
671 on_popup_slow_activate                 (GtkMenuItem     *menuitem,
672                                         gpointer         user_data)
673 {
674     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
675
676     if( p_intf->p_input != NULL )
677     {
678         input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
679     }
680 }
681
682
683 void
684 on_popup_fast_activate                 (GtkMenuItem     *menuitem,
685                                         gpointer         user_data)
686 {
687     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
688
689     if( p_intf->p_input != NULL )
690     {
691         input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
692     }
693 }
694
695
696 void
697 on_popup_audio_toggle                  (GtkCheckMenuItem     *menuitem,
698                                         gpointer              user_data)
699 {
700     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
701     es_descriptor_t *       p_es;
702
703     p_es = (es_descriptor_t*)user_data;
704
705     if( !p_intf->p_sys->b_audio_update )
706     {
707         input_ToggleES( p_intf->p_input, p_es, menuitem->active );
708
709         p_intf->p_sys->b_audio_update = menuitem->active;
710     }
711 }
712
713
714 void
715 on_popup_subtitle_toggle            (GtkCheckMenuItem     *menuitem,
716                                      gpointer              user_data)
717 {
718     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
719     es_descriptor_t *       p_es;
720
721     p_es = (es_descriptor_t*)user_data;
722
723     if( !p_intf->p_sys->b_spu_update )
724     {
725         input_ToggleES( p_intf->p_input, p_es, menuitem->active );
726
727         p_intf->p_sys->b_spu_update = menuitem->active;
728     }
729 }
730
731
732 void
733 on_popup_navigation_toggle             (GtkCheckMenuItem     *menuitem,
734                                         gpointer             user_data)
735 {
736     intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
737
738     if( menuitem->active &&
739         !p_intf->p_sys->b_title_update &&
740         !p_intf->p_sys->b_chapter_update )
741     {
742         input_area_t *  p_area;
743         gint            i_title;
744         gint            i_chapter;
745
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;
749
750
751         if( p_area != p_intf->p_input->stream.pp_areas[i_title] )
752         {
753             p_area = p_intf->p_input->stream.pp_areas[i_title];
754             p_intf->p_sys->b_title_update = 1;
755         }
756
757         p_area->i_part = i_chapter;
758         p_intf->p_sys->b_chapter_update = 1;
759
760         p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
761
762         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
763     }
764 }
765
766
767 void
768 on_popup_angle_toggle                  (GtkCheckMenuItem     *menuitem,
769                                         gpointer             user_data)
770 {
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;
774
775     if( menuitem->active && !p_intf->p_sys->b_angle_update )
776     {
777         p_area->i_angle = i_angle;
778         p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
779
780         p_intf->p_sys->b_angle_update = 1;
781     }
782 }
783
784
785 void
786 on_popup_open_activate                 (GtkMenuItem     *menuitem,
787                                         gpointer         user_data)
788 {
789     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
790
791     /* If we have never used the file selector, open it */
792     if( p_intf->p_sys->p_fileopen == NULL)
793     {
794         p_intf->p_sys->p_fileopen = create_intf_fileopen();
795         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
796                              "p_intf", p_intf );
797     }
798
799     gtk_widget_show( p_intf->p_sys->p_fileopen );
800     gdk_window_raise( p_intf->p_sys->p_fileopen->window );
801 }
802
803
804 void
805 on_popup_disc_activate                 (GtkMenuItem     *menuitem,
806                                         gpointer         user_data)
807 {
808     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
809
810     gtk_widget_show( p_intf->p_sys->p_disc );
811     gdk_window_raise( p_intf->p_sys->p_disc->window );
812 }
813
814
815 void
816 on_popup_network_activate              (GtkMenuItem     *menuitem,
817                                         gpointer         user_data)
818 {
819     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
820
821     gtk_widget_show( p_intf->p_sys->p_network );
822     gdk_window_raise( p_intf->p_sys->p_network->window );
823 }
824
825
826 void
827 on_popup_about_activate                (GtkMenuItem     *menuitem,
828                                         gpointer         user_data)
829 {
830     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
831
832     if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
833     {
834         p_intf->p_sys->p_about = create_intf_about();
835         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
836                              "p_intf", p_intf );
837     }
838     gtk_widget_show( p_intf->p_sys->p_about );
839     gdk_window_raise( p_intf->p_sys->p_about->window );
840 }
841
842
843 void
844 on_popup_exit_activate                 (GtkMenuItem     *menuitem,
845                                         gpointer         user_data)
846 {
847     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
848
849     vlc_mutex_lock( &p_intf->change_lock );
850     p_intf->b_die = 1;
851     vlc_mutex_unlock( &p_intf->change_lock );
852 }
853
854
855 /*****************************************************************************
856  * Fileopen callbacks
857  *****************************************************************************
858  * The following callbacks are related to the file requester.
859  *****************************************************************************/
860 void
861 on_intf_fileopen_destroy               (GtkObject       *object,
862                                         gpointer         user_data)
863 {
864     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_fileopen" );
865
866     p_intf->p_sys->p_fileopen = NULL;
867 }
868
869
870 void
871 on_fileopen_ok_clicked                 (GtkButton       *button,
872                                         gpointer         user_data)
873 {
874     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_fileopen" );
875
876     GtkWidget *filesel;
877     gchar *filename;
878
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));
882
883     intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
884
885     /* Select added item and switch to file interface */
886     if( p_intf->p_input != NULL )
887         p_intf->p_input->b_eof = 1;
888
889 //    p_intf->p_sys->b_mode_changed = 1;
890 }
891
892
893 void
894 on_fileopen_cancel_clicked             (GtkButton       *button,
895                                         gpointer         user_data)
896 {
897     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
898 }
899
900
901 /*****************************************************************************
902  * Playlist callbacks
903  *****************************************************************************
904  * The following callbacks are related to the playlist.
905  *****************************************************************************/
906 void
907 on_intf_playlist_destroy               (GtkObject       *object,
908                                         gpointer         user_data)
909 {
910     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_playlist" );
911
912     p_intf->p_sys->p_playlist = NULL;
913 }
914
915
916 void
917 on_playlist_ok_clicked                 (GtkButton       *button,
918                                         gpointer         user_data)
919 {
920     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_playlist" );
921
922     gtk_widget_hide( p_intf->p_sys->p_playlist );
923 }
924
925
926 void
927 on_playlist_close_clicked              (GtkButton       *button,
928                                         gpointer         user_data)
929 {
930     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
931 }
932
933
934
935 /*****************************************************************************
936  * Module manager callbacks
937  *****************************************************************************
938  * The following callbacks are related to the module manager.
939  *****************************************************************************/
940 void
941 on_intf_modules_destroy                (GtkObject       *object,
942                                         gpointer         user_data)
943 {
944
945 }
946
947
948 void
949 on_modules_ok_clicked                  (GtkButton       *button,
950                                         gpointer         user_data)
951 {
952     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
953
954     gtk_widget_hide( p_intf->p_sys->p_modules );
955 }
956
957
958 void
959 on_modules_apply_clicked               (GtkButton       *button,
960                                         gpointer         user_data)
961 {
962
963 }
964
965
966 void
967 on_modules_cancel_clicked              (GtkButton       *button,
968                                         gpointer         user_data)
969 {
970     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
971 }
972
973
974 /*****************************************************************************
975  * Open disc callbacks
976  *****************************************************************************
977  * The following callbacks are related to the disc manager.
978  *****************************************************************************/
979 void
980 on_disc_dvd_toggled                    (GtkToggleButton *togglebutton,
981                                         gpointer         user_data)
982 {
983     if( togglebutton->active )
984     {
985         gtk_entry_set_text( GTK_ENTRY( lookup_widget(
986             GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/dvd" );
987     }
988 }
989
990
991 void
992 on_disc_vcd_toggled                    (GtkToggleButton *togglebutton,
993                                         gpointer         user_data)
994 {
995     if( togglebutton->active )
996     {
997         gtk_entry_set_text( GTK_ENTRY( lookup_widget(
998             GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/cdrom" );
999     }
1000 }
1001
1002
1003 void
1004 on_disc_ok_clicked                     (GtkButton       *button,
1005                                         gpointer         user_data)
1006 {
1007     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
1008     char *psz_device, *psz_source, *psz_method;
1009
1010     psz_device = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
1011                                          GTK_WIDGET(button), "disc_name" ) ) );
1012
1013     /* "dvd:foo" has size 5 + strlen(foo) */
1014     psz_source = malloc( 5 + strlen( psz_device ) );
1015     if( psz_source == NULL )
1016     {
1017         return;
1018     }
1019
1020     /* Check which method was activated */
1021     if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1022                                           "disc_dvd" ) )->active )
1023     {
1024         psz_method = "dvd";
1025         p_intf->p_sys->i_intf_mode = DVD_MODE;
1026     }
1027     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1028                                                "disc_vcd" ) )->active )
1029     {
1030         psz_method = "vcd";
1031     }
1032     else
1033     {
1034         intf_ErrMsg( "intf error: unknown disc type toggle button position" );
1035         free( psz_source );
1036         return;
1037     }
1038     
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" ) ) ) );
1043
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" ) ) ) );
1047
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 );
1051     free( psz_source );
1052
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;
1058
1059     gtk_widget_hide( p_intf->p_sys->p_disc );
1060 }
1061
1062
1063 void
1064 on_disc_cancel_clicked                 (GtkButton       *button,
1065                                         gpointer         user_data)
1066 {
1067     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
1068 }
1069
1070
1071 /*****************************************************************************
1072  * Network stream callbacks
1073  *****************************************************************************
1074  * The following callbacks are related to the network stream manager.
1075  *****************************************************************************/
1076 void
1077 on_network_ok_clicked                  (GtkButton       *button,
1078                                         gpointer         user_data)
1079 {
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;
1083
1084     psz_server = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
1085                                  GTK_WIDGET(button), "network_server" ) ) );
1086
1087     /* Check which protocol was activated */
1088     if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1089                                           "network_ts" ) )->active )
1090     {
1091         psz_protocol = "ts";
1092     }
1093     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1094                                                "network_rtp" ) )->active )
1095     {
1096         psz_protocol = "rtp";
1097     }
1098     else
1099     {
1100         intf_ErrMsg( "intf error: unknown protocol toggle button position" );
1101         return;
1102     }
1103
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 )
1108     {
1109         intf_ErrMsg( "intf error: invalid port %i", i_port );
1110     }
1111
1112     /* Allocate room for "protocol://server:port" */
1113     psz_source = malloc( strlen( psz_protocol ) + strlen( psz_server ) + 10 );
1114     if( psz_source == NULL )
1115     {
1116         return;
1117     }
1118    
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 );
1122     free( psz_source );
1123
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;
1129
1130     gtk_widget_hide( p_intf->p_sys->p_network );
1131 }
1132
1133
1134 void
1135 on_network_cancel_clicked              (GtkButton       *button,
1136                                         gpointer         user_data)
1137 {
1138     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
1139 }
1140