1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-31 21:15:47 +01:00

WPrefs: grouped items related to the window title alignment 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:44 +01:00
committed by Carlos R. Mafra
parent c0d4c16336
commit 454c7bec5d

View File

@@ -101,6 +101,15 @@ static const struct {
[MSTYLE_FLAT] { "flat", "msty3" } [MSTYLE_FLAT] { "flat", "msty3" }
}; };
/********************************************************************/
static const struct {
const char *label;
const char *db_value;
} wintitle_align[] = {
[WALeft] { N_("Left"), "left" },
[WACenter] { N_("Center"), "center" },
[WARight] { N_("Right"), "right" }
};
/********************************************************************/ /********************************************************************/
typedef struct _Panel { typedef struct _Panel {
@@ -145,7 +154,7 @@ typedef struct _Panel {
WMButton *mstyB[wlengthof_nocheck(menu_style)]; WMButton *mstyB[wlengthof_nocheck(menu_style)];
WMFrame *taliF; WMFrame *taliF;
WMButton *taliB[3]; WMButton *taliB[wlengthof_nocheck(wintitle_align)];
/* */ /* */
@@ -168,7 +177,7 @@ typedef struct _Panel {
menu_style_index menuStyle; menu_style_index menuStyle;
int titleAlignment; WMAlignment titleAlignment;
Pixmap preview; Pixmap preview;
Pixmap previewNoText; Pixmap previewNoText;
@@ -1773,19 +1782,16 @@ static void menuStyleCallback(WMWidget * self, void *data)
static void titleAlignCallback(WMWidget * self, void *data) static void titleAlignCallback(WMWidget * self, void *data)
{ {
_Panel *panel = (_Panel *) data; _Panel *panel = (_Panel *) data;
WMAlignment align;
if (self == panel->taliB[0]) { for (align = 0; align < wlengthof(wintitle_align); align++) {
panel->titleAlignment = WALeft; if (self == panel->taliB[align]) {
updatePreviewBox(panel, 1 << PFOCUSED | 1 << PUNFOCUSED | 1 << POWNER); panel->titleAlignment = align;
break;
} else if (self == panel->taliB[1]) { }
panel->titleAlignment = WACenter;
updatePreviewBox(panel, 1 << PFOCUSED | 1 << PUNFOCUSED | 1 << POWNER);
} else if (self == panel->taliB[2]) {
panel->titleAlignment = WARight;
updatePreviewBox(panel, 1 << PFOCUSED | 1 << PUNFOCUSED | 1 << POWNER);
} }
updatePreviewBox(panel, 1 << PFOCUSED | 1 << PUNFOCUSED | 1 << POWNER);
} }
static void createPanel(Panel * p) static void createPanel(Panel * p)
@@ -2016,20 +2022,10 @@ static void createPanel(Panel * p)
WMMoveWidget(panel->taliF, 15, 100); WMMoveWidget(panel->taliF, 15, 100);
WMSetFrameTitle(panel->taliF, _("Title Alignment")); WMSetFrameTitle(panel->taliF, _("Title Alignment"));
for (i = 0; i < 3; i++) { for (i = 0; i < wlengthof(wintitle_align); i++) {
panel->taliB[i] = WMCreateRadioButton(panel->taliF); panel->taliB[i] = WMCreateRadioButton(panel->taliF);
WMSetButtonAction(panel->taliB[i], titleAlignCallback, panel); WMSetButtonAction(panel->taliB[i], titleAlignCallback, panel);
switch (i) { WMSetButtonText(panel->taliB[i], _(wintitle_align[i].label));
case 0:
WMSetButtonText(panel->taliB[i], _("Left"));
break;
case 1:
WMSetButtonText(panel->taliB[i], _("Center"));
break;
case 2:
WMSetButtonText(panel->taliB[i], _("Right"));
break;
}
WMResizeWidget(panel->taliB[i], 90, 18); WMResizeWidget(panel->taliB[i], 90, 18);
WMMoveWidget(panel->taliB[i], 10, 15 + 20 * i); WMMoveWidget(panel->taliB[i], 10, 15 + 20 * i);
} }
@@ -2100,12 +2096,16 @@ static void showData(_Panel * panel)
} }
str = GetStringForKey("TitleJustify"); str = GetStringForKey("TitleJustify");
if (str && strcasecmp(str, "left") == 0) { panel->titleAlignment = WACenter;
panel->titleAlignment = WALeft; if (str != NULL) {
} else if (str && strcasecmp(str, "right") == 0) { WMAlignment align;
panel->titleAlignment = WARight;
} else { for (align = 0; align < wlengthof(wintitle_align); align++) {
panel->titleAlignment = WACenter; if (strcasecmp(str, wintitle_align[align].db_value) == 0) {
panel->titleAlignment = align;
break;
}
}
} }
for (i = 0; i < wlengthof(colorOptions); i++) { for (i = 0; i < wlengthof(colorOptions); i++) {
@@ -2158,19 +2158,7 @@ static void storeData(_Panel * panel)
} }
SetStringForKey(menu_style[panel->menuStyle].db_value, "MenuStyle"); SetStringForKey(menu_style[panel->menuStyle].db_value, "MenuStyle");
SetStringForKey(wintitle_align[panel->titleAlignment].db_value, "TitleJustify");
switch (panel->titleAlignment) {
case WALeft:
SetStringForKey("left", "TitleJustify");
break;
case WARight:
SetStringForKey("right", "TitleJustify");
break;
default:
case WACenter:
SetStringForKey("center", "TitleJustify");
break;
}
} }
static void prepareForClose(_Panel * panel) static void prepareForClose(_Panel * panel)