+ // this is NULL for a "regular" wxApp, but is set (and freed) by a wxGLApp
+ m_glVisualInfo = (void *) NULL;
+ m_glFBCInfo = (void *) NULL;
+}
+
+wxApp::~wxApp()
+{
+ if (m_idleTag)
+ g_source_remove( m_idleTag );
+}
+
+bool wxApp::OnInitGui()
+{
+ if ( !wxAppBase::OnInitGui() )
+ return false;
+
+ // if this is a wxGLApp (derived from wxApp), and we've already
+ // chosen a specific visual, then derive the GdkVisual from that
+ if (m_glVisualInfo != NULL)
+ {
+ // seems gtk_widget_set_default_visual no longer exists?
+ GdkVisual* vis = gtk_widget_get_default_visual();
+
+ GdkColormap *colormap = gdk_colormap_new( vis, FALSE );
+ gtk_widget_set_default_colormap( colormap );
+ }
+
+ // On some machines, the default visual is just 256 colours, so
+ // we make sure we get the best. This can sometimes be wasteful.
+
+ else
+ if ((gdk_visual_get_best() != gdk_visual_get_system()) && (m_useBestVisual))
+ {
+ /* seems gtk_widget_set_default_visual no longer exists? */
+ GdkVisual* vis = gtk_widget_get_default_visual();
+
+ GdkColormap *colormap = gdk_colormap_new( vis, FALSE );
+ gtk_widget_set_default_colormap( colormap );
+ }
+
+ return true;
+}
+
+GdkVisual *wxApp::GetGdkVisual()
+{
+ GdkVisual *visual = NULL;
+
+ if (m_glVisualInfo)
+ visual = gdkx_visual_get( ((XVisualInfo *) m_glVisualInfo)->visualid );
+ else
+ visual = gdk_drawable_get_visual( wxGetRootWindow()->window );
+
+ wxASSERT( visual );
+
+ return visual;
+}
+
+bool wxApp::Initialize(int& argc, wxChar **argv)
+{
+ bool init_result;
+
+#if wxUSE_THREADS
+ if (!g_thread_supported())
+ g_thread_init(NULL);
+#endif // wxUSE_THREADS
+
+ gtk_set_locale();
+
+ // 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
+
+ // (1) this variable exists for the sole purpose of specifying the encoding
+ // of the filenames for GTK+ programs, so use it if it is set
+ wxString encName(wxGetenv(_T("G_FILENAME_ENCODING")));
+ encName = encName.BeforeFirst(_T(','));
+ if (encName == _T("@locale"))
+ encName.clear();
+ encName.MakeUpper();
+#if wxUSE_INTL
+ if (encName.empty())
+ {
+ // (2) if a non default locale is set, assume that the user wants his
+ // filenames in this locale too
+ encName = wxLocale::GetSystemEncodingName().Upper();
+ // (3) finally use UTF-8 by default
+ if (encName.empty() || encName == _T("US-ASCII"))
+ encName = _T("UTF-8");
+ wxSetEnv(_T("G_FILENAME_ENCODING"), encName);
+ }