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