added new style
[wmaker-crm.git] / WPrefs.app / Preferences.c
blob051c498e80876d9b96580f75450f5f36f6f173f4
1 /* Preferences.c- misc personal preferences
2 *
3 * WPrefs - Window Maker Preferences Program
4 *
5 * Copyright (c) 1998 Alfredo K. Kojima
6 *
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,
20 * USA.
24 #include "WPrefs.h"
26 typedef struct _Panel {
27 WMFrame *frame;
29 char *sectionName;
31 char *description;
33 CallbackRec callbacks;
35 WMWindow *win;
37 WMFrame *sizeF;
38 WMPopUpButton *sizeP;
40 WMFrame *posiF;
41 WMPopUpButton *posiP;
43 WMFrame *ballF;
44 WMButton *ballB[4];
46 WMFrame *optF;
47 WMButton *raisB;
48 #ifdef XKB_MODELOCK
49 WMButton *modeB;
50 #endif /* XKB_MODELOCK */
52 } _Panel;
56 #define ICON_FILE "ergonomic"
59 static void
60 showData(_Panel *panel)
62 char *str;
64 str = GetStringForKey("ResizeDisplay");
65 if (!str)
66 str = "corner";
67 if (strcasecmp(str, "corner")==0)
68 WMSetPopUpButtonSelectedItem(panel->sizeP, 0);
69 else if (strcasecmp(str, "center")==0)
70 WMSetPopUpButtonSelectedItem(panel->sizeP, 1);
71 else if (strcasecmp(str, "floating")==0)
72 WMSetPopUpButtonSelectedItem(panel->sizeP, 2);
73 else if (strcasecmp(str, "line")==0)
74 WMSetPopUpButtonSelectedItem(panel->sizeP, 3);
76 str = GetStringForKey("MoveDisplay");
77 if (!str)
78 str = "corner";
79 if (strcasecmp(str, "corner")==0)
80 WMSetPopUpButtonSelectedItem(panel->posiP, 0);
81 else if (strcasecmp(str, "center")==0)
82 WMSetPopUpButtonSelectedItem(panel->posiP, 1);
83 else if (strcasecmp(str, "floating")==0)
84 WMSetPopUpButtonSelectedItem(panel->posiP, 2);
87 WMSetButtonSelected(panel->raisB, GetBoolForKey("CirculateRaise"));
88 #ifdef XKB_MODELOCK
89 WMSetButtonSelected(panel->modeB, GetBoolForKey("KbdModeLock"));
90 #endif /* XKB_MODELOCK */
92 WMSetButtonSelected(panel->ballB[0], GetBoolForKey("WindowTitleBalloons"));
93 WMSetButtonSelected(panel->ballB[1], GetBoolForKey("MiniwindowTitleBalloons"));
94 WMSetButtonSelected(panel->ballB[2], GetBoolForKey("AppIconBalloons"));
95 WMSetButtonSelected(panel->ballB[3], GetBoolForKey("HelpBalloons"));
99 static void
100 storeData(_Panel *panel)
102 char *str;
104 switch (WMGetPopUpButtonSelectedItem(panel->sizeP)) {
105 case 0:
106 str = "corner";
107 break;
108 case 1:
109 str = "center";
110 break;
111 case 2:
112 str = "floating";
113 break;
114 default:
115 str = "line";
116 break;
118 SetStringForKey(str, "ResizeDisplay");
120 switch (WMGetPopUpButtonSelectedItem(panel->posiP)) {
121 case 0:
122 str = "corner";
123 break;
124 case 1:
125 str = "center";
126 break;
127 default:
128 str = "floating";
129 break;
131 SetStringForKey(str, "MoveDisplay");
133 SetBoolForKey(WMGetButtonSelected(panel->raisB), "CirculateRaise");
134 #ifdef XKB_MODELOCK
135 SetBoolForKey(WMGetButtonSelected(panel->modeB), "KbdModeLock");
136 #endif /* XKB_MODELOCK */
137 SetBoolForKey(WMGetButtonSelected(panel->ballB[0]), "WindowTitleBalloons");
138 SetBoolForKey(WMGetButtonSelected(panel->ballB[1]), "MiniwindowTitleBalloons");
139 SetBoolForKey(WMGetButtonSelected(panel->ballB[2]), "AppIconBalloons");
140 SetBoolForKey(WMGetButtonSelected(panel->ballB[3]), "HelpBalloons");
144 static void
145 createPanel(Panel *p)
147 _Panel *panel = (_Panel*)p;
148 int i;
150 panel->frame = WMCreateFrame(panel->win);
151 WMResizeWidget(panel->frame, FRAME_WIDTH, FRAME_HEIGHT);
152 WMMoveWidget(panel->frame, FRAME_LEFT, FRAME_TOP);
155 /***************** Size Display ****************/
156 panel->sizeF = WMCreateFrame(panel->frame);
157 WMResizeWidget(panel->sizeF, 240, 60);
158 WMMoveWidget(panel->sizeF, 20, 10);
159 WMSetFrameTitle(panel->sizeF, _("Size Display"));
161 WMSetBalloonTextForView(_("The position or style of the window size\n"
162 "display that's shown when a window is resized."),
163 WMWidgetView(panel->sizeF));
165 panel->sizeP = WMCreatePopUpButton(panel->sizeF);
166 WMResizeWidget(panel->sizeP, 200, 20);
167 WMMoveWidget(panel->sizeP, 22, 24);
168 WMAddPopUpButtonItem(panel->sizeP, _("Corner of screen"));
169 WMAddPopUpButtonItem(panel->sizeP, _("Center of screen"));
170 WMAddPopUpButtonItem(panel->sizeP, _("Center of resized window"));
171 WMAddPopUpButtonItem(panel->sizeP, _("Technical drawing-like"));
173 WMMapSubwidgets(panel->sizeF);
175 /***************** Position Display ****************/
176 panel->posiF = WMCreateFrame(panel->frame);
177 WMResizeWidget(panel->posiF, 240, 60);
178 WMMoveWidget(panel->posiF, 20, 75);
179 WMSetFrameTitle(panel->posiF, _("Position Display"));
181 WMSetBalloonTextForView(_("The position or style of the window position\n"
182 "display that's shown when a window is moved."),
183 WMWidgetView(panel->posiF));
185 panel->posiP = WMCreatePopUpButton(panel->posiF);
186 WMResizeWidget(panel->posiP, 200, 20);
187 WMMoveWidget(panel->posiP, 22, 24);
188 WMAddPopUpButtonItem(panel->posiP, _("Corner of screen"));
189 WMAddPopUpButtonItem(panel->posiP, _("Center of screen"));
190 WMAddPopUpButtonItem(panel->posiP, _("Center of resized window"));
192 WMMapSubwidgets(panel->posiF);
194 /***************** Balloon Text ****************/
195 panel->ballF = WMCreateFrame(panel->frame);
196 WMResizeWidget(panel->ballF, 235, 125);
197 WMMoveWidget(panel->ballF, 270, 10);
198 WMSetFrameTitle(panel->ballF, _("Show balloon text for..."));
200 for (i=0; i<4; i++) {
201 panel->ballB[i] = WMCreateSwitchButton(panel->ballF);
202 WMResizeWidget(panel->ballB[i], 205, 20);
203 WMMoveWidget(panel->ballB[i], 15, 20+i*25);
205 WMSetButtonText(panel->ballB[0], _("incomplete window titles"));
206 WMSetButtonText(panel->ballB[1], _("miniwindow titles"));
207 WMSetButtonText(panel->ballB[2], _("application/dock icons"));
208 WMSetButtonText(panel->ballB[3], _("internal help"));
210 WMMapSubwidgets(panel->ballF);
212 /***************** Options ****************/
213 panel->optF = WMCreateFrame(panel->frame);
214 WMResizeWidget(panel->optF, 485, 75);
215 WMMoveWidget(panel->optF, 20, 145);
217 panel->raisB = WMCreateSwitchButton(panel->optF);
218 WMResizeWidget(panel->raisB, 440, 20);
219 WMMoveWidget(panel->raisB, 20, 15);
220 WMSetButtonText(panel->raisB, _("Raise window when switching focus with keyboard (CirculateRaise)."));
222 #ifdef XKB_MODELOCK
223 panel->modeB = WMCreateSwitchButton(panel->optF);
224 WMResizeWidget(panel->modeB, 440, 20);
225 WMMoveWidget(panel->modeB, 20, 40);
226 WMSetButtonText(panel->modeB, _("Keep keyboard language status for each window."));
227 #endif
229 WMMapSubwidgets(panel->optF);
231 WMRealizeWidget(panel->frame);
232 WMMapSubwidgets(panel->frame);
234 showData(panel);
239 Panel*
240 InitPreferences(WMScreen *scr, WMWindow *win)
242 _Panel *panel;
244 panel = wmalloc(sizeof(_Panel));
245 memset(panel, 0, sizeof(_Panel));
247 panel->sectionName = _("Miscellaneous Ergonomic Preferences");
248 panel->description = _("Various settings like balloon text, geometry\n"
249 "displays etc.");
251 panel->win = win;
253 panel->callbacks.createWidgets = createPanel;
254 panel->callbacks.updateDomain = storeData;
256 AddSection(panel, ICON_FILE);
258 return panel;