wmaker: add miniwindow apercu
[wmaker-crm.git] / WPrefs.app / Preferences.c
blobb6b78913c11034062b4d97fc8467b94066a7800b
1 /* Preferences.c- misc ergonomic 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 *sizeF;
36 WMPopUpButton *sizeP;
38 WMFrame *posiF;
39 WMPopUpButton *posiP;
41 WMFrame *ballF;
42 WMButton *ballB[5];
44 WMFrame *optF;
45 WMButton *bounceB;
46 WMButton *bounceUrgB;
47 WMButton *bounceRaisB;
49 WMFrame *borderF;
50 WMSlider *borderS;
51 WMLabel *borderL;
52 WMButton *lrB;
53 WMButton *tbB;
55 } _Panel;
57 #define ICON_FILE "ergonomic"
59 static void borderCallback(WMWidget * w, void *data)
61 _Panel *panel = (_Panel *) data;
62 char buffer[64];
63 int i;
65 /* Parameter not used, but tell the compiler that it is ok */
66 (void) w;
68 i = WMGetSliderValue(panel->borderS);
70 if (i == 0)
71 sprintf(buffer, _("OFF"));
72 else if (i == 1)
73 sprintf(buffer, _("1 pixel"));
74 else if (i <= 4)
75 /* 2-4 */
76 sprintf(buffer, _("%i pixels"), i);
77 else
78 /* >4 */
79 sprintf(buffer, _("%i pixels "), i); /* note space! */
80 WMSetLabelText(panel->borderL, buffer);
83 static void showData(_Panel * panel)
85 char *str;
86 int x;
88 str = GetStringForKey("ResizeDisplay");
89 if (!str)
90 str = "corner";
91 if (strcasecmp(str, "corner") == 0)
92 WMSetPopUpButtonSelectedItem(panel->sizeP, 0);
93 else if (strcasecmp(str, "center") == 0)
94 WMSetPopUpButtonSelectedItem(panel->sizeP, 1);
95 else if (strcasecmp(str, "floating") == 0)
96 WMSetPopUpButtonSelectedItem(panel->sizeP, 2);
97 else if (strcasecmp(str, "line") == 0)
98 WMSetPopUpButtonSelectedItem(panel->sizeP, 3);
99 else if (strcasecmp(str, "none") == 0)
100 WMSetPopUpButtonSelectedItem(panel->sizeP, 4);
102 str = GetStringForKey("MoveDisplay");
103 if (!str)
104 str = "corner";
105 if (strcasecmp(str, "corner") == 0)
106 WMSetPopUpButtonSelectedItem(panel->posiP, 0);
107 else if (strcasecmp(str, "center") == 0)
108 WMSetPopUpButtonSelectedItem(panel->posiP, 1);
109 else if (strcasecmp(str, "floating") == 0)
110 WMSetPopUpButtonSelectedItem(panel->posiP, 2);
111 else if (strcasecmp(str, "none") == 0)
112 WMSetPopUpButtonSelectedItem(panel->posiP, 3);
114 x = GetIntegerForKey("WorkspaceBorderSize");
115 x = x < 0 ? 0 : x;
116 x = x > 5 ? 5 : x;
117 WMSetSliderValue(panel->borderS, x);
118 borderCallback(NULL, panel);
120 str = GetStringForKey("WorkspaceBorder");
121 if (!str)
122 str = "none";
123 if (strcasecmp(str, "LeftRight") == 0) {
124 WMSetButtonSelected(panel->lrB, True);
125 } else if (strcasecmp(str, "TopBottom") == 0) {
126 WMSetButtonSelected(panel->tbB, True);
127 } else if (strcasecmp(str, "AllDirections") == 0) {
128 WMSetButtonSelected(panel->tbB, True);
129 WMSetButtonSelected(panel->lrB, True);
132 WMSetButtonSelected(panel->bounceB, GetBoolForKey("DoNotMakeAppIconsBounce"));
133 if (GetStringForKey("BounceAppIconsWhenUrgent"))
134 WMSetButtonSelected(panel->bounceUrgB, GetBoolForKey("BounceAppIconsWhenUrgent"));
135 WMSetButtonSelected(panel->bounceRaisB, GetBoolForKey("RaiseAppIconsWhenBouncing"));
137 WMSetButtonSelected(panel->ballB[0], GetBoolForKey("WindowTitleBalloons"));
138 WMSetButtonSelected(panel->ballB[1], GetBoolForKey("MiniwindowTitleBalloons"));
139 WMSetButtonSelected(panel->ballB[2], GetBoolForKey("MiniwindowApercuBalloons"));
140 WMSetButtonSelected(panel->ballB[3], GetBoolForKey("AppIconBalloons"));
141 WMSetButtonSelected(panel->ballB[4], GetBoolForKey("HelpBalloons"));
144 static void storeData(_Panel * panel)
146 char *str;
147 Bool lr, tb;
149 switch (WMGetPopUpButtonSelectedItem(panel->sizeP)) {
150 case 0:
151 str = "corner";
152 break;
153 case 1:
154 str = "center";
155 break;
156 case 2:
157 str = "floating";
158 break;
159 case 4:
160 str = "none";
161 break;
162 default:
163 str = "line";
164 break;
166 SetStringForKey(str, "ResizeDisplay");
168 switch (WMGetPopUpButtonSelectedItem(panel->posiP)) {
169 case 0:
170 str = "corner";
171 break;
172 case 1:
173 str = "center";
174 break;
175 case 3:
176 str = "none";
177 break;
178 default:
179 str = "floating";
180 break;
182 SetStringForKey(str, "MoveDisplay");
184 lr = WMGetButtonSelected(panel->lrB);
185 tb = WMGetButtonSelected(panel->tbB);
186 if (lr && tb)
187 str = "AllDirections";
188 else if (lr)
189 str = "LeftRight";
190 else if (tb)
191 str = "TopBottom";
192 else
193 str = "None";
194 SetStringForKey(str, "WorkspaceBorder");
195 SetIntegerForKey(WMGetSliderValue(panel->borderS), "WorkspaceBorderSize");
197 SetBoolForKey(WMGetButtonSelected(panel->bounceB), "DoNotMakeAppIconsBounce");
198 SetBoolForKey(WMGetButtonSelected(panel->bounceUrgB), "BounceAppIconsWhenUrgent");
199 SetBoolForKey(WMGetButtonSelected(panel->bounceRaisB), "RaiseAppIconsWhenBouncing");
200 SetBoolForKey(WMGetButtonSelected(panel->ballB[0]), "WindowTitleBalloons");
201 SetBoolForKey(WMGetButtonSelected(panel->ballB[1]), "MiniwindowTitleBalloons");
202 SetBoolForKey(WMGetButtonSelected(panel->ballB[2]), "MiniwindowApercuBalloons");
203 SetBoolForKey(WMGetButtonSelected(panel->ballB[3]), "AppIconBalloons");
204 SetBoolForKey(WMGetButtonSelected(panel->ballB[4]), "HelpBalloons");
207 static void createPanel(Panel * p)
209 _Panel *panel = (_Panel *) p;
210 int i;
212 panel->box = WMCreateBox(panel->parent);
213 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
215 /***************** Size Display ****************/
216 panel->sizeF = WMCreateFrame(panel->box);
217 WMResizeWidget(panel->sizeF, 240, 60);
218 WMMoveWidget(panel->sizeF, 15, 10);
219 WMSetFrameTitle(panel->sizeF, _("Size Display"));
221 WMSetBalloonTextForView(_("The position or style of the window size\n"
222 "display that's shown when a window is resized."), WMWidgetView(panel->sizeF));
224 panel->sizeP = WMCreatePopUpButton(panel->sizeF);
225 WMResizeWidget(panel->sizeP, 200, 20);
226 WMMoveWidget(panel->sizeP, 20, 24);
227 WMAddPopUpButtonItem(panel->sizeP, _("Corner of screen"));
228 WMAddPopUpButtonItem(panel->sizeP, _("Center of screen"));
229 WMAddPopUpButtonItem(panel->sizeP, _("Center of resized window"));
230 WMAddPopUpButtonItem(panel->sizeP, _("Technical drawing-like"));
231 WMAddPopUpButtonItem(panel->sizeP, _("Disabled"));
233 WMMapSubwidgets(panel->sizeF);
235 /***************** Position Display ****************/
236 panel->posiF = WMCreateFrame(panel->box);
237 WMResizeWidget(panel->posiF, 240, 60);
238 WMMoveWidget(panel->posiF, 15, 75);
239 WMSetFrameTitle(panel->posiF, _("Position Display"));
241 WMSetBalloonTextForView(_("The position or style of the window position\n"
242 "display that's shown when a window is moved."), WMWidgetView(panel->posiF));
244 panel->posiP = WMCreatePopUpButton(panel->posiF);
245 WMResizeWidget(panel->posiP, 200, 20);
246 WMMoveWidget(panel->posiP, 20, 24);
247 WMAddPopUpButtonItem(panel->posiP, _("Corner of screen"));
248 WMAddPopUpButtonItem(panel->posiP, _("Center of screen"));
249 WMAddPopUpButtonItem(panel->posiP, _("Center of resized window"));
250 WMAddPopUpButtonItem(panel->posiP, _("Disabled"));
252 WMMapSubwidgets(panel->posiF);
254 /***************** Balloon Text ****************/
255 panel->ballF = WMCreateFrame(panel->box);
256 WMResizeWidget(panel->ballF, 240, 126);
257 WMMoveWidget(panel->ballF, 265, 10);
258 WMSetFrameTitle(panel->ballF, _("Show balloon for..."));
260 for (i = 0; i < 5; i++) {
261 panel->ballB[i] = WMCreateSwitchButton(panel->ballF);
262 WMResizeWidget(panel->ballB[i], 210, 20);
263 WMMoveWidget(panel->ballB[i], 15, 16 + i * 22);
265 WMSetButtonText(panel->ballB[0], _("incomplete window titles"));
266 WMSetButtonText(panel->ballB[1], _("miniwindow titles"));
267 WMSetButtonText(panel->ballB[2], _("miniwindow apercus"));
268 WMSetButtonText(panel->ballB[3], _("application/dock icons"));
269 WMSetButtonText(panel->ballB[4], _("internal help"));
271 WMMapSubwidgets(panel->ballF);
273 /***************** Options ****************/
274 panel->optF = WMCreateFrame(panel->box);
275 WMResizeWidget(panel->optF, 240, 91);
276 WMMoveWidget(panel->optF, 265, 136);
277 WMSetFrameTitle(panel->optF, _("AppIcon bouncing"));
279 panel->bounceB = WMCreateSwitchButton(panel->optF);
280 WMResizeWidget(panel->bounceB, 210, 25);
281 WMMoveWidget(panel->bounceB, 15, 14);
282 WMSetButtonText(panel->bounceB, _("Disable AppIcon bounce."));
284 panel->bounceUrgB = WMCreateSwitchButton(panel->optF);
285 WMResizeWidget(panel->bounceUrgB, 210, 28);
286 WMMoveWidget(panel->bounceUrgB, 15, 37);
287 WMSetButtonText(panel->bounceUrgB, _("Bounce AppIcon when the application wants attention."));
288 WMSetButtonSelected(panel->bounceUrgB, True); /* defaults to true */
290 panel->bounceRaisB = WMCreateSwitchButton(panel->optF);
291 WMResizeWidget(panel->bounceRaisB, 210, 23);
292 WMMoveWidget(panel->bounceRaisB, 15, 65);
293 WMSetButtonText(panel->bounceRaisB, _("Raise AppIcons when bouncing."));
295 WMMapSubwidgets(panel->optF);
297 /***************** Workspace border ****************/
298 panel->borderF = WMCreateFrame(panel->box);
299 WMResizeWidget(panel->borderF, 240, 82);
300 WMMoveWidget(panel->borderF, 15, 145);
301 WMSetFrameTitle(panel->borderF, _("Workspace border"));
303 panel->borderS = WMCreateSlider(panel->borderF);
304 WMResizeWidget(panel->borderS, 80, 15);
305 WMMoveWidget(panel->borderS, 20, 20);
306 WMSetSliderMinValue(panel->borderS, 0);
307 WMSetSliderMaxValue(panel->borderS, 5);
308 WMSetSliderAction(panel->borderS, borderCallback, panel);
310 panel->borderL = WMCreateLabel(panel->borderF);
311 WMResizeWidget(panel->borderL, 100, 15);
312 WMMoveWidget(panel->borderL, 105, 20);
314 panel->lrB = WMCreateSwitchButton(panel->borderF);
315 WMMoveWidget(panel->lrB, 20, 40);
316 WMResizeWidget(panel->lrB, 100, 30);
317 WMSetButtonText(panel->lrB, _("Left/Right"));
319 panel->tbB = WMCreateSwitchButton(panel->borderF);
320 WMMoveWidget(panel->tbB, 120, 40);
321 WMResizeWidget(panel->tbB, 100, 30);
322 WMSetButtonText(panel->tbB, _("Top/Bottom"));
324 WMMapSubwidgets(panel->borderF);
326 WMRealizeWidget(panel->box);
327 WMMapSubwidgets(panel->box);
329 showData(panel);
332 Panel *InitPreferences(WMWidget *parent)
334 _Panel *panel;
336 panel = wmalloc(sizeof(_Panel));
338 panel->sectionName = _("Miscellaneous Ergonomic Preferences");
339 panel->description = _("Various settings like balloon text, geometry\n" "displays etc.");
341 panel->parent = parent;
343 panel->callbacks.createWidgets = createPanel;
344 panel->callbacks.updateDomain = storeData;
346 AddSection(panel, ICON_FILE);
348 return panel;