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