]> git.sesse.net Git - vlc/blobdiff - plugins/gtk/gtk_callbacks.c
Added memcpyaltivec.
[vlc] / plugins / gtk / gtk_callbacks.c
index d454832cb37714bad65c6f00979bf9a2a6268017..21a4b4b0924ca811b415aba39daeed55cc49f79c 100644 (file)
@@ -2,9 +2,11 @@
  * gtk_callbacks.c : Callbacks for the Gtk+ plugin.
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
+ * $Id: gtk_callbacks.c,v 1.34 2002/03/25 02:06:24 jobi Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Stéphane Borel <stef@via.ecp.fr>
+ *          Julien BLACHE <jb@technologeek.org>
  *      
  * 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
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#define MODULE_NAME gtk
-#include "modules_inner.h"
-
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include "defs.h"
-
+#include <sys/types.h>                                              /* off_t */
 #include <stdlib.h>
 
+#include <videolan/vlc.h>
+
+#include <unistd.h>
+
 #include <gtk/gtk.h>
 
-#include "config.h"
-#include "common.h"
-#include "threads.h"
-#include "mtime.h"
+#include <string.h>
 
 #include "stream_control.h"
 #include "input_ext-intf.h"
 
 #include "interface.h"
-#include "intf_plst.h"
-#include "intf_msg.h"
+#include "intf_playlist.h"
+#include "intf_eject.h"
+
+#include "video.h"
+#include "video_output.h"
 
-#include "gtk_sys.h"
 #include "gtk_callbacks.h"
 #include "gtk_interface.h"
 #include "gtk_support.h"
+#include "gtk_common.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" ) );
-}
+#include "netutils.h"
 
 /*****************************************************************************
  * Callbacks
- ******************************************************************************/
-void
-on_menubar_open_activate               (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
-
-    /* If we have never used the file selector, open it */
-    if( p_intf->p_sys->p_fileopen == NULL)
-    {
-        p_intf->p_sys->p_fileopen = create_intf_fileopen();
-        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
-                             "p_intf", p_intf );
-    }
-
-    gtk_widget_show( p_intf->p_sys->p_fileopen );
-    gdk_window_raise( p_intf->p_sys->p_fileopen->window );
-}
+ *****************************************************************************/
 
+/*
+ * Main interface callbacks
+ */
 
-void
-on_menubar_exit_activate               (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
+gboolean GtkExit( GtkWidget       *widget,
+                  GdkEventButton  *event,
+                  gpointer         user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
 
+    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 );
+    return TRUE;
 }
 
-
-void
-on_menubar_preferences_activate        (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
+gboolean GtkWindowDelete( GtkWidget       *widget,
+                          GdkEvent        *event,
+                          gpointer         user_data )
 {
+    GtkExit( GTK_WIDGET( widget ), NULL, user_data );
 
+    return TRUE;
 }
 
 
-void
-on_menubar_about_activate              (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
+gboolean GtkWindowToggle( GtkWidget       *widget,
+                          GdkEventButton  *event,
+                          gpointer         user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
-
-    if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
-    {
-        p_intf->p_sys->p_about = create_intf_about();
-        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
-                             "p_intf", p_intf );
-    }
-    gtk_widget_show( p_intf->p_sys->p_about );
-    gdk_window_raise( p_intf->p_sys->p_about->window );
-}
-
-
-void
-on_toolbar_open_clicked                (GtkButton       *button,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
-
-    /* If we have never used the file selector, open it */
-    if( p_intf->p_sys->p_fileopen == NULL)
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
+    
+    if( GTK_WIDGET_VISIBLE(p_intf->p_sys->p_window) )
     {
-        p_intf->p_sys->p_fileopen = create_intf_fileopen();
-        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
-                             "p_intf", p_intf );
-    }
-
-    gtk_widget_show( p_intf->p_sys->p_fileopen );
-    gdk_window_raise( p_intf->p_sys->p_fileopen->window );
-}
-
+        gtk_widget_hide( p_intf->p_sys->p_window);
 
-void
-on_toolbar_back_clicked                (GtkButton       *button,
-                                        gpointer         user_data)
-{
-
-}
-
-
-void
-on_toolbar_stop_clicked                (GtkButton       *button,
-                                        gpointer         user_data)
-{
-
-}
-
-
-void
-on_toolbar_play_clicked                (GtkButton       *button,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
-
-    if( p_intf->p_input != NULL )
+    } 
+    else 
     {
-        input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+        gtk_widget_show( p_intf->p_sys->p_window );
     }
-}
-
 
-void
-on_toolbar_pause_clicked               (GtkButton       *button,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
-
-    if( p_intf->p_input != NULL )
-    {
-        input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
-    }
+    return TRUE;
 }
 
-
-void
-on_toolbar_playlist_clicked            (GtkButton       *button,
-                                        gpointer         user_data)
+gboolean GtkFullscreen( GtkWidget       *widget,
+                        GdkEventButton  *event,
+                        gpointer         user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
-
-    if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
+    if( p_vout_bank->i_count )
     {
-//        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 );
-}
+        vlc_mutex_lock( &p_vout_bank->pp_vout[0]->change_lock );
 
+        p_vout_bank->pp_vout[0]->i_changes |= VOUT_FULLSCREEN_CHANGE;
 
-void
-on_toolbar_prev_clicked                (GtkButton       *button,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+        vlc_mutex_unlock( &p_vout_bank->pp_vout[0]->change_lock );
 
-    if( p_intf->p_input != NULL )
-    {
-        /* FIXME: temporary hack */
-        intf_PlstPrev( p_main->p_playlist );
-        intf_PlstPrev( p_main->p_playlist );
-        p_intf->p_input->b_eof = 1;
+        return TRUE;
     }
-}
-
-
-void
-on_toolbar_next_clicked                (GtkButton       *button,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
-
-    if( p_intf->p_input != NULL )
+    else
     {
-        /* FIXME: temporary hack */
-        p_intf->p_input->b_eof = 1;
+        return FALSE;
     }
 }
 
-
-void
-on_popup_play_activate                 (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
+void GtkWindowDrag( 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(menuitem), "intf_popup" );
+    intf_thread_t * p_intf =  GetIntf( GTK_WIDGET(widget), "intf_window" );
+    int end = p_main->p_playlist->i_size;
+    GtkDropDataReceived( p_intf, data, info, PLAYLIST_END );
 
-    if( p_intf->p_input != NULL )
+    if( p_input_bank->pp_input[0] != NULL )
     {
-        input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+       /* FIXME: temporary hack */
+       p_input_bank->pp_input[0]->b_eof = 1;
     }
+     
+    intf_PlaylistJumpto( p_main->p_playlist, end-1 );
 }
 
 
-void
-on_popup_pause_activate                (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+/****************************************************************************
+ * Slider management
+ ****************************************************************************/
 
-    if( p_intf->p_input != NULL )
-    {
-        input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
-    }
-}
-
-
-void
-on_popup_exit_activate                 (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
+gboolean GtkSliderRelease( GtkWidget       *widget,
+                           GdkEventButton  *event,
+                           gpointer         user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
-
-    p_intf->b_die = 1;
-}
-
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
 
-void
-on_intf_window_destroy                 (GtkObject       *object,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_window" );
+    vlc_mutex_lock( &p_intf->change_lock );
+    p_intf->p_sys->b_slider_free = 1;
+    vlc_mutex_unlock( &p_intf->change_lock );
 
-    /* FIXME don't destroy the window, just hide it */
-    p_intf->b_die = 1;
-    p_intf->p_sys->p_window = NULL;
+    return FALSE;
 }
 
 
-void
-on_fileopen_ok_clicked                 (GtkButton       *button,
-                                        gpointer         user_data)
+gboolean GtkSliderPress( GtkWidget       *widget,
+                         GdkEventButton  *event,
+                         gpointer         user_data)
 {
-    GtkWidget *filesel;
-    gchar *filename;
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
 
-    filesel = gtk_widget_get_toplevel (GTK_WIDGET (button));
-    gtk_widget_hide (filesel);
-    filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
+    vlc_mutex_lock( &p_intf->change_lock );
+    p_intf->p_sys->b_slider_free = 0;
+    vlc_mutex_unlock( &p_intf->change_lock );
 
-    intf_PlstAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
+    return FALSE;
 }
 
 
-void
-on_fileopen_cancel_clicked             (GtkButton       *button,
-                                        gpointer         user_data)
-{
-    gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
-}
-
+/****************************************************************************
+ * DVD specific items
+ ****************************************************************************/
 
-void
-on_intf_fileopen_destroy               (GtkObject       *object,
-                                        gpointer         user_data)
+void GtkTitlePrev( GtkButton * button, gpointer user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_fileopen" );
+    intf_thread_t * p_intf;
+    input_area_t *  p_area;
+    int             i_id;
 
-    p_intf->p_sys->p_fileopen = NULL;
-}
+    p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
+    i_id = p_input_bank->pp_input[0]->stream.p_selected_area->i_id - 1;
 
+    /* Disallow area 0 since it is used for video_ts.vob */
+    if( i_id > 0 )
+    {
+        p_area = p_input_bank->pp_input[0]->stream.pp_areas[i_id];
+        input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );
 
-void
-on_popup_open_activate                 (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+        input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
 
-    /* If we have never used the file selector, open it */
-    if( p_intf->p_sys->p_fileopen == NULL)
-    {
-        p_intf->p_sys->p_fileopen = create_intf_fileopen();
-        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
-                             "p_intf", p_intf );
+        p_intf->p_sys->b_title_update = 1;
+        vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
+        GtkSetupMenus( p_intf );
+        vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
     }
-
-    gtk_widget_show( p_intf->p_sys->p_fileopen );
-    gdk_window_raise( p_intf->p_sys->p_fileopen->window );
 }
 
 
-void
-on_popup_about_activate                (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
+void GtkTitleNext( GtkButton * button, gpointer user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+    intf_thread_t * p_intf;
+    input_area_t *  p_area;
+    int             i_id;
 
-    if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
+    p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
+    i_id = p_input_bank->pp_input[0]->stream.p_selected_area->i_id + 1;
+
+    if( i_id < p_input_bank->pp_input[0]->stream.i_area_nb )
     {
-        p_intf->p_sys->p_about = create_intf_about();
-        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
-                             "p_intf", p_intf );
-    }
-    gtk_widget_show( p_intf->p_sys->p_about );
-    gdk_window_raise( p_intf->p_sys->p_about->window );
-}
+        p_area = p_input_bank->pp_input[0]->stream.pp_areas[i_id];   
+        input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );
 
+        input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
 
-void
-on_intf_playlist_destroy               (GtkObject       *object,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_playlist" );
+        p_intf->p_sys->b_title_update = 1;
+        vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
+        GtkSetupMenus( p_intf );
+        vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
+    }
 
-    p_intf->p_sys->p_playlist = NULL;
 }
 
 
-void
-on_playlist_close_clicked              (GtkButton       *button,
-                                        gpointer         user_data)
+void GtkChapterPrev( GtkButton * button, gpointer user_data )
 {
-    gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
-}
-
+    intf_thread_t * p_intf;
+    input_area_t *  p_area;
 
-void
-on_popup_slow_activate                 (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+    p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
+    p_area = p_input_bank->pp_input[0]->stream.p_selected_area;
 
-    if( p_intf->p_input != NULL )
+    if( p_area->i_part > 0 )
     {
-        input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
-    }
-}
+        p_area->i_part--;
+        input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );
 
+        input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
 
-void
-on_popup_fast_activate                 (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-    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 );
+        p_intf->p_sys->b_chapter_update = 1;
+        vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
+        GtkSetupMenus( p_intf );
+        vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
     }
 }
 
 
-void
-on_toolbar_slow_clicked                (GtkButton       *button,
-                                        gpointer         user_data)
+void GtkChapterNext( GtkButton * button, gpointer user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+    intf_thread_t * p_intf;
+    input_area_t *  p_area;
 
-    if( p_intf->p_input != NULL )
-    {
-        input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
-    }
-}
+    p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
+    p_area = p_input_bank->pp_input[0]->stream.p_selected_area;
 
+    if( p_area->i_part < p_area->i_part_nb )
+    {
+        p_area->i_part++;
+        input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );
 
-void
-on_toolbar_fast_clicked                (GtkButton       *button,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+        input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
 
-    if( p_intf->p_input != NULL )
-    {
-        input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
+        p_intf->p_sys->b_chapter_update = 1;
+        vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
+        GtkSetupMenus( p_intf );
+        vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
     }
 }
 
-
-gboolean
-on_hscale_button_release_event         (GtkWidget       *widget,
-                                        GdkEventButton  *event,
-                                        gpointer         user_data)
+/****************************************************************************
+ * Network specific items
+ ****************************************************************************/
+void GtkNetworkJoin( GtkEditable * editable, gpointer user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
-
-    GtkAdjustment *p_adj = gtk_range_get_adjustment( GTK_RANGE(widget) );
-    off_t i_seek;
-
-    vlc_mutex_lock( &p_intf->p_sys->change_lock );
+    int     i_channel;
 
-    if( p_intf->p_input != NULL )
-    {
-        i_seek = (p_adj->value *
-                  p_intf->p_input->stream.p_selected_area->i_size) / 100;
-        input_Seek( p_intf->p_input, i_seek );
-    }
-    p_intf->p_sys->b_scale_isfree = 1;
+    i_channel = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( editable ) );
+//    intf_WarnMsg( 3, "intf info: joining channel %d", i_channel );
 
-    vlc_mutex_unlock( &p_intf->p_sys->change_lock );
-
-    return FALSE;
+//    network_ChannelJoin( i_channel );
 }
 
-
-gboolean
-on_hscale_button_press_event           (GtkWidget       *widget,
-                                        GdkEventButton  *event,
-                                        gpointer         user_data)
+void GtkChannelGo( GtkButton * button, gpointer user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
+    GtkWidget *     window;
+    GtkWidget *     spin;
+    int             i_channel;
 
-    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 );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
 
-    return FALSE;
-}
+    window = gtk_widget_get_toplevel( GTK_WIDGET (button) );
+    spin = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( window ),
+                       "network_channel_spinbutton" ) );
 
+    i_channel = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( spin ) );
+    intf_WarnMsg( 3, "intf info: joining channel %d", i_channel );
 
+    vlc_mutex_lock( &p_intf->change_lock );
+    if( p_input_bank->pp_input[0] != NULL )
+    {
+        /* end playing item */
+        p_input_bank->pp_input[0]->b_eof = 1;
 
-void
-on_intf_modules_destroy                (GtkObject       *object,
-                                        gpointer         user_data)
-{
-
-}
+        /* update playlist */
+        vlc_mutex_lock( &p_main->p_playlist->change_lock );
 
+        p_main->p_playlist->i_index--;
+        p_main->p_playlist->b_stopped = 1;
 
-void
-on_modules_ok_clicked                  (GtkButton       *button,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
+        vlc_mutex_unlock( &p_main->p_playlist->change_lock );
 
-    gtk_widget_hide( p_intf->p_sys->p_modules );
+        /* FIXME: ugly hack to close input and outputs */
+        p_intf->pf_manage( p_intf );
+    }
 
-}
+    network_ChannelJoin( i_channel );
 
+    /* FIXME 2 */
+    p_main->p_playlist->b_stopped = 0;
+    p_intf->pf_manage( p_intf );
 
-void
-on_modules_apply_clicked               (GtkButton       *button,
-                                        gpointer         user_data)
-{
+    vlc_mutex_unlock( &p_intf->change_lock );
 
+//    input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
 }
 
 
-void
-on_modules_cancel_clicked              (GtkButton       *button,
-                                        gpointer         user_data)
+/****************************************************************************
+ * About box
+ ****************************************************************************/
+
+gboolean GtkAboutShow( GtkWidget       *widget,
+                       GdkEventButton  *event,
+                       gpointer         user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
 
-    gtk_widget_hide( p_intf->p_sys->p_modules );
-}
+    if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
+    {
+        p_intf->p_sys->p_about = create_intf_about();
+        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
+                             "p_intf", p_intf );
+    }
+    gtk_widget_show( p_intf->p_sys->p_about );
+    gdk_window_raise( p_intf->p_sys->p_about->window );
 
+    return TRUE;
+}
 
-void
-on_playlist_ok_clicked                 (GtkButton       *button,
-                                        gpointer         user_data)
+void GtkAboutOk( GtkButton * button, gpointer user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_playlist" );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
 
-    gtk_widget_hide( p_intf->p_sys->p_playlist );
+    gtk_widget_hide( p_intf->p_sys->p_about );
 }
 
 
-void
-on_menubar_modules_activate            (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
+/****************************************************************************
+ * Jump box
+ ****************************************************************************/
+
+gboolean GtkJumpShow( GtkWidget       *widget,
+                      GdkEventButton  *event,
+                      gpointer         user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
 
-    if( !GTK_IS_WIDGET( p_intf->p_sys->p_modules ) )
+    if( !GTK_IS_WIDGET( p_intf->p_sys->p_jump ) )
     {
-//        p_intf->p_sys->p_modules = create_intf_modules();
-        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_modules ),
+        p_intf->p_sys->p_jump = create_intf_jump();
+        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_jump ),
                              "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_intf_window_drag_data_received      (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 );
 
-    switch( info )
-    {
-    case DROP_ACCEPT_TEXT_PLAIN: /* FIXME: handle multiple files */
+    gtk_widget_show( p_intf->p_sys->p_jump );
+    gdk_window_raise( p_intf->p_sys->p_jump->window );
 
-        if( i_len < 1 )
-        {
-            return;
-        }
+    return FALSE;
+}
 
-        /* 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 GtkJumpOk( GtkButton       *button,
+                gpointer         user_data)
+{
+    intf_thread_t * p_intf;
+    off_t           i_seek;
+    off_t           i_size;
+    int             i_hours;
+    int             i_minutes;
+    int             i_seconds;
 
-        break;
+    p_intf = GetIntf( GTK_WIDGET( button ), (char*)user_data );
 
-    case DROP_ACCEPT_TEXT_URI_LIST: /* FIXME: handle multiple files */
+#define GET_VALUE( name )                                                   \
+    gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( gtk_object_get_data( \
+        GTK_OBJECT( p_intf->p_sys->p_jump ), name ) ) )
 
-        if( i_len < 2 )
-        {
-            return;
-        }
+    i_hours   = GET_VALUE( "jump_hour_spinbutton" );
+    i_minutes = GET_VALUE( "jump_minute_spinbutton" );
+    i_seconds = GET_VALUE( "jump_second_spinbutton" );
 
-        /* get rid of \r\n at the end */
-        *( psz_text + i_len - 2 ) = 0;
+#undef GET_VALUE
 
-        intf_WarnMsg( 1, "intf: dropped text/uri-list data `%s'", psz_text );
-        intf_PlstAdd( p_main->p_playlist, PLAYLIST_END, psz_text );
-        break;
+    i_seconds += 60 *i_minutes + 3600* i_hours;
 
-    default:
+    vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
+    i_seek = i_seconds * 50 * p_input_bank->pp_input[0]->stream.i_mux_rate;
+    i_size = p_input_bank->pp_input[0]->stream.p_selected_area->i_size;
+    vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
 
-        intf_ErrMsg( "intf error: unknown dropped type");
-        break;
+    if( i_seek < i_size )
+    {
+        input_Seek( p_input_bank->pp_input[0], i_seek );
     }
+    p_main->p_playlist->b_stopped = 0;
+    gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
 }
 
 
-void
-on_about_ok_clicked                    (GtkButton       *button,
-                                        gpointer         user_data)
+void GtkJumpCancel( 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 );
+    gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
 }
 
 
-void
-on_menubar_disc_activate               (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
+/****************************************************************************
+ * Callbacks for menuitems
+ ****************************************************************************/
+void GtkExitActivate( 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 );
+    GtkExit( GTK_WIDGET( menuitem ), NULL, user_data );
 }
 
 
-void
-on_toolbar_disc_clicked                (GtkButton       *button,
-                                        gpointer         user_data)
+void GtkFullscreenActivate( GtkMenuItem * menuitem, gpointer user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "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 );
+    GtkFullscreen( GTK_WIDGET( menuitem ), NULL, user_data );
 }
 
 
-void
-on_disc_ok_clicked                     (GtkButton       *button,
-                                        gpointer         user_data)
+void GtkWindowToggleActivate( GtkMenuItem * menuitem, gpointer user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
-    char *psz_device, *psz_source, *psz_method;
-
-    psz_device = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
-                                         GTK_WIDGET(button), "disc_name" ) ) );
-
-    /* "dvd:foo" has size 5 + strlen(foo) */
-    psz_source = malloc( 5 + strlen( psz_device ) );
-    if( psz_source == NULL )
-    {
-        return;
-    }
-
-    /* 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
-    {
-        intf_ErrMsg( "intf error: unknown toggle button configuration" );
-        free( psz_source );
-        return;
-    }
-    
-    /* 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" ) ) ) );
-
-    main_PutIntVariable( INPUT_CHAPTER_VAR, gtk_spin_button_get_value_as_int(
-                              GTK_SPIN_BUTTON( lookup_widget(
-                                  GTK_WIDGET(button), "disc_chapter" ) ) ) );
-
-    /* Build source name and add it to playlist */
-    sprintf( psz_source, "%s:%s", psz_method, psz_device );
-    intf_PlstAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
-
-    gtk_widget_hide( p_intf->p_sys->p_disc );
+    GtkWindowToggle( GTK_WIDGET( menuitem ), NULL, user_data );
 }
 
 
-void
-on_disc_cancel_clicked                 (GtkButton       *button,
-                                        gpointer         user_data)
+void GtkAboutActivate( GtkMenuItem * menuitem, gpointer user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
-
-    gtk_widget_hide( p_intf->p_sys->p_disc );
+    GtkAboutShow( GTK_WIDGET( menuitem ), NULL, user_data );
 }
 
 
-void
-on_disc_dvd_toggled                    (GtkToggleButton *togglebutton,
-                                        gpointer         user_data)
+void GtkJumpActivate( GtkMenuItem * menuitem, gpointer user_data )
 {
-    if( togglebutton->active )
-    {
-        gtk_entry_set_text( GTK_ENTRY( lookup_widget(
-            GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/dvd" );
-    }
+    GtkJumpShow( GTK_WIDGET( menuitem ), NULL, user_data );
 }
 
 
-void
-on_disc_vcd_toggled                    (GtkToggleButton *togglebutton,
-                                        gpointer         user_data)
+void GtkMessagesActivate( GtkMenuItem * menuitem, gpointer user_data )
 {
-    if( togglebutton->active )
-    {
-        gtk_entry_set_text( GTK_ENTRY( lookup_widget(
-            GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/cdrom" );
-    }
+    GtkMessagesShow( GTK_WIDGET( menuitem ), NULL, user_data );
 }
 
 
-void
-on_popup_disc_activate                 (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
+/****************************************************************************
+ * Callbacks for disc ejection
+ ****************************************************************************/
+gboolean GtkDiscEject ( GtkWidget *widget, GdkEventButton *event,
+                        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 );
-}
+  char *psz_device = NULL;
 
+  /*
+   * Get the active input
+   * Determine whether we can eject a media, ie it's a VCD or DVD
+   * If it's neither a VCD nor a DVD, then return
+   */
 
-void
-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;
+  /*
+   * Don't really know if I must lock the stuff here, we're using it read-only
+   */
 
-    p_es = (es_descriptor_t*)user_data;
+  if (p_main->p_playlist->current.psz_name != NULL)
+  {
+      if (strncmp(p_main->p_playlist->current.psz_name, "dvd", 3)
+          || strncmp(p_main->p_playlist->current.psz_name, "vcd", 3))
+      {
+          /* Determine the device name by omitting the first 4 characters */
+          psz_device = strdup((p_main->p_playlist->current.psz_name + 4));
+      }
+  }
 
-    input_ChangeES( p_intf->p_input, p_es, 1 );
-}
+  if( psz_device == NULL )
+  {
+      return TRUE;
+  }
 
+  /* If there's a stream playing, we aren't allowed to eject ! */
+  if( p_input_bank->pp_input[0] == NULL )
+  {
+      intf_WarnMsg( 4, "intf: ejecting %s", psz_device );
 
-void
-on_popup_subpictures_activate          (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
-    es_descriptor_t *       p_es;
+      intf_Eject( psz_device );
+  }
 
-    p_es = (es_descriptor_t*)user_data;
-
-    input_ChangeES( p_intf->p_input, p_es, 2 );
+  free(psz_device);
+  return TRUE;
 }
 
-
-void
-on_menubar_audio_activate              (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
+void GtkEjectDiscActivate ( 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 );
+  GtkDiscEject( GTK_WIDGET( menuitem ), NULL, user_data );
 }
 
+/****************************************************************************
+ * Messages window
+ ****************************************************************************/
 
-void
-on_menubar_subpictures_activate        (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
+gboolean GtkMessagesShow( GtkWidget       *widget,
+                          GdkEventButton  *event,
+                          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, 2 );
-}
+    static GdkColor black = { 0, 0x0000, 0x0000, 0x0000 };
+    static GdkColormap *colormap;
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
 
+    gtk_widget_show( p_intf->p_sys->p_messages );
+    colormap = gdk_colormap_get_system ();
+    gdk_color_alloc( colormap, &black );
+    gdk_window_set_background( p_intf->p_sys->p_messages_text->text_area,
+                               &black );
 
-void
-on_popup_navigation_activate           (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-    intf_thread_t * p_intf    = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
-    input_area_t *  p_area;
-    gint            i_title;
-    gint            i_chapter;
+    gdk_window_raise( p_intf->p_sys->p_messages->window );
 
-    i_title   = (gint)(user_data) / 100 ;
-    i_chapter = (gint)(user_data) - ( 100 * i_title );
-fprintf(stderr, "title %d chapter %d\n", i_title, i_chapter );
-    p_area    = p_intf->p_input->stream.pp_areas[i_title];
-    p_area->i_part = i_chapter;
+    gtk_text_set_point( p_intf->p_sys->p_messages_text,
+                    gtk_text_get_length( p_intf->p_sys->p_messages_text ) );
 
-    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 );
+    return TRUE;
 }
 
 
 void
-on_menubar_title_activate              (GtkMenuItem     *menuitem,
+GtkMessagesOk                          (GtkButton       *button,
                                         gpointer         user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
-
-    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 );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
+    gtk_widget_hide( p_intf->p_sys->p_messages );
 }
 
 
-void
-on_menubar_chapter_activate            (GtkMenuItem     *menuitem,
+gboolean
+GtkMessagesDelete                      (GtkWidget       *widget,
+                                        GdkEvent        *event,
                                         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;
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
+    gtk_widget_hide( p_intf->p_sys->p_messages );
+    return TRUE;
+}
 
-    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 );
-}