X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c114eb7a9fe8da830622db4e9be301e53734218d..a4761b4c08e6272c69bd242b3323ab47dbbc8902:/src/gtk/app.cpp diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index f530f0998c..2041a588a7 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -48,8 +48,6 @@ // global data //----------------------------------------------------------------------------- -bool g_mainThreadLocked = false; - static GtkWidget *gs_RootWindow = (GtkWidget*) NULL; //----------------------------------------------------------------------------- @@ -206,6 +204,11 @@ bool wxApp::DoIdle() g_source_remove(m_idleSourceId); m_idleSourceId = 0; } + + // Pending events can be added asynchronously, + // need to keep idle source if any have appeared + needMore = needMore || HasPendingEvents(); + // if more idle processing requested if (needMore) { @@ -218,31 +221,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 //----------------------------------------------------------------------------- @@ -278,6 +256,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() ) @@ -356,20 +358,14 @@ 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_ -#if wxUSE_WCHAR_T // gtk+ 2.0 supports Unicode through UTF-8 strings wxConvCurrent = &wxConvUTF8; -#else // !wxUSE_WCHAR_T - if (!wxOKlibc()) - wxConvCurrent = (wxMBConv*) NULL; -#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T // decide which conversion to use for the file names @@ -440,6 +436,7 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_) } argc_ = argcGTK; + argv_[argc_] = NULL; } //else: gtk_init() didn't modify our parameters @@ -581,3 +578,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