]> git.sesse.net Git - vlc/blobdiff - modules/misc/gtk_main.c
Don't include config.h from the headers - refs #297.
[vlc] / modules / misc / gtk_main.c
index 6ec85a06a30ebd55ac070518c0c8386a0f67364f..127e59e455a94b8f34051beb9c8dab4ccc477017 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * gtk_main.c : Gtk+ wrapper for gtk_main
  *****************************************************************************
- * Copyright (C) 2002 VideoLAN
- * $Id: gtk_main.c,v 1.14 2003/03/19 17:40:43 fenrir Exp $
+ * Copyright (C) 2002 the VideoLAN team
+ * $Id$
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 
-#include <stdlib.h>                                              /* atexit() */
 
 #include <gtk/gtk.h>
 
@@ -57,7 +60,7 @@ static vlc_object_t * p_gtk_main = NULL;
  *****************************************************************************/
 vlc_module_begin();
     int i_cap;
-    set_description( _("Gtk+ GUI helper module") );
+    set_description( _("Gtk+ GUI helper") );
 #if defined(MODULE_NAME_IS_gtk_main)
     i_cap = 90;
     add_shortcut( "gtk" );
@@ -83,18 +86,14 @@ vlc_module_end();
  *****************************************************************************/
 static int Open( vlc_object_t *p_this )
 {
-    vlc_value_t lockval;
+    vlc_mutex_t *lock;
 
-    /* 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 );
+    lock = var_AcquireMutex( "gtk" );
 
     if( i_refcount > 0 )
     {
         i_refcount++;
-        vlc_mutex_unlock( lockval.p_address );
+        vlc_mutex_unlock( lock );
 
         return VLC_SUCCESS;
     }
@@ -114,13 +113,12 @@ static int Open( vlc_object_t *p_this )
     {
         vlc_object_destroy( p_gtk_main );
         i_refcount--;
-        vlc_mutex_unlock( lockval.p_address );
-        var_Destroy( p_this->p_libvlc, "gtk" );
+        vlc_mutex_unlock( lock );
         return VLC_ETHREAD;
     }
 
     i_refcount++;
-    vlc_mutex_unlock( lockval.p_address );
+    vlc_mutex_unlock( lock );
 
     return VLC_SUCCESS;
 }
@@ -130,17 +128,15 @@ static int Open( vlc_object_t *p_this )
  *****************************************************************************/
 static void Close( vlc_object_t *p_this )
 {
-    vlc_value_t lockval;
+    vlc_mutex_t *lock;
 
-    var_Get( p_this->p_libvlc, "gtk", &lockval );
-    vlc_mutex_lock( lockval.p_address );
+    lock = var_AcquireMutex( "gtk" );
 
     i_refcount--;
 
     if( i_refcount > 0 )
     {
-        vlc_mutex_unlock( lockval.p_address );
-        var_Destroy( p_this->p_libvlc, "gtk" );
+        vlc_mutex_unlock( lock );
         return;
     }
 
@@ -150,8 +146,7 @@ static void Close( vlc_object_t *p_this )
     vlc_object_destroy( p_gtk_main );
     p_gtk_main = NULL;
 
-    vlc_mutex_unlock( lockval.p_address );
-    var_Destroy( p_this->p_libvlc, "gtk" );
+    vlc_mutex_unlock( lock );
 }
 
 static gint foo( gpointer bar ) { return TRUE; }
@@ -178,7 +173,7 @@ static void GtkMain( vlc_object_t *p_this )
 #endif
 
 #if defined(MODULE_NAME_IS_gnome_main)
-    gnome_init( p_this->p_vlc->psz_object_name, VERSION, i_args, p_args );
+    gnome_init( p_this->p_libvlc->psz_object_name, VERSION, i_args, p_args );
 #elif defined(MODULE_NAME_IS_gnome2_main)
     gnome_program_init( PACKAGE, VERSION, LIBGNOMEUI_MODULE,
                         i_args, p_args,
@@ -202,4 +197,3 @@ static void GtkMain( vlc_object_t *p_this )
 
     gdk_threads_leave();
 }
-