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