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
{
34 CallbackRec callbacks
;
53 #define ICON_FILE "workspace"
55 #define ARQUIVO_XIS "xis"
56 #define DONT_LINK_FILE "dontlinkworkspaces"
57 #define CYCLE_FILE "cycleworkspaces"
58 #define ADVANCE_FILE "advancetonewworkspace"
59 #define DOCK_FILE "dock"
60 #define CLIP_FILE "clip"
65 createImages(WMScreen
*scr
, RContext
*rc
, RImage
*xis
, char *file
,
66 WMPixmap
**icon1
, WMPixmap
**icon2
)
69 RColor gray
= {0xae,0xaa,0xae};
71 *icon1
= WMCreatePixmapFromFile(scr
, file
);
73 wwarning(_("could not load icon %s"), file
);
77 icon
= RLoadImage(rc
, file
, 0);
79 wwarning(_("could not load icon %s"), file
);
83 RCombineImageWithColor(icon
, &gray
);
85 RCombineImagesWithOpaqueness(icon
, xis
, 180);
86 if (!(*icon2
= WMCreatePixmapFromRImage(scr
, icon
, 127))) {
87 wwarning(_("could not process icon %s:"), file
, RMessageForError(RErrorCode
));
97 showData(_Panel
*panel
)
99 WMSetButtonSelected(panel
->linkB
, !GetBoolForKey("DontLinkWorkspaces"));
101 WMSetButtonSelected(panel
->cyclB
, GetBoolForKey("CycleWorkspaces"));
103 WMSetButtonSelected(panel
->newB
, GetBoolForKey("AdvanceToNewWorkspace"));
105 WMSetButtonSelected(panel
->dockB
, !GetBoolForKey("DisableDock"));
107 WMSetButtonSelected(panel
->clipB
, !GetBoolForKey("DisableClip"));
113 createPanel(Panel
*p
)
115 _Panel
*panel
= (_Panel
*)p
;
116 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
117 WMPixmap
*icon1
, *icon2
;
119 RContext
*rc
= WMScreenRContext(scr
);
122 path
= LocateImage(ARQUIVO_XIS
);
124 xis
= RLoadImage(rc
, path
, 0);
126 wwarning(_("could not load image file %s"), path
);
131 panel
->frame
= WMCreateFrame(panel
->win
);
132 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
133 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
135 /***************** Workspace Navigation *****************/
136 panel
->navF
= WMCreateFrame(panel
->frame
);
137 WMResizeWidget(panel
->navF
, 365, 200);
138 WMMoveWidget(panel
->navF
, 20, 15);
139 WMSetFrameTitle(panel
->navF
, _("Workspace Navigation"));
141 panel
->linkB
= WMCreateButton(panel
->navF
, WBTToggle
);
142 WMResizeWidget(panel
->linkB
, 60, 60);
143 WMMoveWidget(panel
->linkB
, 20, 25);
144 WMSetButtonImagePosition(panel
->linkB
, WIPImageOnly
);
145 path
= LocateImage(DONT_LINK_FILE
);
147 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
149 WMSetButtonImage(panel
->linkB
, icon2
);
150 WMReleasePixmap(icon2
);
153 WMSetButtonAltImage(panel
->linkB
, icon1
);
154 WMReleasePixmap(icon1
);
158 panel
->linkL
= WMCreateLabel(panel
->navF
);
159 WMResizeWidget(panel
->linkL
, 260, 38);
160 WMMoveWidget(panel
->linkL
, 85, 25);
161 WMSetLabelTextAlignment(panel
->linkL
, WALeft
);
162 WMSetLabelText(panel
->linkL
,
163 _("drag windows between workspaces."));
166 panel
->cyclB
= WMCreateButton(panel
->navF
, WBTToggle
);
167 WMResizeWidget(panel
->cyclB
, 60, 60);
168 WMMoveWidget(panel
->cyclB
, 285, 75);
169 WMSetButtonImagePosition(panel
->cyclB
, WIPImageOnly
);
170 path
= LocateImage(CYCLE_FILE
);
172 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
174 WMSetButtonImage(panel
->cyclB
, icon2
);
175 WMReleasePixmap(icon2
);
178 WMSetButtonAltImage(panel
->cyclB
, icon1
);
179 WMReleasePixmap(icon1
);
183 panel
->cyclL
= WMCreateLabel(panel
->navF
);
184 WMResizeWidget(panel
->cyclL
, 260, 38);
185 WMMoveWidget(panel
->cyclL
, 20, 85);
186 WMSetLabelTextAlignment(panel
->cyclL
, WARight
);
187 WMSetLabelText(panel
->cyclL
,
188 _("switch to first workspace when switching past the last workspace and vice-versa"));
190 panel
->newB
= WMCreateButton(panel
->navF
, WBTToggle
);
191 WMResizeWidget(panel
->newB
, 60, 60);
192 WMMoveWidget(panel
->newB
, 20, 125);
193 WMSetButtonImagePosition(panel
->newB
, WIPImageOnly
);
194 path
= LocateImage(ADVANCE_FILE
);
196 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
198 WMSetButtonImage(panel
->newB
, icon2
);
199 WMReleasePixmap(icon2
);
202 WMSetButtonAltImage(panel
->newB
, icon1
);
203 WMReleasePixmap(icon1
);
207 panel
->newL
= WMCreateLabel(panel
->navF
);
208 WMResizeWidget(panel
->newL
, 260, 38);
209 WMMoveWidget(panel
->newL
, 85, 140);
210 WMSetLabelTextAlignment(panel
->newL
, WALeft
);
211 WMSetLabelText(panel
->newL
,
212 _("create a new workspace when switching past the last workspace."));
214 WMMapSubwidgets(panel
->navF
);
216 /***************** Dock/Clip *****************/
217 panel
->dockF
= WMCreateFrame(panel
->frame
);
218 WMResizeWidget(panel
->dockF
, 105, 200);
219 WMMoveWidget(panel
->dockF
, 400, 15);
220 WMSetFrameTitle(panel
->dockF
, _("Dock/Clip"));
222 panel
->dockB
= WMCreateButton(panel
->dockF
, WBTToggle
);
223 WMResizeWidget(panel
->dockB
, 64, 64);
224 WMMoveWidget(panel
->dockB
, 20, 30);
225 WMSetButtonImagePosition(panel
->dockB
, WIPImageOnly
);
226 path
= LocateImage(DOCK_FILE
);
228 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
230 WMSetButtonImage(panel
->dockB
, icon2
);
231 WMReleasePixmap(icon2
);
234 WMSetButtonAltImage(panel
->dockB
, icon1
);
235 WMReleasePixmap(icon1
);
239 WMSetBalloonTextForView(_("Disable/enable the application Dock (the\n"
240 "vertical icon bar in the side of the screen)."),
241 WMWidgetView(panel
->dockB
));
243 panel
->clipB
= WMCreateButton(panel
->dockF
, WBTToggle
);
244 WMResizeWidget(panel
->clipB
, 64, 64);
245 WMMoveWidget(panel
->clipB
, 20, 110);
246 WMSetButtonImagePosition(panel
->clipB
, WIPImageOnly
);
247 path
= LocateImage(CLIP_FILE
);
249 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
251 WMSetButtonImage(panel
->clipB
, icon2
);
252 WMReleasePixmap(icon2
);
255 WMSetButtonAltImage(panel
->clipB
, icon1
);
256 WMReleasePixmap(icon1
);
259 WMSetBalloonTextForView(_("Disable/enable the Clip (that thing with\n"
260 "a paper clip icon)."),
261 WMWidgetView(panel
->clipB
));
263 WMMapSubwidgets(panel
->dockF
);
268 WMRealizeWidget(panel
->frame
);
269 WMMapSubwidgets(panel
->frame
);
276 storeData(_Panel
*panel
)
278 SetBoolForKey(!WMGetButtonSelected(panel
->linkB
), "DontLinkWorkspaces");
279 SetBoolForKey(WMGetButtonSelected(panel
->cyclB
), "CycleWorkspaces");
280 SetBoolForKey(WMGetButtonSelected(panel
->newB
), "AdvanceToNewWorkspace");
282 SetBoolForKey(!WMGetButtonSelected(panel
->dockB
), "DisableDock");
283 SetBoolForKey(!WMGetButtonSelected(panel
->clipB
), "DisableClip");
289 InitWorkspace(WMScreen
*scr
, WMWindow
*win
)
293 panel
= wmalloc(sizeof(_Panel
));
294 memset(panel
, 0, sizeof(_Panel
));
296 panel
->sectionName
= _("Workspace Preferences");
298 panel
->description
= _("Workspace navigation features.\n"
299 "You can also enable/disable the Dock and Clip here.");
303 panel
->callbacks
.createWidgets
= createPanel
;
304 panel
->callbacks
.updateDomain
= storeData
;
306 AddSection(panel
, ICON_FILE
);