1 /* Workspace.c- workspace options
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998-2003 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 along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 typedef struct _Panel
{
31 CallbackRec callbacks
;
49 #define ICON_FILE "workspace"
51 #define ARQUIVO_XIS "xis"
52 #define DONT_LINK_FILE "dontlinkworkspaces"
53 #define CYCLE_FILE "cycleworkspaces"
54 #define ADVANCE_FILE "advancetonewworkspace"
55 #define WSNAME_FILE "workspacename"
57 static char *WSNamePositions
[] = {
68 static void showData(_Panel
* panel
)
73 WMSetButtonSelected(panel
->linkB
, !GetBoolForKey("DontLinkWorkspaces"));
75 WMSetButtonSelected(panel
->cyclB
, GetBoolForKey("CycleWorkspaces"));
77 WMSetButtonSelected(panel
->newB
, GetBoolForKey("AdvanceToNewWorkspace"));
79 str
= GetStringForKey("WorkspaceNameDisplayPosition");
84 for (i
= 0; i
< sizeof(WSNamePositions
) / sizeof(WSNamePositions
[0]); i
++) {
85 if (strcasecmp(WSNamePositions
[i
], str
) == 0) {
90 WMSetPopUpButtonSelectedItem(panel
->posP
, idx
);
93 static void createPanel(Panel
* p
)
95 _Panel
*panel
= (_Panel
*) p
;
96 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
99 RContext
*rc
= WMScreenRContext(scr
);
102 path
= LocateImage(ARQUIVO_XIS
);
104 xis
= RLoadImage(rc
, path
, 0);
106 wwarning(_("could not load image file %s"), path
);
111 panel
->box
= WMCreateBox(panel
->parent
);
112 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
114 /***************** Workspace Navigation *****************/
115 panel
->navF
= WMCreateFrame(panel
->box
);
116 WMResizeWidget(panel
->navF
, 490, 210);
117 WMMoveWidget(panel
->navF
, 15, 10);
118 WMSetFrameTitle(panel
->navF
, _("Workspace Navigation"));
120 panel
->cyclB
= WMCreateSwitchButton(panel
->navF
);
121 WMResizeWidget(panel
->cyclB
, 410, 34);
122 WMMoveWidget(panel
->cyclB
, 75, 30);
123 WMSetButtonText(panel
->cyclB
, _("Wrap to the first workspace from the last workspace."));
125 panel
->cyclL
= WMCreateLabel(panel
->navF
);
126 WMResizeWidget(panel
->cyclL
, 60, 60);
127 WMMoveWidget(panel
->cyclL
, 10, 15);
128 WMSetLabelImagePosition(panel
->cyclL
, WIPImageOnly
);
129 CreateImages(scr
, rc
, xis
, CYCLE_FILE
, &icon1
, NULL
);
132 WMSetLabelImage(panel
->cyclL
, icon1
);
133 WMReleasePixmap(icon1
);
136 /**/ panel
->linkB
= WMCreateSwitchButton(panel
->navF
);
137 WMResizeWidget(panel
->linkB
, 410, 34);
138 WMMoveWidget(panel
->linkB
, 75, 75);
139 WMSetButtonText(panel
->linkB
, _("Switch workspaces while dragging windows."));
141 panel
->linkL
= WMCreateLabel(panel
->navF
);
142 WMResizeWidget(panel
->linkL
, 60, 40);
143 WMMoveWidget(panel
->linkL
, 10, 80);
144 WMSetLabelImagePosition(panel
->linkL
, WIPImageOnly
);
145 CreateImages(scr
, rc
, xis
, DONT_LINK_FILE
, &icon1
, NULL
);
148 WMSetLabelImage(panel
->linkL
, icon1
);
149 WMReleasePixmap(icon1
);
152 /**/ panel
->newB
= WMCreateSwitchButton(panel
->navF
);
153 WMResizeWidget(panel
->newB
, 410, 34);
154 WMMoveWidget(panel
->newB
, 75, 120);
155 WMSetButtonText(panel
->newB
, _("Automatically create new workspaces."));
157 panel
->newL
= WMCreateLabel(panel
->navF
);
158 WMResizeWidget(panel
->newL
, 60, 20);
159 WMMoveWidget(panel
->newL
, 10, 130);
160 WMSetLabelImagePosition(panel
->newL
, WIPImageOnly
);
161 CreateImages(scr
, rc
, xis
, ADVANCE_FILE
, &icon1
, NULL
);
164 WMSetLabelImage(panel
->newL
, icon1
);
165 WMReleasePixmap(icon1
);
168 /**/ panel
->posL
= WMCreateLabel(panel
->navF
);
169 WMResizeWidget(panel
->posL
, 200, 30);
170 WMMoveWidget(panel
->posL
, 75, 165);
171 // WMSetLabelTextAlignment(panel->posL, WARight);
172 WMSetLabelText(panel
->posL
, _("Position of workspace name display"));
174 panel
->posiL
= WMCreateLabel(panel
->navF
);
175 WMResizeWidget(panel
->posiL
, 60, 40);
176 WMMoveWidget(panel
->posiL
, 10, 160);
177 WMSetLabelImagePosition(panel
->posiL
, WIPImageOnly
);
178 CreateImages(scr
, rc
, xis
, WSNAME_FILE
, &icon1
, NULL
);
181 WMSetLabelImage(panel
->posiL
, icon1
);
182 WMReleasePixmap(icon1
);
185 panel
->posP
= WMCreatePopUpButton(panel
->navF
);
186 WMResizeWidget(panel
->posP
, 125, 20);
187 WMMoveWidget(panel
->posP
, 290, 170);
188 WMAddPopUpButtonItem(panel
->posP
, _("Disable"));
189 WMAddPopUpButtonItem(panel
->posP
, _("Center"));
190 WMAddPopUpButtonItem(panel
->posP
, _("Top"));
191 WMAddPopUpButtonItem(panel
->posP
, _("Bottom"));
192 WMAddPopUpButtonItem(panel
->posP
, _("Top/Left"));
193 WMAddPopUpButtonItem(panel
->posP
, _("Top/Right"));
194 WMAddPopUpButtonItem(panel
->posP
, _("Bottom/Left"));
195 WMAddPopUpButtonItem(panel
->posP
, _("Bottom/Right"));
197 WMMapSubwidgets(panel
->navF
);
202 WMRealizeWidget(panel
->box
);
203 WMMapSubwidgets(panel
->box
);
208 static void storeData(_Panel
* panel
)
210 SetBoolForKey(!WMGetButtonSelected(panel
->linkB
), "DontLinkWorkspaces");
211 SetBoolForKey(WMGetButtonSelected(panel
->cyclB
), "CycleWorkspaces");
212 SetBoolForKey(WMGetButtonSelected(panel
->newB
), "AdvanceToNewWorkspace");
214 SetStringForKey(WSNamePositions
[WMGetPopUpButtonSelectedItem(panel
->posP
)],
215 "WorkspaceNameDisplayPosition");
218 Panel
*InitWorkspace(WMScreen
* scr
, WMWidget
* parent
)
222 panel
= wmalloc(sizeof(_Panel
));
224 panel
->sectionName
= _("Workspace Preferences");
226 panel
->description
= _("Workspace navigation features.\n"
227 "You can also enable/disable the Dock and Clip here.");
229 panel
->parent
= parent
;
231 panel
->callbacks
.createWidgets
= createPanel
;
232 panel
->callbacks
.updateDomain
= storeData
;
234 AddSection(panel
, ICON_FILE
);