]> git.sesse.net Git - vlc/blob - plugins/gtk/gtk_callbacks.c
*Much work on the gnome interface: added oct's playlist from gtk plugin,
[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.16 2001/05/06 18:32:30 stef Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *          Stéphane Borel <stef@via.ecp.fr>
9  *      
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  * 
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #define MODULE_NAME gtk
26 #include "modules_inner.h"
27
28 /*****************************************************************************
29  * Preamble
30  *****************************************************************************/
31 #include "defs.h"
32 #include <sys/types.h>                                              /* off_t */                           
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     free( psz_source );
549
550     gtk_widget_hide( p_intf->p_sys->p_disc );
551 }
552
553
554 void
555 on_disc_cancel_clicked                 (GtkButton       *button,
556                                         gpointer         user_data)
557 {
558     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
559
560     gtk_widget_hide( p_intf->p_sys->p_disc );
561 }
562
563
564 void
565 on_disc_dvd_toggled                    (GtkToggleButton *togglebutton,
566                                         gpointer         user_data)
567 {
568     if( togglebutton->active )
569     {
570         gtk_entry_set_text( GTK_ENTRY( lookup_widget(
571             GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/dvd" );
572     }
573 }
574
575
576 void
577 on_disc_vcd_toggled                    (GtkToggleButton *togglebutton,
578                                         gpointer         user_data)
579 {
580     if( togglebutton->active )
581     {
582         gtk_entry_set_text( GTK_ENTRY( lookup_widget(
583             GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/cdrom" );
584     }
585 }
586
587
588 void
589 on_popup_disc_activate                 (GtkMenuItem     *menuitem,
590                                         gpointer         user_data)
591 {
592     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
593
594     if( !GTK_IS_WIDGET( p_intf->p_sys->p_disc ) )
595     {
596         p_intf->p_sys->p_disc = create_intf_disc();
597         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_disc ),
598                              "p_intf", p_intf );
599     }
600     gtk_widget_show( p_intf->p_sys->p_disc );
601     gdk_window_raise( p_intf->p_sys->p_disc->window );
602 }
603
604 void
605 on_popup_audio_activate                (GtkMenuItem     *menuitem,
606                                         gpointer         user_data)
607 {
608     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
609     es_descriptor_t *       p_es;
610
611     p_es = (es_descriptor_t*)user_data;
612
613     input_ChangeES( p_intf->p_input, p_es, 1 );
614 }
615
616
617 void
618 on_popup_subpictures_activate          (GtkMenuItem     *menuitem,
619                                         gpointer         user_data)
620 {
621     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
622     es_descriptor_t *       p_es;
623
624     p_es = (es_descriptor_t*)user_data;
625
626     input_ChangeES( p_intf->p_input, p_es, 2 );
627 }
628
629
630 void
631 on_menubar_audio_activate              (GtkMenuItem     *menuitem,
632                                         gpointer         user_data)
633 {
634     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
635     es_descriptor_t *       p_es;
636
637     p_es = (es_descriptor_t*)user_data;
638
639     input_ChangeES( p_intf->p_input, p_es, 1 );
640 }
641
642
643 void
644 on_menubar_subpictures_activate        (GtkMenuItem     *menuitem,
645                                         gpointer         user_data)
646 {
647     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
648     es_descriptor_t *       p_es;
649
650     p_es = (es_descriptor_t*)user_data;
651
652     input_ChangeES( p_intf->p_input, p_es, 2 );
653 }
654
655
656 void
657 on_popup_navigation_activate           (GtkMenuItem     *menuitem,
658                                         gpointer         user_data)
659 {
660     intf_thread_t * p_intf    = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
661     input_area_t *  p_area;
662     gint            i_title;
663     gint            i_chapter;
664
665     i_title   = (gint)(user_data) / 100 ;
666     i_chapter = (gint)(user_data) - ( 100 * i_title );
667     p_area    = p_intf->p_input->stream.pp_areas[i_title];
668     p_area->i_part = i_chapter;
669
670     p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
671     input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
672 }
673
674
675 void
676 on_menubar_title_activate              (GtkMenuItem     *menuitem,
677                                         gpointer         user_data)
678 {
679     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
680
681     p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)user_data );
682     p_intf->p_sys->b_menus_update = 1;
683     input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
684 }
685
686
687 void
688 on_menubar_chapter_activate            (GtkMenuItem     *menuitem,
689                                         gpointer         user_data)
690 {
691     intf_thread_t * p_intf    = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
692     input_area_t *  p_area    = p_intf->p_input->stream.p_selected_area;
693     gint            i_chapter = (gint)user_data;
694
695     p_area->i_part = i_chapter;
696
697     p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
698     input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
699 }
700
701 gboolean
702 on_intf_window_destroy                 (GtkWidget       *widget,
703                                         GdkEvent        *event,
704                                         gpointer         user_data)
705 {
706     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget),  "intf_window" );
707
708     vlc_mutex_lock( &p_intf->change_lock );
709     p_intf->b_die = 1;
710     vlc_mutex_unlock( &p_intf->change_lock );
711
712     return TRUE;
713 }
714
715
716 void
717 on_main_window_toggle                  (GtkMenuItem     *menuitem,
718                                         gpointer         user_data)
719 {
720     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem),  "intf_popup" );
721     
722     if( GTK_WIDGET_VISIBLE(p_intf->p_sys->p_window) ) {
723         gtk_widget_hide( p_intf->p_sys->p_window);
724
725     } 
726     else 
727     {
728         gtk_widget_show( p_intf->p_sys->p_window );
729     }
730 }
731
732
733 gboolean
734 on_playlist_clist_drag_motion          (GtkWidget       *widget,
735                                         GdkDragContext  *drag_context,
736                                         gint             x,
737                                         gint             y,
738                                         guint            time,
739                                         gpointer         user_data)
740 {
741     GtkCList * clist;
742     gint row,col;
743     int dummy;
744     GdkColor color;
745     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget),  "intf_playlist" );
746    
747     
748     clist = GTK_CLIST(lookup_widget( p_intf->p_sys->p_playlist,"playlist_clist"
749              ));
750
751     if(!GTK_WIDGET_TOPLEVEL(widget))
752     {
753         gdk_window_raise( p_intf->p_sys->p_playlist->window );
754     }
755
756     color.red = 0xffff;
757     color.green = 0xffff;
758     color.blue = 0xffff;
759
760     gtk_clist_freeze( clist );
761     
762     for(dummy=0; dummy<clist->rows; dummy++)
763     {
764        gtk_clist_set_background ( clist, dummy , &color);
765     }
766     color.red = 0xffff;
767     color.green = 0;
768     color.blue = 0;
769     gtk_clist_set_background ( clist, p_main->p_playlist->i_index , &color);
770         
771     if( gtk_clist_get_selection_info( clist,x,y ,&row,&col )== 1)
772     {
773         color.red = 0;
774         color.green = 0x9000;
775         color.blue = 0xf000;
776         gtk_clist_set_background ( clist, row-1  , &color);
777         gtk_clist_set_background ( clist, row  , &color);
778     }
779
780     gtk_clist_thaw( clist );
781     
782     return TRUE;
783 }
784
785
786 void
787 on_intf_network_destroy                (GtkObject       *object,
788                                         gpointer         user_data)
789 {
790     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_network" );
791
792     p_intf->p_sys->p_network = NULL;
793 }
794
795
796 void
797 on_network_ok_clicked                  (GtkButton       *button,
798                                         gpointer         user_data)
799 {
800     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_network" );
801     char *psz_source, *psz_server, *psz_protocol;
802     unsigned int i_port;
803
804     psz_server = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
805                                  GTK_WIDGET(button), "network_server" ) ) );
806
807     /* Check which protocol was activated */
808     if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
809                                           "network_ts" ) )->active )
810     {
811         psz_protocol = "ts";
812     }
813     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
814                                                "network_rtp" ) )->active )
815     {
816         psz_protocol = "rtp";
817     }
818     else
819     {
820         intf_ErrMsg( "intf error: unknown protocol toggle button position" );
821         return;
822     }
823
824     /* Get the port number and make sure it will not overflow 5 characters */
825     i_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
826                  lookup_widget( GTK_WIDGET(button), "network_port" ) ) );
827     if( i_port > 65535 )
828     {
829         intf_ErrMsg( "intf error: invalid port %i", i_port );
830     }
831
832     /* Allocate room for "protocol://server:port" */
833     psz_source = malloc( strlen( psz_protocol ) + strlen( psz_server ) + 10 );
834     if( psz_source == NULL )
835     {
836         return;
837     }
838    
839     /* Build source name and add it to playlist */
840     sprintf( psz_source, "%s://%s:%i", psz_protocol, psz_server, i_port );
841     intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
842     free( psz_source );
843
844     gtk_widget_hide( p_intf->p_sys->p_network );
845 }
846
847
848 void
849 on_network_cancel_clicked              (GtkButton       *button,
850                                         gpointer         user_data)
851 {
852     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
853 }
854
855
856 void
857 on_menubar_network_activate            (GtkMenuItem     *menuitem,
858                                         gpointer         user_data)
859 {
860     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
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
867 void
868 on_popup_network_activate              (GtkMenuItem     *menuitem,
869                                         gpointer         user_data)
870 {
871     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
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 void
878 on_toolbar_network_clicked             (GtkButton       *button,
879                                         gpointer         user_data)
880 {
881     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
882
883     gtk_widget_show( p_intf->p_sys->p_network );
884     gdk_window_raise( p_intf->p_sys->p_network->window );
885 }
886
887
888 gboolean
889 on_slider_button_release_event         (GtkWidget       *widget,
890                                         GdkEventButton  *event,
891                                         gpointer         user_data)
892 {
893     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
894
895     vlc_mutex_lock( &p_intf->change_lock );
896     p_intf->p_sys->b_slider_free = 1;
897     vlc_mutex_unlock( &p_intf->change_lock );
898
899     return FALSE;
900 }
901
902
903 gboolean
904 on_slider_button_press_event           (GtkWidget       *widget,
905                                         GdkEventButton  *event,
906                                         gpointer         user_data)
907 {
908     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
909
910     vlc_mutex_lock( &p_intf->change_lock );
911     p_intf->p_sys->b_slider_free = 0;
912     vlc_mutex_unlock( &p_intf->change_lock );
913
914     return FALSE;
915 }
916
917
918 void
919 on_menubar_fullscreen_activate         (GtkMenuItem     *menuitem,
920                                         gpointer         user_data)
921 {
922
923 }
924
925
926 void
927 on_menubar_angle_activate              (GtkMenuItem     *menuitem,
928                                         gpointer         user_data)
929 {
930
931 }
932