1 /* Workspace.c- workspace options
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,
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
)
67 RColor gray
= {0xae,0xaa,0xae};
69 *icon1
= WMCreatePixmapFromFile(scr
, file
);
71 wwarning(_("could not load icon %s"), file
);
75 icon
= RLoadImage(rc
, file
, 0);
77 wwarning(_("could not load icon %s"), file
);
81 RCombineImageWithColor(icon
, &gray
);
83 RCombineImagesWithOpaqueness(icon
, xis
, 180);
84 if (!(*icon2
= WMCreatePixmapFromRImage(scr
, icon
, 127))) {
85 wwarning(_("could not process icon %s:"), file
, RMessageForError(RErrorCode
));
95 showData(_Panel
*panel
)
97 WMSetButtonSelected(panel
->linkB
, !GetBoolForKey("DontLinkWorkspaces"));
99 WMSetButtonSelected(panel
->cyclB
, GetBoolForKey("CycleWorkspaces"));
101 WMSetButtonSelected(panel
->newB
, GetBoolForKey("AdvanceToNewWorkspace"));
103 WMSetButtonSelected(panel
->dockB
, !GetBoolForKey("DisableDock"));
105 WMSetButtonSelected(panel
->clipB
, !GetBoolForKey("DisableClip"));
111 createPanel(Panel
*p
)
113 _Panel
*panel
= (_Panel
*)p
;
114 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
115 WMPixmap
*icon1
, *icon2
;
117 RContext
*rc
= WMScreenRContext(scr
);
120 path
= LocateImage(ARQUIVO_XIS
);
122 xis
= RLoadImage(rc
, path
, 0);
124 wwarning(_("could not load image file %s"), path
);
129 panel
->frame
= WMCreateFrame(panel
->win
);
130 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
131 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
133 /***************** Workspace Navigation *****************/
134 panel
->navF
= WMCreateFrame(panel
->frame
);
135 WMResizeWidget(panel
->navF
, 365, 200);
136 WMMoveWidget(panel
->navF
, 20, 15);
137 WMSetFrameTitle(panel
->navF
, _("Workspace Navigation"));
139 panel
->linkB
= WMCreateButton(panel
->navF
, WBTToggle
);
140 WMResizeWidget(panel
->linkB
, 60, 60);
141 WMMoveWidget(panel
->linkB
, 20, 25);
142 WMSetButtonImagePosition(panel
->linkB
, WIPImageOnly
);
143 path
= LocateImage(DONT_LINK_FILE
);
145 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
147 WMSetButtonImage(panel
->linkB
, icon2
);
148 WMReleasePixmap(icon2
);
151 WMSetButtonAltImage(panel
->linkB
, icon1
);
152 WMReleasePixmap(icon1
);
156 panel
->linkL
= WMCreateLabel(panel
->navF
);
157 WMResizeWidget(panel
->linkL
, 260, 38);
158 WMMoveWidget(panel
->linkL
, 85, 25);
159 WMSetLabelTextAlignment(panel
->linkL
, WALeft
);
160 WMSetLabelText(panel
->linkL
,
161 _("drag windows between workspaces."));
164 panel
->cyclB
= WMCreateButton(panel
->navF
, WBTToggle
);
165 WMResizeWidget(panel
->cyclB
, 60, 60);
166 WMMoveWidget(panel
->cyclB
, 285, 75);
167 WMSetButtonImagePosition(panel
->cyclB
, WIPImageOnly
);
168 path
= LocateImage(CYCLE_FILE
);
170 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
172 WMSetButtonImage(panel
->cyclB
, icon2
);
173 WMReleasePixmap(icon2
);
176 WMSetButtonAltImage(panel
->cyclB
, icon1
);
177 WMReleasePixmap(icon1
);
181 panel
->cyclL
= WMCreateLabel(panel
->navF
);
182 WMResizeWidget(panel
->cyclL
, 260, 38);
183 WMMoveWidget(panel
->cyclL
, 20, 85);
184 WMSetLabelTextAlignment(panel
->cyclL
, WARight
);
185 WMSetLabelText(panel
->cyclL
,
186 _("switch to first workspace when switching past the last workspace and vice-versa"));
188 panel
->newB
= WMCreateButton(panel
->navF
, WBTToggle
);
189 WMResizeWidget(panel
->newB
, 60, 60);
190 WMMoveWidget(panel
->newB
, 20, 125);
191 WMSetButtonImagePosition(panel
->newB
, WIPImageOnly
);
192 path
= LocateImage(ADVANCE_FILE
);
194 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
196 WMSetButtonImage(panel
->newB
, icon2
);
197 WMReleasePixmap(icon2
);
200 WMSetButtonAltImage(panel
->newB
, icon1
);
201 WMReleasePixmap(icon1
);
205 panel
->newL
= WMCreateLabel(panel
->navF
);
206 WMResizeWidget(panel
->newL
, 260, 38);
207 WMMoveWidget(panel
->newL
, 85, 140);
208 WMSetLabelTextAlignment(panel
->newL
, WALeft
);
209 WMSetLabelText(panel
->newL
,
210 _("create a new workspace when switching past the last workspace."));
212 WMMapSubwidgets(panel
->navF
);
214 /***************** Dock/Clip *****************/
215 panel
->dockF
= WMCreateFrame(panel
->frame
);
216 WMResizeWidget(panel
->dockF
, 105, 200);
217 WMMoveWidget(panel
->dockF
, 400, 15);
218 WMSetFrameTitle(panel
->dockF
, _("Dock/Clip"));
220 panel
->dockB
= WMCreateButton(panel
->dockF
, WBTToggle
);
221 WMResizeWidget(panel
->dockB
, 64, 64);
222 WMMoveWidget(panel
->dockB
, 20, 30);
223 WMSetButtonImagePosition(panel
->dockB
, WIPImageOnly
);
224 path
= LocateImage(DOCK_FILE
);
226 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
228 WMSetButtonImage(panel
->dockB
, icon2
);
229 WMReleasePixmap(icon2
);
232 WMSetButtonAltImage(panel
->dockB
, icon1
);
233 WMReleasePixmap(icon1
);
238 panel
->clipB
= WMCreateButton(panel
->dockF
, WBTToggle
);
239 WMResizeWidget(panel
->clipB
, 64, 64);
240 WMMoveWidget(panel
->clipB
, 20, 110);
241 WMSetButtonImagePosition(panel
->clipB
, WIPImageOnly
);
242 path
= LocateImage(CLIP_FILE
);
244 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
246 WMSetButtonImage(panel
->clipB
, icon2
);
247 WMReleasePixmap(icon2
);
250 WMSetButtonAltImage(panel
->clipB
, icon1
);
251 WMReleasePixmap(icon1
);
254 WMMapSubwidgets(panel
->dockF
);
259 WMRealizeWidget(panel
->frame
);
260 WMMapSubwidgets(panel
->frame
);
267 storeData(_Panel
*panel
)
269 SetBoolForKey(!WMGetButtonSelected(panel
->linkB
), "DontLinkWorkspaces");
270 SetBoolForKey(WMGetButtonSelected(panel
->cyclB
), "CycleWorkspaces");
271 SetBoolForKey(WMGetButtonSelected(panel
->newB
), "AdvanceToNewWorkspace");
273 SetBoolForKey(!WMGetButtonSelected(panel
->dockB
), "DisableDock");
274 SetBoolForKey(!WMGetButtonSelected(panel
->clipB
), "DisableClip");
280 InitWorkspace(WMScreen
*scr
, WMWindow
*win
)
284 panel
= wmalloc(sizeof(_Panel
));
285 memset(panel
, 0, sizeof(_Panel
));
287 panel
->sectionName
= _("Workspace Preferences");
291 panel
->callbacks
.createWidgets
= createPanel
;
292 panel
->callbacks
.updateDomain
= storeData
;
294 AddSection(panel
, ICON_FILE
);