]> git.sesse.net Git - vlc/blobdiff - plugins/gnome/intf_gnome.c
* Ported Glide and MGA plugins to the new module API. MGA never worked,
[vlc] / plugins / gnome / intf_gnome.c
index e4448a94adc16edc8663f3cbd47ea957f8cc3c55..f3de8c330e1d2d33b8e88f8c4876b5e5abb409d2 100644 (file)
@@ -2,9 +2,9 @@
  * intf_gnome.c: Gnome interface
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: intf_gnome.c,v 1.9 2001/02/12 00:20:37 sam Exp $
+ * $Id: intf_gnome.c,v 1.15 2001/02/20 07:49:13 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
@@ -21,6 +21,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME gnome
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 #include <string.h>                                            /* strerror() */
 #include <stdio.h>
 
-#include "glib.h"
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/keysym.h>
-
 #include <gnome.h>
 
 #include "config.h"
@@ -96,7 +93,7 @@ void g_atexit( GVoidFunc func )
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void intf_getfunctions( function_list_t * p_function_list )
+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;
@@ -117,7 +114,7 @@ static int intf_Probe( probedata_t *p_data )
         return( 999 );
     }
 
-    return( 40 );
+    return( 100 );
 }
 
 /*****************************************************************************
@@ -134,13 +131,12 @@ static int intf_Open( intf_thread_t *p_intf )
     }
 
     /* Initialize Gnome thread */
-    p_intf->p_sys->b_window = 1;
-    p_intf->p_sys->b_playlist = 0;
-
     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_scale_isfree = 1;
+
     p_intf->p_sys->pf_gtk_callback = NULL;
     p_intf->p_sys->pf_gdk_callback = NULL;
 
@@ -170,16 +166,29 @@ static void intf_Run( intf_thread_t *p_intf )
      * give it an empty one */
     char *p_args[] = { };
 
+    /* The data types we are allowed to receive */
+    static GtkTargetEntry target_table[] =
+    {
+        { "text/uri-list", 0, DROP_ACCEPT_TEXT_URI_LIST },
+        { "text/plain", 0, DROP_ACCEPT_TEXT_PLAIN }
+    };
+
     /* Initialize Gnome */
     gnome_init( p_main->psz_arg0, VERSION, 1, 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_window = create_intf_window( );
     p_intf->p_sys->p_popup = create_intf_popup( );
 
+    /* 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 );
+
     /* 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_sys to keep an eye on it */
@@ -197,6 +206,7 @@ static void intf_Run( intf_thread_t *p_intf )
     p_intf->p_sys->i_timeout = gtk_timeout_add( INTF_IDLE_SLEEP / 1000,
                                                 GnomeManage, p_intf );
  
+
     /* enter gnome mode */
     gtk_main();
 
@@ -224,7 +234,9 @@ static gint GnomeManage( gpointer p_data )
 {
     intf_thread_t *p_intf = (void *)p_data;
 
-    /* if the "display popup" flag has changed */
+    vlc_mutex_lock( &p_intf->p_sys->change_lock );
+
+    /* If the "display popup" flag has changed */
     if( p_intf->b_menu_change )
     {
         gnome_popup_menu_do_popup( p_intf->p_sys->p_popup,
@@ -232,16 +244,45 @@ static gint GnomeManage( gpointer p_data )
         p_intf->b_menu_change = 0;
     }
 
+    /* Manage the slider */
+    if( p_intf->p_input != NULL && p_intf->p_sys->p_window != NULL
+         && p_intf->p_sys->b_scale_isfree )
+    {
+        GtkWidget *p_scale;
+        GtkAdjustment *p_adj;
+   
+        p_scale = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
+                                  p_intf->p_sys->p_window ), "hscale" ) );
+        p_adj = gtk_range_get_adjustment ( GTK_RANGE( p_scale ) );
+
+        /* Update the value */
+        p_adj->value = ( 100. * p_intf->p_input->stream.pp_areas[0]->i_tell )
+                           / p_intf->p_input->stream.pp_areas[0]->i_size;
+
+        /* Gtv does it this way. Why not. */
+        gtk_range_set_adjustment ( GTK_RANGE( p_scale ), p_adj );
+        gtk_range_slider_update ( GTK_RANGE( p_scale ) );
+        gtk_range_clear_background ( GTK_RANGE( p_scale ) );
+        gtk_range_draw_background ( GTK_RANGE( p_scale ) );
+    }
+
     /* Manage core vlc functions through the callback */
     p_intf->pf_manage( p_intf );
 
     if( p_intf->b_die )
     {
-        /* prepare to die, young man */
+        /* Make sure we won't be called again */
+        gtk_timeout_remove( p_intf->p_sys->i_timeout );
+
+        vlc_mutex_unlock( &p_intf->p_sys->change_lock );
+
+        /* Prepare to die, young Skywalker */
         gtk_main_quit();
         return( FALSE );
     }
 
+    vlc_mutex_unlock( &p_intf->p_sys->change_lock );
+
     return( TRUE );
 }