]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/app.cpp
include 'Version' in version string, it's what Apple apps do
[wxWidgets.git] / src / gtk / app.cpp
index 62cf72b0bed670e3d106b35b24af0c2461f80fa2..8a762a4c4de1359ecb193868ff8e3b8e52a70c4d 100644 (file)
 #include "wx/gtk/private.h"
 #include "wx/apptrait.h"
 
+#if wxUSE_LIBHILDON
+    #include <hildon-widgets/hildon-program.h>
+#endif // wxUSE_LIBHILDON
+
 #include <gdk/gdkx.h>
 
 //-----------------------------------------------------------------------------
@@ -44,8 +48,6 @@
 // global data
 //-----------------------------------------------------------------------------
 
-bool   g_mainThreadLocked = false;
-
 static GtkWidget *gs_RootWindow = (GtkWidget*) NULL;
 
 //-----------------------------------------------------------------------------
@@ -214,31 +216,6 @@ bool wxApp::DoIdle()
     return false;
 }
 
-#if wxUSE_THREADS
-
-static GPollFunc wxgs_poll_func;
-
-extern "C" {
-static gint wxapp_poll_func( GPollFD *ufds, guint nfds, gint timeout )
-{
-    gdk_threads_enter();
-
-    wxMutexGuiLeave();
-    g_mainThreadLocked = true;
-
-    gint res = (*wxgs_poll_func)(ufds, nfds, timeout);
-
-    wxMutexGuiEnter();
-    g_mainThreadLocked = false;
-
-    gdk_threads_leave();
-
-    return res;
-}
-}
-
-#endif // wxUSE_THREADS
-
 //-----------------------------------------------------------------------------
 // Access to the root window global
 //-----------------------------------------------------------------------------
@@ -274,6 +251,30 @@ wxApp::~wxApp()
 {
 }
 
+bool wxApp::SetNativeTheme(const wxString& theme)
+{
+    wxString path;
+    path = gtk_rc_get_theme_dir();
+    path += "/";
+    path += theme.utf8_str();
+    path += "/gtk-2.0/gtkrc";
+
+    if ( wxFileExists(path.utf8_str()) )
+        gtk_rc_add_default_file(path.utf8_str());
+    else if ( wxFileExists(theme.utf8_str()) )
+        gtk_rc_add_default_file(theme.utf8_str());
+    else
+    {
+        wxLogWarning("Theme \"%s\" not available.", theme);
+
+        return false;
+    }
+
+    gtk_rc_reparse_all_for_settings(gtk_settings_get_default(), TRUE);
+
+    return true;
+}
+
 bool wxApp::OnInitGui()
 {
     if ( !wxAppBase::OnInitGui() )
@@ -317,6 +318,15 @@ bool wxApp::OnInitGui()
         }
     }
 
+#if wxUSE_LIBHILDON
+    m_hildonProgram = hildon_program_get_instance();
+    if ( !m_hildonProgram )
+    {
+        wxLogError(_("Unable to initialize Hildon program"));
+        return false;
+    }
+#endif // wxUSE_LIBHILDON
+
     return true;
 }
 
@@ -343,10 +353,10 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_)
 
 #if wxUSE_THREADS
     if (!g_thread_supported())
+    {
         g_thread_init(NULL);
-
-    wxgs_poll_func = g_main_context_get_poll_func(NULL);
-    g_main_context_set_poll_func(NULL, wxapp_poll_func);
+        gdk_threads_init();
+    }
 #endif // wxUSE_THREADS
 
     // We should have the wxUSE_WCHAR_T test on the _outside_
@@ -427,6 +437,7 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_)
         }
 
         argc_ = argcGTK;
+        argv_[argc_] = NULL;
     }
     //else: gtk_init() didn't modify our parameters
 
@@ -508,16 +519,21 @@ void wxApp::CleanUp()
 {
     if (m_idleSourceId != 0)
         g_source_remove(m_idleSourceId);
-#if wxUSE_THREADS
-    delete m_idleMutex;
-    m_idleMutex = NULL;
-#endif
+
     // release reference acquired by Initialize()
     g_type_class_unref(g_type_class_peek(GTK_TYPE_WIDGET));
 
     gdk_threads_leave();
 
     wxAppBase::CleanUp();
+
+    // delete this mutex as late as possible as it's used from WakeUpIdle(), in
+    // particular do it after calling the base class CleanUp() which can result
+    // in it being called
+#if wxUSE_THREADS
+    delete m_idleMutex;
+    m_idleMutex = NULL;
+#endif
 }
 
 void wxApp::WakeUpIdle()
@@ -563,3 +579,15 @@ void wxApp::OnAssertFailure(const wxChar *file,
 }
 
 #endif // __WXDEBUG__
+
+#if wxUSE_THREADS
+void wxGUIAppTraits::MutexGuiEnter()
+{
+    gdk_threads_enter();
+}
+
+void wxGUIAppTraits::MutexGuiLeave()
+{
+    gdk_threads_leave();
+}
+#endif // wxUSE_THREADS