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.
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
29 const char *label
; /* Text displayed to user */
31 int def_state
; /* True/False: the default value, if not defined in current config */
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" },
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_("Snapping a window to the top maximizes it to the full screen."),
101 /* default: */ False
, OPTION_WMAKER
, "SnapToTopMaximizesFullscreen" },
103 { N_("Open dialogs in the same workspace as their owners."),
104 /* default: */ False
, OPTION_WMAKER
, "OpenTransientOnOwnerWorkspace" }
110 typedef struct _Panel
{
116 CallbackRec callbacks
;
120 WMButton
*swi
[wlengthof_nocheck(expert_options
)];
122 WMTextField
*textfield
[wlengthof_nocheck(expert_options
)];
126 #define ICON_FILE "expert"
128 static void changeIntTextfield(void *data
, int delta
)
130 WMTextField
*textfield
;
134 textfield
= (WMTextField
*)data
;
135 text
= WMGetTextFieldText(textfield
);
138 sprintf(text
, "%d", value
);
139 WMSetTextFieldText(textfield
, text
);
142 static void downButtonCallback(WMWidget
*self
, void *data
)
145 changeIntTextfield(data
, -1);
148 static void upButtonCallback(WMWidget
*self
, void *data
)
151 changeIntTextfield(data
, 1);
154 static void createPanel(Panel
*p
)
156 _Panel
*panel
= (_Panel
*) p
;
162 panel
->box
= WMCreateBox(panel
->parent
);
163 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
165 sv
= WMCreateScrollView(panel
->box
);
166 WMResizeWidget(sv
, 500, 215);
167 WMMoveWidget(sv
, 12, 10);
168 WMSetScrollViewRelief(sv
, WRSunken
);
169 WMSetScrollViewHasVerticalScroller(sv
, True
);
170 WMSetScrollViewHasHorizontalScroller(sv
, False
);
172 f
= WMCreateFrame(panel
->box
);
173 WMResizeWidget(f
, 495, wlengthof(expert_options
) * 25 + 8);
174 WMSetFrameRelief(f
, WRFlat
);
176 udb
= WMGetStandardUserDefaults();
177 for (i
= 0; i
< wlengthof(expert_options
); i
++) {
178 if (expert_options
[i
].class != OPTION_WMAKER_INT
) {
179 panel
->swi
[i
] = WMCreateSwitchButton(f
);
180 WMResizeWidget(panel
->swi
[i
], FRAME_WIDTH
- 40, 25);
181 WMMoveWidget(panel
->swi
[i
], 5, 5 + i
* 25);
183 WMSetButtonText(panel
->swi
[i
], _(expert_options
[i
].label
));
186 switch (expert_options
[i
].class) {
188 if (GetStringForKey(expert_options
[i
].op_name
))
189 state
= GetBoolForKey(expert_options
[i
].op_name
);
191 state
= expert_options
[i
].def_state
;
194 case OPTION_WMAKER_ARRAY
: {
195 char *str
= GetStringForKey(expert_options
[i
].op_name
);
196 state
= expert_options
[i
].def_state
;
197 if (str
&& strcasecmp(str
, "None") == 0)
203 state
= WMGetUDBoolForKey(udb
, expert_options
[i
].op_name
);
206 case OPTION_WMAKER_INT
:
212 panel
->textfield
[i
] = WMCreateTextField(f
);
213 WMResizeWidget(panel
->textfield
[i
], 41, 20);
214 WMMoveWidget(panel
->textfield
[i
], 22, 7 + i
* 25);
216 down
= WMCreateCommandButton(f
);
217 WMSetButtonImage(down
, WMGetSystemPixmap(WMWidgetScreen(down
), WSIArrowDown
));
218 WMSetButtonAltImage(down
,
219 WMGetSystemPixmap(WMWidgetScreen(down
), WSIHighlightedArrowDown
));
220 WMSetButtonImagePosition(down
, WIPImageOnly
);
221 WMSetButtonAction(down
, downButtonCallback
, panel
->textfield
[i
]);
222 WMResizeWidget(down
, 16, 16);
223 WMMoveWidget(down
, 5, 9 + i
* 25);
225 up
= WMCreateCommandButton(f
);
226 WMSetButtonImage(up
, WMGetSystemPixmap(WMWidgetScreen(up
), WSIArrowUp
));
227 WMSetButtonAltImage(up
, WMGetSystemPixmap(WMWidgetScreen(up
), WSIHighlightedArrowUp
));
228 WMSetButtonImagePosition(up
, WIPImageOnly
);
229 WMSetButtonAction(up
, upButtonCallback
, panel
->textfield
[i
]);
230 WMResizeWidget(up
, 16, 16);
231 WMMoveWidget(up
, 64, 9 + i
* 25);
233 label
= WMCreateLabel(f
);
234 WMSetLabelText(label
, _(expert_options
[i
].label
));
235 WMResizeWidget(label
, FRAME_WIDTH
- 99, 25);
236 WMMoveWidget(label
, 85, 5 + i
* 25);
238 if (GetStringForKey(expert_options
[i
].op_name
))
239 state
= GetIntegerForKey(expert_options
[i
].op_name
);
241 state
= expert_options
[i
].def_state
;
243 sprintf(tmp
, "%d", state
);
244 WMSetTextFieldText(panel
->textfield
[i
], tmp
);
251 wwarning("export_options[%d].class = %d, this should not happen\n",
252 i
, expert_options
[i
].class);
254 state
= expert_options
[i
].def_state
;
257 if (expert_options
[i
].class != OPTION_WMAKER_INT
)
258 WMSetButtonSelected(panel
->swi
[i
], state
);
261 WMMapSubwidgets(panel
->box
);
262 WMSetScrollViewContentView(sv
, WMWidgetView(f
));
263 WMRealizeWidget(panel
->box
);
266 static void storeDefaults(_Panel
*panel
)
268 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
271 for (i
= 0; i
< wlengthof(expert_options
); i
++) {
272 switch (expert_options
[i
].class) {
274 SetBoolForKey(WMGetButtonSelected(panel
->swi
[i
]), expert_options
[i
].op_name
);
277 case OPTION_WMAKER_ARRAY
:
278 if (WMGetButtonSelected(panel
->swi
[i
])) {
279 /* check if the array was not manually modified */
280 char *str
= GetStringForKey(expert_options
[i
].op_name
);
281 if (str
&& strcasecmp(str
, "None") == 0)
282 RemoveObjectForKey(expert_options
[i
].op_name
);
285 SetStringForKey("None", expert_options
[i
].op_name
);
289 WMSetUDBoolForKey(udb
, WMGetButtonSelected(panel
->swi
[i
]), expert_options
[i
].op_name
);
292 case OPTION_WMAKER_INT
:
297 text
= WMGetTextFieldText(panel
->textfield
[i
]);
300 SetIntegerForKey(value
, expert_options
[i
].op_name
);
307 Panel
*InitExpert(WMWidget
*parent
)
311 panel
= wmalloc(sizeof(_Panel
));
313 panel
->sectionName
= _("Expert User Preferences");
315 panel
->description
= _("Options for people who know what they're doing...\n"
316 "Also has some other misc. options.");
318 panel
->parent
= parent
;
320 panel
->callbacks
.createWidgets
= createPanel
;
321 panel
->callbacks
.updateDomain
= storeDefaults
;
323 AddSection(panel
, ICON_FILE
);