Disable pager by default
[wmaker-crm.git] / WPrefs.app / Expert.c
blob0c5df9430d1b246c4479fdcd6a8577dea922071e
1 /* Expert.c- expert user options
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 2014 Window Maker Team
6 * Copyright (c) 1998-2003 Alfredo K. Kojima
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "WPrefs.h"
25 /* This structure containts the list of all the check-buttons to display in the
26 * expert tab of the window with the corresponding information for effect
28 static const struct {
29 const char *label; /* Text displayed to user */
31 int def_state; /* True/False: the default value, if not defined in current config */
33 enum {
34 OPTION_WMAKER,
35 OPTION_WMAKER_ARRAY,
36 OPTION_USERDEF,
37 OPTION_WMAKER_INT
38 } class;
40 const char *op_name; /* The identifier for the option in the config file */
42 } expert_options[] = {
44 { N_("Disable miniwindows (icons for minimized windows). For use with KDE/GNOME."),
45 /* default: */ False, OPTION_WMAKER, "DisableMiniwindows" },
47 { N_("Ignore decoration hints for GTK applications."),
48 /* default: */ False, OPTION_WMAKER, "IgnoreGtkHints" },
50 { N_("Enable workspace pager."),
51 /* default: */ False, OPTION_WMAKER, "EnableWorkspacePager" },
53 { N_("Do not set non-WindowMaker specific parameters (do not use xset)."),
54 /* default: */ False, OPTION_USERDEF, "NoXSetStuff" },
56 { N_("Automatically save session when exiting Window Maker."),
57 /* default: */ False, OPTION_WMAKER, "SaveSessionOnExit" },
59 { N_("Use SaveUnder in window frames, icons, menus and other objects."),
60 /* default: */ False, OPTION_WMAKER, "UseSaveUnders" },
62 { N_("Disable confirmation panel for the Kill command."),
63 /* default: */ False, OPTION_WMAKER, "DontConfirmKill" },
65 { N_("Disable selection animation for selected icons."),
66 /* default: */ False, OPTION_WMAKER, "DisableBlinking" },
68 { N_("Smooth font edges (needs restart)."),
69 /* default: */ True, OPTION_WMAKER, "AntialiasedText" },
71 { N_("Cycle windows only on the active head."),
72 /* default: */ False, OPTION_WMAKER, "CycleActiveHeadOnly" },
74 { N_("Ignore minimized windows when cycling."),
75 /* default: */ False, OPTION_WMAKER, "CycleIgnoreMinimized" },
77 { N_("Show switch panel when cycling windows."),
78 /* default: */ True, OPTION_WMAKER_ARRAY, "SwitchPanelImages" },
80 { N_("Show workspace title on Clip."),
81 /* default: */ True, OPTION_WMAKER, "ShowClipTitle" },
83 { N_("Highlight the icon of the application when it has the focus."),
84 /* default: */ True, OPTION_WMAKER, "HighlightActiveApp" },
86 #ifdef XKB_MODELOCK
87 { N_("Enable keyboard language switch button in window titlebars."),
88 /* default: */ False, OPTION_WMAKER, "KbdModeLock" },
89 #endif /* XKB_MODELOCK */
91 { N_("Maximize (snap) a window to edge or corner by dragging."),
92 /* default: */ False, OPTION_WMAKER, "WindowSnapping" },
94 { N_("Distance from edge to begin window snap."),
95 /* default: */ 1, OPTION_WMAKER_INT, "SnapEdgeDetect" },
97 { N_("Distance from corner to begin window snap."),
98 /* default: */ 10, OPTION_WMAKER_INT, "SnapCornerDetect" },
100 { N_("Open dialogs in the same workspace as their owners."),
101 /* default: */ False, OPTION_WMAKER, "OpenTransientOnOwnerWorkspace" }
107 typedef struct _Panel {
108 WMBox *box;
109 char *sectionName;
111 char *description;
113 CallbackRec callbacks;
115 WMWidget *parent;
117 WMButton *swi[wlengthof_nocheck(expert_options)];
119 WMTextField *textfield[wlengthof_nocheck(expert_options)];
121 } _Panel;
123 #define ICON_FILE "expert"
125 static void changeIntTextfield(void *data, int delta)
127 WMTextField *textfield;
128 char *text;
129 int value;
131 textfield = (WMTextField *)data;
132 text = WMGetTextFieldText(textfield);
133 value = atoi(text);
134 value += delta;
135 sprintf(text, "%d", value);
136 WMSetTextFieldText(textfield, text);
139 static void downButtonCallback(WMWidget *self, void *data)
141 (void) self;
142 changeIntTextfield(data, -1);
145 static void upButtonCallback(WMWidget *self, void *data)
147 (void) self;
148 changeIntTextfield(data, 1);
151 static void createPanel(Panel *p)
153 _Panel *panel = (_Panel *) p;
154 WMScrollView *sv;
155 WMFrame *f;
156 WMUserDefaults *udb;
157 int i, state;
159 panel->box = WMCreateBox(panel->parent);
160 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
162 sv = WMCreateScrollView(panel->box);
163 WMResizeWidget(sv, 500, 215);
164 WMMoveWidget(sv, 12, 10);
165 WMSetScrollViewRelief(sv, WRSunken);
166 WMSetScrollViewHasVerticalScroller(sv, True);
167 WMSetScrollViewHasHorizontalScroller(sv, False);
169 f = WMCreateFrame(panel->box);
170 WMResizeWidget(f, 495, wlengthof(expert_options) * 25 + 8);
171 WMSetFrameRelief(f, WRFlat);
173 udb = WMGetStandardUserDefaults();
174 for (i = 0; i < wlengthof(expert_options); i++) {
175 if (expert_options[i].class != OPTION_WMAKER_INT) {
176 panel->swi[i] = WMCreateSwitchButton(f);
177 WMResizeWidget(panel->swi[i], FRAME_WIDTH - 40, 25);
178 WMMoveWidget(panel->swi[i], 5, 5 + i * 25);
180 WMSetButtonText(panel->swi[i], _(expert_options[i].label));
183 switch (expert_options[i].class) {
184 case OPTION_WMAKER:
185 if (GetStringForKey(expert_options[i].op_name))
186 state = GetBoolForKey(expert_options[i].op_name);
187 else
188 state = expert_options[i].def_state;
189 break;
191 case OPTION_WMAKER_ARRAY: {
192 char *str = GetStringForKey(expert_options[i].op_name);
193 state = expert_options[i].def_state;
194 if (str && strcasecmp(str, "None") == 0)
195 state = False;
197 break;
199 case OPTION_USERDEF:
200 state = WMGetUDBoolForKey(udb, expert_options[i].op_name);
201 break;
203 case OPTION_WMAKER_INT:
205 char tmp[10];
206 WMButton *up, *down;
207 WMLabel *label;
209 panel->textfield[i] = WMCreateTextField(f);
210 WMResizeWidget(panel->textfield[i], 41, 20);
211 WMMoveWidget(panel->textfield[i], 22, 7 + i * 25);
213 down = WMCreateCommandButton(f);
214 WMSetButtonImage(down, WMGetSystemPixmap(WMWidgetScreen(down), WSIArrowDown));
215 WMSetButtonAltImage(down,
216 WMGetSystemPixmap(WMWidgetScreen(down), WSIHighlightedArrowDown));
217 WMSetButtonImagePosition(down, WIPImageOnly);
218 WMSetButtonAction(down, downButtonCallback, panel->textfield[i]);
219 WMResizeWidget(down, 16, 16);
220 WMMoveWidget(down, 5, 9 + i * 25);
222 up = WMCreateCommandButton(f);
223 WMSetButtonImage(up, WMGetSystemPixmap(WMWidgetScreen(up), WSIArrowUp));
224 WMSetButtonAltImage(up, WMGetSystemPixmap(WMWidgetScreen(up), WSIHighlightedArrowUp));
225 WMSetButtonImagePosition(up, WIPImageOnly);
226 WMSetButtonAction(up, upButtonCallback, panel->textfield[i]);
227 WMResizeWidget(up, 16, 16);
228 WMMoveWidget(up, 64, 9 + i * 25);
230 label = WMCreateLabel(f);
231 WMSetLabelText(label, _(expert_options[i].label));
232 WMResizeWidget(label, FRAME_WIDTH - 99, 25);
233 WMMoveWidget(label, 85, 5 + i * 25);
235 if (GetStringForKey(expert_options[i].op_name))
236 state = GetIntegerForKey(expert_options[i].op_name);
237 else
238 state = expert_options[i].def_state;
240 sprintf(tmp, "%d", state);
241 WMSetTextFieldText(panel->textfield[i], tmp);
243 break;
246 default:
247 #ifdef DEBUG
248 wwarning("export_options[%d].class = %d, this should not happen\n",
249 i, expert_options[i].class);
250 #endif
251 state = expert_options[i].def_state;
252 break;
254 if (expert_options[i].class != OPTION_WMAKER_INT)
255 WMSetButtonSelected(panel->swi[i], state);
258 WMMapSubwidgets(panel->box);
259 WMSetScrollViewContentView(sv, WMWidgetView(f));
260 WMRealizeWidget(panel->box);
263 static void storeDefaults(_Panel *panel)
265 WMUserDefaults *udb = WMGetStandardUserDefaults();
266 int i;
268 for (i = 0; i < wlengthof(expert_options); i++) {
269 switch (expert_options[i].class) {
270 case OPTION_WMAKER:
271 SetBoolForKey(WMGetButtonSelected(panel->swi[i]), expert_options[i].op_name);
272 break;
274 case OPTION_WMAKER_ARRAY:
275 if (WMGetButtonSelected(panel->swi[i])) {
276 /* check if the array was not manually modified */
277 char *str = GetStringForKey(expert_options[i].op_name);
278 if (str && strcasecmp(str, "None") == 0)
279 RemoveObjectForKey(expert_options[i].op_name);
281 else
282 SetStringForKey("None", expert_options[i].op_name);
283 break;
285 case OPTION_USERDEF:
286 WMSetUDBoolForKey(udb, WMGetButtonSelected(panel->swi[i]), expert_options[i].op_name);
287 break;
289 case OPTION_WMAKER_INT:
291 char *text;
292 int value;
294 text = WMGetTextFieldText(panel->textfield[i]);
295 value = atoi(text);
297 SetIntegerForKey(value, expert_options[i].op_name);
298 break;
304 Panel *InitExpert(WMWidget *parent)
306 _Panel *panel;
308 panel = wmalloc(sizeof(_Panel));
310 panel->sectionName = _("Expert User Preferences");
312 panel->description = _("Options for people who know what they're doing...\n"
313 "Also has some other misc. options.");
315 panel->parent = parent;
317 panel->callbacks.createWidgets = createPanel;
318 panel->callbacks.updateDomain = storeDefaults;
320 AddSection(panel, ICON_FILE);
322 return panel;