X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a81258bee4e20d3fa9b3d2f6bf3bcd1200d1e5e0..103aec296a2c017f915b4b2b2584191fdb716a75:/src/gtk/utilsres.cpp diff --git a/src/gtk/utilsres.cpp b/src/gtk/utilsres.cpp index 1d6f714528..52e3199178 100644 --- a/src/gtk/utilsres.cpp +++ b/src/gtk/utilsres.cpp @@ -57,19 +57,22 @@ extern XrmDatabase wxResourceDatabase; static char *GetResourcePath(char *buf, char *name, bool create) { - if (create && FileExists(name)) { + if (create && FileExists(name)) + { strcpy(buf, name); return buf; // Exists so ... } if (*name == '/') strcpy(buf, name); - else { + else + { // Put in standard place for resource files if not absolute strcpy(buf, DEFAULT_XRESOURCE_DIR); strcat(buf, "/"); strcat(buf, FileNameFromPath(name)); } - if (create) { + if (create) + { // Touch the file to create it FILE *fd = fopen(buf, "w"); if (fd) fclose(fd); @@ -109,7 +112,7 @@ static char *GetIniFile(char *dest, const char *filename) return dest; } -static void wxXMergeDatabases(void) +static void wxXMergeDatabases() { XrmDatabase homeDB, serverDB, applicationDB; char filenamebuf[1024]; @@ -129,9 +132,12 @@ static void wxXMergeDatabases(void) // window when the server initializes and loaded into the display // structure on XOpenDisplay; // if not defined, use .Xdefaults - if (XResourceManagerString(GDK_DISPLAY()) != NULL) { + if (XResourceManagerString(GDK_DISPLAY()) != NULL) + { serverDB = XrmGetStringDatabase(XResourceManagerString(GDK_DISPLAY())); - } else { + } + else + { (void)GetIniFile(filename, (char *) NULL); serverDB = XrmGetFileDatabase(filename); } @@ -141,7 +147,8 @@ static void wxXMergeDatabases(void) // Open XENVIRONMENT file, or if not defined, the .Xdefaults, // and merge into existing database - if ((environment = getenv("XENVIRONMENT")) == NULL) { + if ((environment = getenv("XENVIRONMENT")) == NULL) + { size_t len; environment = GetIniFile(filename, (const char *) NULL); len = strlen(environment); @@ -159,13 +166,14 @@ static void wxXMergeDatabases(void) // called on application exit //----------------------------------------------------------------------------- -void wxFlushResources(void) +void wxFlushResources() { char nameBuffer[512]; wxNode *node = wxTheResourceCache->First(); while (node) { - char *file = node->key.string; + wxString str = node->GetKeyString(); + char *file = WXSTRINGCAST str; // If file doesn't exist, create it first. (void)GetResourcePath(nameBuffer, file, TRUE); @@ -248,16 +256,21 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value, wxXMergeDatabases(); XrmDatabase database; - if (file) { + if (!file.IsEmpty()) + { char buffer[500]; // Is this right? Trying to get it to look in the user's // home directory instead of current directory -- JACS (void)GetIniFile(buffer, file); - wxNode *node = wxTheResourceCache->Find(buffer); + wxNode *node = (wxNode*) NULL; /* suppress egcs warning */ + node = wxTheResourceCache->Find(buffer); if (node) + { database = (XrmDatabase)node->Data(); - else { + } + else + { database = XrmGetFileDatabase(buffer); wxLogTrace(wxTraceResAlloc, "Get: Number = %d", wxTheResourceCache->Number()); wxTheResourceCache->Append(buffer, (wxObject *)database); @@ -274,11 +287,13 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value, bool success = XrmGetResource(database, buf, "*", str_type, &xvalue); // Try different combinations of upper/lower case, just in case... - if (!success) { + if (!success) + { buf[0] = (isupper(buf[0]) ? tolower(buf[0]) : toupper(buf[0])); success = XrmGetResource(database, buf, "*", str_type, &xvalue); } - if (success) { + if (success) + { if (*value) delete[] *value; *value = new char[xvalue.size + 1]; @@ -292,7 +307,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, float *value, { char *s = (char *) NULL; bool succ = wxGetResource(section, entry, &s, file); - if (succ) { + if (succ) + { *value = (float)strtod(s, (char **) NULL); delete[]s; return TRUE; @@ -304,7 +320,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, long *value, { char *s = (char *) NULL; bool succ = wxGetResource(section, entry, &s, file); - if (succ) { + if (succ) + { *value = strtol(s, (char **) NULL, 10); delete[]s; return TRUE; @@ -316,7 +333,8 @@ bool wxGetResource(const wxString& section, const wxString& entry, int *value, c { char *s = (char *) NULL; bool succ = wxGetResource(section, entry, &s, file); - if (succ) { + if (succ) + { // Handle True, False here // True, Yes, Enables, Set or Activated if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A')