1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

WPrefs: grouped items related to the AppIcon bouncing configuration in a single place

Having all these information spread in different places makes it error
prone when wanting to add/remove/change something in the list are there are
many unrelated places to keep in sync.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-10-26 19:58:46 +01:00
committed by Carlos R. Mafra
parent e73c3e84de
commit d02d362295

View File

@@ -33,6 +33,16 @@ static const struct {
{ "HelpBalloons", N_("internal help"), }
};
static const struct {
const char *db_key;
int default_value;
const char *label;
} appicon_bouncing[] = {
{ "DoNotMakeAppIconsBounce", False, N_("Disable AppIcon bounce.") },
{ "BounceAppIconsWhenUrgent", True, N_("Bounce AppIcon when the application wants attention.") },
{ "RaiseAppIconsWhenBouncing", False, N_("Raise AppIcons when bouncing.") }
};
typedef struct _Panel {
WMBox *box;
@@ -54,9 +64,7 @@ typedef struct _Panel {
WMButton *ballB[wlengthof_nocheck(balloon_choices)];
WMFrame *optF;
WMButton *bounceB;
WMButton *bounceUrgB;
WMButton *bounceRaisB;
WMButton *bounceB[wlengthof_nocheck(appicon_bouncing)];
WMFrame *borderF;
WMSlider *borderS;
@@ -141,10 +149,10 @@ static void showData(_Panel * panel)
WMSetButtonSelected(panel->lrB, True);
}
WMSetButtonSelected(panel->bounceB, GetBoolForKey("DoNotMakeAppIconsBounce"));
if (GetStringForKey("BounceAppIconsWhenUrgent"))
WMSetButtonSelected(panel->bounceUrgB, GetBoolForKey("BounceAppIconsWhenUrgent"));
WMSetButtonSelected(panel->bounceRaisB, GetBoolForKey("RaiseAppIconsWhenBouncing"));
for (x = 0; x < wlengthof(appicon_bouncing); x++) {
if (GetStringForKey(appicon_bouncing[x].db_key))
WMSetButtonSelected(panel->bounceB[x], GetBoolForKey(appicon_bouncing[x].db_key));
}
for (x = 0; x < wlengthof(balloon_choices); x++)
WMSetButtonSelected(panel->ballB[x], GetBoolForKey(balloon_choices[x].db_key));
@@ -204,9 +212,8 @@ static void storeData(_Panel * panel)
SetStringForKey(str, "WorkspaceBorder");
SetIntegerForKey(WMGetSliderValue(panel->borderS), "WorkspaceBorderSize");
SetBoolForKey(WMGetButtonSelected(panel->bounceB), "DoNotMakeAppIconsBounce");
SetBoolForKey(WMGetButtonSelected(panel->bounceUrgB), "BounceAppIconsWhenUrgent");
SetBoolForKey(WMGetButtonSelected(panel->bounceRaisB), "RaiseAppIconsWhenBouncing");
for (i = 0; i < wlengthof(appicon_bouncing); i++)
SetBoolForKey(WMGetButtonSelected(panel->bounceB[i]), appicon_bouncing[i].db_key);
for (i = 0; i < wlengthof(balloon_choices); i++)
SetBoolForKey(WMGetButtonSelected(panel->ballB[i]), balloon_choices[i].db_key);
@@ -280,21 +287,15 @@ static void createPanel(Panel * p)
WMMoveWidget(panel->optF, 265, 136);
WMSetFrameTitle(panel->optF, _("AppIcon bouncing"));
panel->bounceB = WMCreateSwitchButton(panel->optF);
WMResizeWidget(panel->bounceB, 210, 25);
WMMoveWidget(panel->bounceB, 15, 14);
WMSetButtonText(panel->bounceB, _("Disable AppIcon bounce."));
for (i = 0; i < wlengthof(appicon_bouncing); i++) {
panel->bounceB[i] = WMCreateSwitchButton(panel->optF);
WMResizeWidget(panel->bounceB[i], 210, 26);
WMMoveWidget(panel->bounceB[i], 15, 12 + i * 25);
WMSetButtonText(panel->bounceB[i], _(appicon_bouncing[i].label));
panel->bounceUrgB = WMCreateSwitchButton(panel->optF);
WMResizeWidget(panel->bounceUrgB, 210, 28);
WMMoveWidget(panel->bounceUrgB, 15, 37);
WMSetButtonText(panel->bounceUrgB, _("Bounce AppIcon when the application wants attention."));
WMSetButtonSelected(panel->bounceUrgB, True); /* defaults to true */
panel->bounceRaisB = WMCreateSwitchButton(panel->optF);
WMResizeWidget(panel->bounceRaisB, 210, 23);
WMMoveWidget(panel->bounceRaisB, 15, 65);
WMSetButtonText(panel->bounceRaisB, _("Raise AppIcons when bouncing."));
if (appicon_bouncing[i].default_value)
WMSetButtonSelected(panel->bounceB[i], True);
}
WMMapSubwidgets(panel->optF);