1 /* Workspace.c- workspace options
3 * WPrefs - WindowMaker 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,
27 typedef struct _Panel
{
32 CallbackRec callbacks
;
51 #define ICON_FILE "workspace"
53 #define ARQUIVO_XIS "xis"
54 #define DONT_LINK_FILE "dontlinkworkspaces"
55 #define CYCLE_FILE "cycleworkspaces"
56 #define ADVANCE_FILE "advancetonewworkspace"
57 #define DOCK_FILE "dock"
58 #define CLIP_FILE "clip"
63 createImages(WMScreen
*scr
, RContext
*rc
, RImage
*xis
, char *file
,
64 WMPixmap
**icon1
, WMPixmap
**icon2
)
68 *icon1
= WMCreatePixmapFromFile(scr
, file
);
70 wwarning(_("could not load icon %s"), file
);
74 icon
= RLoadImage(rc
, file
, 0);
76 wwarning(_("could not load icon %s"), file
);
81 RCombineImages(icon
, xis
);
82 if (!(*icon2
= WMCreatePixmapFromRImage(scr
, icon
, 127))) {
83 wwarning(_("could not process icon %s:"), file
, RErrorString
);
93 showData(_Panel
*panel
)
95 WMSetButtonSelected(panel
->linkB
, !GetBoolForKey("DontLinkWorkspaces"));
97 WMSetButtonSelected(panel
->cyclB
, GetBoolForKey("CycleWorkspaces"));
99 WMSetButtonSelected(panel
->newB
, GetBoolForKey("AdvanceToNewWorkspace"));
101 WMSetButtonSelected(panel
->dockB
, !GetBoolForKey("DisableDock"));
103 WMSetButtonSelected(panel
->clipB
, !GetBoolForKey("DisableClip"));
109 createPanel(Panel
*p
)
111 _Panel
*panel
= (_Panel
*)p
;
112 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
113 WMPixmap
*icon1
, *icon2
;
115 RContext
*rc
= WMScreenRContext(scr
);
118 path
= LocateImage(ARQUIVO_XIS
);
120 xis
= RLoadImage(rc
, path
, 0);
122 wwarning(_("could not load image file %s"), path
);
127 panel
->frame
= WMCreateFrame(panel
->win
);
128 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
129 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
131 /***************** Workspace Navigation *****************/
132 panel
->navF
= WMCreateFrame(panel
->frame
);
133 WMResizeWidget(panel
->navF
, 365, 200);
134 WMMoveWidget(panel
->navF
, 20, 15);
135 WMSetFrameTitle(panel
->navF
, _("Workspace Navigation"));
137 panel
->linkB
= WMCreateButton(panel
->navF
, WBTToggle
);
138 WMResizeWidget(panel
->linkB
, 60, 60);
139 WMMoveWidget(panel
->linkB
, 20, 25);
140 WMSetButtonImagePosition(panel
->linkB
, WIPImageOnly
);
141 path
= LocateImage(DONT_LINK_FILE
);
143 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
145 WMSetButtonImage(panel
->linkB
, icon2
);
146 WMReleasePixmap(icon2
);
149 WMSetButtonAltImage(panel
->linkB
, icon1
);
150 WMReleasePixmap(icon1
);
154 panel
->linkL
= WMCreateLabel(panel
->navF
);
155 WMResizeWidget(panel
->linkL
, 260, 38);
156 WMMoveWidget(panel
->linkL
, 85, 25);
157 WMSetLabelTextAlignment(panel
->linkL
, WALeft
);
158 WMSetLabelText(panel
->linkL
,
159 _("drag windows between workspaces."));
162 panel
->cyclB
= WMCreateButton(panel
->navF
, WBTToggle
);
163 WMResizeWidget(panel
->cyclB
, 60, 60);
164 WMMoveWidget(panel
->cyclB
, 285, 75);
165 WMSetButtonImagePosition(panel
->cyclB
, WIPImageOnly
);
166 path
= LocateImage(CYCLE_FILE
);
168 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
170 WMSetButtonImage(panel
->cyclB
, icon2
);
171 WMReleasePixmap(icon2
);
174 WMSetButtonAltImage(panel
->cyclB
, icon1
);
175 WMReleasePixmap(icon1
);
179 panel
->cyclL
= WMCreateLabel(panel
->navF
);
180 WMResizeWidget(panel
->cyclL
, 260, 38);
181 WMMoveWidget(panel
->cyclL
, 20, 85);
182 WMSetLabelTextAlignment(panel
->cyclL
, WARight
);
183 WMSetLabelText(panel
->cyclL
,
184 _("switch to first workspace when switching past the last workspace and vice-versa"));
186 panel
->newB
= WMCreateButton(panel
->navF
, WBTToggle
);
187 WMResizeWidget(panel
->newB
, 60, 60);
188 WMMoveWidget(panel
->newB
, 20, 125);
189 WMSetButtonImagePosition(panel
->newB
, WIPImageOnly
);
190 path
= LocateImage(ADVANCE_FILE
);
192 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
194 WMSetButtonImage(panel
->newB
, icon2
);
195 WMReleasePixmap(icon2
);
198 WMSetButtonAltImage(panel
->newB
, icon1
);
199 WMReleasePixmap(icon1
);
203 panel
->newL
= WMCreateLabel(panel
->navF
);
204 WMResizeWidget(panel
->newL
, 260, 38);
205 WMMoveWidget(panel
->newL
, 85, 140);
206 WMSetLabelTextAlignment(panel
->newL
, WALeft
);
207 WMSetLabelText(panel
->newL
,
208 _("create a new workspace when switching past the last workspace."));
210 WMMapSubwidgets(panel
->navF
);
212 /***************** Dock/Clip *****************/
213 panel
->dockF
= WMCreateFrame(panel
->frame
);
214 WMResizeWidget(panel
->dockF
, 105, 200);
215 WMMoveWidget(panel
->dockF
, 400, 15);
216 WMSetFrameTitle(panel
->dockF
, _("Dock/Clip"));
218 panel
->dockB
= WMCreateButton(panel
->dockF
, WBTToggle
);
219 WMResizeWidget(panel
->dockB
, 64, 64);
220 WMMoveWidget(panel
->dockB
, 20, 30);
221 WMSetButtonImagePosition(panel
->dockB
, WIPImageOnly
);
222 path
= LocateImage(DOCK_FILE
);
224 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
226 WMSetButtonImage(panel
->dockB
, icon2
);
227 WMReleasePixmap(icon2
);
230 WMSetButtonAltImage(panel
->dockB
, icon1
);
231 WMReleasePixmap(icon1
);
236 panel
->clipB
= WMCreateButton(panel
->dockF
, WBTToggle
);
237 WMResizeWidget(panel
->clipB
, 64, 64);
238 WMMoveWidget(panel
->clipB
, 20, 110);
239 WMSetButtonImagePosition(panel
->clipB
, WIPImageOnly
);
240 path
= LocateImage(CLIP_FILE
);
242 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
244 WMSetButtonImage(panel
->clipB
, icon2
);
245 WMReleasePixmap(icon2
);
248 WMSetButtonAltImage(panel
->clipB
, icon1
);
249 WMReleasePixmap(icon1
);
252 WMMapSubwidgets(panel
->dockF
);
257 WMRealizeWidget(panel
->frame
);
258 WMMapSubwidgets(panel
->frame
);
265 storeData(_Panel
*panel
)
267 SetBoolForKey(!WMGetButtonSelected(panel
->linkB
), "DontLinkWorkspaces");
268 SetBoolForKey(WMGetButtonSelected(panel
->cyclB
), "CycleWorkspaces");
269 SetBoolForKey(WMGetButtonSelected(panel
->newB
), "AdvanceToNewWorkspace");
271 SetBoolForKey(!WMGetButtonSelected(panel
->dockB
), "DisableDock");
272 SetBoolForKey(!WMGetButtonSelected(panel
->clipB
), "DisableClip");
278 InitWorkspace(WMScreen
*scr
, WMWindow
*win
)
282 panel
= wmalloc(sizeof(_Panel
));
283 memset(panel
, 0, sizeof(_Panel
));
285 panel
->sectionName
= _("Workspace Preferences");
289 panel
->callbacks
.createWidgets
= createPanel
;
290 panel
->callbacks
.updateDomain
= storeData
;
292 AddSection(panel
, ICON_FILE
);