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 along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 typedef struct _Panel
{
31 CallbackRec callbacks
;
54 #define ICON_FILE "iconprefs"
56 static void showIconLayout(WMWidget
* widget
, void *data
)
58 _Panel
*panel
= (_Panel
*) data
;
62 for (i
= 0; i
< 8; i
++) {
63 if (panel
->posB
[i
] == widget
) {
69 if (panel
->iconPos
& 1) {
76 WMResizeWidget(panel
->posV
, w
, h
);
78 switch (panel
->iconPos
& ~1) {
80 WMMoveWidget(panel
->posV
, 2, 2);
83 WMMoveWidget(panel
->posV
, 95 - 2 - w
, 2);
86 WMMoveWidget(panel
->posV
, 2, 70 - 2 - h
);
89 WMMoveWidget(panel
->posV
, 95 - 2 - w
, 70 - 2 - h
);
94 static void showData(_Panel
* panel
)
100 WMSetButtonSelected(panel
->arrB
, GetBoolForKey("AutoArrangeIcons"));
102 WMSetButtonSelected(panel
->omnB
, GetBoolForKey("StickyIcons"));
104 str
= GetStringForKey("IconPosition");
107 if (strlen(str
) != 3) {
108 wwarning("bad value %s for option IconPosition. Using default blh", str
);
112 if (str
[0] == 't' || str
[0] == 'T') {
117 if (str
[1] == 'r' || str
[1] == 'R') {
120 if (str
[2] == 'v' || str
[2] == 'V') {
126 WMPerformButtonClick(panel
->posB
[i
]);
128 i
= GetIntegerForKey("IconSize");
135 WMSetPopUpButtonSelectedItem(panel
->sizeP
, i
);
137 str
= GetStringForKey("IconificationStyle");
140 if (strcasecmp(str
, "none") == 0)
141 WMPerformButtonClick(panel
->animB
[3]);
142 else if (strcasecmp(str
, "twist") == 0)
143 WMPerformButtonClick(panel
->animB
[1]);
144 else if (strcasecmp(str
, "flip") == 0)
145 WMPerformButtonClick(panel
->animB
[2]);
147 WMPerformButtonClick(panel
->animB
[0]);
151 static void createPanel(Panel
* p
)
153 _Panel
*panel
= (_Panel
*) p
;
158 panel
->box
= WMCreateBox(panel
->parent
);
159 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
161 /***************** Positioning of Icons *****************/
162 panel
->posF
= WMCreateFrame(panel
->box
);
163 WMResizeWidget(panel
->posF
, 260, 135);
164 WMMoveWidget(panel
->posF
, 25, 10);
165 WMSetFrameTitle(panel
->posF
, _("Icon Positioning"));
167 for (i
= 0; i
< 8; i
++) {
168 panel
->posB
[i
] = WMCreateButton(panel
->posF
, WBTOnOff
);
169 WMSetButtonAction(panel
->posB
[i
], showIconLayout
, panel
);
172 WMGroupButtons(panel
->posB
[0], panel
->posB
[i
]);
174 WMMoveWidget(panel
->posB
[1], 70, 23);
175 WMResizeWidget(panel
->posB
[1], 47, 15);
176 WMMoveWidget(panel
->posB
[3], 70 + 47, 23);
177 WMResizeWidget(panel
->posB
[3], 47, 15);
179 WMMoveWidget(panel
->posB
[0], 55, 38);
180 WMResizeWidget(panel
->posB
[0], 15, 35);
181 WMMoveWidget(panel
->posB
[4], 55, 38 + 35);
182 WMResizeWidget(panel
->posB
[4], 15, 35);
184 WMMoveWidget(panel
->posB
[5], 70, 38 + 70);
185 WMResizeWidget(panel
->posB
[5], 47, 15);
186 WMMoveWidget(panel
->posB
[7], 70 + 47, 38 + 70);
187 WMResizeWidget(panel
->posB
[7], 47, 15);
189 WMMoveWidget(panel
->posB
[2], 70 + 95, 38);
190 WMResizeWidget(panel
->posB
[2], 15, 35);
191 WMMoveWidget(panel
->posB
[6], 70 + 95, 38 + 35);
192 WMResizeWidget(panel
->posB
[6], 15, 35);
194 color
= WMCreateRGBColor(WMWidgetScreen(panel
->parent
), 0x5100, 0x5100, 0x7100, True
);
195 panel
->posVF
= WMCreateFrame(panel
->posF
);
196 WMResizeWidget(panel
->posVF
, 95, 70);
197 WMMoveWidget(panel
->posVF
, 70, 38);
198 WMSetFrameRelief(panel
->posVF
, WRSunken
);
199 WMSetWidgetBackgroundColor(panel
->posVF
, color
);
200 WMReleaseColor(color
);
202 panel
->posV
= WMCreateFrame(panel
->posVF
);
203 WMSetFrameRelief(panel
->posV
, WRSimple
);
205 WMMapSubwidgets(panel
->posF
);
207 /***************** Animation ****************/
208 panel
->animF
= WMCreateFrame(panel
->box
);
209 WMResizeWidget(panel
->animF
, 205, 135);
210 WMMoveWidget(panel
->animF
, 295, 10);
211 WMSetFrameTitle(panel
->animF
, _("Iconification Animation"));
213 for (i
= 0; i
< 4; i
++) {
214 panel
->animB
[i
] = WMCreateRadioButton(panel
->animF
);
215 WMResizeWidget(panel
->animB
[i
], 170, 20);
216 WMMoveWidget(panel
->animB
[i
], 20, 24 + i
* 25);
218 WMGroupButtons(panel
->animB
[0], panel
->animB
[1]);
219 WMGroupButtons(panel
->animB
[0], panel
->animB
[2]);
220 WMGroupButtons(panel
->animB
[0], panel
->animB
[3]);
222 WMSetButtonText(panel
->animB
[0], _("Shrinking/Zooming"));
223 WMSetButtonText(panel
->animB
[1], _("Spinning/Twisting"));
224 WMSetButtonText(panel
->animB
[2], _("3D-flipping"));
225 WMSetButtonText(panel
->animB
[3], _("None"));
227 WMMapSubwidgets(panel
->animF
);
229 /***************** Options ****************/
230 panel
->optF
= WMCreateFrame(panel
->box
);
231 WMResizeWidget(panel
->optF
, 260, 70);
232 WMMoveWidget(panel
->optF
, 25, 150);
233 /* WMSetFrameTitle(panel->optF, _("Icon Display")); */
235 panel
->arrB
= WMCreateSwitchButton(panel
->optF
);
236 WMResizeWidget(panel
->arrB
, 235, 20);
237 WMMoveWidget(panel
->arrB
, 15, 15);
238 WMSetButtonText(panel
->arrB
, _("Auto-arrange icons"));
240 WMSetBalloonTextForView(_("Keep icons and miniwindows arranged all the time."), WMWidgetView(panel
->arrB
));
242 panel
->omnB
= WMCreateSwitchButton(panel
->optF
);
243 WMResizeWidget(panel
->omnB
, 235, 20);
244 WMMoveWidget(panel
->omnB
, 15, 40);
245 WMSetButtonText(panel
->omnB
, _("Omnipresent miniwindows"));
247 WMSetBalloonTextForView(_("Make miniwindows be present in all workspaces."), WMWidgetView(panel
->omnB
));
249 WMMapSubwidgets(panel
->optF
);
251 /***************** Icon Size ****************/
252 panel
->sizeF
= WMCreateFrame(panel
->box
);
253 WMResizeWidget(panel
->sizeF
, 205, 70);
254 WMMoveWidget(panel
->sizeF
, 295, 150);
255 WMSetFrameTitle(panel
->sizeF
, _("Icon Size"));
257 WMSetBalloonTextForView(_("The size of the dock/application icon and miniwindows"),
258 WMWidgetView(panel
->sizeF
));
260 panel
->sizeP
= WMCreatePopUpButton(panel
->sizeF
);
261 WMResizeWidget(panel
->sizeP
, 156, 20);
262 WMMoveWidget(panel
->sizeP
, 25, 30);
263 for (i
= 24; i
<= 96; i
+= 8) {
264 sprintf(buf
, "%ix%i", i
, i
);
265 WMAddPopUpButtonItem(panel
->sizeP
, buf
);
268 WMMapSubwidgets(panel
->sizeF
);
270 WMRealizeWidget(panel
->box
);
271 WMMapSubwidgets(panel
->box
);
276 static void storeData(_Panel
* panel
)
280 SetBoolForKey(WMGetButtonSelected(panel
->arrB
), "AutoArrangeIcons");
281 SetBoolForKey(WMGetButtonSelected(panel
->omnB
), "StickyIcons");
283 SetIntegerForKey(WMGetPopUpButtonSelectedItem(panel
->sizeP
) * 8 + 24, "IconSize");
287 if (panel
->iconPos
< 4) {
292 if (panel
->iconPos
& 2) {
297 if (panel
->iconPos
& 1) {
302 SetStringForKey(buf
, "IconPosition");
304 if (WMGetButtonSelected(panel
->animB
[0]))
305 SetStringForKey("zoom", "IconificationStyle");
306 else if (WMGetButtonSelected(panel
->animB
[1]))
307 SetStringForKey("twist", "IconificationStyle");
308 else if (WMGetButtonSelected(panel
->animB
[2]))
309 SetStringForKey("flip", "IconificationStyle");
311 SetStringForKey("none", "IconificationStyle");
314 Panel
*InitIcons(WMScreen
* scr
, WMWidget
* parent
)
318 panel
= wmalloc(sizeof(_Panel
));
319 memset(panel
, 0, sizeof(_Panel
));
321 panel
->sectionName
= _("Icon Preferences");
323 panel
->description
= _("Icon/Miniwindow handling options. Icon positioning\n"
324 "area, sizes of icons, miniaturization animation style.");
326 panel
->parent
= parent
;
328 panel
->callbacks
.createWidgets
= createPanel
;
329 panel
->callbacks
.updateDomain
= storeData
;
331 AddSection(panel
, ICON_FILE
);