]> git.sesse.net Git - vlc/blobdiff - modules/misc/gtk_main.c
Added support for oldstyle id3 genres.
[vlc] / modules / misc / gtk_main.c
index 3c684a1a70ce63b6cb8fd94279579d4f1d098f1c..302f63c50ae69235f7eabd136cd8e9db04c258ec 100644 (file)
@@ -2,7 +2,7 @@
  * gtk_main.c : Gtk+ wrapper for gtk_main
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: gtk_main.c,v 1.6 2002/09/30 11:05:39 sam Exp $
+ * $Id: gtk_main.c,v 1.11 2003/01/15 13:16:39 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -10,7 +10,7 @@
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -42,22 +42,11 @@ static void Close   ( vlc_object_t * );
 
 static void GtkMain ( vlc_object_t * );
 
-/*****************************************************************************
- * The gtk_main_t object.
- *****************************************************************************/
-#define MAX_ATEXIT 10
-
-typedef struct gtk_main_t
-{
-    VLC_COMMON_MEMBERS
-
-} gtk_main_t;
-
 /*****************************************************************************
  * Local variables (mutex-protected).
  *****************************************************************************/
-static int           i_refcount = 0;
-static gtk_main_t *  p_gtk_main = NULL;
+static int            i_refcount = 0;
+static vlc_object_t * p_gtk_main = NULL;
 
 /*****************************************************************************
  * Module descriptor
@@ -80,17 +69,23 @@ vlc_module_end();
  *****************************************************************************/
 static int Open( vlc_object_t *p_this )
 {
-    vlc_mutex_lock( p_this->p_vlc->p_global_lock );
+    vlc_value_t lockval;
+
+    /* FIXME: put this in the module (de)initialization ASAP */
+    var_Create( p_this->p_libvlc, "gtk", VLC_VAR_MUTEX );
+
+    var_Get( p_this->p_libvlc, "gtk", &lockval );
+    vlc_mutex_lock( lockval.p_address );
 
     if( i_refcount > 0 )
     {
         i_refcount++;
-        vlc_mutex_unlock( p_this->p_vlc->p_global_lock );
+        vlc_mutex_unlock( lockval.p_address );
 
         return VLC_SUCCESS;
     }
 
-    p_gtk_main = vlc_object_create( p_this, sizeof(gtk_main_t) );
+    p_gtk_main = vlc_object_create( p_this, VLC_OBJECT_GENERIC );
 
     /* Only initialize gthreads if it's the first time we do it */
     if( !g_thread_supported() )
@@ -105,12 +100,13 @@ static int Open( vlc_object_t *p_this )
     {
         vlc_object_destroy( p_gtk_main );
         i_refcount--;
-        vlc_mutex_unlock( p_this->p_vlc->p_global_lock );
+        vlc_mutex_unlock( lockval.p_address );
+        var_Destroy( p_this->p_libvlc, "gtk" );
         return VLC_ETHREAD;
     }
 
     i_refcount++;
-    vlc_mutex_unlock( p_this->p_vlc->p_global_lock );
+    vlc_mutex_unlock( lockval.p_address );
 
     return VLC_SUCCESS;
 }
@@ -120,13 +116,17 @@ static int Open( vlc_object_t *p_this )
  *****************************************************************************/
 static void Close( vlc_object_t *p_this )
 {
-    vlc_mutex_lock( p_this->p_vlc->p_global_lock );
+    vlc_value_t lockval;
+
+    var_Get( p_this->p_libvlc, "gtk", &lockval );
+    vlc_mutex_lock( lockval.p_address );
 
     i_refcount--;
 
     if( i_refcount > 0 )
     {
-        vlc_mutex_unlock( p_this->p_vlc->p_global_lock );
+        vlc_mutex_unlock( lockval.p_address );
+        var_Destroy( p_this->p_libvlc, "gtk" );
         return;
     }
 
@@ -136,13 +136,11 @@ static void Close( vlc_object_t *p_this )
     vlc_object_destroy( p_gtk_main );
     p_gtk_main = NULL;
 
-    vlc_mutex_unlock( p_this->p_vlc->p_global_lock );
+    vlc_mutex_unlock( lockval.p_address );
+    var_Destroy( p_this->p_libvlc, "gtk" );
 }
 
-static gint foo(gpointer foo)
-{
-    return TRUE;
-}
+static gint foo( gpointer bar ) { return TRUE; }
 
 /*****************************************************************************
  * GtkMain: Gtk+ thread
@@ -174,7 +172,8 @@ static void GtkMain( vlc_object_t *p_this )
 
     vlc_thread_ready( p_this );
 
-    /* If we don't add this simple timeout, gtk_main remains stuck ... */
+    /* If we don't add this simple timeout, gtk_main remains stuck if
+     * we try to close the window without having sent any gtk event. */
     gtk_timeout_add( INTF_IDLE_SLEEP / 1000, foo, p_this );
 
     /* Enter Gtk mode */