X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/30083ad8e7c0eb9ea3dcf4f2588149eeb7fe3e32..0cb7e05cd1ffcbb55fea48643fb81e284869ddad:/src/gtk/utilsgtk.cpp diff --git a/src/gtk/utilsgtk.cpp b/src/gtk/utilsgtk.cpp index 698225a0be..13bc7c448c 100644 --- a/src/gtk/utilsgtk.cpp +++ b/src/gtk/utilsgtk.cpp @@ -24,6 +24,8 @@ #include "wx/unix/execute.h" +#include "wx/gtk/private/timer.h" + #ifdef __WXDEBUG__ #include "wx/gtk/assertdlg_gtk.h" #if wxUSE_STACKWALKER @@ -222,6 +224,28 @@ wxCharBuffer wxConvertFromGTK(const wxString& s, wxFontEncoding enc) #endif // !wxUSE_UNICODE +// Returns false if version is certainly greater or equal than major.minor.micro +// Returns true if version is lower than major.minor.micro OR it cannot be +// determined and one should not rely on the availability of pango version +// major.minor.micro, nor the non-availability +const gchar *wx_pango_version_check (int major, int minor, int micro) +{ +#ifdef PANGO_VERSION_MAJOR + if (!gtk_check_version (2,11,0)) + { + // GTK+ 2.11 requires Pango >= 1.15.3 and pango_version_check + // was added in Pango 1.15.2 thus we know for sure the pango lib we're + // using has the pango_version_check function: + return pango_version_check (major, minor, micro); + } + + return "can't check"; +#else // !PANGO_VERSION_MAJOR + return "too old headers"; +#endif +} + + // ---------------------------------------------------------------------------- // subprocess routines // ---------------------------------------------------------------------------- @@ -286,6 +310,11 @@ wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const return wxPORT_GTK; } +wxTimerImpl *wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) +{ + return new wxGTKTimerImpl(timer); +} + #if wxUSE_DETECT_SM static wxString GetSM() { @@ -329,6 +358,14 @@ static wxString GetSM() // wxGUIAppTraits //----------------------------------------------------------------------------- +#if wxUSE_INTL +void wxGUIAppTraits::SetLocale() +{ + gtk_set_locale(); + wxUpdateLocaleIsUtf8(); +} +#endif + #ifdef __WXDEBUG__ #if wxUSE_STACKWALKER @@ -446,5 +483,96 @@ wxString wxGUIAppTraits::GetDesktopEnvironment() const return wxEmptyString; } +#ifdef __WXGTK26__ + +// see the hack below in wxCmdLineParser::GetUsageString(). +// TODO: replace this hack with a g_option_group_get_entries() +// call as soon as such function exists +struct _GOptionGroup +{ + gchar *name; + gchar *description; + gchar *help_description; + + GDestroyNotify destroy_notify; + gpointer user_data; + + GTranslateFunc translate_func; + GDestroyNotify translate_notify; + gpointer translate_data; + + GOptionEntry *entries; + gint n_entries; + + GOptionParseFunc pre_parse_func; + GOptionParseFunc post_parse_func; + GOptionErrorFunc error_func; +}; + +wxString wxGetNameFromGtkOptionEntry(const GOptionEntry *opt) +{ + wxString ret; + + if (opt->short_name) + ret << _T("-") << opt->short_name; + if (opt->long_name) + { + if (!ret.empty()) + ret << _T(", "); + ret << _T("--") << opt->long_name; + + if (opt->arg_description) + ret << _T("=") << opt->arg_description; + } + + return _T(" ") + ret; +} + +#endif // __WXGTK26__ + +wxString +wxGUIAppTraits::GetStandardCmdLineOptions(wxArrayString& names, + wxArrayString& desc) const +{ + wxString usage; + +#ifdef __WXGTK26__ + // check whether GTK version is greater than 2.6 but also lower than 2.12 + // because, as we use the undocumented _GOptionGroup struct, we don't want + // to run this code with future versions which might change it (2.11 is the + // latest one at the time of this writing) + if (!gtk_check_version(2,6,0) && + gtk_check_version(2,12,0)) + { + usage << _("The following standard GTK+ options are also supported:\n"); + // passing true here means that the function can open the default + // display while parsing (not really used here anyhow) + GOptionGroup *gtkOpts = gtk_get_option_group(true); + + // WARNING: here we access the internals of GOptionGroup: + GOptionEntry *entries = ((_GOptionGroup*)gtkOpts)->entries; + unsigned int n_entries = ((_GOptionGroup*)gtkOpts)->n_entries; + wxArrayString namesOptions, descOptions; + + for ( size_t n = 0; n < n_entries; n++ ) + { + if ( entries[n].flags & G_OPTION_FLAG_HIDDEN ) + continue; // skip + + names.push_back(wxGetNameFromGtkOptionEntry(&entries[n])); + + const gchar * const entryDesc = entries[n].description; + desc.push_back(entryDesc ? wxString(entryDesc) : _T("")); + } + + g_option_group_free (gtkOpts); + } +#else + wxUnusedVar(names); + wxUnusedVar(desc); +#endif // __WXGTK26__ + + return usage; +}