1 /* Icons.c- icon preferences
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998-2003 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,
25 typedef struct _Panel
{
32 CallbackRec callbacks
;
55 #define ICON_FILE "iconprefs"
57 static void showIconLayout(WMWidget
* widget
, void *data
)
59 _Panel
*panel
= (_Panel
*) data
;
63 for (i
= 0; i
< 8; i
++) {
64 if (panel
->posB
[i
] == widget
) {
70 if (panel
->iconPos
& 1) {
77 WMResizeWidget(panel
->posV
, w
, h
);
79 switch (panel
->iconPos
& ~1) {
81 WMMoveWidget(panel
->posV
, 2, 2);
84 WMMoveWidget(panel
->posV
, 95 - 2 - w
, 2);
87 WMMoveWidget(panel
->posV
, 2, 70 - 2 - h
);
90 WMMoveWidget(panel
->posV
, 95 - 2 - w
, 70 - 2 - h
);
95 static void showData(_Panel
* panel
)
101 WMSetButtonSelected(panel
->arrB
, GetBoolForKey("AutoArrangeIcons"));
103 WMSetButtonSelected(panel
->omnB
, GetBoolForKey("StickyIcons"));
105 str
= GetStringForKey("IconPosition");
108 if (strlen(str
) != 3) {
109 wwarning("bad value %s for option IconPosition. Using default blh", str
);
113 if (str
[0] == 't' || str
[0] == 'T') {
118 if (str
[1] == 'r' || str
[1] == 'R') {
121 if (str
[2] == 'v' || str
[2] == 'V') {
127 WMPerformButtonClick(panel
->posB
[i
]);
129 i
= GetIntegerForKey("IconSize");
136 WMSetPopUpButtonSelectedItem(panel
->sizeP
, i
);
138 str
= GetStringForKey("IconificationStyle");
141 if (strcasecmp(str
, "none") == 0)
142 WMPerformButtonClick(panel
->animB
[3]);
143 else if (strcasecmp(str
, "twist") == 0)
144 WMPerformButtonClick(panel
->animB
[1]);
145 else if (strcasecmp(str
, "flip") == 0)
146 WMPerformButtonClick(panel
->animB
[2]);
148 WMPerformButtonClick(panel
->animB
[0]);
152 static void createPanel(Panel
* p
)
154 _Panel
*panel
= (_Panel
*) p
;
159 panel
->box
= WMCreateBox(panel
->parent
);
160 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
162 /***************** Positioning of Icons *****************/
163 panel
->posF
= WMCreateFrame(panel
->box
);
164 WMResizeWidget(panel
->posF
, 260, 135);
165 WMMoveWidget(panel
->posF
, 25, 10);
166 WMSetFrameTitle(panel
->posF
, _("Icon Positioning"));
168 for (i
= 0; i
< 8; i
++) {
169 panel
->posB
[i
] = WMCreateButton(panel
->posF
, WBTOnOff
);
170 WMSetButtonAction(panel
->posB
[i
], showIconLayout
, panel
);
173 WMGroupButtons(panel
->posB
[0], panel
->posB
[i
]);
175 WMMoveWidget(panel
->posB
[1], 70, 23);
176 WMResizeWidget(panel
->posB
[1], 47, 15);
177 WMMoveWidget(panel
->posB
[3], 70 + 47, 23);
178 WMResizeWidget(panel
->posB
[3], 47, 15);
180 WMMoveWidget(panel
->posB
[0], 55, 38);
181 WMResizeWidget(panel
->posB
[0], 15, 35);
182 WMMoveWidget(panel
->posB
[4], 55, 38 + 35);
183 WMResizeWidget(panel
->posB
[4], 15, 35);
185 WMMoveWidget(panel
->posB
[5], 70, 38 + 70);
186 WMResizeWidget(panel
->posB
[5], 47, 15);
187 WMMoveWidget(panel
->posB
[7], 70 + 47, 38 + 70);
188 WMResizeWidget(panel
->posB
[7], 47, 15);
190 WMMoveWidget(panel
->posB
[2], 70 + 95, 38);
191 WMResizeWidget(panel
->posB
[2], 15, 35);
192 WMMoveWidget(panel
->posB
[6], 70 + 95, 38 + 35);
193 WMResizeWidget(panel
->posB
[6], 15, 35);
195 color
= WMCreateRGBColor(WMWidgetScreen(panel
->parent
), 0x5100, 0x5100, 0x7100, True
);
196 panel
->posVF
= WMCreateFrame(panel
->posF
);
197 WMResizeWidget(panel
->posVF
, 95, 70);
198 WMMoveWidget(panel
->posVF
, 70, 38);
199 WMSetFrameRelief(panel
->posVF
, WRSunken
);
200 WMSetWidgetBackgroundColor(panel
->posVF
, color
);
201 WMReleaseColor(color
);
203 panel
->posV
= WMCreateFrame(panel
->posVF
);
204 WMSetFrameRelief(panel
->posV
, WRSimple
);
206 WMMapSubwidgets(panel
->posF
);
208 /***************** Animation ****************/
209 panel
->animF
= WMCreateFrame(panel
->box
);
210 WMResizeWidget(panel
->animF
, 205, 135);
211 WMMoveWidget(panel
->animF
, 295, 10);
212 WMSetFrameTitle(panel
->animF
, _("Iconification Animation"));
214 for (i
= 0; i
< 4; i
++) {
215 panel
->animB
[i
] = WMCreateRadioButton(panel
->animF
);
216 WMResizeWidget(panel
->animB
[i
], 170, 20);
217 WMMoveWidget(panel
->animB
[i
], 20, 24 + i
* 25);
219 WMGroupButtons(panel
->animB
[0], panel
->animB
[1]);
220 WMGroupButtons(panel
->animB
[0], panel
->animB
[2]);
221 WMGroupButtons(panel
->animB
[0], panel
->animB
[3]);
223 WMSetButtonText(panel
->animB
[0], _("Shrinking/Zooming"));
224 WMSetButtonText(panel
->animB
[1], _("Spinning/Twisting"));
225 WMSetButtonText(panel
->animB
[2], _("3D-flipping"));
226 WMSetButtonText(panel
->animB
[3], _("None"));
228 WMMapSubwidgets(panel
->animF
);
230 /***************** Options ****************/
231 panel
->optF
= WMCreateFrame(panel
->box
);
232 WMResizeWidget(panel
->optF
, 260, 70);
233 WMMoveWidget(panel
->optF
, 25, 150);
234 /* WMSetFrameTitle(panel->optF, _("Icon Display")); */
236 panel
->arrB
= WMCreateSwitchButton(panel
->optF
);
237 WMResizeWidget(panel
->arrB
, 235, 20);
238 WMMoveWidget(panel
->arrB
, 15, 15);
239 WMSetButtonText(panel
->arrB
, _("Auto-arrange icons"));
241 WMSetBalloonTextForView(_("Keep icons and miniwindows arranged all the time."), WMWidgetView(panel
->arrB
));
243 panel
->omnB
= WMCreateSwitchButton(panel
->optF
);
244 WMResizeWidget(panel
->omnB
, 235, 20);
245 WMMoveWidget(panel
->omnB
, 15, 40);
246 WMSetButtonText(panel
->omnB
, _("Omnipresent miniwindows"));
248 WMSetBalloonTextForView(_("Make miniwindows be present in all workspaces."), WMWidgetView(panel
->omnB
));
250 WMMapSubwidgets(panel
->optF
);
252 /***************** Icon Size ****************/
253 panel
->sizeF
= WMCreateFrame(panel
->box
);
254 WMResizeWidget(panel
->sizeF
, 205, 70);
255 WMMoveWidget(panel
->sizeF
, 295, 150);
256 WMSetFrameTitle(panel
->sizeF
, _("Icon Size"));
258 WMSetBalloonTextForView(_("The size of the dock/application icon and miniwindows"),
259 WMWidgetView(panel
->sizeF
));
261 panel
->sizeP
= WMCreatePopUpButton(panel
->sizeF
);
262 WMResizeWidget(panel
->sizeP
, 156, 20);
263 WMMoveWidget(panel
->sizeP
, 25, 30);
264 for (i
= 24; i
<= 96; i
+= 8) {
265 sprintf(buf
, "%ix%i", i
, i
);
266 WMAddPopUpButtonItem(panel
->sizeP
, buf
);
269 WMMapSubwidgets(panel
->sizeF
);
271 WMRealizeWidget(panel
->box
);
272 WMMapSubwidgets(panel
->box
);
277 static void storeData(_Panel
* panel
)
281 SetBoolForKey(WMGetButtonSelected(panel
->arrB
), "AutoArrangeIcons");
282 SetBoolForKey(WMGetButtonSelected(panel
->omnB
), "StickyIcons");
284 SetIntegerForKey(WMGetPopUpButtonSelectedItem(panel
->sizeP
) * 8 + 24, "IconSize");
288 if (panel
->iconPos
< 4) {
293 if (panel
->iconPos
& 2) {
298 if (panel
->iconPos
& 1) {
303 SetStringForKey(buf
, "IconPosition");
305 if (WMGetButtonSelected(panel
->animB
[0]))
306 SetStringForKey("zoom", "IconificationStyle");
307 else if (WMGetButtonSelected(panel
->animB
[1]))
308 SetStringForKey("twist", "IconificationStyle");
309 else if (WMGetButtonSelected(panel
->animB
[2]))
310 SetStringForKey("flip", "IconificationStyle");
312 SetStringForKey("none", "IconificationStyle");
315 Panel
*InitIcons(WMScreen
* scr
, WMWidget
* parent
)
319 panel
= wmalloc(sizeof(_Panel
));
320 memset(panel
, 0, sizeof(_Panel
));
322 panel
->sectionName
= _("Icon Preferences");
324 panel
->description
= _("Icon/Miniwindow handling options. Icon positioning\n"
325 "area, sizes of icons, miniaturization animation style.");
327 panel
->parent
= parent
;
329 panel
->callbacks
.createWidgets
= createPanel
;
330 panel
->callbacks
.updateDomain
= storeData
;
332 AddSection(panel
, ICON_FILE
);