Files
wmaker/WPrefs.app/Workspace.c
T

241 lines
6.4 KiB
C
Raw Normal View History

1998-09-29 22:36:29 +00:00
/* Workspace.c- workspace options
2004-10-12 21:28:27 +00:00
*
1998-10-21 14:43:47 +00:00
* WPrefs - Window Maker Preferences Program
2004-10-12 21:28:27 +00:00
*
2003-01-16 23:30:45 +00:00
* Copyright (c) 1998-2003 Alfredo K. Kojima
2004-10-12 21:28:27 +00:00
*
1998-09-29 22:36:29 +00:00
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1998-09-29 22:36:29 +00:00
*/
#include "WPrefs.h"
typedef struct _Panel {
2009-08-20 00:59:40 +02:00
WMBox *box;
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
char *sectionName;
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
char *description;
1999-04-25 01:49:46 +00:00
2009-08-20 00:59:40 +02:00
CallbackRec callbacks;
2009-08-20 00:59:40 +02:00
WMWidget *parent;
2009-08-20 00:59:40 +02:00
WMFrame *navF;
1999-10-20 03:25:06 +00:00
2009-08-20 00:59:40 +02:00
WMButton *linkB;
WMButton *cyclB;
WMButton *newB;
WMLabel *linkL;
WMLabel *cyclL;
WMLabel *newL;
2009-08-20 00:59:40 +02:00
WMLabel *posiL;
WMLabel *posL;
WMPopUpButton *posP;
1998-09-29 22:36:29 +00:00
} _Panel;
#define ICON_FILE "workspace"
#define ARQUIVO_XIS "xis"
#define DONT_LINK_FILE "dontlinkworkspaces"
#define CYCLE_FILE "cycleworkspaces"
#define ADVANCE_FILE "advancetonewworkspace"
1999-10-23 21:57:52 +00:00
#define WSNAME_FILE "workspacename"
1998-09-29 22:36:29 +00:00
1999-10-20 03:25:06 +00:00
static char *WSNamePositions[] = {
2009-08-20 00:59:40 +02:00
"none",
"center",
"top",
"bottom",
"topleft",
"topright",
"bottomleft",
"bottomright"
1999-10-20 03:25:06 +00:00
};
2009-08-20 00:59:40 +02:00
static void showData(_Panel * panel)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
int i, idx;
char *str;
1999-10-20 03:25:06 +00:00
2009-08-20 00:59:40 +02:00
WMSetButtonSelected(panel->linkB, !GetBoolForKey("DontLinkWorkspaces"));
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
WMSetButtonSelected(panel->cyclB, GetBoolForKey("CycleWorkspaces"));
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
WMSetButtonSelected(panel->newB, GetBoolForKey("AdvanceToNewWorkspace"));
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
str = GetStringForKey("WorkspaceNameDisplayPosition");
if (!str)
str = "center";
1999-10-20 03:25:06 +00:00
2009-08-20 00:59:40 +02:00
idx = 1; /* center */
for (i = 0; i < wlengthof(WSNamePositions); i++) {
2009-08-20 00:59:40 +02:00
if (strcasecmp(WSNamePositions[i], str) == 0) {
idx = i;
break;
}
}
WMSetPopUpButtonSelectedItem(panel->posP, idx);
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
static void createPanel(Panel * p)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
_Panel *panel = (_Panel *) p;
WMScreen *scr = WMWidgetScreen(panel->parent);
2013-04-12 02:20:54 +01:00
WMPixmap *icon1;
2009-08-20 00:59:40 +02:00
RImage *xis = NULL;
RContext *rc = WMScreenRContext(scr);
char *path;
path = LocateImage(ARQUIVO_XIS);
if (path) {
xis = RLoadImage(rc, path, 0);
if (!xis) {
wwarning(_("could not load image file %s"), path);
}
wfree(path);
}
panel->box = WMCreateBox(panel->parent);
WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
/***************** Workspace Navigation *****************/
2009-08-20 00:59:40 +02:00
panel->navF = WMCreateFrame(panel->box);
WMResizeWidget(panel->navF, 490, 210);
WMMoveWidget(panel->navF, 15, 8);
2009-08-20 00:59:40 +02:00
WMSetFrameTitle(panel->navF, _("Workspace Navigation"));
panel->cyclB = WMCreateSwitchButton(panel->navF);
WMResizeWidget(panel->cyclB, 410, 34);
WMMoveWidget(panel->cyclB, 75, 26);
WMSetButtonText(panel->cyclB, _("Wrap to the first workspace from the last workspace"));
2009-08-20 00:59:40 +02:00
panel->cyclL = WMCreateLabel(panel->navF);
WMResizeWidget(panel->cyclL, 60, 60);
WMMoveWidget(panel->cyclL, 10, 12);
2009-08-20 00:59:40 +02:00
WMSetLabelImagePosition(panel->cyclL, WIPImageOnly);
CreateImages(scr, rc, xis, CYCLE_FILE, &icon1, NULL);
if (icon1)
{
WMSetLabelImage(panel->cyclL, icon1);
WMReleasePixmap(icon1);
2009-08-20 00:59:40 +02:00
}
/**/ panel->linkB = WMCreateSwitchButton(panel->navF);
WMResizeWidget(panel->linkB, 410, 34);
WMMoveWidget(panel->linkB, 75, 73);
WMSetButtonText(panel->linkB, _("Switch workspaces while dragging windows"));
2009-08-20 00:59:40 +02:00
panel->linkL = WMCreateLabel(panel->navF);
WMResizeWidget(panel->linkL, 60, 40);
WMMoveWidget(panel->linkL, 10, 77);
2009-08-20 00:59:40 +02:00
WMSetLabelImagePosition(panel->linkL, WIPImageOnly);
CreateImages(scr, rc, xis, DONT_LINK_FILE, &icon1, NULL);
if (icon1)
{
WMSetLabelImage(panel->linkL, icon1);
WMReleasePixmap(icon1);
2009-08-20 00:59:40 +02:00
}
/**/ panel->newB = WMCreateSwitchButton(panel->navF);
WMResizeWidget(panel->newB, 410, 34);
WMMoveWidget(panel->newB, 75, 115);
WMSetButtonText(panel->newB, _("Automatically create new workspaces"));
2009-08-20 00:59:40 +02:00
panel->newL = WMCreateLabel(panel->navF);
WMResizeWidget(panel->newL, 60, 20);
WMMoveWidget(panel->newL, 10, 123);
2009-08-20 00:59:40 +02:00
WMSetLabelImagePosition(panel->newL, WIPImageOnly);
CreateImages(scr, rc, xis, ADVANCE_FILE, &icon1, NULL);
if (icon1)
{
WMSetLabelImage(panel->newL, icon1);
WMReleasePixmap(icon1);
2009-08-20 00:59:40 +02:00
}
/**/ panel->posL = WMCreateLabel(panel->navF);
WMResizeWidget(panel->posL, 275, 30);
WMMoveWidget(panel->posL, 75, 161);
// WMSetLabelTextAlignment(panel->posL, WARight);
WMSetLabelText(panel->posL, _("Position of workspace name display"));
2009-08-20 00:59:40 +02:00
panel->posiL = WMCreateLabel(panel->navF);
WMResizeWidget(panel->posiL, 60, 40);
WMMoveWidget(panel->posiL, 10, 156);
2009-08-20 00:59:40 +02:00
WMSetLabelImagePosition(panel->posiL, WIPImageOnly);
CreateImages(scr, rc, xis, WSNAME_FILE, &icon1, NULL);
if (icon1)
{
WMSetLabelImage(panel->posiL, icon1);
WMReleasePixmap(icon1);
2009-08-20 00:59:40 +02:00
}
panel->posP = WMCreatePopUpButton(panel->navF);
WMResizeWidget(panel->posP, 125, 20);
WMMoveWidget(panel->posP, 350, 166);
2009-08-20 00:59:40 +02:00
WMAddPopUpButtonItem(panel->posP, _("Disable"));
WMAddPopUpButtonItem(panel->posP, _("Center"));
WMAddPopUpButtonItem(panel->posP, _("Top"));
WMAddPopUpButtonItem(panel->posP, _("Bottom"));
WMAddPopUpButtonItem(panel->posP, _("Top/Left"));
WMAddPopUpButtonItem(panel->posP, _("Top/Right"));
WMAddPopUpButtonItem(panel->posP, _("Bottom/Left"));
WMAddPopUpButtonItem(panel->posP, _("Bottom/Right"));
WMMapSubwidgets(panel->navF);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
if (xis)
RReleaseImage(xis);
WMRealizeWidget(panel->box);
WMMapSubwidgets(panel->box);
showData(panel);
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
static void storeData(_Panel * panel)
1998-09-29 22:36:29 +00:00
{
int tmp = WMGetPopUpButtonSelectedItem(panel->posP);
if (tmp < 0)
return;
2009-08-20 00:59:40 +02:00
SetBoolForKey(!WMGetButtonSelected(panel->linkB), "DontLinkWorkspaces");
SetBoolForKey(WMGetButtonSelected(panel->cyclB), "CycleWorkspaces");
SetBoolForKey(WMGetButtonSelected(panel->newB), "AdvanceToNewWorkspace");
2004-10-12 21:28:27 +00:00
SetStringForKey(WSNamePositions[tmp], "WorkspaceNameDisplayPosition");
1998-09-29 22:36:29 +00:00
}
Panel *InitWorkspace(WMWidget *parent)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
_Panel *panel;
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
panel = wmalloc(sizeof(_Panel));
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
panel->sectionName = _("Workspace Preferences");
1999-04-25 01:49:46 +00:00
panel->description = _("Workspace navigation features\n"
"and workspace name display settings.");
1999-04-25 01:49:46 +00:00
2009-08-20 00:59:40 +02:00
panel->parent = parent;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
panel->callbacks.createWidgets = createPanel;
panel->callbacks.updateDomain = storeData;
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
AddSection(panel, ICON_FILE);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
return panel;
1998-09-29 22:36:29 +00:00
}