mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
WPrefs: grouped items related to the possible window placement algorithms 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:
committed by
Carlos R. Mafra
parent
8522283d68
commit
efe0da4618
@@ -77,13 +77,16 @@ typedef struct _Panel {
|
|||||||
|
|
||||||
#define THUMB_SIZE 16
|
#define THUMB_SIZE 16
|
||||||
|
|
||||||
static const char *const placements[] = {
|
static const struct {
|
||||||
"auto",
|
const char *db_value;
|
||||||
"random",
|
const char *label;
|
||||||
"manual",
|
} window_placements[] = {
|
||||||
"cascade",
|
{ "auto", N_("Automatic") },
|
||||||
"smart",
|
{ "random", N_("Random") },
|
||||||
"center"
|
{ "manual", N_("Manual") },
|
||||||
|
{ "cascade", N_("Cascade") },
|
||||||
|
{ "smart", N_("Smart") },
|
||||||
|
{ "center", N_("Center") }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
@@ -158,22 +161,16 @@ static void resizeCallback(WMWidget * w, void *data)
|
|||||||
|
|
||||||
static int getPlacement(const char *str)
|
static int getPlacement(const char *str)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (strcasecmp(str, "auto") == 0)
|
for (i = 0; i < wlengthof(window_placements); i++) {
|
||||||
return 0;
|
if (strcasecmp(str, window_placements[i].db_value) == 0)
|
||||||
else if (strcasecmp(str, "random") == 0)
|
return i;
|
||||||
return 1;
|
}
|
||||||
else if (strcasecmp(str, "manual") == 0)
|
|
||||||
return 2;
|
|
||||||
else if (strcasecmp(str, "cascade") == 0)
|
|
||||||
return 3;
|
|
||||||
else if (strcasecmp(str, "smart") == 0)
|
|
||||||
return 4;
|
|
||||||
else if (strcasecmp(str, "center") == 0)
|
|
||||||
return 5;
|
|
||||||
else
|
|
||||||
wwarning(_("bad option value %s in WindowPlacement. Using default value"), str);
|
wwarning(_("bad option value %s in WindowPlacement. Using default value"), str);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -260,7 +257,7 @@ static void storeData(_Panel * panel)
|
|||||||
SetBoolForKey(WMGetButtonSelected(panel->opaqresizeB), "OpaqueResize");
|
SetBoolForKey(WMGetButtonSelected(panel->opaqresizeB), "OpaqueResize");
|
||||||
SetBoolForKey(WMGetButtonSelected(panel->opaqkeybB), "OpaqueMoveResizeKeyboard");
|
SetBoolForKey(WMGetButtonSelected(panel->opaqkeybB), "OpaqueMoveResizeKeyboard");
|
||||||
|
|
||||||
SetStringForKey(placements[WMGetPopUpButtonSelectedItem(panel->placP)], "WindowPlacement");
|
SetStringForKey(window_placements[WMGetPopUpButtonSelectedItem(panel->placP)].db_value, "WindowPlacement");
|
||||||
sprintf(buf, "%i", WMGetSliderValue(panel->hsli));
|
sprintf(buf, "%i", WMGetSliderValue(panel->hsli));
|
||||||
x = WMCreatePLString(buf);
|
x = WMCreatePLString(buf);
|
||||||
sprintf(buf, "%i", WMGetSliderValue(panel->vsli));
|
sprintf(buf, "%i", WMGetSliderValue(panel->vsli));
|
||||||
@@ -314,12 +311,9 @@ static void createPanel(Panel * p)
|
|||||||
panel->placP = WMCreatePopUpButton(panel->placF);
|
panel->placP = WMCreatePopUpButton(panel->placF);
|
||||||
WMResizeWidget(panel->placP, 105, 20);
|
WMResizeWidget(panel->placP, 105, 20);
|
||||||
WMMoveWidget(panel->placP, 10, 20);
|
WMMoveWidget(panel->placP, 10, 20);
|
||||||
WMAddPopUpButtonItem(panel->placP, _("Automatic"));
|
|
||||||
WMAddPopUpButtonItem(panel->placP, _("Random"));
|
for (i = 0; i < wlengthof(window_placements); i++)
|
||||||
WMAddPopUpButtonItem(panel->placP, _("Manual"));
|
WMAddPopUpButtonItem(panel->placP, _(window_placements[i].label));
|
||||||
WMAddPopUpButtonItem(panel->placP, _("Cascade"));
|
|
||||||
WMAddPopUpButtonItem(panel->placP, _("Smart"));
|
|
||||||
WMAddPopUpButtonItem(panel->placP, _("Center"));
|
|
||||||
|
|
||||||
panel->porigL = WMCreateLabel(panel->placF);
|
panel->porigL = WMCreateLabel(panel->placF);
|
||||||
WMResizeWidget(panel->porigL, 110, 32);
|
WMResizeWidget(panel->porigL, 110, 32);
|
||||||
|
|||||||
Reference in New Issue
Block a user