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