WPrefs: Moved widgets in Workspace panel so that label is not truncated
[wmaker-crm.git] / WPrefs.app / Workspace.c
bloba38273850a709a5965cc3096f69e72e6bac713c6
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.
22 #include "WPrefs.h"
24 typedef struct _Panel {
25 WMBox *box;
27 char *sectionName;
29 char *description;
31 CallbackRec callbacks;
33 WMWidget *parent;
35 WMFrame *navF;
37 WMButton *linkB;
38 WMButton *cyclB;
39 WMButton *newB;
40 WMLabel *linkL;
41 WMLabel *cyclL;
42 WMLabel *newL;
44 WMLabel *posiL;
45 WMLabel *posL;
46 WMPopUpButton *posP;
47 } _Panel;
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[] = {
58 "none",
59 "center",
60 "top",
61 "bottom",
62 "topleft",
63 "topright",
64 "bottomleft",
65 "bottomright"
68 static void showData(_Panel * panel)
70 int i, idx;
71 char *str;
73 WMSetButtonSelected(panel->linkB, !GetBoolForKey("DontLinkWorkspaces"));
75 WMSetButtonSelected(panel->cyclB, GetBoolForKey("CycleWorkspaces"));
77 WMSetButtonSelected(panel->newB, GetBoolForKey("AdvanceToNewWorkspace"));
79 str = GetStringForKey("WorkspaceNameDisplayPosition");
80 if (!str)
81 str = "center";
83 idx = 1; /* center */
84 for (i = 0; i < wlengthof(WSNamePositions); i++) {
85 if (strcasecmp(WSNamePositions[i], str) == 0) {
86 idx = i;
87 break;
90 WMSetPopUpButtonSelectedItem(panel->posP, idx);
93 static void createPanel(Panel * p)
95 _Panel *panel = (_Panel *) p;
96 WMScreen *scr = WMWidgetScreen(panel->parent);
97 WMPixmap *icon1;
98 RImage *xis = NULL;
99 RContext *rc = WMScreenRContext(scr);
100 char *path;
102 path = LocateImage(ARQUIVO_XIS);
103 if (path) {
104 xis = RLoadImage(rc, path, 0);
105 if (!xis) {
106 wwarning(_("could not load image file %s"), path);
108 wfree(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);
130 if (icon1)
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);
146 if (icon1)
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);
162 if (icon1)
164 WMSetLabelImage(panel->newL, icon1);
165 WMReleasePixmap(icon1);
168 /**/ panel->posL = WMCreateLabel(panel->navF);
169 WMResizeWidget(panel->posL, 275, 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);
179 if (icon1)
181 WMSetLabelImage(panel->posiL, icon1);
182 WMReleasePixmap(icon1);
185 panel->posP = WMCreatePopUpButton(panel->navF);
186 WMResizeWidget(panel->posP, 125, 20);
187 WMMoveWidget(panel->posP, 350, 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);
199 if (xis)
200 RReleaseImage(xis);
202 WMRealizeWidget(panel->box);
203 WMMapSubwidgets(panel->box);
205 showData(panel);
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(WMWidget *parent)
220 _Panel *panel;
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);
236 return panel;