1 /* MenuPreferences.c- menu related preferences
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998 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
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
26 typedef struct _Panel
{
33 CallbackRec callbacks
;
52 #define ICON_FILE "menuprefs"
53 #define SPEED_IMAGE "speed%i"
54 #define SPEED_IMAGE_S "speed%is"
56 #define MENU_ALIGN1 "menualign1"
57 #define MENU_ALIGN2 "menualign2"
61 showData(_Panel
*panel
)
63 WMPerformButtonClick(panel
->scrB
[GetSpeedForKey("MenuScrollSpeed")]);
65 if (GetBoolForKey("AlignSubmenus"))
66 WMPerformButtonClick(panel
->aliyB
);
68 WMPerformButtonClick(panel
->alinB
);
70 WMSetButtonSelected(panel
->wrapB
, GetBoolForKey("WrapMenus"));
72 WMSetButtonSelected(panel
->autoB
, GetBoolForKey("ScrollableMenus"));
77 storeData(_Panel
*panel
)
82 if (WMGetButtonSelected(panel
->scrB
[i
]))
85 SetSpeedForKey(i
, "MenuScrollSpeed");
87 SetBoolForKey(WMGetButtonSelected(panel
->aliyB
), "AlignSubmenus");
89 SetBoolForKey(WMGetButtonSelected(panel
->wrapB
), "WrapMenus");
90 SetBoolForKey(WMGetButtonSelected(panel
->autoB
), "ScrollableMenus");
97 _Panel
*panel
= (_Panel
*)p
;
98 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
105 panel
->box
= WMCreateBox(panel
->parent
);
106 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 0, 0);
108 /***************** Menu Scroll Speed ****************/
109 panel
->scrF
= WMCreateFrame(panel
->box
);
110 WMResizeWidget(panel
->scrF
, 235, 90);
111 WMMoveWidget(panel
->scrF
, 25, 20);
112 WMSetFrameTitle(panel
->scrF
, _("Menu Scrolling Speed"));
115 buf1
= wmalloc(strlen(SPEED_IMAGE
)+1);
116 buf2
= wmalloc(strlen(SPEED_IMAGE_S
)+1);
117 for (i
= 0; i
< 5; i
++) {
118 panel
->scrB
[i
] = WMCreateCustomButton(panel
->scrF
, WBBStateChangeMask
);
119 WMResizeWidget(panel
->scrB
[i
], 40, 40);
120 WMMoveWidget(panel
->scrB
[i
], 15+(40*i
), 30);
121 WMSetButtonBordered(panel
->scrB
[i
], False
);
122 WMSetButtonImagePosition(panel
->scrB
[i
], WIPImageOnly
);
124 WMGroupButtons(panel
->scrB
[0], panel
->scrB
[i
]);
126 sprintf(buf1
, SPEED_IMAGE
, i
);
127 sprintf(buf2
, SPEED_IMAGE_S
, i
);
128 path
= LocateImage(buf1
);
130 icon
= WMCreatePixmapFromFile(scr
, path
);
132 WMSetButtonImage(panel
->scrB
[i
], icon
);
133 WMReleasePixmap(icon
);
135 wwarning(_("could not load icon file %s"), path
);
139 path
= LocateImage(buf2
);
141 icon
= WMCreatePixmapFromFile(scr
, path
);
143 WMSetButtonAltImage(panel
->scrB
[i
], icon
);
144 WMReleasePixmap(icon
);
146 wwarning(_("could not load icon file %s"), path
);
154 WMMapSubwidgets(panel
->scrF
);
156 /***************** Submenu Alignment ****************/
158 panel
->aliF
= WMCreateFrame(panel
->box
);
159 WMResizeWidget(panel
->aliF
, 220, 90);
160 WMMoveWidget(panel
->aliF
, 280, 20);
161 WMSetFrameTitle(panel
->aliF
, _("Submenu Alignment"));
163 panel
->alinB
= WMCreateButton(panel
->aliF
, WBTOnOff
);
164 WMResizeWidget(panel
->alinB
, 48, 48);
165 WMMoveWidget(panel
->alinB
, 56, 25);
166 WMSetButtonImagePosition(panel
->alinB
, WIPImageOnly
);
167 path
= LocateImage(MENU_ALIGN1
);
169 icon
= WMCreatePixmapFromFile(scr
, path
);
171 WMSetButtonImage(panel
->alinB
, icon
);
172 WMReleasePixmap(icon
);
174 wwarning(_("could not load icon file %s"), path
);
178 panel
->aliyB
= WMCreateButton(panel
->aliF
, WBTOnOff
);
179 WMResizeWidget(panel
->aliyB
, 48, 48);
180 WMMoveWidget(panel
->aliyB
, 120, 25);
181 WMSetButtonImagePosition(panel
->aliyB
, WIPImageOnly
);
182 path
= LocateImage(MENU_ALIGN2
);
184 icon
= WMCreatePixmapFromFile(scr
, path
);
186 WMSetButtonImage(panel
->aliyB
, icon
);
187 WMReleasePixmap(icon
);
189 wwarning(_("could not load icon file %s"), path
);
193 WMGroupButtons(panel
->alinB
, panel
->aliyB
);
195 WMMapSubwidgets(panel
->aliF
);
197 /***************** Options ****************/
198 panel
->optF
= WMCreateFrame(panel
->box
);
199 WMResizeWidget(panel
->optF
, 475, 80);
200 WMMoveWidget(panel
->optF
, 25, 130);
202 panel
->wrapB
= WMCreateSwitchButton(panel
->optF
);
203 WMResizeWidget(panel
->wrapB
, 440, 32);
204 WMMoveWidget(panel
->wrapB
, 25, 8);
205 WMSetButtonText(panel
->wrapB
, _("Always open submenus inside the screen, instead of scrolling.\nNote: this is annoying."));
207 panel
->autoB
= WMCreateSwitchButton(panel
->optF
);
208 WMResizeWidget(panel
->autoB
, 440, 32);
209 WMMoveWidget(panel
->autoB
, 25, 45);
210 WMSetButtonText(panel
->autoB
, _("Scroll off-screen menus when pointer is moved over them."));
212 WMMapSubwidgets(panel
->optF
);
214 WMRealizeWidget(panel
->box
);
215 WMMapSubwidgets(panel
->box
);
223 InitMenuPreferences(WMScreen
*scr
, WMWidget
*parent
)
227 panel
= wmalloc(sizeof(_Panel
));
228 memset(panel
, 0, sizeof(_Panel
));
230 panel
->sectionName
= _("Menu Preferences");
232 panel
->description
= _("Menu usability related options. Scrolling speed,\n"
233 "alignment of submenus etc.");
235 panel
->parent
= parent
;
237 panel
->callbacks
.createWidgets
= createPanel
;
238 panel
->callbacks
.updateDomain
= storeData
;
240 AddSection(panel
, ICON_FILE
);