]> git.sesse.net Git - vlc/blobdiff - plugins/gtk/gtk_callbacks.c
* Bug fixes and enhancements in the Gtk+/Gnome interfaces.
[vlc] / plugins / gtk / gtk_callbacks.c
index 93491832f430df56cf6b7271ee9414d9927b6f91..81db397a2a8c30ac62d7c25affcf8549124b93cb 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (C) 2000, 2001 VideoLAN
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
+ *          Stéphane Borel <stef@via.ecp.fr>
  *      
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *****************************************************************************/
 #include "defs.h"
 
+#include <stdlib.h>
+
 #include <gtk/gtk.h>
 
+#include <string.h>
+
 #include "config.h"
 #include "common.h"
 #include "threads.h"
 #include "input_ext-intf.h"
 
 #include "interface.h"
-#include "intf_plst.h"
+#include "intf_playlist.h"
 #include "intf_msg.h"
 
-#include "gtk_sys.h"
 #include "gtk_callbacks.h"
 #include "gtk_interface.h"
 #include "gtk_support.h"
+#include "intf_gtk.h"
 
 #include "main.h"
 
-/*****************************************************************************
- * Inline function to retrieve the interface structure
- *****************************************************************************/
-static __inline__ intf_thread_t * GetIntf( GtkWidget *item, char * psz_parent )
-{
-    return( gtk_object_get_data( GTK_OBJECT( lookup_widget(item, psz_parent) ),
-                                 "p_intf" ) );
-}
+/****************************************************************************
+ * External function
+ */
+void on_generic_drop_data_received( intf_thread_t * p_intf,
+                        GtkSelectionData *data, guint info, int position);
+
+
 
 /*****************************************************************************
  * Callbacks
@@ -86,27 +90,11 @@ on_menubar_exit_activate               (GtkMenuItem     *menuitem,
 {
     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
 
+    vlc_mutex_lock( &p_intf->change_lock );
     p_intf->b_die = 1;
+    vlc_mutex_unlock( &p_intf->change_lock );
 }
 
-
-void
-on_menubar_playlist_activate           (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
-
-    if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
-    {
-//        p_intf->p_sys->p_playlist = create_intf_playlist();
-        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
-                             "p_intf", p_intf );
-    }
-    gtk_widget_show( p_intf->p_sys->p_playlist );
-    gdk_window_raise( p_intf->p_sys->p_playlist->window );
-}
-
-
 void
 on_menubar_preferences_activate        (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
@@ -192,24 +180,6 @@ on_toolbar_pause_clicked               (GtkButton       *button,
     }
 }
 
-
-void
-on_toolbar_playlist_clicked            (GtkButton       *button,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
-
-    if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
-    {
-//        p_intf->p_sys->p_playlist = create_intf_playlist();
-        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
-                             "p_intf", p_intf );
-    }
-    gtk_widget_show( p_intf->p_sys->p_playlist );
-    gdk_window_raise( p_intf->p_sys->p_playlist->window );
-}
-
-
 void
 on_toolbar_prev_clicked                (GtkButton       *button,
                                         gpointer         user_data)
@@ -219,8 +189,8 @@ on_toolbar_prev_clicked                (GtkButton       *button,
     if( p_intf->p_input != NULL )
     {
         /* FIXME: temporary hack */
-        intf_PlstPrev( p_main->p_playlist );
-        intf_PlstPrev( p_main->p_playlist );
+        intf_PlaylistPrev( p_main->p_playlist );
+        intf_PlaylistPrev( p_main->p_playlist );
         p_intf->p_input->b_eof = 1;
     }
 }
@@ -272,22 +242,11 @@ on_popup_exit_activate                 (GtkMenuItem     *menuitem,
 {
     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
 
+    vlc_mutex_lock( &p_intf->change_lock );
     p_intf->b_die = 1;
+    vlc_mutex_unlock( &p_intf->change_lock );
 }
 
-
-void
-on_intf_window_destroy                 (GtkObject       *object,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_window" );
-
-    /* FIXME don't destroy the window, just hide it */
-    p_intf->b_die = 1;
-    p_intf->p_sys->p_window = NULL;
-}
-
-
 void
 on_fileopen_ok_clicked                 (GtkButton       *button,
                                         gpointer         user_data)
@@ -299,7 +258,7 @@ on_fileopen_ok_clicked                 (GtkButton       *button,
     gtk_widget_hide (filesel);
     filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
 
-    intf_PlstAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
+    intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
 }
 
 
@@ -355,31 +314,37 @@ on_popup_about_activate                (GtkMenuItem     *menuitem,
     gtk_widget_show( p_intf->p_sys->p_about );
     gdk_window_raise( p_intf->p_sys->p_about->window );
 }
-
-
 void
-on_intf_playlist_destroy               (GtkObject       *object,
+on_popup_slow_activate                 (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_playlist" );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
 
-    p_intf->p_sys->p_playlist = NULL;
+    if( p_intf->p_input != NULL )
+    {
+        input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
+    }
 }
 
 
 void
-on_playlist_close_clicked              (GtkButton       *button,
+on_popup_fast_activate                 (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-    gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+
+    if( p_intf->p_input != NULL )
+    {
+        input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
+    }
 }
 
 
 void
-on_popup_slow_activate                 (GtkMenuItem     *menuitem,
+on_toolbar_slow_clicked                (GtkButton       *button,
                                         gpointer         user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
 
     if( p_intf->p_input != NULL )
     {
@@ -389,10 +354,10 @@ on_popup_slow_activate                 (GtkMenuItem     *menuitem,
 
 
 void
-on_popup_fast_activate                 (GtkMenuItem     *menuitem,
+on_toolbar_fast_clicked                (GtkButton       *button,
                                         gpointer         user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
 
     if( p_intf->p_input != NULL )
     {
@@ -402,195 +367,539 @@ on_popup_fast_activate                 (GtkMenuItem     *menuitem,
 
 
 void
-on_toolbar_slow_clicked                (GtkButton       *button,
+on_intf_modules_destroy                (GtkObject       *object,
                                         gpointer         user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
 
-    if( p_intf->p_input != NULL )
+}
+
+
+void
+on_modules_ok_clicked                  (GtkButton       *button,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
+
+    gtk_widget_hide( p_intf->p_sys->p_modules );
+
+}
+
+
+void
+on_modules_apply_clicked               (GtkButton       *button,
+                                        gpointer         user_data)
+{
+
+}
+
+
+void
+on_modules_cancel_clicked              (GtkButton       *button,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
+
+    gtk_widget_hide( p_intf->p_sys->p_modules );
+}
+
+void
+on_menubar_modules_activate            (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+
+    if( !GTK_IS_WIDGET( p_intf->p_sys->p_modules ) )
     {
-        input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
+//        p_intf->p_sys->p_modules = create_intf_modules();
+        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_modules ),
+                             "p_intf", p_intf );
     }
+    gtk_widget_show( p_intf->p_sys->p_modules );
+    gdk_window_raise( p_intf->p_sys->p_modules->window );
 }
 
 
 void
-on_toolbar_fast_clicked                (GtkButton       *button,
+on_intf_window_drag_data_received      (GtkWidget       *widget,
+                                        GdkDragContext  *drag_context,
+                                        gint             x,
+                                        gint             y,
+                                        GtkSelectionData *data,
+                                        guint            info,
+                                        guint            time,
+                                        gpointer         user_data)
+{
+    intf_thread_t * p_intf =  GetIntf( GTK_WIDGET(widget), "intf_window" );
+    int end = p_main->p_playlist->i_size;
+    on_generic_drop_data_received( p_intf, data, info, PLAYLIST_END);
+
+     if( p_intf->p_input != NULL )
+     {
+        /* FIXME: temporary hack */
+        p_intf->p_input->b_eof = 1;
+     }
+     
+    intf_PlaylistJumpto( p_main->p_playlist, end-1 );
+
+}
+
+
+void
+on_about_ok_clicked                    (GtkButton       *button,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_about" );
+
+    gtk_widget_hide( p_intf->p_sys->p_about );
+}
+
+
+void
+on_menubar_disc_activate               (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+
+    if( !GTK_IS_WIDGET( p_intf->p_sys->p_disc ) )
+    {
+        p_intf->p_sys->p_disc = create_intf_disc();
+        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_disc ),
+                             "p_intf", p_intf );
+    }
+    gtk_widget_show( p_intf->p_sys->p_disc );
+    gdk_window_raise( p_intf->p_sys->p_disc->window );
+}
+
+
+void
+on_toolbar_disc_clicked                (GtkButton       *button,
                                         gpointer         user_data)
 {
     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
 
-    if( p_intf->p_input != NULL )
+    if( !GTK_IS_WIDGET( p_intf->p_sys->p_disc ) )
     {
-        input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
+        p_intf->p_sys->p_disc = create_intf_disc();
+        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_disc ),
+                             "p_intf", p_intf );
     }
+    gtk_widget_show( p_intf->p_sys->p_disc );
+    gdk_window_raise( p_intf->p_sys->p_disc->window );
 }
 
 
-gboolean
-on_hscale_button_release_event         (GtkWidget       *widget,
-                                        GdkEventButton  *event,
+void
+on_disc_ok_clicked                     (GtkButton       *button,
                                         gpointer         user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
+    char *psz_device, *psz_source, *psz_method;
 
-    GtkAdjustment *p_adj = gtk_range_get_adjustment( GTK_RANGE(widget) );
-    off_t i_seek;
+    psz_device = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
+                                         GTK_WIDGET(button), "disc_name" ) ) );
 
-    vlc_mutex_lock( &p_intf->p_sys->change_lock );
+    /* "dvd:foo" has size 5 + strlen(foo) */
+    psz_source = malloc( 5 + strlen( psz_device ) );
+    if( psz_source == NULL )
+    {
+        return;
+    }
 
-    if( p_intf->p_input != NULL )
+    /* Check which method was activated */
+    if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
+                                          "disc_dvd" ) )->active )
+    {
+        psz_method = "dvd";
+    }
+    else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
+                                               "disc_vcd" ) )->active )
+    {
+        psz_method = "vcd";
+    }
+    else
     {
-        i_seek = (p_adj->value *
-                  p_intf->p_input->stream.p_selected_area->i_size) / 100;
-        input_Seek( p_intf->p_input, i_seek );
+        intf_ErrMsg( "intf error: unknown toggle button configuration" );
+        free( psz_source );
+        return;
     }
-    p_intf->p_sys->b_scale_isfree = 1;
+    
+    /* Select title and chapter */
+    main_PutIntVariable( INPUT_TITLE_VAR, gtk_spin_button_get_value_as_int(
+                              GTK_SPIN_BUTTON( lookup_widget(
+                                  GTK_WIDGET(button), "disc_title" ) ) ) );
 
-    vlc_mutex_unlock( &p_intf->p_sys->change_lock );
+    main_PutIntVariable( INPUT_CHAPTER_VAR, gtk_spin_button_get_value_as_int(
+                              GTK_SPIN_BUTTON( lookup_widget(
+                                  GTK_WIDGET(button), "disc_chapter" ) ) ) );
 
-    return FALSE;
+    /* Build source name and add it to playlist */
+    sprintf( psz_source, "%s:%s", psz_method, psz_device );
+    intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
+
+    gtk_widget_hide( p_intf->p_sys->p_disc );
 }
 
 
-gboolean
-on_hscale_button_press_event           (GtkWidget       *widget,
-                                        GdkEventButton  *event,
+void
+on_disc_cancel_clicked                 (GtkButton       *button,
                                         gpointer         user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
 
-    vlc_mutex_lock( &p_intf->p_sys->change_lock );
-    p_intf->p_sys->b_scale_isfree = 0;
-    vlc_mutex_unlock( &p_intf->p_sys->change_lock );
+    gtk_widget_hide( p_intf->p_sys->p_disc );
+}
 
-    return FALSE;
+
+void
+on_disc_dvd_toggled                    (GtkToggleButton *togglebutton,
+                                        gpointer         user_data)
+{
+    if( togglebutton->active )
+    {
+        gtk_entry_set_text( GTK_ENTRY( lookup_widget(
+            GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/dvd" );
+    }
+}
+
+
+void
+on_disc_vcd_toggled                    (GtkToggleButton *togglebutton,
+                                        gpointer         user_data)
+{
+    if( togglebutton->active )
+    {
+        gtk_entry_set_text( GTK_ENTRY( lookup_widget(
+            GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/cdrom" );
+    }
 }
 
 
+void
+on_popup_disc_activate                 (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+
+    if( !GTK_IS_WIDGET( p_intf->p_sys->p_disc ) )
+    {
+        p_intf->p_sys->p_disc = create_intf_disc();
+        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_disc ),
+                             "p_intf", p_intf );
+    }
+    gtk_widget_show( p_intf->p_sys->p_disc );
+    gdk_window_raise( p_intf->p_sys->p_disc->window );
+}
 
 void
-on_intf_modules_destroy                (GtkObject       *object,
+on_popup_audio_activate                (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+    es_descriptor_t *       p_es;
 
+    p_es = (es_descriptor_t*)user_data;
+
+    input_ChangeES( p_intf->p_input, p_es, 1 );
 }
 
 
 void
-on_modules_ok_clicked                  (GtkButton       *button,
+on_popup_subpictures_activate          (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+    es_descriptor_t *       p_es;
 
-    gtk_widget_hide( p_intf->p_sys->p_modules );
+    p_es = (es_descriptor_t*)user_data;
 
+    input_ChangeES( p_intf->p_input, p_es, 2 );
 }
 
 
 void
-on_modules_apply_clicked               (GtkButton       *button,
+on_menubar_audio_activate              (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+    es_descriptor_t *       p_es;
 
+    p_es = (es_descriptor_t*)user_data;
+
+    input_ChangeES( p_intf->p_input, p_es, 1 );
 }
 
 
 void
-on_modules_cancel_clicked              (GtkButton       *button,
+on_menubar_subpictures_activate        (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+    es_descriptor_t *       p_es;
 
-    gtk_widget_hide( p_intf->p_sys->p_modules );
+    p_es = (es_descriptor_t*)user_data;
+
+    input_ChangeES( p_intf->p_input, p_es, 2 );
 }
 
 
 void
-on_playlist_ok_clicked                 (GtkButton       *button,
+on_popup_navigation_activate           (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_playlist" );
+    intf_thread_t * p_intf    = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+    input_area_t *  p_area;
+    gint            i_title;
+    gint            i_chapter;
+
+    i_title   = (gint)(user_data) / 100 ;
+    i_chapter = (gint)(user_data) - ( 100 * i_title );
+    p_area    = p_intf->p_input->stream.pp_areas[i_title];
+    p_area->i_part = i_chapter;
 
-    gtk_widget_hide( p_intf->p_sys->p_playlist );
+    p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
+    input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
 }
 
 
 void
-on_menubar_modules_activate            (GtkMenuItem     *menuitem,
+on_menubar_title_activate              (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
 
-    if( !GTK_IS_WIDGET( p_intf->p_sys->p_modules ) )
+    p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)user_data );
+    p_intf->p_sys->b_menus_update = 1;
+    input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+}
+
+
+void
+on_menubar_chapter_activate            (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+    intf_thread_t * p_intf    = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+    input_area_t *  p_area    = p_intf->p_input->stream.p_selected_area;
+    gint            i_chapter = (gint)user_data;
+
+    p_area->i_part = i_chapter;
+
+    p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
+    input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+}
+
+gboolean
+on_intf_window_destroy                 (GtkWidget       *widget,
+                                        GdkEvent        *event,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget),  "intf_window" );
+
+    vlc_mutex_lock( &p_intf->change_lock );
+    p_intf->b_die = 1;
+    vlc_mutex_unlock( &p_intf->change_lock );
+
+    return TRUE;
+}
+
+
+void
+on_main_window_toggle                  (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem),  "intf_popup" );
+    
+    if( GTK_WIDGET_VISIBLE(p_intf->p_sys->p_window) ) {
+        gtk_widget_hide( p_intf->p_sys->p_window);
+
+    } 
+    else 
     {
-//        p_intf->p_sys->p_modules = create_intf_modules();
-        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_modules ),
-                             "p_intf", p_intf );
+        gtk_widget_show( p_intf->p_sys->p_window );
     }
-    gtk_widget_show( p_intf->p_sys->p_modules );
-    gdk_window_raise( p_intf->p_sys->p_modules->window );
 }
 
 
-void
-on_intf_window_drag_data_received      (GtkWidget       *widget,
+gboolean
+on_playlist_clist_drag_motion          (GtkWidget       *widget,
                                         GdkDragContext  *drag_context,
                                         gint             x,
                                         gint             y,
-                                        GtkSelectionData *data,
-                                        guint            info,
                                         guint            time,
                                         gpointer         user_data)
 {
-    char *psz_text = data->data;
-    int i_len      = strlen( psz_text );
+    GtkCList * clist;
+    gint row,col;
+    int dummy;
+    GdkColor color;
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget),  "intf_playlist" );
+   
+    
+    clist = GTK_CLIST(lookup_widget( p_intf->p_sys->p_playlist,"playlist_clist"
+             ));
+
+    if(!GTK_WIDGET_TOPLEVEL(widget))
+    {
+        gdk_window_raise( p_intf->p_sys->p_playlist->window );
+    }
 
-    switch( info )
+    color.red = 0xffff;
+    color.green = 0xffff;
+    color.blue = 0xffff;
+
+    gtk_clist_freeze( clist );
+    
+    for(dummy=0; dummy<clist->rows; dummy++)
+    {
+       gtk_clist_set_background ( clist, dummy , &color);
+    }
+    color.red = 0xffff;
+    color.green = 0;
+    color.blue = 0;
+    gtk_clist_set_background ( clist, p_main->p_playlist->i_index , &color);
+        
+    if( gtk_clist_get_selection_info( clist,x,y ,&row,&col )== 1)
     {
-    case DROP_ACCEPT_TEXT_PLAIN: /* FIXME: handle multiple files */
+        color.red = 0;
+        color.green = 0x9000;
+        color.blue = 0xf000;
+        gtk_clist_set_background ( clist, row-1  , &color);
+        gtk_clist_set_background ( clist, row  , &color);
+    }
 
-        if( i_len < 1 )
-        {
-            return;
-        }
+    gtk_clist_thaw( clist );
+    
+    return TRUE;
+}
 
-        /* get rid of ' ' at the end */
-        *( psz_text + i_len - 1 ) = 0;
 
-        intf_WarnMsg( 1, "intf: dropped text/uri-list data `%s'", psz_text );
-        intf_PlstAdd( p_main->p_playlist, PLAYLIST_END, psz_text );
+void
+on_intf_network_destroy                (GtkObject       *object,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_network" );
 
-        break;
+    p_intf->p_sys->p_network = NULL;
+}
 
-    case DROP_ACCEPT_TEXT_URI_LIST: /* FIXME: handle multiple files */
 
-        if( i_len < 2 )
-        {
-            return;
-        }
+void
+on_network_ok_clicked                  (GtkButton       *button,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_network" );
+    char *psz_source, *psz_server, *psz_protocol;
+    unsigned int i_port;
 
-        /* get rid of \r\n at the end */
-        *( psz_text + i_len - 2 ) = 0;
+    psz_server = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
+                                 GTK_WIDGET(button), "network_server" ) ) );
 
-        intf_WarnMsg( 1, "intf: dropped text/uri-list data `%s'", psz_text );
-        intf_PlstAdd( p_main->p_playlist, PLAYLIST_END, psz_text );
-        break;
+    /* Check which protocol was activated */
+    if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
+                                          "network_ts" ) )->active )
+    {
+        psz_protocol = "ts";
+    }
+    else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
+                                               "network_rtp" ) )->active )
+    {
+        psz_protocol = "rtp";
+    }
+    else
+    {
+        intf_ErrMsg( "intf error: unknown protocol toggle button position" );
+        return;
+    }
 
-    default:
+    /* Get the port number and make sure it will not overflow 5 characters */
+    i_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
+                 lookup_widget( GTK_WIDGET(button), "network_port" ) ) );
+    if( i_port > 65535 )
+    {
+        intf_ErrMsg( "intf error: invalid port %i", i_port );
+    }
 
-        intf_ErrMsg( "intf error: unknown dropped type");
-        break;
+    /* Allocate room for "protocol://server:port" */
+    psz_source = malloc( strlen( psz_protocol ) + strlen( psz_server ) + 10 );
+    if( psz_source == NULL )
+    {
+        return;
     }
+   
+    /* Build source name and add it to playlist */
+    sprintf( psz_source, "%s://%s:%i", psz_protocol, psz_server, i_port );
+    intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
+    free( psz_source );
+
+    gtk_widget_hide( p_intf->p_sys->p_network );
 }
 
 
 void
-on_about_ok_clicked                    (GtkButton       *button,
+on_network_cancel_clicked              (GtkButton       *button,
                                         gpointer         user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_about" );
+    gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
+}
 
-    gtk_widget_hide( p_intf->p_sys->p_about );
+
+void
+on_menubar_network_activate            (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+
+    gtk_widget_show( p_intf->p_sys->p_network );
+    gdk_window_raise( p_intf->p_sys->p_network->window );
+}
+
+
+void
+on_popup_network_activate              (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+
+    gtk_widget_show( p_intf->p_sys->p_network );
+    gdk_window_raise( p_intf->p_sys->p_network->window );
+}
+
+void
+on_toolbar_network_clicked             (GtkButton       *button,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+
+    gtk_widget_show( p_intf->p_sys->p_network );
+    gdk_window_raise( p_intf->p_sys->p_network->window );
+}
+
+
+gboolean
+on_slider_button_release_event         (GtkWidget       *widget,
+                                        GdkEventButton  *event,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
+
+    vlc_mutex_lock( &p_intf->change_lock );
+    p_intf->p_sys->b_slider_free = 1;
+    vlc_mutex_unlock( &p_intf->change_lock );
+
+    return FALSE;
+}
+
+
+gboolean
+on_slider_button_press_event           (GtkWidget       *widget,
+                                        GdkEventButton  *event,
+                                        gpointer         user_data)
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
+
+    vlc_mutex_lock( &p_intf->change_lock );
+    p_intf->p_sys->b_slider_free = 0;
+    vlc_mutex_unlock( &p_intf->change_lock );
+
+    return FALSE;
 }