1 /* Icons.c- icon preferences
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998 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,
27 typedef struct _Panel
{
32 CallbackRec callbacks
;
57 #define ICON_FILE "iconprefs"
61 showIconLayout(WMWidget
*widget
, void *data
)
63 _Panel
*panel
= (_Panel
*)data
;
68 if (panel
->posB
[i
] == widget
) {
74 if (panel
->iconPos
& 1) {
81 WMResizeWidget(panel
->posV
, w
, h
);
83 switch (panel
->iconPos
& ~1) {
85 WMMoveWidget(panel
->posV
, 2, 2);
88 WMMoveWidget(panel
->posV
, 95-2-w
, 2);
91 WMMoveWidget(panel
->posV
, 2, 70-2-h
);
94 WMMoveWidget(panel
->posV
, 95-2-w
, 70-2-h
);
100 #define MIN(a,b) ((a) < (b) ? (a) : (b))
103 showData(_Panel
*panel
)
109 WMSetButtonSelected(panel
->arrB
, GetBoolForKey("AutoArrangeIcons"));
111 WMSetButtonSelected(panel
->omnB
, GetBoolForKey("StickyIcons"));
113 str
= GetStringForKey("IconPosition");
116 if (strlen(str
)!=3) {
117 wwarning("bad value %s for option IconPosition. Using default blh",
122 if (str
[0]=='t' || str
[0]=='T') {
127 if (str
[1]=='r' || str
[1]=='R') {
130 if (str
[2]=='v' || str
[2]=='V') {
136 WMPerformButtonClick(panel
->posB
[i
]);
138 i
= GetIntegerForKey("IconSize");
145 WMSetPopUpButtonSelectedItem(panel
->sizeP
, i
);
147 str
= GetStringForKey("IconificationStyle");
150 if (strcasecmp(str
, "none")==0)
151 WMPerformButtonClick(panel
->animB
[3]);
152 else if (strcasecmp(str
, "twist")==0)
153 WMPerformButtonClick(panel
->animB
[1]);
154 else if (strcasecmp(str
, "flip")==0)
155 WMPerformButtonClick(panel
->animB
[2]);
157 WMPerformButtonClick(panel
->animB
[0]);
165 createPanel(Panel
*p
)
167 _Panel
*panel
= (_Panel
*)p
;
172 panel
->frame
= WMCreateFrame(panel
->win
);
173 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
174 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
176 /***************** Positioning of Icons *****************/
177 panel
->posF
= WMCreateFrame(panel
->frame
);
178 WMResizeWidget(panel
->posF
, 260, 135);
179 WMMoveWidget(panel
->posF
, 25, 10);
180 WMSetFrameTitle(panel
->posF
, _("Icon Positioning"));
182 for (i
=0; i
<8; i
++) {
183 panel
->posB
[i
] = WMCreateButton(panel
->posF
, WBTOnOff
);
184 WMSetButtonAction(panel
->posB
[i
], showIconLayout
, panel
);
187 WMGroupButtons(panel
->posB
[0], panel
->posB
[i
]);
189 WMMoveWidget(panel
->posB
[1], 70, 23);
190 WMResizeWidget(panel
->posB
[1], 47, 15);
191 WMMoveWidget(panel
->posB
[3], 70+47, 23);
192 WMResizeWidget(panel
->posB
[3], 47, 15);
194 WMMoveWidget(panel
->posB
[0], 55, 38);
195 WMResizeWidget(panel
->posB
[0], 15, 35);
196 WMMoveWidget(panel
->posB
[4], 55, 38+35);
197 WMResizeWidget(panel
->posB
[4], 15, 35);
199 WMMoveWidget(panel
->posB
[5], 70, 38+70);
200 WMResizeWidget(panel
->posB
[5], 47, 15);
201 WMMoveWidget(panel
->posB
[7], 70+47, 38+70);
202 WMResizeWidget(panel
->posB
[7], 47, 15);
204 WMMoveWidget(panel
->posB
[2], 70+95, 38);
205 WMResizeWidget(panel
->posB
[2], 15, 35);
206 WMMoveWidget(panel
->posB
[6], 70+95, 38+35);
207 WMResizeWidget(panel
->posB
[6], 15, 35);
209 color
= WMCreateRGBColor(WMWidgetScreen(panel
->win
), 0x5100, 0x5100,
211 panel
->posVF
= WMCreateFrame(panel
->posF
);
212 WMResizeWidget(panel
->posVF
, 95, 70);
213 WMMoveWidget(panel
->posVF
, 70, 38);
214 WMSetFrameRelief(panel
->posVF
, WRSunken
);
215 WMSetWidgetBackgroundColor(panel
->posVF
, color
);
216 WMReleaseColor(color
);
218 panel
->posV
= WMCreateFrame(panel
->posVF
);
219 WMSetFrameRelief(panel
->posV
, WRSimple
);
221 WMMapSubwidgets(panel
->posF
);
223 /***************** Animation ****************/
224 panel
->animF
= WMCreateFrame(panel
->frame
);
225 WMResizeWidget(panel
->animF
, 205, 135);
226 WMMoveWidget(panel
->animF
, 295, 10);
227 WMSetFrameTitle(panel
->animF
, _("Iconification Animation"));
229 for (i
=0; i
<4; i
++) {
230 panel
->animB
[i
] = WMCreateRadioButton(panel
->animF
);
231 WMResizeWidget(panel
->animB
[i
], 170, 20);
232 WMMoveWidget(panel
->animB
[i
], 20, 24+i
*25);
234 WMGroupButtons(panel
->animB
[0], panel
->animB
[1]);
235 WMGroupButtons(panel
->animB
[0], panel
->animB
[2]);
236 WMGroupButtons(panel
->animB
[0], panel
->animB
[3]);
238 WMSetButtonText(panel
->animB
[0], _("Shrinking/Zooming"));
239 WMSetButtonText(panel
->animB
[1], _("Spinning/Twisting"));
240 WMSetButtonText(panel
->animB
[2], _("3D-flipping"));
241 WMSetButtonText(panel
->animB
[3], _("None"));
243 WMMapSubwidgets(panel
->animF
);
245 /***************** Options ****************/
246 panel
->optF
= WMCreateFrame(panel
->frame
);
247 WMResizeWidget(panel
->optF
, 260, 70);
248 WMMoveWidget(panel
->optF
, 25, 150);
249 WMSetFrameTitle(panel
->optF
, _("Icon Display"));
251 panel
->arrB
= WMCreateSwitchButton(panel
->optF
);
252 WMResizeWidget(panel
->arrB
, 235, 20);
253 WMMoveWidget(panel
->arrB
, 15, 15);
254 WMSetButtonText(panel
->arrB
, _("Auto-arrange icons"));
256 panel
->omnB
= WMCreateSwitchButton(panel
->optF
);
257 WMResizeWidget(panel
->omnB
, 235, 20);
258 WMMoveWidget(panel
->omnB
, 15, 40);
259 WMSetButtonText(panel
->omnB
, _("Omnipresent miniwindows"));
261 WMMapSubwidgets(panel
->optF
);
263 /***************** Icon Size ****************/
264 panel
->sizeF
= WMCreateFrame(panel
->frame
);
265 WMResizeWidget(panel
->sizeF
, 205, 70);
266 WMMoveWidget(panel
->sizeF
, 295, 150);
267 WMSetFrameTitle(panel
->sizeF
, _("Icon Size"));
270 panel
->sizeP
= WMCreatePopUpButton(panel
->sizeF
);
271 WMResizeWidget(panel
->sizeP
, 156, 20);
272 WMMoveWidget(panel
->sizeP
, 25, 30);
273 for (i
=24; i
<=96; i
+=8) {
274 sprintf(buf
, "%ix%i", i
, i
);
275 WMAddPopUpButtonItem(panel
->sizeP
, buf
);
278 WMMapSubwidgets(panel
->sizeF
);
280 WMRealizeWidget(panel
->frame
);
281 WMMapSubwidgets(panel
->frame
);
288 storeData(_Panel
*panel
)
292 SetBoolForKey(WMGetButtonSelected(panel
->arrB
), "AutoArrangeIcons");
293 SetBoolForKey(WMGetButtonSelected(panel
->omnB
), "StickyIcons");
295 SetIntegerForKey(WMGetPopUpButtonSelectedItem(panel
->sizeP
)*8+24,
300 if (panel
->iconPos
< 4) {
305 if (panel
->iconPos
& 2) {
310 if (panel
->iconPos
& 1) {
315 SetStringForKey(buf
, "IconPosition");
317 if (WMGetButtonSelected(panel
->animB
[0]))
318 SetStringForKey("zoom", "IconificationStyle");
319 else if (WMGetButtonSelected(panel
->animB
[1]))
320 SetStringForKey("twist", "IconificationStyle");
321 else if (WMGetButtonSelected(panel
->animB
[2]))
322 SetStringForKey("flip", "IconificationStyle");
324 SetStringForKey("none", "IconificationStyle");
330 InitIcons(WMScreen
*scr
, WMWindow
*win
)
334 panel
= wmalloc(sizeof(_Panel
));
335 memset(panel
, 0, sizeof(_Panel
));
337 panel
->sectionName
= _("Icon Preferences");
341 panel
->callbacks
.createWidgets
= createPanel
;
342 panel
->callbacks
.updateDomain
= storeData
;
344 AddSection(panel
, ICON_FILE
);