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");
148 if (strcasecmp(str
, "none")==0)
149 WMPerformButtonClick(panel
->animB
[3]);
150 else if (strcasecmp(str
, "twist")==0)
151 WMPerformButtonClick(panel
->animB
[1]);
152 else if (strcasecmp(str
, "flip")==0)
153 WMPerformButtonClick(panel
->animB
[2]);
155 WMPerformButtonClick(panel
->animB
[0]);
163 createPanel(Panel
*p
)
165 _Panel
*panel
= (_Panel
*)p
;
170 panel
->frame
= WMCreateFrame(panel
->win
);
171 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
172 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
174 /***************** Positioning of Icons *****************/
175 panel
->posF
= WMCreateFrame(panel
->frame
);
176 WMResizeWidget(panel
->posF
, 260, 135);
177 WMMoveWidget(panel
->posF
, 25, 10);
178 WMSetFrameTitle(panel
->posF
, _("Icon Positioning"));
180 for (i
=0; i
<8; i
++) {
181 panel
->posB
[i
] = WMCreateButton(panel
->posF
, WBTOnOff
);
182 WMSetButtonAction(panel
->posB
[i
], showIconLayout
, panel
);
185 WMGroupButtons(panel
->posB
[0], panel
->posB
[i
]);
187 WMMoveWidget(panel
->posB
[1], 70, 23);
188 WMResizeWidget(panel
->posB
[1], 47, 15);
189 WMMoveWidget(panel
->posB
[3], 70+47, 23);
190 WMResizeWidget(panel
->posB
[3], 47, 15);
192 WMMoveWidget(panel
->posB
[0], 55, 38);
193 WMResizeWidget(panel
->posB
[0], 15, 35);
194 WMMoveWidget(panel
->posB
[4], 55, 38+35);
195 WMResizeWidget(panel
->posB
[4], 15, 35);
197 WMMoveWidget(panel
->posB
[5], 70, 38+70);
198 WMResizeWidget(panel
->posB
[5], 47, 15);
199 WMMoveWidget(panel
->posB
[7], 70+47, 38+70);
200 WMResizeWidget(panel
->posB
[7], 47, 15);
202 WMMoveWidget(panel
->posB
[2], 70+95, 38);
203 WMResizeWidget(panel
->posB
[2], 15, 35);
204 WMMoveWidget(panel
->posB
[6], 70+95, 38+35);
205 WMResizeWidget(panel
->posB
[6], 15, 35);
207 color
= WMCreateRGBColor(WMWidgetScreen(panel
->win
), 0x5100, 0x5100,
209 panel
->posVF
= WMCreateFrame(panel
->posF
);
210 WMResizeWidget(panel
->posVF
, 95, 70);
211 WMMoveWidget(panel
->posVF
, 70, 38);
212 WMSetFrameRelief(panel
->posVF
, WRSunken
);
213 WMSetWidgetBackgroundColor(panel
->posVF
, color
);
214 WMReleaseColor(color
);
216 panel
->posV
= WMCreateFrame(panel
->posVF
);
217 WMSetFrameRelief(panel
->posV
, WRSimple
);
219 WMMapSubwidgets(panel
->posF
);
221 /***************** Animation ****************/
222 panel
->animF
= WMCreateFrame(panel
->frame
);
223 WMResizeWidget(panel
->animF
, 205, 135);
224 WMMoveWidget(panel
->animF
, 295, 10);
225 WMSetFrameTitle(panel
->animF
, _("Iconification Animation"));
227 for (i
=0; i
<4; i
++) {
228 panel
->animB
[i
] = WMCreateRadioButton(panel
->animF
);
229 WMResizeWidget(panel
->animB
[i
], 170, 20);
230 WMMoveWidget(panel
->animB
[i
], 20, 24+i
*25);
232 WMGroupButtons(panel
->animB
[0], panel
->animB
[1]);
233 WMGroupButtons(panel
->animB
[0], panel
->animB
[2]);
234 WMGroupButtons(panel
->animB
[0], panel
->animB
[3]);
236 WMSetButtonText(panel
->animB
[0], _("Shrinking/Zooming"));
237 WMSetButtonText(panel
->animB
[1], _("Spinning/Twisting"));
238 WMSetButtonText(panel
->animB
[2], _("3D-flipping"));
239 WMSetButtonText(panel
->animB
[3], _("None"));
241 WMMapSubwidgets(panel
->animF
);
243 /***************** Options ****************/
244 panel
->optF
= WMCreateFrame(panel
->frame
);
245 WMResizeWidget(panel
->optF
, 260, 70);
246 WMMoveWidget(panel
->optF
, 25, 150);
247 WMSetFrameTitle(panel
->optF
, _("Icon Display"));
249 panel
->arrB
= WMCreateSwitchButton(panel
->optF
);
250 WMResizeWidget(panel
->arrB
, 235, 20);
251 WMMoveWidget(panel
->arrB
, 15, 15);
252 WMSetButtonText(panel
->arrB
, _("Auto-arrange icons"));
254 panel
->omnB
= WMCreateSwitchButton(panel
->optF
);
255 WMResizeWidget(panel
->omnB
, 235, 20);
256 WMMoveWidget(panel
->omnB
, 15, 40);
257 WMSetButtonText(panel
->omnB
, _("Omnipresent miniwindows"));
259 WMMapSubwidgets(panel
->optF
);
261 /***************** Icon Size ****************/
262 panel
->sizeF
= WMCreateFrame(panel
->frame
);
263 WMResizeWidget(panel
->sizeF
, 205, 70);
264 WMMoveWidget(panel
->sizeF
, 295, 150);
265 WMSetFrameTitle(panel
->sizeF
, _("Icon Size"));
268 panel
->sizeP
= WMCreatePopUpButton(panel
->sizeF
);
269 WMResizeWidget(panel
->sizeP
, 156, 20);
270 WMMoveWidget(panel
->sizeP
, 25, 30);
271 for (i
=24; i
<=96; i
+=8) {
272 sprintf(buf
, "%ix%i", i
, i
);
273 WMAddPopUpButtonItem(panel
->sizeP
, buf
);
276 WMMapSubwidgets(panel
->sizeF
);
278 WMRealizeWidget(panel
->frame
);
279 WMMapSubwidgets(panel
->frame
);
286 storeData(_Panel
*panel
)
290 SetBoolForKey(WMGetButtonSelected(panel
->arrB
), "AutoArrangeIcons");
291 SetBoolForKey(WMGetButtonSelected(panel
->omnB
), "StickyIcons");
293 SetIntegerForKey(WMGetPopUpButtonSelectedItem(panel
->sizeP
)*8+24,
298 if (panel
->iconPos
< 4) {
303 if (panel
->iconPos
& 2) {
308 if (panel
->iconPos
& 1) {
313 SetStringForKey(buf
, "IconPosition");
315 if (WMGetButtonSelected(panel
->animB
[0]))
316 SetStringForKey("zoom", "IconificationStyle");
317 else if (WMGetButtonSelected(panel
->animB
[1]))
318 SetStringForKey("twist", "IconificationStyle");
319 else if (WMGetButtonSelected(panel
->animB
[2]))
320 SetStringForKey("flip", "IconificationStyle");
322 SetStringForKey("none", "IconificationStyle");
328 InitIcons(WMScreen
*scr
, WMWindow
*win
)
332 panel
= wmalloc(sizeof(_Panel
));
333 memset(panel
, 0, sizeof(_Panel
));
335 panel
->sectionName
= _("Icon Preferences");
339 panel
->callbacks
.createWidgets
= createPanel
;
340 panel
->callbacks
.updateDomain
= storeData
;
342 AddSection(panel
, ICON_FILE
);