* details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with these librararies and programs; if not, write
+ * License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* include files */
/*+++++++++++++++++++++++++++++++++++++++*/
#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
#include <sys/types.h>
+#include <errno.h>
#if defined(_AIX) || defined(__apollo)
#include <sys/dir.h>
XtFree(bd_desc);
/* Set up DialogBox button labels. */
- strings[0] = XmStringCreateLocalized (_DtOkString);
- strings[1] = XmStringCreateLocalized (_DtApplyString);
- strings[2] = XmStringCreateLocalized (_DtCloseString);
- strings[3] = XmStringCreateLocalized (_DtHelpString);
+ strings[0] = XmStringCreateLocalized ((String) _DtOkString);
+ strings[1] = XmStringCreateLocalized ((String) _DtApplyString);
+ strings[2] = XmStringCreateLocalized ((String) _DtCloseString);
+ strings[3] = XmStringCreateLocalized ((String) _DtHelpString);
/* saveRestore
* Note that save.poscnt has been initialized elsewhere.
backdrops.maxNumBitmaps += 100;
}
+/************************************************************************
+ * cmpstringp()
+ * qsort() sort function, used for sorting bitmap names into alphabetical order
+ * can't use strcmp() due to char** rather than char*
+ ************************************************************************/
+static int
+cmpstringp(const void *p1, const void *p2)
+{
+ return strcmp(*(char * const *) p1, *(char * const *) p2);
+}
+
/************************************************************************
* ReadBitmaps()
* Create an array of bitmaps by reading backdrop directories in the
/* read the directory $HOME/.dt/backdrops */
string = (char *)XtMalloc(strlen(style.home) + strlen("/.dt/backdrops") + 1);
- sprintf(string, "%s/.dt/backdrops", style.home);
- ReadBitmapDirectory(string);
if (string != NULL)
+ {
+ sprintf(string, "%s/.dt/backdrops", style.home);
+ ReadBitmapDirectory(string);
XtFree(string);
+ }
if (backdrops.tmpNumBitmaps == 0)
{
free_dirList(backdrops.dirList, backdrops.dirCount);
return 0;
}
+
+ /* Sort the list into alphanetical order */
+ qsort(backdrops.tmpBitmapNames, backdrops.tmpNumBitmaps, sizeof(char *), cmpstringp);
/* get the fg/bg colors from Dtwm */
if (backdrops.newColors)
filep = readdir(dirp);
continue;
}
-
- /* strip suffix off filename */
name = (char *) XtMalloc(strlen(filep->d_name) + 1);
strcpy (name, filep->d_name);
- (void)strtok(name, ".");
+
+ /* strip suffix off filename if it's a .pm or .bm
+ * motif requires other formats like jpg, png etc to
+ * have the extension on to work with the XmGetPixmap() calls */
+ if(strlen(name) > 3
+ && (0 == strcmp(name + strlen(name) - 3, ".pm")
+ || 0 == strcmp(name + strlen(name) - 3, ".bm")))
+ {
+ (void)strtok(name, ".");
+ }
+
/* check for duplicates */
duplicate = 0;
backdrops.selected);
sprintf(bufr, "%s*backdropsDialog.selectedItem: %s\n", bufr,
backdrops.bitmapNames[backdrops.selected]);
- write (fd, bufr, strlen(bufr));
+ if(-1 == write (fd, bufr, strlen(bufr))) {
+ perror(strerror(errno));
+ }
}
}