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:
@@ -15,7 +15,7 @@
|
||||
#include "wx/string.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPlatformInfo
|
||||
// wxPlatformInfo enums & structs
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// VERY IMPORTANT: when changing these enum values, also change the relative
|
||||
@@ -114,6 +114,31 @@ enum wxEndianness
|
||||
wxENDIAN_MAX
|
||||
};
|
||||
|
||||
// informations about a linux distro returned by the lsb_release utility
|
||||
struct wxLinuxDistributionInfo
|
||||
{
|
||||
wxString Id;
|
||||
wxString Release;
|
||||
wxString CodeName;
|
||||
wxString Description;
|
||||
|
||||
bool operator==(const wxLinuxDistributionInfo& ldi) const
|
||||
{
|
||||
return Id == ldi.Id &&
|
||||
Release == ldi.Release &&
|
||||
CodeName == ldi.CodeName &&
|
||||
Description == ldi.Description;
|
||||
}
|
||||
|
||||
bool operator!=(const wxLinuxDistributionInfo& ldi) const
|
||||
{ return !(*this == ldi); }
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPlatformInfo
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Information about the toolkit that the app is running under and some basic
|
||||
// platform and architecture info
|
||||
class WXDLLIMPEXP_BASE wxPlatformInfo
|
||||
@@ -161,6 +186,7 @@ public:
|
||||
static wxString GetArchName(wxArchitecture arch);
|
||||
static wxString GetEndiannessName(wxEndianness end);
|
||||
|
||||
|
||||
// getters
|
||||
// -----------------
|
||||
|
||||
@@ -196,6 +222,8 @@ public:
|
||||
|
||||
wxOperatingSystemId GetOperatingSystemId() const
|
||||
{ return m_os; }
|
||||
wxLinuxDistributionInfo GetLinuxDistributionInfo() const
|
||||
{ return m_ldi; }
|
||||
wxPortId GetPortId() const
|
||||
{ return m_port; }
|
||||
wxArchitecture GetArchitecture() const
|
||||
@@ -219,6 +247,16 @@ public:
|
||||
{ return GetArchName(m_arch); }
|
||||
wxString GetEndiannessName() const
|
||||
{ return GetEndiannessName(m_endian); }
|
||||
wxString GetOperatingSystemDescription() const
|
||||
{ return m_osDesc; }
|
||||
wxString GetDesktopEnvironment() const
|
||||
{ return m_desktopEnv; }
|
||||
|
||||
static wxString GetOperatingSystemDirectory();
|
||||
// doesn't make sense to store inside wxPlatformInfo the OS directory,
|
||||
// thus this function is static; note that this function simply calls
|
||||
// wxGetOSDirectory() and is here just to make it easier for the user to
|
||||
// find it that feature (global functions can be difficult to find in the docs)
|
||||
|
||||
// setters
|
||||
// -----------------
|
||||
@@ -230,12 +268,20 @@ public:
|
||||
|
||||
void SetOperatingSystemId(wxOperatingSystemId n)
|
||||
{ m_os = n; }
|
||||
void SetOperatingSystemDescription(const wxString& desc)
|
||||
{ m_osDesc = desc; }
|
||||
void SetPortId(wxPortId n)
|
||||
{ m_port = n; }
|
||||
void SetArchitecture(wxArchitecture n)
|
||||
{ m_arch = n; }
|
||||
void SetEndianness(wxEndianness n)
|
||||
{ m_endian = n; }
|
||||
|
||||
void SetDesktopEnvironment(const wxString& de)
|
||||
{ m_desktopEnv = de; }
|
||||
void SetLinuxDistributionInfo(const wxLinuxDistributionInfo& di)
|
||||
{ m_ldi = di; }
|
||||
|
||||
|
||||
// miscellaneous
|
||||
// -----------------
|
||||
@@ -244,9 +290,13 @@ public:
|
||||
{
|
||||
return m_osVersionMajor != -1 && m_osVersionMinor != -1 &&
|
||||
m_os != wxOS_UNKNOWN &&
|
||||
!m_osDesc.IsEmpty() &&
|
||||
m_tkVersionMajor != -1 && m_tkVersionMinor != -1 &&
|
||||
m_port != wxPORT_UNKNOWN &&
|
||||
m_arch != wxARCH_INVALID && m_endian != wxENDIAN_INVALID;
|
||||
m_arch != wxARCH_INVALID &&
|
||||
m_endian != wxENDIAN_INVALID;
|
||||
|
||||
// do not check linux-specific info; it's ok to have them empty
|
||||
}
|
||||
|
||||
|
||||
@@ -269,6 +319,16 @@ protected:
|
||||
|
||||
// Operating system ID.
|
||||
wxOperatingSystemId m_os;
|
||||
|
||||
// Operating system description.
|
||||
wxString m_osDesc;
|
||||
|
||||
|
||||
// linux-specific
|
||||
// -----------------
|
||||
|
||||
wxString m_desktopEnv;
|
||||
wxLinuxDistributionInfo m_ldi;
|
||||
|
||||
|
||||
// toolkit
|
||||
@@ -288,7 +348,7 @@ protected:
|
||||
// others
|
||||
// -----------------
|
||||
|
||||
// architecture of the OS
|
||||
// architecture of the OS/machine
|
||||
wxArchitecture m_arch;
|
||||
|
||||
// endianness of the machine
|
||||
|
@@ -32,7 +32,7 @@ class WXDLLIMPEXP_FWD_BASE wxArrayInt;
|
||||
// wxLongLong
|
||||
#include "wx/longlong.h"
|
||||
|
||||
// need for wxOperatingSystemId
|
||||
// needed for wxOperatingSystemId, wxLinuxDistributionInfo
|
||||
#include "wx/platinfo.h"
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
@@ -116,6 +116,11 @@ WXDLLIMPEXP_BASE bool wxIsPlatformLittleEndian();
|
||||
// Get platform architecture
|
||||
WXDLLIMPEXP_BASE bool wxIsPlatform64Bit();
|
||||
|
||||
#ifdef __LINUX__
|
||||
// Get linux-distro informations
|
||||
WXDLLIMPEXP_BASE wxLinuxDistributionInfo wxGetLinuxDistributionInfo();
|
||||
#endif
|
||||
|
||||
// Return a string with the current date/time
|
||||
WXDLLIMPEXP_BASE wxString wxNow();
|
||||
|
||||
|
Reference in New Issue
Block a user