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
;
58 #define ICON_FILE "iconprefs"
62 showIconLayout(WMWidget
*widget
, void *data
)
64 _Panel
*panel
= (_Panel
*)data
;
67 if (WMGetButtonSelected(panel
->horB
)) {
74 WMResizeWidget(panel
->posV
, w
, h
);
76 if (WMGetButtonSelected(panel
->nwB
)) {
77 WMMoveWidget(panel
->posV
, 2, 2);
78 } else if (WMGetButtonSelected(panel
->neB
)) {
79 WMMoveWidget(panel
->posV
, 95-2-w
, 2);
80 } else if (WMGetButtonSelected(panel
->swB
)) {
81 WMMoveWidget(panel
->posV
, 2, 70-2-h
);
83 WMMoveWidget(panel
->posV
, 95-2-w
, 70-2-h
);
88 #define MIN(a,b) ((a) < (b) ? (a) : (b))
91 showData(_Panel
*panel
)
97 WMSetButtonSelected(panel
->arrB
, GetBoolForKey("AutoArrangeIcons"));
99 WMSetButtonSelected(panel
->omnB
, GetBoolForKey("StickyIcons"));
101 str
= GetStringForKey("IconPosition");
104 if (strlen(str
)!=3) {
105 wwarning("bad value %s for option IconPosition. Using default blh",
110 if (str
[0]=='t' || str
[0]=='T') {
111 if (str
[1]=='r' || str
[1]=='R') {
112 WMPerformButtonClick(panel
->neB
);
114 WMPerformButtonClick(panel
->nwB
);
117 if (str
[1]=='r' || str
[1]=='R') {
118 WMPerformButtonClick(panel
->seB
);
120 WMPerformButtonClick(panel
->swB
);
123 if (str
[2]=='v' || str
[2]=='V') {
124 WMPerformButtonClick(panel
->verB
);
126 WMPerformButtonClick(panel
->horB
);
129 i
= GetIntegerForKey("IconSize");
136 WMSetPopUpButtonSelectedItem(panel
->sizeP
, i
);
143 createPanel(Panel
*p
)
145 _Panel
*panel
= (_Panel
*)p
;
150 panel
->frame
= WMCreateFrame(panel
->win
);
151 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
152 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
154 /***************** Positioning of Icons *****************/
155 panel
->posF
= WMCreateFrame(panel
->frame
);
156 WMResizeWidget(panel
->posF
, 475, 135);
157 WMMoveWidget(panel
->posF
, 25, 10);
158 WMSetFrameTitle(panel
->posF
, _("Icon Positioning"));
160 panel
->nwB
= WMCreateRadioButton(panel
->posF
);
161 WMResizeWidget(panel
->nwB
, 110, 20);
162 WMMoveWidget(panel
->nwB
, 15, 25);
163 WMSetButtonImagePosition(panel
->nwB
, WIPRight
);
164 WMSetButtonTextAlignment(panel
->nwB
, WARight
);
165 WMSetButtonText(panel
->nwB
, "Top left");
166 WMSetButtonAction(panel
->nwB
, showIconLayout
, panel
);
168 panel
->neB
= WMCreateRadioButton(panel
->posF
);
169 WMResizeWidget(panel
->neB
, 110, 20);
170 WMMoveWidget(panel
->neB
, 230, 25);
171 WMSetButtonImagePosition(panel
->neB
, WIPLeft
);
172 WMSetButtonTextAlignment(panel
->neB
, WALeft
);
173 WMSetButtonText(panel
->neB
, "Top right");
174 WMSetButtonAction(panel
->neB
, showIconLayout
, panel
);
176 panel
->swB
= WMCreateRadioButton(panel
->posF
);
177 WMResizeWidget(panel
->swB
, 110, 20);
178 WMMoveWidget(panel
->swB
, 15, 95);
179 WMSetButtonText(panel
->swB
, "Bottom left");
180 WMSetButtonTextAlignment(panel
->swB
, WARight
);
181 WMSetButtonImagePosition(panel
->swB
, WIPRight
);
182 WMSetButtonAction(panel
->swB
, showIconLayout
, panel
);
184 panel
->seB
= WMCreateRadioButton(panel
->posF
);
185 WMResizeWidget(panel
->seB
, 110, 20);
186 WMMoveWidget(panel
->seB
, 230, 95);
187 WMSetButtonText(panel
->seB
, "Bottom right");
188 WMSetButtonAction(panel
->seB
, showIconLayout
, panel
);
190 WMGroupButtons(panel
->nwB
, panel
->neB
);
191 WMGroupButtons(panel
->nwB
, panel
->seB
);
192 WMGroupButtons(panel
->nwB
, panel
->swB
);
194 color
= WMCreateRGBColor(WMWidgetScreen(panel
->win
), 0x5100, 0x5100,
196 panel
->posVF
= WMCreateFrame(panel
->posF
);
197 WMResizeWidget(panel
->posVF
, 95, 70);
198 WMMoveWidget(panel
->posVF
, 130, 35);
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 panel
->verB
= WMCreateRadioButton(panel
->posF
);
207 WMResizeWidget(panel
->verB
, 120, 20);
208 WMMoveWidget(panel
->verB
, 345, 45);
209 WMSetButtonText(panel
->verB
, "Vertical");
210 WMSetButtonAction(panel
->verB
, showIconLayout
, panel
);
212 panel
->horB
= WMCreateRadioButton(panel
->posF
);
213 WMResizeWidget(panel
->horB
, 120, 20);
214 WMMoveWidget(panel
->horB
, 345, 80);
215 WMSetButtonText(panel
->horB
, "Horizontal");
216 WMSetButtonAction(panel
->horB
, showIconLayout
, panel
);
219 WMGroupButtons(panel
->horB
, panel
->verB
);
221 WMMapSubwidgets(panel
->posF
);
223 /***************** Options ****************/
224 panel
->optF
= WMCreateFrame(panel
->frame
);
225 WMResizeWidget(panel
->optF
, 260, 65);
226 WMMoveWidget(panel
->optF
, 25, 155);
228 panel
->arrB
= WMCreateSwitchButton(panel
->optF
);
229 WMResizeWidget(panel
->arrB
, 235, 20);
230 WMMoveWidget(panel
->arrB
, 15, 10);
231 WMSetButtonText(panel
->arrB
, _("Auto-arrange icons"));
233 panel
->omnB
= WMCreateSwitchButton(panel
->optF
);
234 WMResizeWidget(panel
->omnB
, 235, 20);
235 WMMoveWidget(panel
->omnB
, 15, 35);
236 WMSetButtonText(panel
->omnB
, _("Omnipresent miniwindows"));
238 WMMapSubwidgets(panel
->optF
);
240 /***************** Icon Size ****************/
241 panel
->sizeF
= WMCreateFrame(panel
->frame
);
242 WMResizeWidget(panel
->sizeF
, 205, 70);
243 WMMoveWidget(panel
->sizeF
, 295, 150);
244 WMSetFrameTitle(panel
->sizeF
, _("Icon Size"));
247 panel
->sizeP
= WMCreatePopUpButton(panel
->sizeF
);
248 WMResizeWidget(panel
->sizeP
, 156, 20);
249 WMMoveWidget(panel
->sizeP
, 25, 30);
250 for (i
=24; i
<=96; i
+=8) {
251 sprintf(buf
, "%ix%i", i
, i
);
252 WMAddPopUpButtonItem(panel
->sizeP
, buf
);
255 WMMapSubwidgets(panel
->sizeF
);
257 WMRealizeWidget(panel
->frame
);
258 WMMapSubwidgets(panel
->frame
);
265 storeData(_Panel
*panel
)
269 SetBoolForKey(WMGetButtonSelected(panel
->arrB
), "AutoArrangeIcons");
270 SetBoolForKey(WMGetButtonSelected(panel
->omnB
), "StickyIcons");
272 SetIntegerForKey(WMGetPopUpButtonSelectedItem(panel
->sizeP
)*8+24,
276 if (WMGetButtonSelected(panel
->nwB
)) {
279 } else if (WMGetButtonSelected(panel
->neB
)) {
282 } else if (WMGetButtonSelected(panel
->swB
)) {
290 if (WMGetButtonSelected(panel
->horB
)) {
295 SetStringForKey(buf
, "IconPosition");
301 InitIcons(WMScreen
*scr
, WMWindow
*win
)
305 panel
= wmalloc(sizeof(_Panel
));
306 memset(panel
, 0, sizeof(_Panel
));
308 panel
->sectionName
= _("Icon Preferences");
312 panel
->callbacks
.createWidgets
= createPanel
;
313 panel
->callbacks
.updateDomain
= storeData
;
315 AddSection(panel
, ICON_FILE
);