Files
wmaker/WPrefs.app/Workspace.c
T

378 lines
9.8 KiB
C
Raw Normal View History

1998-09-29 22:36:29 +00:00
/* Workspace.c- workspace options
*
1998-10-21 14:43:47 +00:00
* WPrefs - Window Maker Preferences Program
1998-09-29 22:36:29 +00:00
*
* Copyright (c) 1998-2002 Alfredo K. Kojima
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include "WPrefs.h"
typedef struct _Panel {
WMBox *box;
1998-09-29 22:36:29 +00:00
char *sectionName;
1999-04-25 01:49:46 +00:00
char *description;
1998-09-29 22:36:29 +00:00
CallbackRec callbacks;
WMWidget *parent;
1998-09-29 22:36:29 +00:00
WMFrame *navF;
1999-10-20 03:25:06 +00:00
1998-09-29 22:36:29 +00:00
WMButton *linkB;
WMButton *cyclB;
WMButton *newB;
WMLabel *linkL;
WMLabel *cyclL;
WMLabel *newL;
1999-10-20 03:25:06 +00:00
WMLabel *posiL;
WMLabel *posL;
WMPopUpButton *posP;
1998-09-29 22:36:29 +00:00
WMFrame *dockF;
WMButton *dockB;
WMButton *clipB;
} _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
#define DOCK_FILE "dock"
#define CLIP_FILE "clip"
1999-10-20 03:25:06 +00:00
static char *WSNamePositions[] = {
"none",
"center",
"top",
"bottom",
"topleft",
"topright",
"bottomleft",
"bottomright"
};
1998-09-29 22:36:29 +00:00
static void
createImages(WMScreen *scr, RContext *rc, RImage *xis, char *file,
WMPixmap **icon1, WMPixmap **icon2)
{
RImage *icon;
1998-10-21 14:43:47 +00:00
RColor gray = {0xae,0xaa,0xae};
1998-09-29 22:36:29 +00:00
*icon1 = WMCreatePixmapFromFile(scr, file);
if (!*icon1) {
wwarning(_("could not load icon %s"), file);
1999-10-20 03:25:06 +00:00
if (icon2)
*icon2 = NULL;
1998-09-29 22:36:29 +00:00
return;
}
1999-10-20 03:25:06 +00:00
if (!icon2)
return;
1998-09-29 22:36:29 +00:00
icon = RLoadImage(rc, file, 0);
if (!icon) {
wwarning(_("could not load icon %s"), file);
*icon2 = NULL;
return;
}
1998-10-21 14:43:47 +00:00
RCombineImageWithColor(icon, &gray);
1998-09-29 22:36:29 +00:00
if (xis) {
1998-10-21 14:43:47 +00:00
RCombineImagesWithOpaqueness(icon, xis, 180);
1998-09-29 22:36:29 +00:00
if (!(*icon2 = WMCreatePixmapFromRImage(scr, icon, 127))) {
1998-10-21 14:43:47 +00:00
wwarning(_("could not process icon %s:"), file, RMessageForError(RErrorCode));
1998-09-29 22:36:29 +00:00
*icon2 = NULL;
}
}
2001-04-21 07:12:21 +00:00
RReleaseImage(icon);
1998-09-29 22:36:29 +00:00
}
static void
showData(_Panel *panel)
{
1999-10-20 03:25:06 +00:00
int i, idx;
char *str;
1998-09-29 22:36:29 +00:00
WMSetButtonSelected(panel->linkB, !GetBoolForKey("DontLinkWorkspaces"));
WMSetButtonSelected(panel->cyclB, GetBoolForKey("CycleWorkspaces"));
WMSetButtonSelected(panel->newB, GetBoolForKey("AdvanceToNewWorkspace"));
WMSetButtonSelected(panel->dockB, !GetBoolForKey("DisableDock"));
WMSetButtonSelected(panel->clipB, !GetBoolForKey("DisableClip"));
1999-10-20 03:25:06 +00:00
str = GetStringForKey("WorkspaceNameDisplayPosition");
if (!str)
str = "center";
idx = 1; /* center */
1999-11-01 15:45:07 +00:00
for (i = 0; i < sizeof(WSNamePositions)/sizeof(char*); i++) {
if (strcasecmp(WSNamePositions[i], str) == 0) {
1999-10-20 03:25:06 +00:00
idx = i;
break;
}
}
WMSetPopUpButtonSelectedItem(panel->posP, idx);
1998-09-29 22:36:29 +00:00
}
static void
createPanel(Panel *p)
{
_Panel *panel = (_Panel*)p;
WMScreen *scr = WMWidgetScreen(panel->parent);
1998-09-29 22:36:29 +00:00
WMPixmap *icon1, *icon2;
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);
1998-09-29 22:36:29 +00:00
}
panel->box = WMCreateBox(panel->parent);
2001-04-25 02:03:08 +00:00
WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
1998-09-29 22:36:29 +00:00
/***************** Workspace Navigation *****************/
panel->navF = WMCreateFrame(panel->box);
1999-10-20 03:25:06 +00:00
WMResizeWidget(panel->navF, 365, 210);
WMMoveWidget(panel->navF, 15, 10);
1998-09-29 22:36:29 +00:00
WMSetFrameTitle(panel->navF, _("Workspace Navigation"));
1999-10-20 03:25:06 +00:00
panel->cyclB = WMCreateSwitchButton(panel->navF);
WMResizeWidget(panel->cyclB, 280, 34);
WMMoveWidget(panel->cyclB, 75, 30);
WMSetButtonText(panel->cyclB,
2000-11-12 04:03:30 +00:00
_("wrap to the first workspace after the\nlast workspace."));
1999-10-20 03:25:06 +00:00
panel->cyclL = WMCreateLabel(panel->navF);
WMResizeWidget(panel->cyclL, 60, 60);
WMMoveWidget(panel->cyclL, 10, 15);
WMSetLabelImagePosition(panel->cyclL, WIPImageOnly);
path = LocateImage(CYCLE_FILE);
1998-09-29 22:36:29 +00:00
if (path) {
1999-10-20 03:25:06 +00:00
createImages(scr, rc, xis, path, &icon1, NULL);
1998-09-29 22:36:29 +00:00
if (icon1) {
1999-10-20 03:25:06 +00:00
WMSetLabelImage(panel->cyclL, icon1);
1998-09-29 22:36:29 +00:00
WMReleasePixmap(icon1);
}
wfree(path);
1998-09-29 22:36:29 +00:00
}
1999-10-20 03:25:06 +00:00
/**/
panel->linkB = WMCreateSwitchButton(panel->navF);
WMResizeWidget(panel->linkB, 280, 34);
WMMoveWidget(panel->linkB, 75, 75);
WMSetButtonText(panel->linkB,
_("switch workspaces while dragging windows."));
1998-09-29 22:36:29 +00:00
panel->linkL = WMCreateLabel(panel->navF);
1999-10-20 03:25:06 +00:00
WMResizeWidget(panel->linkL, 60, 40);
WMMoveWidget(panel->linkL, 10, 80);
WMSetLabelImagePosition(panel->linkL, WIPImageOnly);
path = LocateImage(DONT_LINK_FILE);
if (path) {
createImages(scr, rc, xis, path, &icon1, NULL);
if (icon1) {
WMSetLabelImage(panel->linkL, icon1);
WMReleasePixmap(icon1);
}
wfree(path);
1999-10-20 03:25:06 +00:00
}
1998-09-29 22:36:29 +00:00
1999-10-20 03:25:06 +00:00
/**/
1998-09-29 22:36:29 +00:00
1999-10-20 03:25:06 +00:00
panel->newB = WMCreateSwitchButton(panel->navF);
WMResizeWidget(panel->newB, 280, 34);
WMMoveWidget(panel->newB, 75, 120);
WMSetButtonText(panel->newB,
_("automatically create new workspaces."));
panel->newL = WMCreateLabel(panel->navF);
WMResizeWidget(panel->newL, 60, 20);
WMMoveWidget(panel->newL, 10, 130);
WMSetLabelImagePosition(panel->newL, WIPImageOnly);
path = LocateImage(ADVANCE_FILE);
1998-09-29 22:36:29 +00:00
if (path) {
1999-10-20 03:25:06 +00:00
createImages(scr, rc, xis, path, &icon1, NULL);
1998-09-29 22:36:29 +00:00
if (icon1) {
1999-10-20 03:25:06 +00:00
WMSetLabelImage(panel->newL, icon1);
1998-09-29 22:36:29 +00:00
WMReleasePixmap(icon1);
}
wfree(path);
1998-09-29 22:36:29 +00:00
}
1999-10-20 03:25:06 +00:00
/**/
panel->posL = WMCreateLabel(panel->navF);
WMResizeWidget(panel->posL, 140, 30);
WMMoveWidget(panel->posL, 75, 165);
WMSetLabelTextAlignment(panel->posL, WARight);
WMSetLabelText(panel->posL,
2000-11-12 04:03:30 +00:00
_("Position of workspace\nname display"));
1998-09-29 22:36:29 +00:00
1999-10-20 03:25:06 +00:00
panel->posiL = WMCreateLabel(panel->navF);
WMResizeWidget(panel->posiL, 60, 40);
WMMoveWidget(panel->posiL, 10, 160);
WMSetLabelImagePosition(panel->posiL, WIPImageOnly);
1999-10-23 21:57:52 +00:00
path = LocateImage(WSNAME_FILE);
1998-09-29 22:36:29 +00:00
if (path) {
1999-10-20 03:25:06 +00:00
createImages(scr, rc, xis, path, &icon1, NULL);
1998-09-29 22:36:29 +00:00
if (icon1) {
1999-10-20 03:25:06 +00:00
WMSetLabelImage(panel->posiL, icon1);
1998-09-29 22:36:29 +00:00
WMReleasePixmap(icon1);
}
wfree(path);
1998-09-29 22:36:29 +00:00
}
1999-10-20 03:25:06 +00:00
panel->posP = WMCreatePopUpButton(panel->navF);
WMResizeWidget(panel->posP, 125, 20);
WMMoveWidget(panel->posP, 225, 175);
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"));
1998-09-29 22:36:29 +00:00
WMMapSubwidgets(panel->navF);
/***************** Dock/Clip *****************/
panel->dockF = WMCreateFrame(panel->box);
1999-10-20 03:25:06 +00:00
WMResizeWidget(panel->dockF, 115, 210);
WMMoveWidget(panel->dockF, 390, 10);
1998-09-29 22:36:29 +00:00
WMSetFrameTitle(panel->dockF, _("Dock/Clip"));
panel->dockB = WMCreateButton(panel->dockF, WBTToggle);
WMResizeWidget(panel->dockB, 64, 64);
1999-10-20 03:25:06 +00:00
WMMoveWidget(panel->dockB, 25, 35);
1998-09-29 22:36:29 +00:00
WMSetButtonImagePosition(panel->dockB, WIPImageOnly);
path = LocateImage(DOCK_FILE);
if (path) {
createImages(scr, rc, xis, path, &icon1, &icon2);
if (icon2) {
WMSetButtonImage(panel->dockB, icon2);
WMReleasePixmap(icon2);
}
if (icon1) {
WMSetButtonAltImage(panel->dockB, icon1);
WMReleasePixmap(icon1);
}
wfree(path);
1998-09-29 22:36:29 +00:00
}
1999-04-25 01:49:46 +00:00
WMSetBalloonTextForView(_("Disable/enable the application Dock (the\n"
"vertical icon bar in the side of the screen)."),
WMWidgetView(panel->dockB));
1998-09-29 22:36:29 +00:00
panel->clipB = WMCreateButton(panel->dockF, WBTToggle);
WMResizeWidget(panel->clipB, 64, 64);
1999-10-20 03:25:06 +00:00
WMMoveWidget(panel->clipB, 25, 120);
1998-09-29 22:36:29 +00:00
WMSetButtonImagePosition(panel->clipB, WIPImageOnly);
path = LocateImage(CLIP_FILE);
if (path) {
createImages(scr, rc, xis, path, &icon1, &icon2);
if (icon2) {
WMSetButtonImage(panel->clipB, icon2);
WMReleasePixmap(icon2);
}
if (icon1) {
WMSetButtonAltImage(panel->clipB, icon1);
WMReleasePixmap(icon1);
}
wfree(path);
1998-09-29 22:36:29 +00:00
}
1999-04-25 01:49:46 +00:00
WMSetBalloonTextForView(_("Disable/enable the Clip (that thing with\n"
"a paper clip icon)."),
WMWidgetView(panel->clipB));
1998-09-29 22:36:29 +00:00
WMMapSubwidgets(panel->dockF);
if (xis)
2001-04-21 07:12:21 +00:00
RReleaseImage(xis);
1998-09-29 22:36:29 +00:00
WMRealizeWidget(panel->box);
WMMapSubwidgets(panel->box);
2000-04-02 00:04:06 +00:00
1998-09-29 22:36:29 +00:00
showData(panel);
}
static void
storeData(_Panel *panel)
{
SetBoolForKey(!WMGetButtonSelected(panel->linkB), "DontLinkWorkspaces");
SetBoolForKey(WMGetButtonSelected(panel->cyclB), "CycleWorkspaces");
SetBoolForKey(WMGetButtonSelected(panel->newB), "AdvanceToNewWorkspace");
SetBoolForKey(!WMGetButtonSelected(panel->dockB), "DisableDock");
SetBoolForKey(!WMGetButtonSelected(panel->clipB), "DisableClip");
1999-10-20 03:25:06 +00:00
SetStringForKey(WSNamePositions[WMGetPopUpButtonSelectedItem(panel->posP)],
"WorkspaceNameDisplayPosition");
1998-09-29 22:36:29 +00:00
}
Panel*
InitWorkspace(WMScreen *scr, WMWidget *parent)
1998-09-29 22:36:29 +00:00
{
_Panel *panel;
panel = wmalloc(sizeof(_Panel));
memset(panel, 0, sizeof(_Panel));
panel->sectionName = _("Workspace Preferences");
1999-04-25 01:49:46 +00:00
panel->description = _("Workspace navigation features.\n"
"You can also enable/disable the Dock and Clip here.");
panel->parent = parent;
1998-09-29 22:36:29 +00:00
panel->callbacks.createWidgets = createPanel;
panel->callbacks.updateDomain = storeData;
AddSection(panel, ICON_FILE);
return panel;
}