add wxGetLinuxDistributionInfo() and wxPlatformInfo::GetLinuxDistribution() functions; also add to wxPlatformInfo the GetOperatingSystemDescription(), GetDesktopEnvironment(), GetOperatingSystemDirectory() functions to group in the same class (wxPlatformInfo) all available platform-detection functions

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60873 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2009-06-02 13:01:41 +00:00
parent ed1288eef0
commit 23790a2a29
7 changed files with 206 additions and 9 deletions

View File

@@ -107,6 +107,24 @@ enum wxEndianness
wxENDIAN_MAX
};
/**
A structure containing informations about a Linux distribution as returned
by the @c lsb_release utility.
See wxGetLinuxDistributionInfo() or wxPlatformInfo::GetLinuxDistributionInfo()
for more info.
*/
struct wxLinuxDistributionInfo
{
wxString Id; //!< The id of the distribution; e.g. "Ubuntu"
wxString Release; //!< The version of the distribution; e.g. "9.04"
wxString CodeName; //!< The code name of the distribution; e.g. "jaunty"
wxString Description; //!< The description of the distribution; e.g. "Ubuntu 9.04"
bool operator==(const wxLinuxDistributionInfo& ldi) const;
bool operator!=(const wxLinuxDistributionInfo& ldi) const;
};
/**
@class wxPlatformInfo
@@ -117,8 +135,16 @@ enum wxEndianness
This class does not only have @e getters for the informations above, it also has
@e setters. This allows you to e.g. save the current platform informations in a
data file (maybe in string form) so that when you later load it, you can easily
retrieve (see the static getters for string->enum conversion functions) the
signature of the system which generated it.
retrieve (see the static getters for string->enum conversion functions) and store
inside a wxPlatformInfo instance (using its setters) the signature of the system
which generated it.
In general however you only need to use the static Get() function and then
access the various informations for the current platform:
@code
wxLogMessage("This application is running under %s.",
wxPlatformInfo::Get().GetOperatingSystemIdName());
@endcode
@library{wxbase}
@category{cfg}
@@ -285,6 +311,13 @@ public:
static wxString GetPortIdShortName(wxPortId port,
bool usingUniversal);
/**
Returns the operating system directory.
See wxGetOSDirectory() for more info.
*/
static wxString GetOperatingSystemDirectory();
//@}
@@ -323,11 +356,32 @@ public:
Returns the operating system ID of this wxPlatformInfo instance.
*/
wxOperatingSystemId GetOperatingSystemId() const;
/**
Returns the description of the operating system of this wxPlatformInfo instance.
See wxGetOSDescription() for more info.
*/
wxString GetOperatingSystemDescription() const;
/**
Returns the wxWidgets port ID associated with this wxPlatformInfo instance.
*/
wxPortId GetPortId() const;
/**
Returns the Linux distribution info associated with this wxPlatformInfo instance.
See wxGetLinuxDistributionInfo() for more info.
*/
wxLinuxDistributionInfo GetLinuxDistributionInfo() const;
/**
Returns the desktop environment associated with this wxPlatformInfo instance.
See wxAppTraits::GetDesktopEnvironment() for more info.
*/
wxString GetDesktopEnvironment() const;
/**
Returns the run-time major version of the toolkit associated with this
@@ -436,8 +490,22 @@ public:
Sets the version of the toolkit associated with this wxPlatformInfo instance.
*/
void SetToolkitVersion(int major, int minor);
/**
Sets the operating system description associated with this wxPlatformInfo instance.
*/
void SetOperatingSystemDescription(const wxString& desc);
/**
Sets the desktop environment associated with this wxPlatformInfo instance.
*/
void SetDesktopEnvironment(const wxString& de);
/**
Sets the linux distribution info associated with this wxPlatformInfo instance.
*/
void SetLinuxDistributionInfo(const wxLinuxDistributionInfo& di);
//@}
};

View File

@@ -684,6 +684,23 @@ bool wxIsPlatform64Bit();
*/
bool wxIsPlatformLittleEndian();
/**
Returns a structure containing informations about the currently running
Linux distribution.
This function uses the @c lsb_release utility which is part of the
<tt>Linux Standard Base Core</tt> specification
(see http://refspecs.linux-foundation.org/lsb.shtml) since the very first LSB
release 1.0 (released in 2001).
The @c lsb_release utility is very common on modern Linux distributions but in
case it's not available, then this function will return a ::wxLinuxDistributionInfo
structure containing empty strings.
This function is Linux-specific and is only available when the @c __LINUX__
symbol is defined.
*/
wxLinuxDistributionInfo wxGetLinuxDistributionInfo();
//@}