Files
wmaker/WPrefs.app/Icons.c
T

360 lines
9.3 KiB
C
Raw Normal View History

1998-09-29 22:36:29 +00:00
/* Icons.c- icon preferences
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
2004-10-12 21:28:27 +00:00
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
1998-09-29 22:36:29 +00:00
* 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;
2004-10-12 21:28:27 +00:00
WMWidget *parent;
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
WMFrame *posF;
WMFrame *posVF;
WMFrame *posV;
1998-11-27 12:26:46 +00:00
WMButton *posB[8];
1998-09-29 22:36:29 +00:00
1998-11-23 11:32:19 +00:00
WMFrame *animF;
WMButton *animB[4];
1998-09-29 22:36:29 +00:00
WMFrame *optF;
WMButton *arrB;
WMButton *omnB;
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
WMFrame *sizeF;
WMPopUpButton *sizeP;
1998-11-27 12:26:46 +00:00
int iconPos;
1998-09-29 22:36:29 +00:00
} _Panel;
#define ICON_FILE "iconprefs"
static void
showIconLayout(WMWidget *widget, void *data)
{
_Panel *panel = (_Panel*)data;
int w, h;
1998-11-27 12:26:46 +00:00
int i;
2004-10-12 21:28:27 +00:00
1998-11-27 12:26:46 +00:00
for (i=0; i<8; i++) {
2004-10-12 21:28:27 +00:00
if (panel->posB[i] == widget) {
panel->iconPos = i;
break;
}
1998-11-27 12:26:46 +00:00
}
if (panel->iconPos & 1) {
2004-10-12 21:28:27 +00:00
w = 32;
h = 8;
1998-09-29 22:36:29 +00:00
} else {
2004-10-12 21:28:27 +00:00
w = 8;
h = 32;
1998-09-29 22:36:29 +00:00
}
WMResizeWidget(panel->posV, w, h);
2004-10-12 21:28:27 +00:00
1998-11-27 12:26:46 +00:00
switch (panel->iconPos & ~1) {
2004-10-12 21:28:27 +00:00
case 0:
WMMoveWidget(panel->posV, 2, 2);
break;
case 2:
WMMoveWidget(panel->posV, 95-2-w, 2);
break;
case 4:
WMMoveWidget(panel->posV, 2, 70-2-h);
break;
default:
WMMoveWidget(panel->posV, 95-2-w, 70-2-h);
break;
1998-09-29 22:36:29 +00:00
}
}
static void
showData(_Panel *panel)
{
int i;
char *str;
char *def = "blh";
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
WMSetButtonSelected(panel->arrB, GetBoolForKey("AutoArrangeIcons"));
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
WMSetButtonSelected(panel->omnB, GetBoolForKey("StickyIcons"));
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
str = GetStringForKey("IconPosition");
if (!str)
2004-10-12 21:28:27 +00:00
str = def;
1998-09-29 22:36:29 +00:00
if (strlen(str)!=3) {
2004-10-12 21:28:27 +00:00
wwarning("bad value %s for option IconPosition. Using default blh",
str);
str = def;
1998-09-29 22:36:29 +00:00
}
if (str[0]=='t' || str[0]=='T') {
2004-10-12 21:28:27 +00:00
i = 0;
1998-09-29 22:36:29 +00:00
} else {
2004-10-12 21:28:27 +00:00
i = 4;
1998-11-27 12:26:46 +00:00
}
if (str[1]=='r' || str[1]=='R') {
2004-10-12 21:28:27 +00:00
i += 2;
1998-09-29 22:36:29 +00:00
}
if (str[2]=='v' || str[2]=='V') {
2004-10-12 21:28:27 +00:00
i += 0;
1998-09-29 22:36:29 +00:00
} else {
2004-10-12 21:28:27 +00:00
i += 1;
1998-09-29 22:36:29 +00:00
}
1998-11-27 12:26:46 +00:00
panel->iconPos = i;
WMPerformButtonClick(panel->posB[i]);
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
i = GetIntegerForKey("IconSize");
i = (i-24)/8;
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
if (i<0)
2004-10-12 21:28:27 +00:00
i = 0;
1998-09-29 22:36:29 +00:00
else if (i>9)
2004-10-12 21:28:27 +00:00
i = 9;
1998-11-23 11:32:19 +00:00
WMSetPopUpButtonSelectedItem(panel->sizeP, i);
2004-10-12 21:28:27 +00:00
1998-11-23 11:32:19 +00:00
str = GetStringForKey("IconificationStyle");
if (!str)
2004-10-12 21:28:27 +00:00
str = "zoom";
1998-11-23 11:32:19 +00:00
if (strcasecmp(str, "none")==0)
2004-10-12 21:28:27 +00:00
WMPerformButtonClick(panel->animB[3]);
1998-11-23 11:32:19 +00:00
else if (strcasecmp(str, "twist")==0)
2004-10-12 21:28:27 +00:00
WMPerformButtonClick(panel->animB[1]);
1998-11-23 11:32:19 +00:00
else if (strcasecmp(str, "flip")==0)
2004-10-12 21:28:27 +00:00
WMPerformButtonClick(panel->animB[2]);
1998-11-23 11:32:19 +00:00
else {
2004-10-12 21:28:27 +00:00
WMPerformButtonClick(panel->animB[0]);
1998-11-23 11:32:19 +00:00
}
1998-09-29 22:36:29 +00:00
}
static void
createPanel(Panel *p)
{
_Panel *panel = (_Panel*)p;
WMColor *color;
int i;
char buf[16];
panel->box = WMCreateBox(panel->parent);
2001-04-25 02:03:08 +00:00
WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
/***************** Positioning of Icons *****************/
panel->posF = WMCreateFrame(panel->box);
1998-11-23 11:32:19 +00:00
WMResizeWidget(panel->posF, 260, 135);
1998-09-29 22:36:29 +00:00
WMMoveWidget(panel->posF, 25, 10);
WMSetFrameTitle(panel->posF, _("Icon Positioning"));
1998-11-27 12:26:46 +00:00
for (i=0; i<8; i++) {
2004-10-12 21:28:27 +00:00
panel->posB[i] = WMCreateButton(panel->posF, WBTOnOff);
WMSetButtonAction(panel->posB[i], showIconLayout, panel);
1998-09-29 22:36:29 +00:00
2004-10-12 21:28:27 +00:00
if (i>0)
WMGroupButtons(panel->posB[0], panel->posB[i]);
1998-11-27 12:26:46 +00:00
}
WMMoveWidget(panel->posB[1], 70, 23);
WMResizeWidget(panel->posB[1], 47, 15);
WMMoveWidget(panel->posB[3], 70+47, 23);
WMResizeWidget(panel->posB[3], 47, 15);
WMMoveWidget(panel->posB[0], 55, 38);
WMResizeWidget(panel->posB[0], 15, 35);
WMMoveWidget(panel->posB[4], 55, 38+35);
WMResizeWidget(panel->posB[4], 15, 35);
WMMoveWidget(panel->posB[5], 70, 38+70);
WMResizeWidget(panel->posB[5], 47, 15);
WMMoveWidget(panel->posB[7], 70+47, 38+70);
WMResizeWidget(panel->posB[7], 47, 15);
WMMoveWidget(panel->posB[2], 70+95, 38);
WMResizeWidget(panel->posB[2], 15, 35);
WMMoveWidget(panel->posB[6], 70+95, 38+35);
WMResizeWidget(panel->posB[6], 15, 35);
1998-09-29 22:36:29 +00:00
2004-10-12 21:28:27 +00:00
color = WMCreateRGBColor(WMWidgetScreen(panel->parent), 0x5100, 0x5100,
0x7100, True);
1998-09-29 22:36:29 +00:00
panel->posVF = WMCreateFrame(panel->posF);
WMResizeWidget(panel->posVF, 95, 70);
1998-11-27 12:26:46 +00:00
WMMoveWidget(panel->posVF, 70, 38);
1998-09-29 22:36:29 +00:00
WMSetFrameRelief(panel->posVF, WRSunken);
WMSetWidgetBackgroundColor(panel->posVF, color);
WMReleaseColor(color);
panel->posV = WMCreateFrame(panel->posVF);
WMSetFrameRelief(panel->posV, WRSimple);
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
WMMapSubwidgets(panel->posF);
2004-10-12 21:28:27 +00:00
1998-11-23 11:32:19 +00:00
/***************** Animation ****************/
panel->animF = WMCreateFrame(panel->box);
1998-11-23 11:32:19 +00:00
WMResizeWidget(panel->animF, 205, 135);
WMMoveWidget(panel->animF, 295, 10);
WMSetFrameTitle(panel->animF, _("Iconification Animation"));
for (i=0; i<4; i++) {
2004-10-12 21:28:27 +00:00
panel->animB[i] = WMCreateRadioButton(panel->animF);
WMResizeWidget(panel->animB[i], 170, 20);
WMMoveWidget(panel->animB[i], 20, 24+i*25);
1998-11-23 11:32:19 +00:00
}
WMGroupButtons(panel->animB[0], panel->animB[1]);
WMGroupButtons(panel->animB[0], panel->animB[2]);
WMGroupButtons(panel->animB[0], panel->animB[3]);
WMSetButtonText(panel->animB[0], _("Shrinking/Zooming"));
WMSetButtonText(panel->animB[1], _("Spinning/Twisting"));
WMSetButtonText(panel->animB[2], _("3D-flipping"));
WMSetButtonText(panel->animB[3], _("None"));
WMMapSubwidgets(panel->animF);
1998-09-29 22:36:29 +00:00
/***************** Options ****************/
panel->optF = WMCreateFrame(panel->box);
1999-01-11 12:28:12 +00:00
WMResizeWidget(panel->optF, 260, 70);
WMMoveWidget(panel->optF, 25, 150);
2004-10-12 21:28:27 +00:00
/* WMSetFrameTitle(panel->optF, _("Icon Display"));*/
1998-09-29 22:36:29 +00:00
panel->arrB = WMCreateSwitchButton(panel->optF);
WMResizeWidget(panel->arrB, 235, 20);
1999-01-11 12:28:12 +00:00
WMMoveWidget(panel->arrB, 15, 15);
1998-09-29 22:36:29 +00:00
WMSetButtonText(panel->arrB, _("Auto-arrange icons"));
1999-04-25 01:49:46 +00:00
WMSetBalloonTextForView(_("Keep icons and miniwindows arranged all the time."),
2004-10-12 21:28:27 +00:00
WMWidgetView(panel->arrB));
1999-04-25 01:49:46 +00:00
1998-09-29 22:36:29 +00:00
panel->omnB = WMCreateSwitchButton(panel->optF);
WMResizeWidget(panel->omnB, 235, 20);
1999-01-11 12:28:12 +00:00
WMMoveWidget(panel->omnB, 15, 40);
1998-09-29 22:36:29 +00:00
WMSetButtonText(panel->omnB, _("Omnipresent miniwindows"));
1999-04-25 01:49:46 +00:00
WMSetBalloonTextForView(_("Make miniwindows be present in all workspaces."),
2004-10-12 21:28:27 +00:00
WMWidgetView(panel->omnB));
1999-04-25 01:49:46 +00:00
1998-09-29 22:36:29 +00:00
WMMapSubwidgets(panel->optF);
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
/***************** Icon Size ****************/
panel->sizeF = WMCreateFrame(panel->box);
1998-09-29 22:36:29 +00:00
WMResizeWidget(panel->sizeF, 205, 70);
WMMoveWidget(panel->sizeF, 295, 150);
WMSetFrameTitle(panel->sizeF, _("Icon Size"));
1999-04-25 01:49:46 +00:00
WMSetBalloonTextForView(_("The size of the dock/application icon and miniwindows"),
2004-10-12 21:28:27 +00:00
WMWidgetView(panel->sizeF));
1998-09-29 22:36:29 +00:00
panel->sizeP = WMCreatePopUpButton(panel->sizeF);
WMResizeWidget(panel->sizeP, 156, 20);
WMMoveWidget(panel->sizeP, 25, 30);
for (i=24; i<=96; i+=8) {
2004-10-12 21:28:27 +00:00
sprintf(buf, "%ix%i", i, i);
WMAddPopUpButtonItem(panel->sizeP, buf);
1998-09-29 22:36:29 +00:00
}
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
WMMapSubwidgets(panel->sizeF);
WMRealizeWidget(panel->box);
WMMapSubwidgets(panel->box);
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
showData(panel);
}
static void
storeData(_Panel *panel)
{
char buf[8];
1998-11-23 11:32:19 +00:00
1998-09-29 22:36:29 +00:00
SetBoolForKey(WMGetButtonSelected(panel->arrB), "AutoArrangeIcons");
SetBoolForKey(WMGetButtonSelected(panel->omnB), "StickyIcons");
SetIntegerForKey(WMGetPopUpButtonSelectedItem(panel->sizeP)*8+24,
2004-10-12 21:28:27 +00:00
"IconSize");
1998-09-29 22:36:29 +00:00
1998-11-27 12:26:46 +00:00
buf[3] = 0;
if (panel->iconPos < 4) {
2004-10-12 21:28:27 +00:00
buf[0] = 't';
1998-09-29 22:36:29 +00:00
} else {
2004-10-12 21:28:27 +00:00
buf[0] = 'b';
1998-11-27 12:26:46 +00:00
}
if (panel->iconPos & 2) {
2004-10-12 21:28:27 +00:00
buf[1] = 'r';
1998-11-27 12:26:46 +00:00
} else {
2004-10-12 21:28:27 +00:00
buf[1] = 'l';
1998-09-29 22:36:29 +00:00
}
1998-11-27 12:26:46 +00:00
if (panel->iconPos & 1) {
2004-10-12 21:28:27 +00:00
buf[2] = 'h';
1998-09-29 22:36:29 +00:00
} else {
2004-10-12 21:28:27 +00:00
buf[2] = 'v';
1998-09-29 22:36:29 +00:00
}
SetStringForKey(buf, "IconPosition");
1998-11-23 11:32:19 +00:00
if (WMGetButtonSelected(panel->animB[0]))
2004-10-12 21:28:27 +00:00
SetStringForKey("zoom", "IconificationStyle");
1998-11-23 11:32:19 +00:00
else if (WMGetButtonSelected(panel->animB[1]))
2004-10-12 21:28:27 +00:00
SetStringForKey("twist", "IconificationStyle");
1998-11-23 11:32:19 +00:00
else if (WMGetButtonSelected(panel->animB[2]))
2004-10-12 21:28:27 +00:00
SetStringForKey("flip", "IconificationStyle");
else
SetStringForKey("none", "IconificationStyle");
1998-09-29 22:36:29 +00:00
}
Panel*
InitIcons(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 = _("Icon Preferences");
1999-04-25 01:49:46 +00:00
panel->description = _("Icon/Miniwindow handling options. Icon positioning\n"
2004-10-12 21:28:27 +00:00
"area, sizes of icons, miniaturization animation style.");
1999-04-25 01:49:46 +00:00
panel->parent = parent;
1999-04-25 01:49:46 +00:00
1998-09-29 22:36:29 +00:00
panel->callbacks.createWidgets = createPanel;
panel->callbacks.updateDomain = storeData;
AddSection(panel, ICON_FILE);
return panel;
}
2004-10-12 21:28:27 +00:00