]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/utilsres.cpp
wxMenu::Insert() seems to work, bug in wxMenuBase::Insert() is corrected
[wxWidgets.git] / src / gtk / utilsres.cpp
index 619a055713690a2132ab4da38cd9bcaa27af48ec..ea2c8af90e2ea6c85a639958dd1ac60714308782 100644 (file)
 #include "wx/utils.h"
 #include "wx/string.h"
 #include "wx/list.h"
+#include "wx/log.h"
+#include "wx/gdicmn.h"
 
 #include <ctype.h>
 #include <string.h>
 #include <unistd.h>
-#ifdef __SVR4__
-#include <sys/systeminfo.h>
-#endif
+//#ifdef __SVR4__
+//#include <sys/systeminfo.h>
+//#endif
 
 #include "gdk/gdkx.h"        // GDK_DISPLAY
 #include "gdk/gdkprivate.h"  // gdk_progclass
@@ -30,7 +32,6 @@
 #include <X11/Xutil.h>
 #include <X11/Xresource.h>
 
-#include "wx/log.h"
 
 //-----------------------------------------------------------------------------
 // constants
@@ -39,9 +40,9 @@
 // Yuck this is really BOTH site and platform dependent
 // so we should use some other strategy!
 #ifdef __SUN__
-    #define DEFAULT_XRESOURCE_DIR _T("/usr/openwin/lib/app-defaults")
+#   define DEFAULT_XRESOURCE_DIR wxT("/usr/openwin/lib/app-defaults")
 #else
-    #define DEFAULT_XRESOURCE_DIR _T("/usr/lib/X11/app-defaults")
+#   define DEFAULT_XRESOURCE_DIR wxT("/usr/lib/X11/app-defaults")
 #endif
 
 //-----------------------------------------------------------------------------
@@ -62,19 +63,19 @@ static wxChar *GetResourcePath(wxChar *buf, wxChar *name, bool create)
         wxStrcpy(buf, name);
         return buf; // Exists so ...
     }
-    if (*name == _T('/'))
+    if (*name == wxT('/'))
         wxStrcpy(buf, name);
     else 
     {
         // Put in standard place for resource files if not absolute
         wxStrcpy(buf, DEFAULT_XRESOURCE_DIR);
-        wxStrcat(buf, _T("/"));
+        wxStrcat(buf, wxT("/"));
         wxStrcat(buf, FileNameFromPath(name));
     }
     if (create) 
     {
         // Touch the file to create it
-        FILE *fd = fopen(wxConv_file.cWX2MB(buf), "w");
+        FILE *fd = fopen(wxConvCurrent->cWX2MB(buf), "w");
         if (fd) fclose(fd);
     }
     return buf;
@@ -85,7 +86,7 @@ static wxChar *GetResourcePath(wxChar *buf, wxChar *name, bool create)
 // the Real User, then determine the Real home dir.
 static wxChar *GetIniFile(wxChar *dest, const wxChar *filename)
 {
-    wxChar *home = (wxChar *) NULL;
+    const wxChar *home = (const wxChar *) NULL;
     if (filename && wxIsAbsolutePath(filename))
     {
       wxStrcpy(dest, filename);
@@ -95,18 +96,18 @@ static wxChar *GetIniFile(wxChar *dest, const wxChar *filename)
       if ((home = wxGetUserHome(wxString())) != NULL)
       {
         wxStrcpy(dest, home);
-        if (dest[wxStrlen(dest) - 1] != _T('/')) wxStrcat(dest, _T("/"));
+        if (dest[wxStrlen(dest) - 1] != wxT('/')) wxStrcat(dest, wxT("/"));
         if (filename == NULL)
         {
-          if ((filename = wxGetenv(_T("XENVIRONMENT"))) == NULL) filename = _T(".Xdefaults");
+          if ((filename = wxGetenv(wxT("XENVIRONMENT"))) == NULL) filename = wxT(".Xdefaults");
         }
         else
-          if (*filename != _T('.')) wxStrcat(dest, _T("."));
+          if (*filename != wxT('.')) wxStrcat(dest, wxT("."));
         wxStrcat(dest, filename);
       }
       else
       {
-        dest[0] = _T('\0');
+        dest[0] = wxT('\0');
       }
     }
     return dest;
@@ -139,7 +140,7 @@ static void wxXMergeDatabases()
     else 
     {
         (void)GetIniFile(filename, (wxChar *) NULL);
-        serverDB = XrmGetFileDatabase(wxConv_file.cWX2MB(filename));
+        serverDB = XrmGetFileDatabase(wxConvCurrent->cWX2MB(filename));
     }
     if (serverDB)
         XrmMergeDatabases(serverDB, &wxResourceDatabase);
@@ -147,32 +148,18 @@ static void wxXMergeDatabases()
     // Open XENVIRONMENT file, or if not defined, the .Xdefaults,
     // and merge into existing database
 
-    if ((environment = wxGetenv(_T("XENVIRONMENT"))) == NULL) 
+    if ((environment = wxGetenv(wxT("XENVIRONMENT"))) == NULL) 
     {
-        size_t len;
-#if wxUSE_UNICODE
-       char hostbuf[1024];
-#endif
         environment = GetIniFile(filename, (const wxChar *) NULL);
-        len = wxStrlen(environment);
-#if !defined(SVR4) || defined(__sgi)
-#if wxUSE_UNICODE
-        (void)gethostname(hostbuf, 1024 - len);
-#else
-        (void)gethostname(environment + len, 1024 - len);
-#endif
-#else
-#if wxUSE_UNICODE
-        (void)sysinfo(SI_HOSTNAME, hostbuf, 1024 - len);
-#else
-        (void)sysinfo(SI_HOSTNAME, environment + len, 1024 - len);
-#endif
-#endif
-#if wxUSE_UNICODE
-       wxStrcat(environment, wxConv_libc.cMB2WX(hostbuf));
-#endif
+        size_t len = wxStrlen(environment);
+
+        wxChar hostbuf[1024];
+        (void)wxGetHostName(hostbuf, WXSIZEOF(hostbuf) - len);
+
+        wxStrcat(environment, hostbuf);
     }
-    if ((homeDB = XrmGetFileDatabase(wxConv_file.cWX2MB(environment))))
+
+    if ((homeDB = XrmGetFileDatabase(wxConvCurrent->cWX2MB(environment))))
         XrmMergeDatabases(homeDB, &wxResourceDatabase);
 }
 
@@ -192,7 +179,7 @@ void wxFlushResources()
         (void)GetResourcePath(nameBuffer, file, TRUE);
 
         XrmDatabase database = (XrmDatabase)node->Data();
-        XrmPutFileDatabase(database, wxConv_file.cWX2MB(nameBuffer));
+        XrmPutFileDatabase(database, wxConvCurrent->cWX2MB(nameBuffer));
         XrmDestroyDatabase(database);
         wxNode *next = node->Next();
 //        delete node;
@@ -202,7 +189,7 @@ void wxFlushResources()
 
 void wxDeleteResources(const wxChar *file)
 {
-    wxLogTrace(wxTraceResAlloc, _T("Delete: Number = %d"), wxTheResourceCache->Number());
+    wxLogTrace(wxTraceResAlloc, wxT("Delete: Number = %d"), wxTheResourceCache->Number());
     wxChar buffer[500];
     (void)GetIniFile(buffer, file);
 
@@ -231,12 +218,12 @@ bool wxWriteResource(const wxString& section, const wxString& entry, const wxStr
     if (node)
         database = (XrmDatabase)node->Data();
     else {
-        database = XrmGetFileDatabase(wxConv_file.cWX2MB(buffer));
-        wxLogTrace(wxTraceResAlloc, _T("Write: Number = %d"), wxTheResourceCache->Number());
+        database = XrmGetFileDatabase(wxConvCurrent->cWX2MB(buffer));
+        wxLogTrace(wxTraceResAlloc, wxT("Write: Number = %d"), wxTheResourceCache->Number());
         wxTheResourceCache->Append(buffer, (wxObject *)database);
     }
     char resName[300];
-    strcpy(resName, !section.IsNull() ? MBSTRINGCAST section.mb_str() : "wxWindows");
+    strcpy(resName, !section.IsNull() ? wxMBSTRINGCAST section.mb_str() : "wxWindows");
     strcat(resName, ".");
     strcat(resName, entry.mb_str());
     XrmPutStringResource(&database, resName, value.mb_str());
@@ -285,8 +272,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value,
         }
         else
         {
-            database = XrmGetFileDatabase(wxConv_file.cWX2MB(buffer));
-            wxLogTrace(wxTraceResAlloc, _T("Get: Number = %d"), wxTheResourceCache->Number());
+            database = XrmGetFileDatabase(wxConvCurrent->cWX2MB(buffer));
+            wxLogTrace(wxTraceResAlloc, wxT("Get: Number = %d"), wxTheResourceCache->Number());
             wxTheResourceCache->Append(buffer, (wxObject *)database);
         }
     } else