~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201207201942

« back to all changes in this revision

Viewing changes to lib/appUtil/appUtilX11.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-03-20 10:19:00 UTC
  • mfrom: (1.1.4 upstream) (2.4.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090320101900-1o604camiubq2de8
Tags: 2009.03.18-154848-2
Correcting patch system depends (Closes: #520493).

Show diffs side-by-side

added added

removed removed

Lines of Context:
152
152
       */
153
153
      if (iconName[0] != '/') {
154
154
         char *ctmp2;
155
 
         char *ctmpext;
156
155
         int i;
157
156
 
 
157
         static const char *iconExtensions[] = {
 
158
            "",         // MUST be first entry.
 
159
            ".png",
 
160
            ".xpm",
 
161
            ".gif",
 
162
            ".svg",
 
163
         };
 
164
 
158
165
         myIconName = NULL;
159
 
         ctmpext = strrchr(iconName, '.');
 
166
 
160
167
         ctmp2 = g_alloca(PATH_MAX);
161
168
         for (i = 0; !myIconName && i < ARRAYSIZE(extraIconPaths); i++) {
 
169
            int j;
 
170
 
162
171
            if (!extraIconPaths[i]) {
163
172
               continue;
164
173
            }
165
174
 
166
 
            if (ctmpext) {
167
 
               g_snprintf(ctmp2, PATH_MAX, "%s/%s", extraIconPaths[i], iconName);
168
 
               if (g_file_test(ctmp2, G_FILE_TEST_EXISTS)) {
169
 
                  myIconName = ctmp2;
 
175
            /*
 
176
             * Per Desktop Entry Specification and Icon Theme Specification, I don't
 
177
             * believe that the iconName, unless it's an absolute path, should include
 
178
             * the file extension.
 
179
             *
 
180
             * However, empirical evidence shows that -many- applications ignore that
 
181
             * and may specify an icon of, for example, "foo.png".  We'll also handle
 
182
             * those special cases here.
 
183
             */
 
184
            for (j = 0; !myIconName && j < ARRAYSIZE(iconExtensions); j++) {
 
185
               g_snprintf(ctmp2, PATH_MAX, "%s/%s%s", extraIconPaths[i], iconName,
 
186
                          iconExtensions[j]);
 
187
               if (!g_file_test(ctmp2, G_FILE_TEST_EXISTS)) {
 
188
                  continue;
 
189
               }
 
190
 
 
191
               if (j != 0) {
 
192
                  /*
 
193
                   * Case 1:  We located an icon by appending an image extension to
 
194
                   * IconName.  Success!
 
195
                   */
 
196
                  myIconName = ctmp2;           // Will break "i" loop.
170
197
                  foundItInFile = TRUE;
171
 
               }
172
 
            } else {
173
 
               static const char *iconExtensions[] = {
174
 
                  ".png",
175
 
                  ".xpm",
176
 
                  ".gif",
177
 
                  ".svg",
178
 
               };
179
 
               int j;
180
 
 
181
 
               for (j = 0; j < ARRAYSIZE(iconExtensions); j++) {
182
 
                  g_snprintf(ctmp2, PATH_MAX, "%s/%s%s",
183
 
                             extraIconPaths[i],
184
 
                             iconName, iconExtensions[j]);
185
 
                  if (g_file_test(ctmp2, G_FILE_TEST_EXISTS)) {
186
 
                     myIconName = ctmp2;
187
 
                     foundItInFile = TRUE;
188
 
                     break;
 
198
                  break;
 
199
               } else {
 
200
                  /*
 
201
                   * Case 2:  We found an icon without appending an extension.  Verify
 
202
                   * that the filename contains a valid image extension.
 
203
                   */
 
204
                  int k;
 
205
                  char *ctmpext = strrchr(ctmp2, '.');
 
206
                  for (k = 1; ctmpext && k < ARRAYSIZE(iconExtensions); k++) {
 
207
                     if (strcmp(ctmpext, iconExtensions[k]) == 0) {
 
208
                        myIconName = ctmp2;     // Will break "i" loop.
 
209
                        foundItInFile = TRUE;
 
210
                        break;
 
211
                     }
189
212
                  }
190
213
               }
191
214
            }
666
689
      "python2.4",
667
690
      "python2.3",
668
691
      "python2.2",
669
 
      "perl"
 
692
      "perl",
 
693
      "sh",
 
694
      "bash",
670
695
   };
671
696
   char cbuf[PATH_MAX];
672
697
   int i;