1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
|
/* MenuPreferences.c- menu related preferences
*
* WPrefs - Window Maker Preferences Program
*
* Copyright (c) 1998-2003 Alfredo K. Kojima
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "WPrefs.h"
typedef struct _Panel {
WMBox *box;
char *sectionName;
char *description;
CallbackRec callbacks;
WMWidget *parent;
WMFrame *scrF;
WMButton *scrB[5];
WMFrame *aliF;
WMButton *aliyB;
WMButton *alinB;
WMFrame *optF;
WMButton *autoB;
WMButton *autoC;
WMButton *wrapB;
} _Panel;
#define ICON_FILE "menuprefs"
#define SPEED_IMAGE "speed%i"
#define SPEED_IMAGE_S "speed%is"
#define MENU_ALIGN1 "menualign1"
#define MENU_ALIGN2 "menualign2"
static void showData(_Panel * panel)
{
WMPerformButtonClick(panel->scrB[GetSpeedForKey("MenuScrollSpeed")]);
if (GetBoolForKey("AlignSubmenus"))
WMPerformButtonClick(panel->aliyB);
else
WMPerformButtonClick(panel->alinB);
WMSetButtonSelected(panel->wrapB, GetBoolForKey("WrapMenus"));
WMSetButtonSelected(panel->autoB, GetBoolForKey("ScrollableMenus"));
WMSetButtonSelected(panel->autoC, GetBoolForKey("ViKeyMenus"));
}
static void storeData(_Panel * panel)
{
int i;
for (i = 0; i < wlengthof(panel->scrB); i++) {
if (WMGetButtonSelected(panel->scrB[i]))
break;
}
SetSpeedForKey(i, "MenuScrollSpeed");
SetBoolForKey(WMGetButtonSelected(panel->aliyB), "AlignSubmenus");
SetBoolForKey(WMGetButtonSelected(panel->wrapB), "WrapMenus");
SetBoolForKey(WMGetButtonSelected(panel->autoB), "ScrollableMenus");
SetBoolForKey(WMGetButtonSelected(panel->autoC), "ViKeyMenus");
}
static void createPanel(Panel * p)
{
_Panel *panel = (_Panel *) p;
WMScreen *scr = WMWidgetScreen(panel->parent);
WMPixmap *icon;
int i;
char *buf1, *buf2;
char *path;
panel->box = WMCreateBox(panel->parent);
WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
/***************** Menu Scroll Speed ****************/
panel->scrF = WMCreateFrame(panel->box);
WMResizeWidget(panel->scrF, 235, 90);
WMMoveWidget(panel->scrF, 25, 20);
WMSetFrameTitle(panel->scrF, _("Menu Scrolling Speed"));
buf1 = wmalloc(strlen(SPEED_IMAGE) + 1);
buf2 = wmalloc(strlen(SPEED_IMAGE_S) + 1);
for (i = 0; i < wlengthof(panel->scrB); i++) {
panel->scrB[i] = WMCreateCustomButton(panel->scrF, WBBStateChangeMask);
WMResizeWidget(panel->scrB[i], 40, 40);
WMMoveWidget(panel->scrB[i], 15 + (40 * i), 30);
WMSetButtonBordered(panel->scrB[i], False);
WMSetButtonImagePosition(panel->scrB[i], WIPImageOnly);
if (i > 0) {
WMGroupButtons(panel->scrB[0], panel->scrB[i]);
}
sprintf(buf1, SPEED_IMAGE, i);
sprintf(buf2, SPEED_IMAGE_S, i);
path = LocateImage(buf1);
if (path) {
icon = WMCreatePixmapFromFile(scr, path);
if (icon) {
WMSetButtonImage(panel->scrB[i], icon);
WMReleasePixmap(icon);
} else {
wwarning(_("could not load icon file %s"), path);
}
wfree(path);
}
path = LocateImage(buf2);
if (path) {
icon = WMCreatePixmapFromFile(scr, path);
if (icon) {
WMSetButtonAltImage(panel->scrB[i], icon);
WMReleasePixmap(icon);
} else {
wwarning(_("could not load icon file %s"), path);
}
wfree(path);
}
}
wfree(buf1);
wfree(buf2);
WMMapSubwidgets(panel->scrF);
/***************** Submenu Alignment ****************/
panel->aliF = WMCreateFrame(panel->box);
WMResizeWidget(panel->aliF, 220, 90);
WMMoveWidget(panel->aliF, 280, 20);
WMSetFrameTitle(panel->aliF, _("Submenu Alignment"));
panel->alinB = WMCreateButton(panel->aliF, WBTOnOff);
WMResizeWidget(panel->alinB, 48, 48);
WMMoveWidget(panel->alinB, 56, 25);
WMSetButtonImagePosition(panel->alinB, WIPImageOnly);
path = LocateImage(MENU_ALIGN1);
if (path) {
icon = WMCreatePixmapFromFile(scr, path);
if (icon) {
WMSetButtonImage(panel->alinB, icon);
WMReleasePixmap(icon);
} else {
wwarning(_("could not load icon file %s"), path);
}
wfree(path);
}
panel->aliyB = WMCreateButton(panel->aliF, WBTOnOff);
WMResizeWidget(panel->aliyB, 48, 48);
WMMoveWidget(panel->aliyB, 120, 25);
WMSetButtonImagePosition(panel->aliyB, WIPImageOnly);
path = LocateImage(MENU_ALIGN2);
if (path) {
icon = WMCreatePixmapFromFile(scr, path);
if (icon) {
WMSetButtonImage(panel->aliyB, icon);
WMReleasePixmap(icon);
} else {
wwarning(_("could not load icon file %s"), path);
}
wfree(path);
}
WMGroupButtons(panel->alinB, panel->aliyB);
WMMapSubwidgets(panel->aliF);
/***************** Options ****************/
panel->optF = WMCreateFrame(panel->box);
WMResizeWidget(panel->optF, 475, 96);
WMMoveWidget(panel->optF, 25, 120);
panel->wrapB = WMCreateSwitchButton(panel->optF);
WMResizeWidget(panel->wrapB, 440, 32);
WMMoveWidget(panel->wrapB, 25, 8);
WMSetButtonText(panel->wrapB, _("Always open submenus inside the screen, instead of scrolling."));
panel->autoB = WMCreateSwitchButton(panel->optF);
WMResizeWidget(panel->autoB, 440, 32);
WMMoveWidget(panel->autoB, 25, 34);
WMSetButtonText(panel->autoB, _("Scroll off-screen menus when pointer is moved over them."));
panel->autoC = WMCreateSwitchButton(panel->optF);
WMResizeWidget(panel->autoC, 440, 32);
WMMoveWidget(panel->autoC, 25, 58);
WMSetButtonText(panel->autoC, _("Use h/j/k/l keys to select menu options."));
WMMapSubwidgets(panel->optF);
WMRealizeWidget(panel->box);
WMMapSubwidgets(panel->box);
showData(panel);
}
Panel *InitMenuPreferences(WMWidget *parent)
{
_Panel *panel;
panel = wmalloc(sizeof(_Panel));
panel->sectionName = _("Menu Preferences");
panel->description = _("Menu usability related options. Scrolling speed,\n" "alignment of submenus etc.");
panel->parent = parent;
panel->callbacks.createWidgets = createPanel;
panel->callbacks.updateDomain = storeData;
AddSection(panel, ICON_FILE);
return panel;
}
|