* 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>
*
* 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
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
*****************************************************************************/
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() )
{
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;
}
*****************************************************************************/
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;
}
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
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 */