1 /* geticonset.c - outputs icon configuration from WindowMaker to stdout
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998, 1999 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
23 #define PROG_VERSION "geticonset (Window Maker) 0.1"
31 #include "../src/wconfig.h"
39 defaultsPathForDomain(char *domain
)
41 static char path
[1024];
44 gspath
= getenv("GNUSTEP_USER_ROOT");
51 home
= getenv("HOME");
53 printf("%s:could not get HOME environment variable!\n", ProgName
);
57 strcat(path
, "/GNUstep/");
59 strcat(path
, DEFAULTS_DIR
);
69 printf("Usage: %s [OPTIONS] [FILE]\n", ProgName
);
70 puts("Retrieves program icon configuration and output to FILE or to stdout");
72 puts(" --help display this help and exit");
73 puts(" --version output version information and exit");
78 main(int argc
, char **argv
)
80 proplist_t window_name
, icon_key
, window_attrs
, icon_value
;
81 proplist_t all_windows
, iconset
;
89 for (i
= 1; i
< argc
; i
++) {
90 if (strcmp(argv
[i
], "-h")==0
91 || strcmp(argv
[i
], "--help")==0) {
94 } else if (strcmp(argv
[i
], "--version")==0) {
100 path
= defaultsPathForDomain("WMWindowAttributes");
102 all_windows
= PLGetProplistWithPath(path
);
104 printf("%s:could not load WindowMaker configuration file \"%s\".\n",
109 iconset
= PLMakeDictionaryFromEntries(NULL
, NULL
, NULL
);
111 keylist
= PLGetAllDictionaryKeys(all_windows
);
112 icon_key
= PLMakeString("Icon");
114 for (i
=0; i
<PLGetNumberOfElements(keylist
); i
++) {
117 window_name
= PLGetArrayElement(keylist
, i
);
118 if (!PLIsString(window_name
))
121 window_attrs
= PLGetDictionaryEntry(all_windows
, window_name
);
122 if (window_attrs
&& PLIsDictionary(window_attrs
)) {
123 icon_value
= PLGetDictionaryEntry(window_attrs
, icon_key
);
126 icondic
= PLMakeDictionaryFromEntries(icon_key
, icon_value
,
129 PLInsertDictionaryEntry(iconset
, window_name
, icondic
);
137 val
= PLMakeString(argv
[1]);
138 PLSetFilename(iconset
, val
);
141 puts(PLGetDescriptionIndent(iconset
, 0));