Workspace clip creation in two steps
[wmaker-crm.git] / WPrefs.app / Icons.c
blob98352a1b9ea9cb348256eb1725eec9bb5588fb8f
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.
22 #include "WPrefs.h"
24 typedef struct _Panel {
25 WMBox *box;
27 char *sectionName;
29 char *description;
31 CallbackRec callbacks;
33 WMWidget *parent;
35 WMFrame *posF;
36 WMFrame *posVF;
37 WMFrame *posV;
39 WMButton *posB[8];
41 WMFrame *animF;
42 WMButton *animB[4];
44 WMFrame *optF;
45 WMButton *arrB;
46 WMButton *omnB;
47 WMButton *sclB;
49 WMFrame *sizeF;
50 WMPopUpButton *sizeP;
52 int iconPos;
53 } _Panel;
55 #define ICON_FILE "iconprefs"
57 static void showIconLayout(WMWidget * widget, void *data)
59 _Panel *panel = (_Panel *) data;
60 int w, h;
61 int i;
63 for (i = 0; i < 8; i++) {
64 if (panel->posB[i] == widget) {
65 panel->iconPos = i;
66 break;
70 if (panel->iconPos & 1) {
71 w = 32;
72 h = 8;
73 } else {
74 w = 8;
75 h = 32;
77 WMResizeWidget(panel->posV, w, h);
79 switch (panel->iconPos & ~1) {
80 case 0:
81 WMMoveWidget(panel->posV, 2, 2);
82 break;
83 case 2:
84 WMMoveWidget(panel->posV, 95 - 2 - w, 2);
85 break;
86 case 4:
87 WMMoveWidget(panel->posV, 2, 70 - 2 - h);
88 break;
89 default:
90 WMMoveWidget(panel->posV, 95 - 2 - w, 70 - 2 - h);
91 break;
95 static void showData(_Panel * panel)
97 int i;
98 char *str;
99 char *def = "blh";
101 WMSetButtonSelected(panel->arrB, GetBoolForKey("AutoArrangeIcons"));
102 WMSetButtonSelected(panel->omnB, GetBoolForKey("StickyIcons"));
103 WMSetButtonSelected(panel->sclB, GetBoolForKey("SingleClickLaunch"));
105 str = GetStringForKey("IconPosition");
106 if (!str)
107 str = def;
108 if (strlen(str) != 3) {
109 wwarning("bad value %s for option IconPosition. Using default blh", str);
110 str = def;
113 if (str[0] == 't' || str[0] == 'T') {
114 i = 0;
115 } else {
116 i = 4;
118 if (str[1] == 'r' || str[1] == 'R') {
119 i += 2;
121 if (str[2] == 'v' || str[2] == 'V') {
122 i += 0;
123 } else {
124 i += 1;
126 panel->iconPos = i;
127 WMPerformButtonClick(panel->posB[i]);
129 i = GetIntegerForKey("IconSize");
130 i = (i - 24) / 8;
132 if (i < 0)
133 i = 0;
134 else if (i > 9)
135 i = 9;
136 WMSetPopUpButtonSelectedItem(panel->sizeP, i);
138 str = GetStringForKey("IconificationStyle");
139 if (!str)
140 str = "zoom";
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]);
147 else {
148 WMPerformButtonClick(panel->animB[0]);
152 static void createPanel(Panel * p)
154 _Panel *panel = (_Panel *) p;
155 WMColor *color;
156 int i;
157 char buf[16];
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, 210, 140);
165 WMMoveWidget(panel->posF, 20, 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);
172 if (i > 0)
173 WMGroupButtons(panel->posB[0], panel->posB[i]);
175 WMMoveWidget(panel->posB[1], 58, 25);
176 WMResizeWidget(panel->posB[1], 47, 15);
177 WMMoveWidget(panel->posB[3], 58 + 47, 25);
178 WMResizeWidget(panel->posB[3], 47, 15);
180 WMMoveWidget(panel->posB[0], 43, 40);
181 WMResizeWidget(panel->posB[0], 15, 35);
182 WMMoveWidget(panel->posB[4], 43, 40 + 35);
183 WMResizeWidget(panel->posB[4], 15, 35);
185 WMMoveWidget(panel->posB[5], 58, 40 + 70);
186 WMResizeWidget(panel->posB[5], 47, 15);
187 WMMoveWidget(panel->posB[7], 58 + 47, 40 + 70);
188 WMResizeWidget(panel->posB[7], 47, 15);
190 WMMoveWidget(panel->posB[2], 58 + 95, 40);
191 WMResizeWidget(panel->posB[2], 15, 35);
192 WMMoveWidget(panel->posB[6], 58 + 95, 40 + 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, 58, 40);
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 /***************** Icon Size ****************/
209 panel->sizeF = WMCreateFrame(panel->box);
210 WMResizeWidget(panel->sizeF, 210, 70);
211 WMMoveWidget(panel->sizeF, 20, 155);
212 WMSetFrameTitle(panel->sizeF, _("Icon Size"));
214 WMSetBalloonTextForView(_("The size of the dock/application icon and miniwindows"),
215 WMWidgetView(panel->sizeF));
217 panel->sizeP = WMCreatePopUpButton(panel->sizeF);
218 WMResizeWidget(panel->sizeP, 161, 20);
219 WMMoveWidget(panel->sizeP, 25, 30);
220 for (i = 24; i <= 96; i += 8) {
221 sprintf(buf, "%ix%i", i, i);
222 WMAddPopUpButtonItem(panel->sizeP, buf);
225 WMMapSubwidgets(panel->sizeF);
227 /***************** Animation ****************/
228 panel->animF = WMCreateFrame(panel->box);
229 WMResizeWidget(panel->animF, 260, 110);
230 WMMoveWidget(panel->animF, 240, 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], 145, 20);
236 WMMoveWidget(panel->animB[i], 15, 18 + i * 22);
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->box);
251 WMResizeWidget(panel->optF, 260, 95);
252 WMMoveWidget(panel->optF, 240, 130);
253 /* WMSetFrameTitle(panel->optF, _("Icon Display")); */
255 panel->arrB = WMCreateSwitchButton(panel->optF);
256 WMResizeWidget(panel->arrB, 235, 20);
257 WMMoveWidget(panel->arrB, 15, 10);
258 WMSetButtonText(panel->arrB, _("Auto-arrange icons"));
260 WMSetBalloonTextForView(_("Keep icons and miniwindows arranged all the time."), WMWidgetView(panel->arrB));
262 panel->omnB = WMCreateSwitchButton(panel->optF);
263 WMResizeWidget(panel->omnB, 235, 20);
264 WMMoveWidget(panel->omnB, 15, 37);
265 WMSetButtonText(panel->omnB, _("Omnipresent miniwindows"));
267 WMSetBalloonTextForView(_("Make miniwindows be present in all workspaces."), WMWidgetView(panel->omnB));
269 panel->sclB = WMCreateSwitchButton(panel->optF);
270 WMResizeWidget(panel->sclB, 235, 28);
271 WMMoveWidget(panel->sclB, 15, 60);
272 WMSetButtonText(panel->sclB, _("Single click activation"));
274 WMSetBalloonTextForView(_("Launch applications and restore windows with a single click."), WMWidgetView(panel->sclB));
276 WMMapSubwidgets(panel->optF);
278 WMRealizeWidget(panel->box);
279 WMMapSubwidgets(panel->box);
281 showData(panel);
284 static void storeData(_Panel * panel)
286 char buf[8];
288 SetBoolForKey(WMGetButtonSelected(panel->arrB), "AutoArrangeIcons");
289 SetBoolForKey(WMGetButtonSelected(panel->omnB), "StickyIcons");
290 SetBoolForKey(WMGetButtonSelected(panel->sclB), "SingleClickLaunch");
292 SetIntegerForKey(WMGetPopUpButtonSelectedItem(panel->sizeP) * 8 + 24, "IconSize");
294 buf[3] = 0;
296 if (panel->iconPos < 4) {
297 buf[0] = 't';
298 } else {
299 buf[0] = 'b';
301 if (panel->iconPos & 2) {
302 buf[1] = 'r';
303 } else {
304 buf[1] = 'l';
306 if (panel->iconPos & 1) {
307 buf[2] = 'h';
308 } else {
309 buf[2] = 'v';
311 SetStringForKey(buf, "IconPosition");
313 if (WMGetButtonSelected(panel->animB[0]))
314 SetStringForKey("zoom", "IconificationStyle");
315 else if (WMGetButtonSelected(panel->animB[1]))
316 SetStringForKey("twist", "IconificationStyle");
317 else if (WMGetButtonSelected(panel->animB[2]))
318 SetStringForKey("flip", "IconificationStyle");
319 else
320 SetStringForKey("none", "IconificationStyle");
323 Panel *InitIcons(WMScreen * scr, WMWidget * parent)
325 _Panel *panel;
327 panel = wmalloc(sizeof(_Panel));
329 panel->sectionName = _("Icon Preferences");
331 panel->description = _("Icon/Miniwindow handling options. Icon positioning\n"
332 "area, sizes of icons, miniaturization animation style.");
334 panel->parent = parent;
336 panel->callbacks.createWidgets = createPanel;
337 panel->callbacks.updateDomain = storeData;
339 AddSection(panel, ICON_FILE);
341 return panel;