]> git.sesse.net Git - vlc/blobdiff - modules/misc/gtk_main.c
* src/extras/libc.c: New vlc_wraptext function,
[vlc] / modules / misc / gtk_main.c
index 0f5f2c875a5ad94f925938e75c657ffea3638354..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.8 2002/10/04 13:13:54 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_libvlc->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_libvlc->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_libvlc->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_libvlc->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_libvlc->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_libvlc->global_lock );
+        vlc_mutex_unlock( lockval.p_address );
+        var_Destroy( p_this->p_libvlc, "gtk" );
         return;
     }
 
@@ -136,7 +136,8 @@ static void Close( vlc_object_t *p_this )
     vlc_object_destroy( p_gtk_main );
     p_gtk_main = NULL;
 
-    vlc_mutex_unlock( &p_this->p_libvlc->global_lock );
+    vlc_mutex_unlock( lockval.p_address );
+    var_Destroy( p_this->p_libvlc, "gtk" );
 }
 
 static gint foo( gpointer bar ) { return TRUE; }