News: described the new features for future 0.95.6 release
[wmaker-crm.git] / WPrefs.app / Expert.c
blobe939df036921435d72768f6f2d824e793997d375
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 const 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 const 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_("Ignore minimized windows when cycling."),
66 /* default: */ False, OPTION_WMAKER, "CycleIgnoreMinimized" },
68 { N_("Show workspace title on Clip."),
69 /* default: */ True, OPTION_WMAKER, "ShowClipTitle" },
71 { N_("Highlight the icon of the application when it has the focus."),
72 /* default: */ True, OPTION_WMAKER, "HighlightActiveApp" },
74 #ifdef XKB_MODELOCK
75 { N_("Enable keyboard language switch button in window titlebars."),
76 /* default: */ False, OPTION_WMAKER, "KbdModeLock" }
77 #endif /* XKB_MODELOCK */
82 typedef struct _Panel {
83 WMBox *box;
84 char *sectionName;
86 char *description;
88 CallbackRec callbacks;
90 WMWidget *parent;
92 WMButton *swi[sizeof(expert_options) / sizeof(expert_options[0])];
94 } _Panel;
96 #define ICON_FILE "expert"
99 static void createPanel(Panel * p)
101 _Panel *panel = (_Panel *) p;
102 WMScrollView *sv;
103 WMFrame *f;
104 WMUserDefaults *udb;
105 int i, state;
107 panel->box = WMCreateBox(panel->parent);
108 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
110 sv = WMCreateScrollView(panel->box);
111 WMResizeWidget(sv, 500, 215);
112 WMMoveWidget(sv, 12, 10);
113 WMSetScrollViewRelief(sv, WRSunken);
114 WMSetScrollViewHasVerticalScroller(sv, True);
115 WMSetScrollViewHasHorizontalScroller(sv, False);
117 f = WMCreateFrame(panel->box);
118 WMResizeWidget(f, 495, wlengthof(expert_options) * 25 + 8);
119 WMSetFrameRelief(f, WRFlat);
121 udb = WMGetStandardUserDefaults();
122 for (i = 0; i < wlengthof(expert_options); i++) {
123 panel->swi[i] = WMCreateSwitchButton(f);
124 WMResizeWidget(panel->swi[i], FRAME_WIDTH - 40, 25);
125 WMMoveWidget(panel->swi[i], 5, 5 + i * 25);
127 WMSetButtonText(panel->swi[i], _(expert_options[i].label));
129 switch (expert_options[i].class) {
130 case OPTION_WMAKER:
131 if (GetStringForKey(expert_options[i].op_name))
132 state = GetBoolForKey(expert_options[i].op_name);
133 else
134 state = expert_options[i].def_state;
135 break;
137 case OPTION_USERDEF:
138 state = WMGetUDBoolForKey(udb, expert_options[i].op_name);
139 break;
141 default:
142 #ifdef DEBUG
143 wwarning("export_options[%d].class = %d, this should not happen\n",
144 i, expert_options[i].class);
145 #endif
146 state = expert_options[i].def_state;
147 break;
149 WMSetButtonSelected(panel->swi[i], state);
152 WMMapSubwidgets(panel->box);
153 WMSetScrollViewContentView(sv, WMWidgetView(f));
154 WMRealizeWidget(panel->box);
157 static void storeDefaults(_Panel * panel)
159 WMUserDefaults *udb = WMGetStandardUserDefaults();
160 int i;
162 for (i = 0; i < wlengthof(expert_options); i++) {
163 switch (expert_options[i].class) {
164 case OPTION_WMAKER:
165 SetBoolForKey(WMGetButtonSelected(panel->swi[i]), expert_options[i].op_name);
166 break;
168 case OPTION_USERDEF:
169 WMSetUDBoolForKey(udb, WMGetButtonSelected(panel->swi[i]), expert_options[i].op_name);
170 break;
175 Panel *InitExpert(WMWidget *parent)
177 _Panel *panel;
179 panel = wmalloc(sizeof(_Panel));
181 panel->sectionName = _("Expert User Preferences");
183 panel->description = _("Options for people who know what they're doing...\n"
184 "Also has some other misc. options.");
186 panel->parent = parent;
188 panel->callbacks.createWidgets = createPanel;
189 panel->callbacks.updateDomain = storeDefaults;
191 AddSection(panel, ICON_FILE);
193 return panel;