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
{
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
);
102 #define MIN(a,b) ((a) < (b) ? (a) : (b))
105 showData(_Panel
*panel
)
111 WMSetButtonSelected(panel
->arrB
, GetBoolForKey("AutoArrangeIcons"));
113 WMSetButtonSelected(panel
->omnB
, GetBoolForKey("StickyIcons"));
115 str
= GetStringForKey("IconPosition");
118 if (strlen(str
)!=3) {
119 wwarning("bad value %s for option IconPosition. Using default blh",
124 if (str
[0]=='t' || str
[0]=='T') {
129 if (str
[1]=='r' || str
[1]=='R') {
132 if (str
[2]=='v' || str
[2]=='V') {
138 WMPerformButtonClick(panel
->posB
[i
]);
140 i
= GetIntegerForKey("IconSize");
147 WMSetPopUpButtonSelectedItem(panel
->sizeP
, i
);
149 str
= GetStringForKey("IconificationStyle");
152 if (strcasecmp(str
, "none")==0)
153 WMPerformButtonClick(panel
->animB
[3]);
154 else if (strcasecmp(str
, "twist")==0)
155 WMPerformButtonClick(panel
->animB
[1]);
156 else if (strcasecmp(str
, "flip")==0)
157 WMPerformButtonClick(panel
->animB
[2]);
159 WMPerformButtonClick(panel
->animB
[0]);
167 createPanel(Panel
*p
)
169 _Panel
*panel
= (_Panel
*)p
;
174 panel
->frame
= WMCreateFrame(panel
->win
);
175 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
176 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
178 /***************** Positioning of Icons *****************/
179 panel
->posF
= WMCreateFrame(panel
->frame
);
180 WMResizeWidget(panel
->posF
, 260, 135);
181 WMMoveWidget(panel
->posF
, 25, 10);
182 WMSetFrameTitle(panel
->posF
, _("Icon Positioning"));
184 for (i
=0; i
<8; i
++) {
185 panel
->posB
[i
] = WMCreateButton(panel
->posF
, WBTOnOff
);
186 WMSetButtonAction(panel
->posB
[i
], showIconLayout
, panel
);
189 WMGroupButtons(panel
->posB
[0], panel
->posB
[i
]);
191 WMMoveWidget(panel
->posB
[1], 70, 23);
192 WMResizeWidget(panel
->posB
[1], 47, 15);
193 WMMoveWidget(panel
->posB
[3], 70+47, 23);
194 WMResizeWidget(panel
->posB
[3], 47, 15);
196 WMMoveWidget(panel
->posB
[0], 55, 38);
197 WMResizeWidget(panel
->posB
[0], 15, 35);
198 WMMoveWidget(panel
->posB
[4], 55, 38+35);
199 WMResizeWidget(panel
->posB
[4], 15, 35);
201 WMMoveWidget(panel
->posB
[5], 70, 38+70);
202 WMResizeWidget(panel
->posB
[5], 47, 15);
203 WMMoveWidget(panel
->posB
[7], 70+47, 38+70);
204 WMResizeWidget(panel
->posB
[7], 47, 15);
206 WMMoveWidget(panel
->posB
[2], 70+95, 38);
207 WMResizeWidget(panel
->posB
[2], 15, 35);
208 WMMoveWidget(panel
->posB
[6], 70+95, 38+35);
209 WMResizeWidget(panel
->posB
[6], 15, 35);
211 color
= WMCreateRGBColor(WMWidgetScreen(panel
->win
), 0x5100, 0x5100,
213 panel
->posVF
= WMCreateFrame(panel
->posF
);
214 WMResizeWidget(panel
->posVF
, 95, 70);
215 WMMoveWidget(panel
->posVF
, 70, 38);
216 WMSetFrameRelief(panel
->posVF
, WRSunken
);
217 WMSetWidgetBackgroundColor(panel
->posVF
, color
);
218 WMReleaseColor(color
);
220 panel
->posV
= WMCreateFrame(panel
->posVF
);
221 WMSetFrameRelief(panel
->posV
, WRSimple
);
223 WMMapSubwidgets(panel
->posF
);
225 /***************** Animation ****************/
226 panel
->animF
= WMCreateFrame(panel
->frame
);
227 WMResizeWidget(panel
->animF
, 205, 135);
228 WMMoveWidget(panel
->animF
, 295, 10);
229 WMSetFrameTitle(panel
->animF
, _("Iconification Animation"));
231 for (i
=0; i
<4; i
++) {
232 panel
->animB
[i
] = WMCreateRadioButton(panel
->animF
);
233 WMResizeWidget(panel
->animB
[i
], 170, 20);
234 WMMoveWidget(panel
->animB
[i
], 20, 24+i
*25);
236 WMGroupButtons(panel
->animB
[0], panel
->animB
[1]);
237 WMGroupButtons(panel
->animB
[0], panel
->animB
[2]);
238 WMGroupButtons(panel
->animB
[0], panel
->animB
[3]);
240 WMSetButtonText(panel
->animB
[0], _("Shrinking/Zooming"));
241 WMSetButtonText(panel
->animB
[1], _("Spinning/Twisting"));
242 WMSetButtonText(panel
->animB
[2], _("3D-flipping"));
243 WMSetButtonText(panel
->animB
[3], _("None"));
245 WMMapSubwidgets(panel
->animF
);
247 /***************** Options ****************/
248 panel
->optF
= WMCreateFrame(panel
->frame
);
249 WMResizeWidget(panel
->optF
, 260, 70);
250 WMMoveWidget(panel
->optF
, 25, 150);
251 /* WMSetFrameTitle(panel->optF, _("Icon Display"));*/
253 panel
->arrB
= WMCreateSwitchButton(panel
->optF
);
254 WMResizeWidget(panel
->arrB
, 235, 20);
255 WMMoveWidget(panel
->arrB
, 15, 15);
256 WMSetButtonText(panel
->arrB
, _("Auto-arrange icons"));
258 WMSetBalloonTextForView(_("Keep icons and miniwindows arranged all the time."),
259 WMWidgetView(panel
->arrB
));
261 panel
->omnB
= WMCreateSwitchButton(panel
->optF
);
262 WMResizeWidget(panel
->omnB
, 235, 20);
263 WMMoveWidget(panel
->omnB
, 15, 40);
264 WMSetButtonText(panel
->omnB
, _("Omnipresent miniwindows"));
266 WMSetBalloonTextForView(_("Make miniwindows be present in all workspaces."),
267 WMWidgetView(panel
->omnB
));
269 WMMapSubwidgets(panel
->optF
);
271 /***************** Icon Size ****************/
272 panel
->sizeF
= WMCreateFrame(panel
->frame
);
273 WMResizeWidget(panel
->sizeF
, 205, 70);
274 WMMoveWidget(panel
->sizeF
, 295, 150);
275 WMSetFrameTitle(panel
->sizeF
, _("Icon Size"));
277 WMSetBalloonTextForView(_("The size of the dock/application icon and miniwindows"),
278 WMWidgetView(panel
->sizeF
));
280 panel
->sizeP
= WMCreatePopUpButton(panel
->sizeF
);
281 WMResizeWidget(panel
->sizeP
, 156, 20);
282 WMMoveWidget(panel
->sizeP
, 25, 30);
283 for (i
=24; i
<=96; i
+=8) {
284 sprintf(buf
, "%ix%i", i
, i
);
285 WMAddPopUpButtonItem(panel
->sizeP
, buf
);
288 WMMapSubwidgets(panel
->sizeF
);
290 WMRealizeWidget(panel
->frame
);
291 WMMapSubwidgets(panel
->frame
);
298 storeData(_Panel
*panel
)
302 SetBoolForKey(WMGetButtonSelected(panel
->arrB
), "AutoArrangeIcons");
303 SetBoolForKey(WMGetButtonSelected(panel
->omnB
), "StickyIcons");
305 SetIntegerForKey(WMGetPopUpButtonSelectedItem(panel
->sizeP
)*8+24,
310 if (panel
->iconPos
< 4) {
315 if (panel
->iconPos
& 2) {
320 if (panel
->iconPos
& 1) {
325 SetStringForKey(buf
, "IconPosition");
327 if (WMGetButtonSelected(panel
->animB
[0]))
328 SetStringForKey("zoom", "IconificationStyle");
329 else if (WMGetButtonSelected(panel
->animB
[1]))
330 SetStringForKey("twist", "IconificationStyle");
331 else if (WMGetButtonSelected(panel
->animB
[2]))
332 SetStringForKey("flip", "IconificationStyle");
334 SetStringForKey("none", "IconificationStyle");
340 InitIcons(WMScreen
*scr
, WMWindow
*win
)
344 panel
= wmalloc(sizeof(_Panel
));
345 memset(panel
, 0, sizeof(_Panel
));
347 panel
->sectionName
= _("Icon Preferences");
349 panel
->description
= _("Icon/Miniwindow handling options. Icon positioning\n"
350 "area, sizes of icons, miniaturization animation style.");
354 panel
->callbacks
.createWidgets
= createPanel
;
355 panel
->callbacks
.updateDomain
= storeData
;
357 AddSection(panel
, ICON_FILE
);