]> git.sesse.net Git - vlc/blobdiff - plugins/gnome/intf_gnome.c
* Bug fixes and enhancements in the Gtk+/Gnome interfaces.
[vlc] / plugins / gnome / intf_gnome.c
index 3ce80c6ff957f97ab30387155234730495c16991..34ee18a17ad126b8f1918d2518ed2dc41203e356 100644 (file)
@@ -2,8 +2,9 @@
  * intf_gnome.c: Gnome interface
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
+ * $Id: intf_gnome.c,v 1.22 2001/03/15 01:42:19 sam Exp $
  *
- * Authors:
+ * Authors: Samuel Hocevar <sam@zoy.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
@@ -20,6 +21,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME gnome
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 #include <errno.h>                                                 /* ENOMEM */
 #include <stdlib.h>                                                /* free() */
 #include <string.h>                                            /* strerror() */
-#include <sys/types.h>                        /* on BSD, uio.h needs types.h */
-#include <sys/uio.h>                                          /* for input.h */
+#include <stdio.h>
 
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/keysym.h>
+#include <gnome.h>
 
 #include "config.h"
 #include "common.h"
 #include "threads.h"
 #include "mtime.h"
-#include "plugins.h"
+#include "tests.h"
+#include "modules.h"
 
 #include "stream_control.h"
 #include "input_ext-intf.h"
 
-#include "video.h"
-#include "video_output.h"
-
-#include "audio_output.h" /* needed for mute */
-
 #include "intf_msg.h"
 #include "interface.h"
 
-#include "main.h"
-
-#include <stdio.h>
+#include "gnome_callbacks.h"
+#include "gnome_interface.h"
+#include "gnome_support.h"
+#include "intf_gnome.h"
 
-#include <gnome.h>
+#include "main.h"
 
-#include "intf_gnome_thread.h"
-#include "intf_gnome.h"
-#include "intf_gnome_interface.h"
-#include "intf_gnome_support.h"
+/*****************************************************************************
+ * Local prototypes.
+ *****************************************************************************/
+static int  intf_Probe     ( probedata_t *p_data );
+static int  intf_Open      ( intf_thread_t *p_intf );
+static void intf_Close     ( intf_thread_t *p_intf );
+static void intf_Run       ( intf_thread_t *p_intf );
+
+static gint GnomeManage    ( gpointer p_data );
+static gint GnomeLanguageMenus( gpointer, GtkWidget *, es_descriptor_t *, gint,
+                              void (*pf_toggle)(GtkCheckMenuItem *, gpointer) );
+static gint GnomeChapterMenu  ( gpointer, GtkWidget *,
+                              void (*pf_toggle)(GtkCheckMenuItem *, gpointer) );
+static gint GnomeTitleMenu    ( gpointer, GtkWidget *, 
+                              void (*pf_toggle)(GtkCheckMenuItem *, gpointer) );
+static gint GnomeSetupMenu    ( intf_thread_t * p_intf );
+static void GnomeDisplayDate  ( GtkAdjustment *p_adj );
 
 /*****************************************************************************
- * intf_GnomeCreate: initialize and create window
+ * g_atexit: kludge to avoid the Gnome thread to segfault at exit
+ *****************************************************************************
+ * gtk_init() makes several calls to g_atexit() which calls atexit() to
+ * register tidying callbacks to be called at program exit. Since the Gnome
+ * plugin is likely to be unloaded at program exit, we have to export this
+ * symbol to intercept the g_atexit() calls. Talk about crude hack.
  *****************************************************************************/
-int intf_GnomeCreate( intf_thread_t *p_intf )
+void g_atexit( GVoidFunc func )
 {
-    char       *psz_display;
+    intf_thread_t *p_intf = p_main->p_intf;
 
-    /* Allocate instance and initialize some members */
-    p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
-    if( p_intf->p_sys == NULL )
+    if( p_intf->p_sys->pf_gdk_callback == NULL )
     {
-        intf_ErrMsg("error: %s\n", strerror(ENOMEM));
-        return( 1 );
+        p_intf->p_sys->pf_gdk_callback = func;
     }
-
-    p_intf->p_sys->p_gnome = malloc( sizeof( gnome_thread_t ) );
-    if( p_intf->p_sys->p_gnome == NULL )
+    else if( p_intf->p_sys->pf_gtk_callback == NULL )
     {
-        intf_ErrMsg("error: %s\n", strerror(ENOMEM));
-        free( p_intf->p_sys );
-        return( 1 );
+        p_intf->p_sys->pf_gtk_callback = func;
     }
+    /* else nothing, but we could do something here */
+    return;
+}
 
-    /* Open display, unsing 'vlc_display' or DISPLAY environment variable */
-    psz_display = XDisplayName( main_GetPszVariable( VOUT_DISPLAY_VAR, NULL ) );
-    p_intf->p_sys->p_display = XOpenDisplay( psz_display );
   if( !p_intf->p_sys->p_display )                                 /* error */
-    {
-        intf_ErrMsg("error: can't open display %s\n", psz_display );
-        free( p_intf->p_sys->p_gnome );
-        free( p_intf->p_sys );
-        return( 1 );
-    }
-    p_intf->p_sys->i_screen = DefaultScreen( p_intf->p_sys->p_display );
+/*****************************************************************************
+ * Functions exported as capabilities. They are declared as static so that
+ * we don't pollute the namespace too much.
*****************************************************************************/
+void _M( intf_getfunctions )( function_list_t * p_function_list )
+{
+    p_function_list->pf_probe = intf_Probe;
+    p_function_list->functions.intf.pf_open  = intf_Open;
+    p_function_list->functions.intf.pf_close = intf_Close;
+    p_function_list->functions.intf.pf_run   = intf_Run;
+}
 
-    /* Spawn base window - this window will include the video output window */
-    if( GnomeCreateWindow( p_intf ) )
+/*****************************************************************************
+ * intf_Probe: probe the interface and return a score
+ *****************************************************************************
+ * This function tries to initialize Gnome and returns a score to the
+ * plugin manager so that it can select the best plugin.
+ *****************************************************************************/
+static int intf_Probe( probedata_t *p_data )
+{
+    if( TestMethod( INTF_METHOD_VAR, "gnome" ) )
     {
-        intf_ErrMsg( "error: can't create output window\n" );
-        XCloseDisplay( p_intf->p_sys->p_display );
-        free( p_intf->p_sys->p_gnome );
-        free( p_intf->p_sys );
-        return( 1 );
+        return( 999 );
     }
 
-    /* Spawn video output thread */
-    if( p_main->b_video )
-    {
-        p_intf->p_vout = vout_CreateThread( psz_display, p_intf->p_sys->window,
-                                            p_intf->p_sys->i_width,
-                                            p_intf->p_sys->i_height, NULL, 0,
-                                            (void *)&p_intf->p_sys->colormap );
+    return( 100 );
+}
 
-        if( p_intf->p_vout == NULL )                                /* error */
-        {
-            intf_ErrMsg("error: can't create video output thread\n" );
-            GnomeDestroyWindow( p_intf );
-            XCloseDisplay( p_intf->p_sys->p_display );
-            free( p_intf->p_sys->p_gnome );
-            free( p_intf->p_sys );
-            return( 1 );
-        }
+/*****************************************************************************
+ * intf_Open: initialize and create window
+ *****************************************************************************/
+static int intf_Open( intf_thread_t *p_intf )
+{
+    /* Allocate instance and initialize some members */
+    p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
+    if( p_intf->p_sys == NULL )
+    {
+        intf_ErrMsg("error: %s", strerror(ENOMEM));
+        return( 1 );
     }
 
-    /* Spawn Gnome thread */
-    p_intf->p_sys->p_gnome->b_die = 0;
-    p_intf->p_sys->p_gnome->b_error = 0;
-    
-    p_intf->p_sys->p_gnome->b_popup_changed = 0;
-    p_intf->p_sys->p_gnome->b_window_changed = 0;
-    p_intf->p_sys->p_gnome->b_playlist_changed = 0;
+    /* Initialize Gnome thread */
+    p_intf->p_sys->b_popup_changed = 0;
+    p_intf->p_sys->b_window_changed = 0;
+    p_intf->p_sys->b_playlist_changed = 0;
+    p_intf->p_sys->b_menus_update = 1;
 
-    vlc_thread_create( &p_intf->p_sys->p_gnome->thread_id, "gnome",
-                       (void *)GnomeThread, p_intf->p_sys->p_gnome );
+    p_intf->p_sys->b_slider_free = 1;
 
-    /* create basic key bindings */
-    intf_AssignNormalKeys( p_intf );
-    
+    p_intf->p_sys->pf_gtk_callback = NULL;
+    p_intf->p_sys->pf_gdk_callback = NULL;
 
-    /* Disable screen saver and return */
-    p_intf->p_sys->i_ss_count = 1;
-    GnomeDisableScreenSaver( p_intf );
     return( 0 );
 }
 
 /*****************************************************************************
- * intf_GnomeDestroy: destroy interface window
+ * intf_Close: destroy interface window
  *****************************************************************************/
-void intf_GnomeDestroy( intf_thread_t *p_intf )
+static void intf_Close( intf_thread_t *p_intf )
 {
-    /* Enable screen saver */
-    GnomeEnableScreenSaver( p_intf );
+    /* Destroy structure */
+    free( p_intf->p_sys );
+}
+
+/*****************************************************************************
+ * intf_Run: Gnome thread
+ *****************************************************************************
+ * this part of the interface is in a separate thread so that we can call
+ * gtk_main() from within it without annoying the rest of the program.
+ * XXX: the approach may look kludgy, and probably is, but I could not find
+ * a better way to dynamically load a Gnome interface at runtime.
+ *****************************************************************************/
+static void intf_Run( intf_thread_t *p_intf )
+{
+    /* gnome_init needs to know the command line. We don't care, so we
+     * give it an empty one */
+    char *p_args[] = { "" };
+    int   i_args   = 1;
 
-    /* Close input thread, if any (blocking) */
-    if( p_intf->p_input )
+    /* The data types we are allowed to receive */
+    static GtkTargetEntry target_table[] =
     {
-        input_DestroyThread( p_intf->p_input, NULL );
-    }
+        { "text/uri-list", 0, DROP_ACCEPT_TEXT_URI_LIST },
+        { "text/plain",    0, DROP_ACCEPT_TEXT_PLAIN }
+    };
+
+    /* intf_Manage callback timeout */
+    int i_timeout;
+
+    /* Initialize Gnome */
+    gnome_init( p_main->psz_arg0, VERSION, i_args, p_args );
+
+    /* Create some useful widgets that will certainly be used */
+    p_intf->p_sys->p_window = create_intf_window( );
+    p_intf->p_sys->p_popup = create_intf_popup( );
+    p_intf->p_sys->p_disc = create_intf_disc( );
+    p_intf->p_sys->p_network = create_intf_network( );
+
+    /* Set the title of the main window */
+    gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_window),
+                          VOUT_TITLE " (Gnome interface)");
+
+    /* Accept file drops on the main window */
+    gtk_drag_dest_set( GTK_WIDGET( p_intf->p_sys->p_window ),
+                       GTK_DEST_DEFAULT_ALL, target_table,
+                       1, GDK_ACTION_COPY );
+
+    /* Get the interface labels */
+    #define P_LABEL( name ) GTK_LABEL( gtk_object_get_data( \
+                         GTK_OBJECT( p_intf->p_sys->p_window ), name ) )
+    p_intf->p_sys->p_label_date = P_LABEL( "label_date" );
+    p_intf->p_sys->p_label_status = P_LABEL( "label_status" );
+    #undef P_LABEL
+
+    /* Connect the date display to the slider */
+    #define P_SLIDER GTK_RANGE( gtk_object_get_data( \
+                         GTK_OBJECT( p_intf->p_sys->p_window ), "slider" ) )
+    p_intf->p_sys->p_adj = gtk_range_get_adjustment( P_SLIDER );
+
+    gtk_signal_connect ( GTK_OBJECT( p_intf->p_sys->p_adj ), "value_changed",
+                         GTK_SIGNAL_FUNC( GnomeDisplayDate ), NULL );
+    p_intf->p_sys->f_adj_oldvalue = 0;
+    #undef P_SLIDER
+
+    /* We don't create these ones yet because we perhaps won't need them */
+    p_intf->p_sys->p_about = NULL;
+    p_intf->p_sys->p_playlist = NULL;
+    p_intf->p_sys->p_modules = NULL;
+    p_intf->p_sys->p_fileopen = NULL;
+
+    /* Store p_intf to keep an eye on it */
+    gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_window),
+                         "p_intf", p_intf );
+
+    gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_popup),
+                         "p_intf", p_intf );
+
+    gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_disc),
+                         "p_intf", p_intf );
+
+    gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_network),
+                         "p_intf", p_intf );
 
-    /* Close video output thread, if any (blocking) */
-    if( p_intf->p_vout )
+    gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_adj),
+                         "p_intf", p_intf );
+
+    /* Show the control window */
+    gtk_widget_show( p_intf->p_sys->p_window );
+
+    /* Sleep to avoid using all CPU - since some interfaces needs to access
+     * keyboard events, a 100ms delay is a good compromise */
+    i_timeout = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, GnomeManage, p_intf );
+
+    /* Enter gnome mode */
+    gtk_main();
+
+    /* Remove the timeout */
+    gtk_timeout_remove( i_timeout );
+
+    /* Get rid of stored callbacks so we can unload the plugin */
+    if( p_intf->p_sys->pf_gtk_callback != NULL )
     {
-        vout_DestroyThread( p_intf->p_vout, NULL );
+        p_intf->p_sys->pf_gtk_callback( );
+        p_intf->p_sys->pf_gtk_callback = NULL;
+
     }
 
-    /* Close gnome thread, if any (blocking) */
-    if( p_intf->p_sys->p_gnome->thread_id )
+    if( p_intf->p_sys->pf_gdk_callback != NULL )
     {
-        p_intf->p_sys->p_gnome->b_die = 1;
-        intf_Msg( "waiting for Gnome thread to terminate\n" );
-        vlc_thread_join( p_intf->p_sys->p_gnome->thread_id );
-        intf_Msg( "Gnome thread terminated\n" );
+        p_intf->p_sys->pf_gdk_callback( );
+        p_intf->p_sys->pf_gdk_callback = NULL;
     }
-
-    /* Close main window and display */
-    GnomeDestroyWindow( p_intf );
-    XCloseDisplay( p_intf->p_sys->p_display );
-
-    /* Destroy structures */
-    free( p_intf->p_sys->p_gnome );
-    free( p_intf->p_sys );
 }
 
+/* following functions are local */
+
 /*****************************************************************************
- * intf_GnomeManage: event loop
+ * GnomeManage: manage main thread messages
+ *****************************************************************************
+ * In this function, called approx. 10 times a second, we check what the
+ * main program wanted to tell us.
  *****************************************************************************/
-void intf_GnomeManage( intf_thread_t *p_intf )
+static gint GnomeManage( gpointer p_data )
 {
-    /* Manage main window */
-    GnomeManageWindow( p_intf );
+#define p_intf ((intf_thread_t *)p_data)
 
-    /* Manage messages from the Gnome interface */
-    GnomeManageInterface( p_intf );
-}
+    vlc_mutex_lock( &p_intf->change_lock );
 
-/* following functions are local */
+    /* If the "display popup" flag has changed */
+    if( p_intf->b_menu_change )
+    {
+        gnome_popup_menu_do_popup( p_intf->p_sys->p_popup,
+                                   NULL, NULL, NULL, NULL );
+        p_intf->b_menu_change = 0;
+    }
 
-/*****************************************************************************
- * GnomeCreateWindow: open and set-up X11 main window
- *****************************************************************************/
-static int GnomeCreateWindow( intf_thread_t *p_intf )
-{
-    XSizeHints              xsize_hints;
-    XSetWindowAttributes    xwindow_attributes;
-    XGCValues               xgcvalues;
-    XEvent                  xevent;
-    boolean_t               b_expose;
-    boolean_t               b_configure_notify;
-    boolean_t               b_map_notify;
-
-    /* Set main window's size */
-    p_intf->p_sys->i_width =  main_GetIntVariable( VOUT_WIDTH_VAR,
-                                                   VOUT_WIDTH_DEFAULT );
-    p_intf->p_sys->i_height = main_GetIntVariable( VOUT_HEIGHT_VAR,
-                                                   VOUT_HEIGHT_DEFAULT );
-
-    /* Prepare window manager hints and properties */
-    xsize_hints.base_width =            p_intf->p_sys->i_width;
-    xsize_hints.base_height =           p_intf->p_sys->i_height;
-    xsize_hints.flags =                 PSize;
-    p_intf->p_sys->wm_protocols =       XInternAtom( p_intf->p_sys->p_display,
-                                                     "WM_PROTOCOLS", True );
-    p_intf->p_sys->wm_delete_window =   XInternAtom( p_intf->p_sys->p_display,
-                                                     "WM_DELETE_WINDOW", True );
-
-    /* Prepare window attributes */
-    xwindow_attributes.backing_store = Always;       /* save the hidden part */
-    xwindow_attributes.background_pixel = WhitePixel( p_intf->p_sys->p_display,
-                                                      p_intf->p_sys->i_screen );
-
-    xwindow_attributes.event_mask = ExposureMask | StructureNotifyMask;
-
-    /* Create the window and set hints - the window must receive ConfigureNotify
-     * events, and, until it is displayed, Expose and MapNotify events. */
-    p_intf->p_sys->window =
-            XCreateWindow( p_intf->p_sys->p_display,
-                           DefaultRootWindow( p_intf->p_sys->p_display ),
-                           0, 0,
-                           p_intf->p_sys->i_width, p_intf->p_sys->i_height, 1,
-                           0, InputOutput, 0,
-                           CWBackingStore | CWBackPixel | CWEventMask,
-                           &xwindow_attributes );
-
-    /* Set window manager hints and properties: size hints, command,
-     * window's name, and accepted protocols */
-    XSetWMNormalHints( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                       &xsize_hints );
-    XSetCommand( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                 p_main->ppsz_argv, p_main->i_argc );
-    XStoreName( p_intf->p_sys->p_display, p_intf->p_sys->window, VOUT_TITLE );
-    if( (p_intf->p_sys->wm_protocols == None)        /* use WM_DELETE_WINDOW */
-        || (p_intf->p_sys->wm_delete_window == None)
-        || !XSetWMProtocols( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                             &p_intf->p_sys->wm_delete_window, 1 ) )
+    /* Update language/chapter menus after user request */
+    if( p_intf->p_input != NULL && p_intf->p_sys->p_window != NULL &&
+        p_intf->p_sys->b_menus_update )
     {
-        /* WM_DELETE_WINDOW is not supported by window manager */
-        intf_Msg("error: missing or bad window manager - please exit program kindly.\n");
+        GnomeSetupMenu( p_intf );
     }
 
-    /* Creation of a graphic context that doesn't generate a GraphicsExpose
-     * event when using functions like XCopyArea */
-    xgcvalues.graphics_exposures = False;
-    p_intf->p_sys->gc =  XCreateGC( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                                    GCGraphicsExposures, &xgcvalues);
-
-    /* Send orders to server, and wait until window is displayed - three
-     * events must be received: a MapNotify event, an Expose event allowing
-     * drawing in the window, and a ConfigureNotify to get the window
-     * dimensions. Once those events have been received, only ConfigureNotify
-     * events need to be received. */
-    b_expose = 0;
-    b_configure_notify = 0;
-    b_map_notify = 0;
-    XMapWindow( p_intf->p_sys->p_display, p_intf->p_sys->window);
-    do
+    /* Manage the slider */
+    if( p_intf->p_input != NULL )
     {
-        XNextEvent( p_intf->p_sys->p_display, &xevent);
-        if( (xevent.type == Expose)
-            && (xevent.xexpose.window == p_intf->p_sys->window) )
-        {
-            b_expose = 1;
-        }
-        else if( (xevent.type == MapNotify)
-                 && (xevent.xmap.window == p_intf->p_sys->window) )
+        float newvalue = p_intf->p_sys->p_adj->value;
+
+#define p_area p_intf->p_input->stream.p_selected_area
+        /* If the user hasn't touched the slider since the last time,
+         * then the input can safely change it */
+        if( newvalue == p_intf->p_sys->f_adj_oldvalue )
         {
-            b_map_notify = 1;
+            /* Update the value */
+            p_intf->p_sys->p_adj->value = p_intf->p_sys->f_adj_oldvalue =
+                ( 100. * p_area->i_tell ) / p_area->i_size;
+
+            gtk_signal_emit_by_name( GTK_OBJECT( p_intf->p_sys->p_adj ),
+                                     "value_changed" );
         }
-        else if( (xevent.type == ConfigureNotify)
-                 && (xevent.xconfigure.window == p_intf->p_sys->window) )
+        /* Otherwise, send message to the input if the user has
+         * finished dragging the slider */
+        else if( p_intf->p_sys->b_slider_free )
         {
-            b_configure_notify = 1;
-            p_intf->p_sys->i_width = xevent.xconfigure.width;
-            p_intf->p_sys->i_height = xevent.xconfigure.height;
+            off_t i_seek = ( newvalue * p_area->i_size ) / 100;
+
+            input_Seek( p_intf->p_input, i_seek );
+
+            /* Update the old value */
+            p_intf->p_sys->f_adj_oldvalue = newvalue;
         }
-    } while( !( b_expose && b_configure_notify && b_map_notify ) );
+#undef p_area
+    }
 
-    XSelectInput( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                  StructureNotifyMask | KeyPressMask | ButtonPressMask );
+    /* Manage core vlc functions through the callback */
+    p_intf->pf_manage( p_intf );
 
-    if( XDefaultDepth(p_intf->p_sys->p_display, p_intf->p_sys->i_screen) == 8 )
+    if( p_intf->b_die )
     {
-        /* Allocate a new palette */
-        p_intf->p_sys->colormap = XCreateColormap( p_intf->p_sys->p_display,
-                              DefaultRootWindow( p_intf->p_sys->p_display ),
-                              DefaultVisual( p_intf->p_sys->p_display,
-                                             p_intf->p_sys->i_screen ),
-                              AllocAll );
-
-        xwindow_attributes.colormap = p_intf->p_sys->colormap;
-        XChangeWindowAttributes( p_intf->p_sys->p_display,
-                                 p_intf->p_sys->window,
-                                 CWColormap, &xwindow_attributes );
+        vlc_mutex_unlock( &p_intf->change_lock );
+
+        /* Prepare to die, young Skywalker */
+        gtk_main_quit();
+
+        /* Just in case */
+        return( FALSE );
     }
 
-    /* At this stage, the window is open, displayed, and ready to receive data */
-    return( 0 );
-}
+    vlc_mutex_unlock( &p_intf->change_lock );
 
-/*****************************************************************************
- * GnomeDestroyWindow: destroy X11 main window
- *****************************************************************************/
-static void GnomeDestroyWindow( intf_thread_t *p_intf )
-{
-    XUnmapWindow( p_intf->p_sys->p_display, p_intf->p_sys->window );
-    XFreeGC( p_intf->p_sys->p_display, p_intf->p_sys->gc );
-    XDestroyWindow( p_intf->p_sys->p_display, p_intf->p_sys->window );
+    return( TRUE );
+
+#undef p_intf
 }
 
 /*****************************************************************************
- * GnomeManageWindow: manage X11 main window
+ * GnomeLanguageMenus: update interactive menus of the interface
+ *****************************************************************************
+ * Sets up menus with information from input:
+ *  -languages
+ *  -sub-pictures
+ * Warning: since this function is designed to be called by management
+ * function, the interface lock has to be taken
  *****************************************************************************/
-static void GnomeManageWindow( intf_thread_t *p_intf )
+static gint GnomeLanguageMenus( gpointer          p_data,
+                                GtkWidget *       p_root,
+                                es_descriptor_t * p_es,
+                                gint              i_type,
+                          void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) )
 {
-    XEvent      xevent;                                         /* X11 event */
-    boolean_t   b_resized;                        /* window has been resized */
-    char        i_key;                                    /* ISO Latin-1 key */
-
-    /* Handle X11 events: ConfigureNotify events are parsed to know if the
-     * output window's size changed, MapNotify and UnmapNotify to know if the
-     * window is mapped (and if the display is useful), and ClientMessages
-     * to intercept window destruction requests */
-    b_resized = 0;
-    while( XCheckWindowEvent( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                              StructureNotifyMask | KeyPressMask |
-                              ButtonPressMask, &xevent ) == True )
-    {
-        /* ConfigureNotify event: prepare  */
-        if( (xevent.type == ConfigureNotify)
-            && ((xevent.xconfigure.width != p_intf->p_sys->i_width)
-                || (xevent.xconfigure.height != p_intf->p_sys->i_height)) )
-        {
-            /* Update dimensions */
-            b_resized = 1;
-            p_intf->p_sys->i_width = xevent.xconfigure.width;
-            p_intf->p_sys->i_height = xevent.xconfigure.height;
-        }
-        /* MapNotify event: change window status and disable screen saver */
-        else if( xevent.type == MapNotify)
-        {
-            if( (p_intf->p_vout != NULL) && !p_intf->p_vout->b_active )
-            {
-                GnomeDisableScreenSaver( p_intf );
-                p_intf->p_vout->b_active = 1;
-            }
-        }
-        /* UnmapNotify event: change window status and enable screen saver */
-        else if( xevent.type == UnmapNotify )
-        {
-            if( (p_intf->p_vout != NULL) && p_intf->p_vout->b_active )
-            {
-                GnomeEnableScreenSaver( p_intf );
-                p_intf->p_vout->b_active = 0;
-            }
-        }
-        /* Keyboard event */
-        else if( xevent.type == KeyPress )
-        {
-            if( XLookupString( &xevent.xkey, &i_key, 1, NULL, NULL ) )
-            {
-                if( intf_ProcessKey( p_intf, i_key ) )
-                {
-                    intf_DbgMsg( "unhandled key '%c' (%i)\n", (char) i_key, i_key );
-                }
-            }
-        }
-        /* Mouse click */
-        else if( xevent.type == ButtonPress )
-        {
-            switch( ((XButtonEvent *)&xevent)->button )
-            {
-                case Button1:
-                    /* in this part we will eventually manage
-                     * clicks for DVD navigation for instance */
-                    break;
-
-                case Button2:
-                    GnomeTogglePointer( p_intf );
-                    break;
-
-                case Button3:
-                    /* toggle the menu display */
-                    vlc_mutex_lock( &p_intf->p_sys->p_gnome->change_lock );
-                    p_intf->p_sys->p_gnome->b_popup_changed = 1;
-                    vlc_mutex_unlock( &p_intf->p_sys->p_gnome->change_lock );
-                    break;
-            }
+    intf_thread_t *     p_intf;
+    GtkWidget *         p_menu;
+    GtkWidget *         p_separator;
+    GtkWidget *         p_item;
+    GtkWidget *         p_item_off;
+    GSList *            p_group;
+    char *              psz_name;
+    gint                b_active;
+    gint                b_audio;
+    gint                b_spu;
+    gint                i;
 
-        }
-#ifdef DEBUG
-        /* Other event */
-        else
-        {
-            intf_DbgMsg( "%p -> unhandled event type %d received\n",
-                         p_intf, xevent.type );
-        }
-#endif
-    }
+    
 
-    /* ClientMessage event - only WM_PROTOCOLS with WM_DELETE_WINDOW data
-     * are handled - according to the man pages, the format is always 32
-     * in this case */
-    while( XCheckTypedEvent( p_intf->p_sys->p_display,
-                             ClientMessage, &xevent ) )
-    {
-        if( (xevent.xclient.message_type == p_intf->p_sys->wm_protocols)
-            && (xevent.xclient.data.l[0] == p_intf->p_sys->wm_delete_window ) )
-        {
-            p_intf->b_die = 1;
-        }
-        else
-        {
-            intf_DbgMsg( "%p -> unhandled ClientMessage received\n", p_intf );
-        }
-    }
+    /* cast */
+    p_intf = (intf_thread_t *)p_data;
+
+    vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
+
+    /* removes previous menu */
+    gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_root ) );
+
+    b_audio = ( i_type == 1 );
+    p_group = NULL;
+
+    /* menu container */
+    p_menu = gtk_menu_new();
 
-    /*
-     * Handle vout or interface windows resizing
-     */
-    if( p_intf->p_vout != NULL )
+    /* special case for "off" item */
+    b_active = ( p_es == NULL ) ? TRUE : FALSE;
+    psz_name = "Off";
+
+    p_item_off = gtk_radio_menu_item_new_with_label( p_group, psz_name );
+    p_group = gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item_off ) );
+    gtk_widget_show( p_item_off );
+    gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_off ),
+                                    b_active );
+    gtk_menu_append( GTK_MENU( p_menu ), p_item_off );
+
+    p_separator = gtk_menu_item_new();
+    gtk_widget_show( p_separator );
+    gtk_menu_append( GTK_MENU( p_menu ), p_separator );
+    gtk_widget_set_sensitive( p_separator, FALSE );
+
+    /* create a set of language buttons and append them to the container */
+    for( i = 0 ; i < p_intf->p_input->stream.i_es_number ; i++ )
     {
-        if( b_resized )
-        {
-            /* If interface window has been resized, change vout size */
-            intf_DbgMsg( "resizing output window\n" );
-            vlc_mutex_lock( &p_intf->p_vout->change_lock );
-            p_intf->p_vout->i_width =  p_intf->p_sys->i_width;
-            p_intf->p_vout->i_height = p_intf->p_sys->i_height;
-            p_intf->p_vout->i_changes |= VOUT_SIZE_CHANGE;
-            vlc_mutex_unlock( &p_intf->p_vout->change_lock );
-        }
-        else if( (p_intf->p_vout->i_width  != p_intf->p_sys->i_width) ||
-                 (p_intf->p_vout->i_height != p_intf->p_sys->i_height) )
+
+        b_audio = ( i_type == 1 ) && p_intf->p_input->stream.pp_es[i]->b_audio;
+        b_spu   = ( i_type == 2 ) && p_intf->p_input->stream.pp_es[i]->b_spu;
+
+        if( b_audio || b_spu )
         {
-           /* If video output size has changed, change interface window size */
-            intf_DbgMsg( "resizing output window\n" );
-            p_intf->p_sys->i_width =    p_intf->p_vout->i_width;
-            p_intf->p_sys->i_height =   p_intf->p_vout->i_height;
-            XResizeWindow( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                           p_intf->p_sys->i_width, p_intf->p_sys->i_height );
+            b_active = ( p_es == p_intf->p_input->stream.pp_es[i] ) ? TRUE :
+                                                                      FALSE;
+            psz_name = p_intf->p_input->stream.pp_es[i]->psz_desc;
+
+            p_item = gtk_radio_menu_item_new_with_label( p_group, psz_name );
+            p_group =
+                gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
+            gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item ),
+                                            b_active );
+            gtk_menu_append( GTK_MENU( p_menu ), p_item );
+            gtk_widget_show( p_item );
+
+            /* setup signal hanling */
+            gtk_signal_connect( GTK_OBJECT( p_item ), "toggled",
+                            GTK_SIGNAL_FUNC( pf_toggle ),
+                            (gpointer)( p_intf->p_input->stream.pp_es[i] ) );
+
         }
     }
+
+    /* signal hanling for off - dunno why this does not work
+     * if it is before the loop */
+    gtk_signal_connect( GTK_OBJECT( p_item_off ), "toggled",
+                        GTK_SIGNAL_FUNC ( pf_toggle ), NULL );
+
+    /* link the new menu to the menubar item */
+    gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );
+
+    /* be sure that menu is sensitive */
+    gtk_widget_set_sensitive( p_root, TRUE );
+
+    vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
+
+    return TRUE;
 }
 
 /*****************************************************************************
- * GnomeEnableScreenSaver: enable screen saver
- *****************************************************************************
- * This function enable the screen saver on a display after it had been
- * disabled by XDisableScreenSaver. Both functions use a counter mechanism to
- * know wether the screen saver can be activated or not: if n successive calls
- * are made to XDisableScreenSaver, n successive calls to XEnableScreenSaver
- * will be required before the screen saver could effectively be activated.
+ * GnomeChapterMenu: generate chapter menu for current title
  *****************************************************************************/
-void GnomeEnableScreenSaver( intf_thread_t *p_intf )
+static gint GnomeChapterMenu( gpointer p_data, GtkWidget * p_chapter,
+                        void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) )
 {
-    if( p_intf->p_sys->i_ss_count++ == 0 )
+    intf_thread_t *     p_intf;
+    char                psz_name[10];
+    GtkWidget *         p_chapter_menu;
+    GtkWidget *         p_item;
+    GSList *            p_chapter_group;
+    gint                i_title;
+    gint                i_chapter;
+    gint                b_active;
+
+    /* cast */
+    p_intf = (intf_thread_t*)p_data;
+
+    /* removes previous menu */
+    gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_chapter ) );
+
+    p_chapter_group = NULL;
+
+    i_title = p_intf->p_input->stream.p_selected_area->i_id;
+    p_chapter_menu = gtk_menu_new();
+
+    for( i_chapter = 0;
+         i_chapter < p_intf->p_input->stream.pp_areas[i_title]->i_part_nb ;
+         i_chapter++ )
     {
-        intf_Msg( "Enabling screen saver\n" );
-        XSetScreenSaver( p_intf->p_sys->p_display, p_intf->p_sys->i_ss_timeout,
-                         p_intf->p_sys->i_ss_interval, p_intf->p_sys->i_ss_blanking,
-                         p_intf->p_sys->i_ss_exposure );
+        b_active = ( p_intf->p_input->stream.pp_areas[i_title]->i_part
+                     == i_chapter + 1 ) ? 1 : 0;
+        
+        sprintf( psz_name, "Chapter %d", i_chapter + 1 );
+
+        p_item = gtk_radio_menu_item_new_with_label( p_chapter_group,
+                                                     psz_name );
+        p_chapter_group =
+            gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
+        gtk_menu_append( GTK_MENU( p_chapter_menu ), p_item );
+        gtk_widget_show( p_item );
+        gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item ),
+                                        b_active );
+
+        /* setup signal hanling */
+        gtk_signal_connect( GTK_OBJECT( p_item ),
+                        "toggled",
+                        GTK_SIGNAL_FUNC( pf_toggle ),
+                        (gpointer)(i_chapter + 1) );
     }
+
+    /* link the new menu to the title menu item */
+    gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_chapter ),
+                               p_chapter_menu );
+
+    /* be sure that chapter menu is sensitive */
+    gtk_widget_set_sensitive( p_chapter, TRUE );
+
+    return TRUE;
 }
 
 /*****************************************************************************
- * GnomeDisableScreenSaver: disable screen saver
+ * GnomeTitleMenu: sets menus for titles and chapters selection
  *****************************************************************************
- * See XEnableScreenSaver
+ * Generates two types of menus:
+ *  -simple list of titles
+ *  -cascaded lists of chapters for each title
  *****************************************************************************/
-void GnomeDisableScreenSaver( intf_thread_t *p_intf )
+static gint GnomeTitleMenu( gpointer       p_data,
+                            GtkWidget *    p_navigation, 
+                            void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) )
 {
-    if( --p_intf->p_sys->i_ss_count == 0 )
+    intf_thread_t *     p_intf;
+    char                psz_name[10];
+    GtkWidget *         p_title_menu;
+    GtkWidget *         p_title_item;
+    GtkWidget *         p_chapter_menu;
+    GtkWidget *         p_item;
+    GSList *            p_title_group;
+    GSList *            p_chapter_group;
+    gint                i_title;
+    gint                i_chapter;
+    gint                b_active;
+
+    /* cast */
+    p_intf = (intf_thread_t*)p_data;
+
+    p_title_menu = gtk_menu_new();
+    p_title_group = NULL;
+    p_chapter_group = NULL;
+
+    /* loop on titles */
+    for( i_title = 1 ;
+         i_title < p_intf->p_input->stream.i_area_nb ;
+         i_title++ )
     {
-        /* Save screen saver informations */
-        XGetScreenSaver( p_intf->p_sys->p_display, &p_intf->p_sys->i_ss_timeout,
-                         &p_intf->p_sys->i_ss_interval, &p_intf->p_sys->i_ss_blanking,
-                         &p_intf->p_sys->i_ss_exposure );
-
-        /* Disable screen saver */
-        intf_Msg("Disabling screen saver\n");
-        XSetScreenSaver( p_intf->p_sys->p_display, 0,
-                         p_intf->p_sys->i_ss_interval, p_intf->p_sys->i_ss_blanking,
-                         p_intf->p_sys->i_ss_exposure );
-    }
-}
+        b_active = ( p_intf->p_input->stream.pp_areas[i_title] ==
+                     p_intf->p_input->stream.p_selected_area ) ? 1 : 0;
+        sprintf( psz_name, "Title %d", i_title );
 
-/*****************************************************************************
- * GnomeTogglePointer: hide or show the mouse pointer
- *****************************************************************************
- * This function hides the X pointer if it is visible by putting it at
- * coordinates (32,32) and setting the pointer sprite to a blank one. To
- * show it again, we disable the sprite and restore the original coordinates.
- *****************************************************************************/
-void GnomeTogglePointer( intf_thread_t *p_intf )
-{
-    static Cursor cursor;
-    static boolean_t b_cursor = 0;
+        p_title_item = gtk_radio_menu_item_new_with_label( p_title_group,
+                                                           psz_name );
+        p_title_group =
+            gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_title_item ) );
+        gtk_menu_append( GTK_MENU( p_title_menu ), p_title_item );
+        gtk_widget_show( p_title_item );
 
-    if( p_intf->p_sys->b_mouse )
-    {
-        p_intf->p_sys->b_mouse = 0;
+                                           
 
-        if( !b_cursor )
+        if( pf_toggle == on_menubar_title_toggle )
         {
-            XColor color;
-            Pixmap blank = XCreatePixmap( p_intf->p_sys->p_display,
-                               DefaultRootWindow(p_intf->p_sys->p_display),
-                               1, 1, 1 );
-
-            XParseColor( p_intf->p_sys->p_display,
-                         XCreateColormap( p_intf->p_sys->p_display,
-                                          DefaultRootWindow(
-                                                  p_intf->p_sys->p_display ),
-                                          DefaultVisual(
-                                                  p_intf->p_sys->p_display,
-                                                  p_intf->p_sys->i_screen ),
-                                          AllocNone ),
-                         "black", &color );
-
-            cursor = XCreatePixmapCursor( p_intf->p_sys->p_display,
-                           blank, blank, &color, &color, 1, 1 );
-
-            b_cursor = 1;
+
+            gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_title_item ),
+                                        b_active );
+            /* setup signal hanling */
+            gtk_signal_connect( GTK_OBJECT( p_title_item ),
+                     "toggled",
+                     GTK_SIGNAL_FUNC( pf_toggle ),
+                     (gpointer)(p_intf->p_input->stream.pp_areas[i_title]) );
+        }
+        else
+        {
+            p_chapter_menu = gtk_menu_new();
+    
+            for( i_chapter = 0;
+                 i_chapter <
+                        p_intf->p_input->stream.pp_areas[i_title]->i_part_nb ;
+                 i_chapter++ )
+            {
+                b_active = ( p_intf->p_input->stream.pp_areas[i_title]->i_part
+                             == i_chapter + 1 ) ? 1 : 0;
+                
+                sprintf( psz_name, "Chapter %d", i_chapter + 1 );
+    
+                p_item = gtk_radio_menu_item_new_with_label(
+                                                p_chapter_group, psz_name );
+                p_chapter_group = gtk_radio_menu_item_group(
+                                                GTK_RADIO_MENU_ITEM( p_item ) );
+                gtk_menu_append( GTK_MENU( p_chapter_menu ), p_item );
+                gtk_widget_show( p_item );
+                gtk_check_menu_item_set_active(
+                                    GTK_CHECK_MENU_ITEM( p_item ), b_active );
+
+                /* setup signal hanling */
+                gtk_signal_connect( GTK_OBJECT( p_item ),
+                           "toggled",
+                           GTK_SIGNAL_FUNC( pf_toggle ),
+                           (gpointer)( ( i_title * 100 ) + ( i_chapter + 1) ) );
         }
-        XDefineCursor( p_intf->p_sys->p_display,
-                       p_intf->p_sys->window, cursor );
-    }
-    else
-    {
-        p_intf->p_sys->b_mouse = 1;
 
-        XUndefineCursor( p_intf->p_sys->p_display, p_intf->p_sys->window );
+        /* link the new menu to the title menu item */
+        gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_item ),
+                                   p_chapter_menu );
+        }
+
+        /* be sure that chapter menu is sensitive */
+        gtk_widget_set_sensitive( p_title_menu, TRUE );
+
     }
+
+    /* link the new menu to the menubar item */
+    gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_navigation ), p_title_menu );
+
+    /* be sure that menu is sensitive */
+    gtk_widget_set_sensitive( p_navigation, TRUE );
+
+
+    return TRUE;
 }
 
 /*****************************************************************************
- * GnomeManageInterface: manage messages from the Gnome interface
-
- *****************************************************************************
- * In this function, called approx. 10 times a second, we check what the
- * Gnome interface wanted to tell us.
+ * GnomeSetupMenu: function that generates title/chapter/audio/subpic
+ * menus with help from preceding functions
  *****************************************************************************/
-static void GnomeManageInterface( intf_thread_t *p_intf )
+static gint GnomeSetupMenu( intf_thread_t * p_intf )
 {
-    gnome_thread_t *p_gnome = p_intf->p_sys->p_gnome;
+    es_descriptor_t *   p_audio_es;
+    es_descriptor_t *   p_spu_es;
+    GtkWidget *         p_menubar_menu;
+    GtkWidget *         p_popup_menu;
+    gint                i;
 
-    /* lock the change structure */
-    vlc_mutex_lock( &p_gnome->change_lock );
+    p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( 
+                 p_intf->p_sys->p_window ), "menubar_title" ) );
 
-    /* you killed my father, prepare to die */
-    if( p_gnome->b_die )
-    {
-        p_intf->b_die = 1;
-    }
+    GnomeTitleMenu( p_intf, p_menubar_menu, on_menubar_title_toggle );
 
-    if( p_gnome->b_activity_changed )
-    {
-        vlc_mutex_lock( &p_intf->p_vout->picture_lock );
-        p_intf->p_vout->b_active = p_gnome->b_activity;
-        /* having to access p_main sucks */
-        p_main->p_aout->b_active = p_gnome->b_activity;
-        vlc_mutex_unlock( &p_intf->p_vout->picture_lock );
+    p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( 
+                 p_intf->p_sys->p_window ), "menubar_chapter" ) );
 
-        p_gnome->b_activity_changed = 0;
-    }
+    GnomeChapterMenu( p_intf, p_menubar_menu, on_menubar_chapter_toggle );
 
-    /* unlock the change structure */
-    vlc_mutex_unlock( &p_gnome->change_lock );
-}
+    p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( 
+                 p_intf->p_sys->p_popup ), "popup_navigation" ) );
 
-/*****************************************************************************
- * GnomeManageMain: manage main thread messages
- *****************************************************************************
- * In this function, called approx. 10 times a second, we check what the
- * main program wanted to tell us.
- *****************************************************************************/
-static gint GnomeManageMain( gpointer p_data )
-{
-    gnome_thread_t *p_gnome = (void *)p_data;
+    GnomeTitleMenu( p_intf, p_popup_menu, on_popup_navigation_toggle );
 
-    /* lock the change structure */
-    vlc_mutex_lock( &p_gnome->change_lock );
+    /* look for selected ES */
+    p_audio_es = NULL;
+    p_spu_es = NULL;
 
-    if( p_gnome->b_die )
+    for( i = 0 ; i < p_intf->p_input->stream.i_selected_es_number ; i++ )
     {
-        /* unlock the change structure */
-        vlc_mutex_unlock( &p_gnome->change_lock );
+        if( p_intf->p_input->stream.pp_es[i]->b_audio )
+        {
+            p_audio_es = p_intf->p_input->stream.pp_es[i];
+        }
 
-        /* prepare to die, young man */
-        gtk_main_quit();
-        return( FALSE );
+        if( p_intf->p_input->stream.pp_es[i]->b_spu )
+        {
+            p_spu_es = p_intf->p_input->stream.pp_es[i];
+        }
     }
 
-    /* if the "display popup" flag has changed */
-    if( p_gnome->b_popup_changed )
-    {
-        gnome_popup_menu_do_popup( p_gnome->p_popup,
-                                   NULL, NULL, NULL, NULL );
-        p_gnome->b_popup_changed = 0;
-    }
+    /* audio menus */
 
-    /* unlock the change structure */
-    vlc_mutex_unlock( &p_gnome->change_lock );
+    /* find audio root menu */
+    p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
+                         p_intf->p_sys->p_window ), "menubar_audio" ) );
 
-    return( TRUE );
+    p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( 
+                 p_intf->p_sys->p_popup ), "popup_audio" ) );
+
+    GnomeLanguageMenus( p_intf, p_menubar_menu, p_audio_es, 1,
+                      on_menubar_audio_toggle );
+    GnomeLanguageMenus( p_intf, p_popup_menu, p_audio_es, 1,
+                      on_popup_audio_toggle );
+
+    /* sub picture menus */
+
+    /* find spu root menu */
+    p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
+                      p_intf->p_sys->p_window ), "menubar_subtitle" ) );
+
+    p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( 
+                 p_intf->p_sys->p_popup ), "popup_subtitle" ) );
+
+    GnomeLanguageMenus( p_intf, p_menubar_menu, p_spu_es, 2,
+                      on_menubar_subtitle_toggle  );
+    GnomeLanguageMenus( p_intf, p_popup_menu, p_spu_es, 2,
+                      on_popup_subtitle_toggle );
+
+    /* everything is ready */
+    p_intf->p_sys->b_menus_update = 0;
+
+    return TRUE;
 }
 
 /*****************************************************************************
- * GnomeThread: special Gnome thread
+ * GnomeDisplayDate: display stream date
  *****************************************************************************
- * this part of the interface is in a separate thread so that we can call
- * gtk_main() from within it without annoying the rest of the program.
- * XXX: the approach may look kludgy, and probably is, but I could not find
- * a better way to dynamically load a Gnome interface at runtime.
+ * This function displays the current date related to the position in
+ * the stream. It is called whenever the slider changes its value.
  *****************************************************************************/
-void GnomeThread( gnome_thread_t *p_gnome )
+void GnomeDisplayDate( GtkAdjustment *p_adj )
 {
-    /* gnome_init needs to know the command line. We don't care, so we
-     * give it an empty one */
-    char *p_args[] = { };
+    intf_thread_t *p_intf;
+   
+    p_intf = gtk_object_get_data( GTK_OBJECT( p_adj ), "p_intf" );
 
-    /* Sleep to avoid using all CPU - since some interfaces needs to access
-     * keyboard events, a 100ms delay is a good compromise */
-    gtk_timeout_add( INTF_IDLE_SLEEP / 1000, GnomeManageMain, p_gnome );
-    gnome_init( "vlc", VERSION, 1, p_args );
-
-    /* create some useful widgets that will certainly be used */
-    p_gnome->p_window = create_intf_window();
-    p_gnome->p_popup = create_intf_popup( );
-
-    /* we don't create these ones yet because we perhaps won't need them */
-    p_gnome->p_about = NULL;
-    p_gnome->p_playlist = NULL;
+    if( p_intf->p_input != NULL )
+    {
+#define p_area p_intf->p_input->stream.p_selected_area
+        char psz_time[ OFFSETTOTIME_MAX_SIZE ];
 
-    /* store p_sys to keep an eye on it */
-    gtk_object_set_data( GTK_OBJECT(p_gnome->p_window), "p_gnome", p_gnome );
-    gtk_object_set_data( GTK_OBJECT(p_gnome->p_popup), "p_gnome", p_gnome );
+        vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
 
-    /* show the control window */
-    //gtk_widget_show( p_gnome->p_window );
+        gtk_label_set_text( p_intf->p_sys->p_label_date,
+                            input_OffsetToTime( p_intf->p_input, psz_time,
+                                   ( p_area->i_size * p_adj->value ) / 100 ) );
 
-    /* enter gnome mode */
-    gtk_main();
+        vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
+#undef p_area
+     }
 }
 
+