1 /* Icons.c- icon preferences
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998-2002 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
{
34 CallbackRec callbacks
;
59 #define ICON_FILE "iconprefs"
63 showIconLayout(WMWidget
*widget
, void *data
)
65 _Panel
*panel
= (_Panel
*)data
;
70 if (panel
->posB
[i
] == widget
) {
76 if (panel
->iconPos
& 1) {
83 WMResizeWidget(panel
->posV
, w
, h
);
85 switch (panel
->iconPos
& ~1) {
87 WMMoveWidget(panel
->posV
, 2, 2);
90 WMMoveWidget(panel
->posV
, 95-2-w
, 2);
93 WMMoveWidget(panel
->posV
, 2, 70-2-h
);
96 WMMoveWidget(panel
->posV
, 95-2-w
, 70-2-h
);
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
;
173 panel
->box
= WMCreateBox(panel
->parent
);
174 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
176 /***************** Positioning of Icons *****************/
177 panel
->posF
= WMCreateFrame(panel
->box
);
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
->parent
), 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
->box
);
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
->box
);
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 WMSetBalloonTextForView(_("Keep icons and miniwindows arranged all the time."),
257 WMWidgetView(panel
->arrB
));
259 panel
->omnB
= WMCreateSwitchButton(panel
->optF
);
260 WMResizeWidget(panel
->omnB
, 235, 20);
261 WMMoveWidget(panel
->omnB
, 15, 40);
262 WMSetButtonText(panel
->omnB
, _("Omnipresent miniwindows"));
264 WMSetBalloonTextForView(_("Make miniwindows be present in all workspaces."),
265 WMWidgetView(panel
->omnB
));
267 WMMapSubwidgets(panel
->optF
);
269 /***************** Icon Size ****************/
270 panel
->sizeF
= WMCreateFrame(panel
->box
);
271 WMResizeWidget(panel
->sizeF
, 205, 70);
272 WMMoveWidget(panel
->sizeF
, 295, 150);
273 WMSetFrameTitle(panel
->sizeF
, _("Icon Size"));
275 WMSetBalloonTextForView(_("The size of the dock/application icon and miniwindows"),
276 WMWidgetView(panel
->sizeF
));
278 panel
->sizeP
= WMCreatePopUpButton(panel
->sizeF
);
279 WMResizeWidget(panel
->sizeP
, 156, 20);
280 WMMoveWidget(panel
->sizeP
, 25, 30);
281 for (i
=24; i
<=96; i
+=8) {
282 sprintf(buf
, "%ix%i", i
, i
);
283 WMAddPopUpButtonItem(panel
->sizeP
, buf
);
286 WMMapSubwidgets(panel
->sizeF
);
288 WMRealizeWidget(panel
->box
);
289 WMMapSubwidgets(panel
->box
);
296 storeData(_Panel
*panel
)
300 SetBoolForKey(WMGetButtonSelected(panel
->arrB
), "AutoArrangeIcons");
301 SetBoolForKey(WMGetButtonSelected(panel
->omnB
), "StickyIcons");
303 SetIntegerForKey(WMGetPopUpButtonSelectedItem(panel
->sizeP
)*8+24,
308 if (panel
->iconPos
< 4) {
313 if (panel
->iconPos
& 2) {
318 if (panel
->iconPos
& 1) {
323 SetStringForKey(buf
, "IconPosition");
325 if (WMGetButtonSelected(panel
->animB
[0]))
326 SetStringForKey("zoom", "IconificationStyle");
327 else if (WMGetButtonSelected(panel
->animB
[1]))
328 SetStringForKey("twist", "IconificationStyle");
329 else if (WMGetButtonSelected(panel
->animB
[2]))
330 SetStringForKey("flip", "IconificationStyle");
332 SetStringForKey("none", "IconificationStyle");
338 InitIcons(WMScreen
*scr
, WMWidget
*parent
)
342 panel
= wmalloc(sizeof(_Panel
));
343 memset(panel
, 0, sizeof(_Panel
));
345 panel
->sectionName
= _("Icon Preferences");
347 panel
->description
= _("Icon/Miniwindow handling options. Icon positioning\n"
348 "area, sizes of icons, miniaturization animation style.");
350 panel
->parent
= parent
;
352 panel
->callbacks
.createWidgets
= createPanel
;
353 panel
->callbacks
.updateDomain
= storeData
;
355 AddSection(panel
, ICON_FILE
);