Moved parameters of WPrefs's expert check-buttons to a single place
[wmaker-crm.git] / WPrefs.app / Expert.c
blobc6ecefd5616a590f4235346dabafc552e9da5c45
1 /* Expert.c- expert user options
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 /* This structure containts the list of all the check-buttons to display in the
25 * expert tab of the window with the corresponding information for effect
27 static const struct {
28 char *label; /* Text displayed to user */
30 int def_state; /* True/False: the default value, if not defined in current config */
32 enum {
33 OPTION_WMAKER,
34 OPTION_USERDEF
35 } class;
37 char *op_name; /* The identifier for the option in the config file */
39 } expert_options[] = {
41 { N_("Disable miniwindows (icons for minimized windows). For use with KDE/GNOME."),
42 /* default: */ False, OPTION_WMAKER, "DisableMiniwindows" },
44 { N_("Do not set non-WindowMaker specific parameters (do not use xset)."),
45 /* default: */ False, OPTION_USERDEF, "NoXSetStuff" },
47 { N_("Automatically save session when exiting Window Maker."),
48 /* default: */ False, OPTION_WMAKER, "SaveSessionOnExit" },
50 { N_("Use SaveUnder in window frames, icons, menus and other objects."),
51 /* default: */ False, OPTION_WMAKER, "UseSaveUnders" },
53 { N_("Disable confirmation panel for the Kill command."),
54 /* default: */ False, OPTION_WMAKER, "DontConfirmKill" },
56 { N_("Disable selection animation for selected icons."),
57 /* default: */ False, OPTION_WMAKER, "DisableBlinking" },
59 { N_("Smooth font edges (needs restart)."),
60 /* default: */ True, OPTION_WMAKER, "AntialiasedText" },
62 { N_("Cycle windows only on the active head."),
63 /* default: */ False, OPTION_WMAKER, "CycleActiveHeadOnly" },
65 { N_("Show workspace title on Clip."),
66 /* default: */ True, OPTION_WMAKER, "ShowClipTitle" },
68 { N_("Highlight the icon of the application when it has the focus."),
69 /* default: */ True, OPTION_WMAKER, "HighlightActiveApp" },
71 #ifdef XKB_MODELOCK
72 { N_("Enable keyboard language switch button in window titlebars."),
73 /* default: */ False, OPTION_WMAKER, "KbdModeLock" }
74 #endif /* XKB_MODELOCK */
79 typedef struct _Panel {
80 WMBox *box;
81 char *sectionName;
83 char *description;
85 CallbackRec callbacks;
87 WMWidget *parent;
89 WMButton *swi[sizeof(expert_options) / sizeof(expert_options[0])];
91 } _Panel;
93 #define ICON_FILE "expert"
96 static void createPanel(Panel * p)
98 _Panel *panel = (_Panel *) p;
99 WMScrollView *sv;
100 WMFrame *f;
101 WMUserDefaults *udb;
102 int i, state;
104 panel->box = WMCreateBox(panel->parent);
105 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
107 sv = WMCreateScrollView(panel->box);
108 WMResizeWidget(sv, 500, 215);
109 WMMoveWidget(sv, 12, 10);
110 WMSetScrollViewRelief(sv, WRSunken);
111 WMSetScrollViewHasVerticalScroller(sv, True);
112 WMSetScrollViewHasHorizontalScroller(sv, False);
114 f = WMCreateFrame(panel->box);
115 WMResizeWidget(f, 495, (sizeof(expert_options) / sizeof(expert_options[0])) * 25 + 8);
116 WMSetFrameRelief(f, WRFlat);
118 udb = WMGetStandardUserDefaults();
119 for (i = 0; i < sizeof(expert_options) / sizeof(expert_options[0]); i++) {
120 panel->swi[i] = WMCreateSwitchButton(f);
121 WMResizeWidget(panel->swi[i], FRAME_WIDTH - 40, 25);
122 WMMoveWidget(panel->swi[i], 5, 5 + i * 25);
124 WMSetButtonText(panel->swi[i], _(expert_options[i].label));
126 switch (expert_options[i].class) {
127 case OPTION_WMAKER:
128 if (GetStringForKey(expert_options[i].op_name))
129 state = GetBoolForKey(expert_options[i].op_name);
130 else
131 state = expert_options[i].def_state;
132 break;
134 case OPTION_USERDEF:
135 state = WMGetUDBoolForKey(udb, expert_options[i].op_name);
136 break;
139 WMSetButtonSelected(panel->swi[i], state);
142 WMMapSubwidgets(panel->box);
143 WMSetScrollViewContentView(sv, WMWidgetView(f));
144 WMRealizeWidget(panel->box);
147 static void storeDefaults(_Panel * panel)
149 WMUserDefaults *udb = WMGetStandardUserDefaults();
150 int i;
152 for (i = 0; i < sizeof(expert_options) / sizeof(expert_options[0]); i++) {
153 switch (expert_options[i].class) {
154 case OPTION_WMAKER:
155 SetBoolForKey(WMGetButtonSelected(panel->swi[i]), expert_options[i].op_name);
156 break;
158 case OPTION_USERDEF:
159 WMSetUDBoolForKey(udb, WMGetButtonSelected(panel->swi[i]), expert_options[i].op_name);
160 break;
165 Panel *InitExpert(WMScreen * scr, WMWidget * parent)
167 _Panel *panel;
169 panel = wmalloc(sizeof(_Panel));
171 panel->sectionName = _("Expert User Preferences");
173 panel->description = _("Options for people who know what they're doing...\n"
174 "Also has some other misc. options.");
176 panel->parent = parent;
178 panel->callbacks.createWidgets = createPanel;
179 panel->callbacks.updateDomain = storeDefaults;
181 AddSection(panel, ICON_FILE);
183 return panel;