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
;
61 #define ICON_FILE "iconprefs"
65 showIconLayout(WMWidget
*widget
, void *data
)
67 _Panel
*panel
= (_Panel
*)data
;
70 if (WMGetButtonSelected(panel
->horB
)) {
77 WMResizeWidget(panel
->posV
, w
, h
);
79 if (WMGetButtonSelected(panel
->nwB
)) {
80 WMMoveWidget(panel
->posV
, 2, 2);
81 } else if (WMGetButtonSelected(panel
->neB
)) {
82 WMMoveWidget(panel
->posV
, 95-2-w
, 2);
83 } else if (WMGetButtonSelected(panel
->swB
)) {
84 WMMoveWidget(panel
->posV
, 2, 70-2-h
);
86 WMMoveWidget(panel
->posV
, 95-2-w
, 70-2-h
);
91 #define MIN(a,b) ((a) < (b) ? (a) : (b))
94 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",
113 if (str
[0]=='t' || str
[0]=='T') {
114 if (str
[1]=='r' || str
[1]=='R') {
115 WMPerformButtonClick(panel
->neB
);
117 WMPerformButtonClick(panel
->nwB
);
120 if (str
[1]=='r' || str
[1]=='R') {
121 WMPerformButtonClick(panel
->seB
);
123 WMPerformButtonClick(panel
->swB
);
126 if (str
[2]=='v' || str
[2]=='V') {
127 WMPerformButtonClick(panel
->verB
);
129 WMPerformButtonClick(panel
->horB
);
132 i
= GetIntegerForKey("IconSize");
139 WMSetPopUpButtonSelectedItem(panel
->sizeP
, i
);
141 str
= GetStringForKey("IconificationStyle");
142 if (strcasecmp(str
, "none")==0)
143 WMPerformButtonClick(panel
->animB
[3]);
144 else if (strcasecmp(str
, "twist")==0)
145 WMPerformButtonClick(panel
->animB
[1]);
146 else if (strcasecmp(str
, "flip")==0)
147 WMPerformButtonClick(panel
->animB
[2]);
149 WMPerformButtonClick(panel
->animB
[0]);
157 createPanel(Panel
*p
)
159 _Panel
*panel
= (_Panel
*)p
;
164 panel
->frame
= WMCreateFrame(panel
->win
);
165 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
166 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
168 /***************** Positioning of Icons *****************/
169 panel
->posF
= WMCreateFrame(panel
->frame
);
170 WMResizeWidget(panel
->posF
, 260, 135);
171 WMMoveWidget(panel
->posF
, 25, 10);
172 WMSetFrameTitle(panel
->posF
, _("Icon Positioning"));
174 panel
->nwB
= WMCreateButton(panel
->posF
, WBTOnOff
);
175 WMResizeWidget(panel
->nwB
, 24, 24);
176 WMMoveWidget(panel
->nwB
, 15, 25);
177 WMSetButtonAction(panel
->nwB
, showIconLayout
, panel
);
179 panel
->neB
= WMCreateButton(panel
->posF
, WBTOnOff
);
180 WMResizeWidget(panel
->neB
, 24, 24);
181 WMMoveWidget(panel
->neB
, 115, 25);
182 WMSetButtonAction(panel
->neB
, showIconLayout
, panel
);
184 panel
->swB
= WMCreateButton(panel
->posF
, WBTOnOff
);
185 WMResizeWidget(panel
->swB
, 24, 24);
186 WMMoveWidget(panel
->swB
, 15, 100);
187 WMSetButtonAction(panel
->swB
, showIconLayout
, panel
);
189 panel
->seB
= WMCreateButton(panel
->posF
, WBTOnOff
);
190 WMResizeWidget(panel
->seB
, 24, 24);
191 WMMoveWidget(panel
->seB
, 115, 100);
192 WMSetButtonAction(panel
->seB
, showIconLayout
, panel
);
194 WMGroupButtons(panel
->nwB
, panel
->neB
);
195 WMGroupButtons(panel
->nwB
, panel
->seB
);
196 WMGroupButtons(panel
->nwB
, panel
->swB
);
198 color
= WMCreateRGBColor(WMWidgetScreen(panel
->win
), 0x5100, 0x5100,
200 panel
->posVF
= WMCreateFrame(panel
->posF
);
201 WMResizeWidget(panel
->posVF
, 95, 70);
202 WMMoveWidget(panel
->posVF
, 30, 38);
203 WMSetFrameRelief(panel
->posVF
, WRSunken
);
204 WMSetWidgetBackgroundColor(panel
->posVF
, color
);
205 WMReleaseColor(color
);
207 panel
->posV
= WMCreateFrame(panel
->posVF
);
208 WMSetFrameRelief(panel
->posV
, WRSimple
);
210 panel
->verB
= WMCreateRadioButton(panel
->posF
);
211 WMResizeWidget(panel
->verB
, 105, 20);
212 WMMoveWidget(panel
->verB
, 150, 45);
213 WMSetButtonText(panel
->verB
, "Vertical");
214 WMSetButtonAction(panel
->verB
, showIconLayout
, panel
);
216 panel
->horB
= WMCreateRadioButton(panel
->posF
);
217 WMResizeWidget(panel
->horB
, 105, 20);
218 WMMoveWidget(panel
->horB
, 150, 75);
219 WMSetButtonText(panel
->horB
, "Horizontal");
220 WMSetButtonAction(panel
->horB
, showIconLayout
, panel
);
223 WMGroupButtons(panel
->horB
, panel
->verB
);
225 WMMapSubwidgets(panel
->posF
);
227 /***************** Animation ****************/
228 panel
->animF
= WMCreateFrame(panel
->frame
);
229 WMResizeWidget(panel
->animF
, 205, 135);
230 WMMoveWidget(panel
->animF
, 295, 10);
231 WMSetFrameTitle(panel
->animF
, _("Iconification Animation"));
233 for (i
=0; i
<4; i
++) {
234 panel
->animB
[i
] = WMCreateRadioButton(panel
->animF
);
235 WMResizeWidget(panel
->animB
[i
], 170, 20);
236 WMMoveWidget(panel
->animB
[i
], 20, 24+i
*25);
238 WMGroupButtons(panel
->animB
[0], panel
->animB
[1]);
239 WMGroupButtons(panel
->animB
[0], panel
->animB
[2]);
240 WMGroupButtons(panel
->animB
[0], panel
->animB
[3]);
242 WMSetButtonText(panel
->animB
[0], _("Shrinking/Zooming"));
243 WMSetButtonText(panel
->animB
[1], _("Spinning/Twisting"));
244 WMSetButtonText(panel
->animB
[2], _("3D-flipping"));
245 WMSetButtonText(panel
->animB
[3], _("None"));
247 WMMapSubwidgets(panel
->animF
);
249 /***************** Options ****************/
250 panel
->optF
= WMCreateFrame(panel
->frame
);
251 WMResizeWidget(panel
->optF
, 260, 65);
252 WMMoveWidget(panel
->optF
, 25, 155);
254 panel
->arrB
= WMCreateSwitchButton(panel
->optF
);
255 WMResizeWidget(panel
->arrB
, 235, 20);
256 WMMoveWidget(panel
->arrB
, 15, 10);
257 WMSetButtonText(panel
->arrB
, _("Auto-arrange icons"));
259 panel
->omnB
= WMCreateSwitchButton(panel
->optF
);
260 WMResizeWidget(panel
->omnB
, 235, 20);
261 WMMoveWidget(panel
->omnB
, 15, 35);
262 WMSetButtonText(panel
->omnB
, _("Omnipresent miniwindows"));
264 WMMapSubwidgets(panel
->optF
);
266 /***************** Icon Size ****************/
267 panel
->sizeF
= WMCreateFrame(panel
->frame
);
268 WMResizeWidget(panel
->sizeF
, 205, 70);
269 WMMoveWidget(panel
->sizeF
, 295, 150);
270 WMSetFrameTitle(panel
->sizeF
, _("Icon Size"));
273 panel
->sizeP
= WMCreatePopUpButton(panel
->sizeF
);
274 WMResizeWidget(panel
->sizeP
, 156, 20);
275 WMMoveWidget(panel
->sizeP
, 25, 30);
276 for (i
=24; i
<=96; i
+=8) {
277 sprintf(buf
, "%ix%i", i
, i
);
278 WMAddPopUpButtonItem(panel
->sizeP
, buf
);
281 WMMapSubwidgets(panel
->sizeF
);
283 WMRealizeWidget(panel
->frame
);
284 WMMapSubwidgets(panel
->frame
);
291 storeData(_Panel
*panel
)
295 SetBoolForKey(WMGetButtonSelected(panel
->arrB
), "AutoArrangeIcons");
296 SetBoolForKey(WMGetButtonSelected(panel
->omnB
), "StickyIcons");
298 SetIntegerForKey(WMGetPopUpButtonSelectedItem(panel
->sizeP
)*8+24,
302 if (WMGetButtonSelected(panel
->nwB
)) {
305 } else if (WMGetButtonSelected(panel
->neB
)) {
308 } else if (WMGetButtonSelected(panel
->swB
)) {
316 if (WMGetButtonSelected(panel
->horB
)) {
321 SetStringForKey(buf
, "IconPosition");
323 if (WMGetButtonSelected(panel
->animB
[0]))
324 SetStringForKey("zoom", "IconificationStyle");
325 else if (WMGetButtonSelected(panel
->animB
[1]))
326 SetStringForKey("twist", "IconificationStyle");
327 else if (WMGetButtonSelected(panel
->animB
[2]))
328 SetStringForKey("flip", "IconificationStyle");
330 SetStringForKey("none", "IconificationStyle");
336 InitIcons(WMScreen
*scr
, WMWindow
*win
)
340 panel
= wmalloc(sizeof(_Panel
));
341 memset(panel
, 0, sizeof(_Panel
));
343 panel
->sectionName
= _("Icon Preferences");
347 panel
->callbacks
.createWidgets
= createPanel
;
348 panel
->callbacks
.updateDomain
= storeData
;
350 AddSection(panel
, ICON_FILE
);