]> git.sesse.net Git - vlc/blob - plugins/gnome/gnome_callbacks.c
-Fall back to one-packet-once reading in dvd input since multi-block
[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.20 2001/04/03 03:39:41 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_chapter_prev_clicked         (GtkButton       *button,
165                                         gpointer         user_data)
166 {
167     intf_thread_t * p_intf;
168     input_area_t *  p_area;
169
170     p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
171     p_area = p_intf->p_input->stream.p_selected_area;
172
173     if( p_area->i_part - 1 >= 0 )
174     {
175         p_area->i_part--;
176         p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
177         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
178     }
179 }
180
181
182 void
183 on_button_chapter_next_clicked         (GtkButton       *button,
184                                         gpointer         user_data)
185 {
186     intf_thread_t * p_intf;
187     input_area_t *  p_area;
188
189     p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
190     p_area = p_intf->p_input->stream.p_selected_area;
191
192     if( p_area->i_part + 1 < p_area->i_part_nb )
193     {
194         p_area->i_part++;
195         p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
196         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
197     }
198 }
199
200
201 /*****************************************************************************
202  * Menubar callbacks
203  *****************************************************************************
204  * The following callbacks are related to the menubar of the main
205  * interface window.
206  *****************************************************************************/
207 void
208 on_menubar_open_activate               (GtkMenuItem     *menuitem,
209                                         gpointer         user_data)
210 {
211     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
212
213     /* If we have never used the file selector, open it */
214     if( p_intf->p_sys->p_fileopen == NULL)
215     {
216         p_intf->p_sys->p_fileopen = create_intf_fileopen();
217         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
218                              "p_intf", p_intf );
219     }
220
221     gtk_widget_show( p_intf->p_sys->p_fileopen );
222     gdk_window_raise( p_intf->p_sys->p_fileopen->window );
223 }
224
225
226 void
227 on_menubar_disc_activate               (GtkMenuItem     *menuitem,
228                                         gpointer         user_data)
229 {
230     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
231
232     gtk_widget_show( p_intf->p_sys->p_disc );
233     gdk_window_raise( p_intf->p_sys->p_disc->window );
234 }
235
236
237 void
238 on_menubar_network_activate            (GtkMenuItem     *menuitem,
239                                         gpointer         user_data)
240 {
241     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
242
243     gtk_widget_show( p_intf->p_sys->p_network );
244     gdk_window_raise( p_intf->p_sys->p_network->window );
245 }
246
247
248 void
249 on_menubar_exit_activate               (GtkMenuItem     *menuitem,
250                                         gpointer         user_data)
251 {
252     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
253
254     vlc_mutex_lock( &p_intf->change_lock );
255     p_intf->b_die = 1;
256     vlc_mutex_unlock( &p_intf->change_lock );
257 }
258
259
260 void
261 on_menubar_playlist_activate           (GtkMenuItem     *menuitem,
262                                         gpointer         user_data)
263 {
264     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
265
266     if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
267     {
268         p_intf->p_sys->p_playlist = create_intf_playlist();
269         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
270                              "p_intf", p_intf );
271     }
272     gtk_widget_show( p_intf->p_sys->p_playlist );
273     gdk_window_raise( p_intf->p_sys->p_playlist->window );
274 }
275
276
277 void
278 on_menubar_audio_toggle                (GtkCheckMenuItem     *menuitem,
279                                         gpointer              user_data)
280 {
281     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
282     es_descriptor_t *       p_es;
283
284     p_es = (es_descriptor_t*)user_data;
285
286     if( p_intf->p_sys->b_menus_ready )
287     {
288         input_ToggleES( p_intf->p_input, p_es, menuitem->active );
289     }
290 }
291
292
293 void
294 on_menubar_subtitle_toggle             (GtkCheckMenuItem     *menuitem,
295                                         gpointer              user_data)
296 {
297     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
298     es_descriptor_t *       p_es;
299
300     p_es = (es_descriptor_t*)user_data;
301
302     if( p_intf->p_sys->b_menus_ready )
303     {
304         input_ToggleES( p_intf->p_input, p_es, menuitem->active );
305     }
306 }
307
308
309 void
310 on_menubar_title_toggle                (GtkCheckMenuItem     *menuitem,
311                                         gpointer              user_data)
312 {
313     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
314
315     if( menuitem->active && p_intf->p_sys->b_menus_ready )
316     {
317         p_intf->p_input->pf_set_area( p_intf->p_input,
318                                      (input_area_t*)user_data );
319         p_intf->p_sys->b_menus_update = 1;
320         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
321     }
322 }
323
324
325 void
326 on_menubar_chapter_toggle              (GtkCheckMenuItem     *menuitem,
327                                         gpointer              user_data)
328 {
329     intf_thread_t * p_intf    = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
330     input_area_t *  p_area    = p_intf->p_input->stream.p_selected_area;
331     gint            i_chapter = (gint)user_data;
332
333     if( menuitem->active && p_intf->p_sys->b_menus_ready )
334     {
335         p_area->i_part = i_chapter;
336         p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
337     }
338
339     input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
340 }
341
342 void
343 on_menubar_modules_activate            (GtkMenuItem     *menuitem,
344                                         gpointer         user_data)
345 {
346     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
347
348     if( !GTK_IS_WIDGET( p_intf->p_sys->p_modules ) )
349     {
350         p_intf->p_sys->p_modules = create_intf_modules();
351         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_modules ),
352                              "p_intf", p_intf );
353     }
354     gtk_widget_show( p_intf->p_sys->p_modules );
355     gdk_window_raise( p_intf->p_sys->p_modules->window );
356 }
357
358
359 void
360 on_menubar_preferences_activate        (GtkMenuItem     *menuitem,
361                                         gpointer         user_data)
362 {
363
364 }
365
366
367 void
368 on_menubar_about_activate              (GtkMenuItem     *menuitem,
369                                         gpointer         user_data)
370 {
371     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
372
373     if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
374     {
375         p_intf->p_sys->p_about = create_intf_about();
376         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
377                              "p_intf", p_intf );
378     }
379     gtk_widget_show( p_intf->p_sys->p_about );
380     gdk_window_raise( p_intf->p_sys->p_about->window );
381 }
382
383
384 /*****************************************************************************
385  * Toolbar callbacks
386  *****************************************************************************
387  * The following callbacks are related to the toolbar of the main
388  * interface window.
389  *****************************************************************************/
390 void
391 on_toolbar_open_clicked                (GtkButton       *button,
392                                         gpointer         user_data)
393 {
394     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
395
396     /* If we have never used the file selector, open it */
397     if( p_intf->p_sys->p_fileopen == NULL)
398     {
399         p_intf->p_sys->p_fileopen = create_intf_fileopen();
400         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
401                              "p_intf", p_intf );
402     }
403
404     gtk_widget_show( p_intf->p_sys->p_fileopen );
405     gdk_window_raise( p_intf->p_sys->p_fileopen->window );
406 }
407
408
409 void
410 on_toolbar_disc_clicked                (GtkButton       *button,
411                                         gpointer         user_data)
412 {
413     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
414
415     gtk_widget_show( p_intf->p_sys->p_disc );
416     gdk_window_raise( p_intf->p_sys->p_disc->window );
417 }
418
419
420 void
421 on_toolbar_network_clicked             (GtkButton       *button,
422                                         gpointer         user_data)
423 {
424     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
425
426     gtk_widget_show( p_intf->p_sys->p_network );
427     gdk_window_raise( p_intf->p_sys->p_network->window );
428 }
429
430
431 void
432 on_toolbar_back_clicked                (GtkButton       *button,
433                                         gpointer         user_data)
434 {
435
436 }
437
438
439 void
440 on_toolbar_stop_clicked                (GtkButton       *button,
441                                         gpointer         user_data)
442 {
443
444 }
445
446
447 void
448 on_toolbar_play_clicked                (GtkButton       *button,
449                                         gpointer         user_data)
450 {
451     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
452
453     if( p_intf->p_input != NULL )
454     {
455         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
456     }
457 }
458
459
460 void
461 on_toolbar_pause_clicked               (GtkButton       *button,
462                                         gpointer         user_data)
463 {
464     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
465
466     if( p_intf->p_input != NULL )
467     {
468         input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
469     }
470 }
471
472
473 void
474 on_toolbar_slow_clicked                (GtkButton       *button,
475                                         gpointer         user_data)
476 {
477     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
478
479     if( p_intf->p_input != NULL )
480     {
481         input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
482     }
483 }
484
485
486 void
487 on_toolbar_fast_clicked                (GtkButton       *button,
488                                         gpointer         user_data)
489 {
490     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
491
492     if( p_intf->p_input != NULL )
493     {
494         input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
495     }
496 }
497
498
499 void
500 on_toolbar_playlist_clicked            (GtkButton       *button,
501                                         gpointer         user_data)
502 {
503     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
504
505     if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
506     {
507         p_intf->p_sys->p_playlist = create_intf_playlist();
508         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
509                              "p_intf", p_intf );
510     }
511     gtk_widget_show( p_intf->p_sys->p_playlist );
512     gdk_window_raise( p_intf->p_sys->p_playlist->window );
513 }
514
515
516 void
517 on_toolbar_prev_clicked                (GtkButton       *button,
518                                         gpointer         user_data)
519 {
520     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
521
522     if( p_intf->p_input != NULL )
523     {
524         /* FIXME: temporary hack */
525         intf_PlaylistPrev( p_main->p_playlist );
526         intf_PlaylistPrev( p_main->p_playlist );
527         p_intf->p_input->b_eof = 1;
528     }
529 }
530
531
532 void
533 on_toolbar_next_clicked                (GtkButton       *button,
534                                         gpointer         user_data)
535 {
536     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
537
538     if( p_intf->p_input != NULL )
539     {
540         /* FIXME: temporary hack */
541         p_intf->p_input->b_eof = 1;
542     }
543 }
544
545
546 void
547 on_toolbar_prev_title_clicked         (GtkButton       *button,
548                                        gpointer         user_data)
549 {
550     intf_thread_t * p_intf;
551     input_area_t *  p_area;
552     int             i_id;
553
554     p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
555     i_id = p_intf->p_input->stream.p_selected_area->i_id - 1;
556
557     if( i_id >= 0 )
558     {
559         p_area = p_intf->p_input->stream.pp_areas[i_id];
560         p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
561         p_intf->p_sys->b_menus_update = 1;
562         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
563     }
564 }
565
566
567 void
568 on_toolbar_next_title_clicked          (GtkButton       *button,
569                                         gpointer         user_data)
570 {
571     intf_thread_t * p_intf;
572     input_area_t *  p_area;
573     int             i_id;
574
575     p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
576     i_id = p_intf->p_input->stream.p_selected_area->i_id + 1;
577
578     if( i_id < p_intf->p_input->stream.i_area_nb )
579     {
580         p_area = p_intf->p_input->stream.pp_areas[i_id];   
581         p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
582         p_intf->p_sys->b_menus_update = 1;
583         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
584     }
585 }
586
587
588 /*****************************************************************************
589  * Popup callbacks
590  *****************************************************************************
591  * The following callbacks are related to the popup menu. The popup
592  * menu is activated when right-clicking on the video output window.
593  *****************************************************************************/
594 void
595 on_popup_play_activate                 (GtkMenuItem     *menuitem,
596                                         gpointer         user_data)
597 {
598     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
599
600     if( p_intf->p_input != NULL )
601     {
602         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
603     }
604 }
605
606
607 void
608 on_popup_pause_activate                (GtkMenuItem     *menuitem,
609                                         gpointer         user_data)
610 {
611     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
612
613     if( p_intf->p_input != NULL )
614     {
615         input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
616     }
617 }
618
619
620 void
621 on_popup_slow_activate                 (GtkMenuItem     *menuitem,
622                                         gpointer         user_data)
623 {
624     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
625
626     if( p_intf->p_input != NULL )
627     {
628         input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
629     }
630 }
631
632
633 void
634 on_popup_fast_activate                 (GtkMenuItem     *menuitem,
635                                         gpointer         user_data)
636 {
637     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
638
639     if( p_intf->p_input != NULL )
640     {
641         input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
642     }
643 }
644
645
646 void
647 on_popup_audio_toggle                  (GtkCheckMenuItem     *menuitem,
648                                         gpointer              user_data)
649 {
650     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
651     es_descriptor_t *       p_es;
652
653     p_es = (es_descriptor_t*)user_data;
654
655     if( p_intf->p_sys->b_menus_ready )
656     {
657         input_ToggleES( p_intf->p_input, p_es, menuitem->active );
658     }
659 }
660
661
662 void
663 on_popup_subtitle_toggle            (GtkCheckMenuItem     *menuitem,
664                                      gpointer              user_data)
665 {
666     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
667     es_descriptor_t *       p_es;
668
669     p_es = (es_descriptor_t*)user_data;
670
671     if( p_intf->p_sys->b_menus_ready )
672     {
673         input_ToggleES( p_intf->p_input, p_es, menuitem->active );
674     }
675 }
676
677
678 void
679 on_popup_navigation_toggle             (GtkCheckMenuItem     *menuitem,
680                                         gpointer             user_data)
681 {
682     intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
683
684     if( menuitem->active && p_intf->p_sys->b_menus_ready )
685     {
686         input_area_t *  p_area;
687         gint            i_title;
688         gint            i_chapter;
689
690         i_title   = (gint)(user_data) / 100;
691         i_chapter = (gint)(user_data) - ( 100 * i_title );
692
693         if( i_title != p_intf->p_input->stream.p_selected_area->i_id )
694         {
695             p_intf->p_sys->b_menus_update = 1;
696         }
697
698         p_area = p_intf->p_input->stream.pp_areas[i_title];
699         p_area->i_part = i_chapter;
700
701         p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
702         input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
703     }
704 }
705
706
707 void
708 on_popup_open_activate                 (GtkMenuItem     *menuitem,
709                                         gpointer         user_data)
710 {
711     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
712
713     /* If we have never used the file selector, open it */
714     if( p_intf->p_sys->p_fileopen == NULL)
715     {
716         p_intf->p_sys->p_fileopen = create_intf_fileopen();
717         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
718                              "p_intf", p_intf );
719     }
720
721     gtk_widget_show( p_intf->p_sys->p_fileopen );
722     gdk_window_raise( p_intf->p_sys->p_fileopen->window );
723 }
724
725
726 void
727 on_popup_disc_activate                 (GtkMenuItem     *menuitem,
728                                         gpointer         user_data)
729 {
730     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
731
732     gtk_widget_show( p_intf->p_sys->p_disc );
733     gdk_window_raise( p_intf->p_sys->p_disc->window );
734 }
735
736
737 void
738 on_popup_network_activate              (GtkMenuItem     *menuitem,
739                                         gpointer         user_data)
740 {
741     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
742
743     gtk_widget_show( p_intf->p_sys->p_network );
744     gdk_window_raise( p_intf->p_sys->p_network->window );
745 }
746
747
748 void
749 on_popup_about_activate                (GtkMenuItem     *menuitem,
750                                         gpointer         user_data)
751 {
752     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
753
754     if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
755     {
756         p_intf->p_sys->p_about = create_intf_about();
757         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
758                              "p_intf", p_intf );
759     }
760     gtk_widget_show( p_intf->p_sys->p_about );
761     gdk_window_raise( p_intf->p_sys->p_about->window );
762 }
763
764
765 void
766 on_popup_exit_activate                 (GtkMenuItem     *menuitem,
767                                         gpointer         user_data)
768 {
769     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
770
771     vlc_mutex_lock( &p_intf->change_lock );
772     p_intf->b_die = 1;
773     vlc_mutex_unlock( &p_intf->change_lock );
774 }
775
776
777 /*****************************************************************************
778  * Fileopen callbacks
779  *****************************************************************************
780  * The following callbacks are related to the file requester.
781  *****************************************************************************/
782 void
783 on_intf_fileopen_destroy               (GtkObject       *object,
784                                         gpointer         user_data)
785 {
786     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_fileopen" );
787
788     p_intf->p_sys->p_fileopen = NULL;
789 }
790
791
792 void
793 on_fileopen_ok_clicked                 (GtkButton       *button,
794                                         gpointer         user_data)
795 {
796     GtkWidget *filesel;
797     gchar *filename;
798
799     filesel = gtk_widget_get_toplevel (GTK_WIDGET (button));
800     gtk_widget_hide (filesel);
801     filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
802
803     intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
804 }
805
806
807 void
808 on_fileopen_cancel_clicked             (GtkButton       *button,
809                                         gpointer         user_data)
810 {
811     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
812 }
813
814
815 /*****************************************************************************
816  * Playlist callbacks
817  *****************************************************************************
818  * The following callbacks are related to the playlist.
819  *****************************************************************************/
820 void
821 on_intf_playlist_destroy               (GtkObject       *object,
822                                         gpointer         user_data)
823 {
824     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_playlist" );
825
826     p_intf->p_sys->p_playlist = NULL;
827 }
828
829
830 void
831 on_playlist_ok_clicked                 (GtkButton       *button,
832                                         gpointer         user_data)
833 {
834     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_playlist" );
835
836     gtk_widget_hide( p_intf->p_sys->p_playlist );
837 }
838
839
840 void
841 on_playlist_close_clicked              (GtkButton       *button,
842                                         gpointer         user_data)
843 {
844     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
845 }
846
847
848
849 /*****************************************************************************
850  * Module manager callbacks
851  *****************************************************************************
852  * The following callbacks are related to the module manager.
853  *****************************************************************************/
854 void
855 on_intf_modules_destroy                (GtkObject       *object,
856                                         gpointer         user_data)
857 {
858
859 }
860
861
862 void
863 on_modules_ok_clicked                  (GtkButton       *button,
864                                         gpointer         user_data)
865 {
866     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
867
868     gtk_widget_hide( p_intf->p_sys->p_modules );
869 }
870
871
872 void
873 on_modules_apply_clicked               (GtkButton       *button,
874                                         gpointer         user_data)
875 {
876
877 }
878
879
880 void
881 on_modules_cancel_clicked              (GtkButton       *button,
882                                         gpointer         user_data)
883 {
884     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
885 }
886
887
888 /*****************************************************************************
889  * Open disc callbacks
890  *****************************************************************************
891  * The following callbacks are related to the disc manager.
892  *****************************************************************************/
893 void
894 on_disc_dvd_toggled                    (GtkToggleButton *togglebutton,
895                                         gpointer         user_data)
896 {
897     if( togglebutton->active )
898     {
899         gtk_entry_set_text( GTK_ENTRY( lookup_widget(
900             GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/dvd" );
901     }
902 }
903
904
905 void
906 on_disc_vcd_toggled                    (GtkToggleButton *togglebutton,
907                                         gpointer         user_data)
908 {
909     if( togglebutton->active )
910     {
911         gtk_entry_set_text( GTK_ENTRY( lookup_widget(
912             GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/cdrom" );
913     }
914 }
915
916
917 void
918 on_disc_ok_clicked                     (GtkButton       *button,
919                                         gpointer         user_data)
920 {
921     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
922     char *psz_device, *psz_source, *psz_method;
923
924     psz_device = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
925                                          GTK_WIDGET(button), "disc_name" ) ) );
926
927     /* "dvd:foo" has size 5 + strlen(foo) */
928     psz_source = malloc( 5 + strlen( psz_device ) );
929     if( psz_source == NULL )
930     {
931         return;
932     }
933
934     /* Check which method was activated */
935     if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
936                                           "disc_dvd" ) )->active )
937     {
938         psz_method = "dvd";
939         p_intf->p_sys->i_intf_mode = DVD_MODE;
940         p_intf->p_sys->b_mode_changed = 1;
941     }
942     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
943                                                "disc_vcd" ) )->active )
944     {
945         psz_method = "vcd";
946     }
947     else
948     {
949         intf_ErrMsg( "intf error: unknown disc type toggle button position" );
950         free( psz_source );
951         return;
952     }
953     
954     /* Select title and chapter */
955     main_PutIntVariable( INPUT_TITLE_VAR, gtk_spin_button_get_value_as_int(
956                               GTK_SPIN_BUTTON( lookup_widget(
957                                   GTK_WIDGET(button), "disc_title" ) ) ) );
958
959     main_PutIntVariable( INPUT_CHAPTER_VAR, gtk_spin_button_get_value_as_int(
960                               GTK_SPIN_BUTTON( lookup_widget(
961                                   GTK_WIDGET(button), "disc_chapter" ) ) ) );
962
963     /* Build source name and add it to playlist */
964     sprintf( psz_source, "%s:%s", psz_method, psz_device );
965     intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
966     free( psz_source );
967
968     gtk_widget_hide( p_intf->p_sys->p_disc );
969 }
970
971
972 void
973 on_disc_cancel_clicked                 (GtkButton       *button,
974                                         gpointer         user_data)
975 {
976     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
977 }
978
979
980 /*****************************************************************************
981  * Network stream callbacks
982  *****************************************************************************
983  * The following callbacks are related to the network stream manager.
984  *****************************************************************************/
985 void
986 on_network_ok_clicked                  (GtkButton       *button,
987                                         gpointer         user_data)
988 {
989     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_network" );
990     char *psz_source, *psz_server, *psz_protocol;
991     unsigned int i_port;
992
993     psz_server = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
994                                  GTK_WIDGET(button), "network_server" ) ) );
995
996     /* Check which protocol was activated */
997     if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
998                                           "network_ts" ) )->active )
999     {
1000         psz_protocol = "ts";
1001     }
1002     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
1003                                                "network_rtp" ) )->active )
1004     {
1005         psz_protocol = "rtp";
1006     }
1007     else
1008     {
1009         intf_ErrMsg( "intf error: unknown protocol toggle button position" );
1010         return;
1011     }
1012
1013     /* Get the port number and make sure it will not overflow 5 characters */
1014     i_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
1015                  lookup_widget( GTK_WIDGET(button), "network_port" ) ) );
1016     if( i_port > 65535 )
1017     {
1018         intf_ErrMsg( "intf error: invalid port %i", i_port );
1019     }
1020
1021     /* Allocate room for "protocol://server:port" */
1022     psz_source = malloc( strlen( psz_protocol ) + strlen( psz_server ) + 10 );
1023     if( psz_source == NULL )
1024     {
1025         return;
1026     }
1027    
1028     /* Build source name and add it to playlist */
1029     sprintf( psz_source, "%s://%s:%i", psz_protocol, psz_server, i_port );
1030     intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
1031     free( psz_source );
1032
1033     gtk_widget_hide( p_intf->p_sys->p_network );
1034 }
1035
1036
1037 void
1038 on_network_cancel_clicked              (GtkButton       *button,
1039                                         gpointer         user_data)
1040 {
1041     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
1042 }
1043