From: Christophe CURIS <christophe.cu...@free.fr> 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.
Took the opportunity to de-CamelCase the name of the variable to comply with project's coding rules. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> --- WPrefs.app/WindowHandling.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/WPrefs.app/WindowHandling.c b/WPrefs.app/WindowHandling.c index 4a8f1bc..f3500d8 100644 --- a/WPrefs.app/WindowHandling.c +++ b/WPrefs.app/WindowHandling.c @@ -86,11 +86,14 @@ static const char *const placements[] = { "center" }; -static const char *const dragMaximizedWindowOptions[] = { - "Move", - "RestoreGeometry", - "Unmaximize", - "NoMove" +static const struct { + const char *db_value; + const char *label; +} drag_maximized_window_options[] = { + { "Move", N_("...change position (normal behavior)") }, + { "RestoreGeometry", N_("...restore unmaximized geometry") }, + { "Unmaximize", N_("...consider the window unmaximized") }, + { "NoMove", N_("...do not move the window") } }; static void sliderCallback(WMWidget * w, void *data) @@ -177,19 +180,17 @@ static int getPlacement(const char *str) static int getDragMaximizedWindow(const char *str) { + int i; + if (!str) return 0; - if (strcasecmp(str, "Move") == 0) - return 0; - else if (strcasecmp(str, "RestoreGeometry") == 0) - return 1; - else if (strcasecmp(str, "Unmaximize") == 0) - return 2; - else if (strcasecmp(str, "NoMove") == 0) - return 3; - else - wwarning(_("bad option value %s in WindowPlacement. Using default value"), str); + for (i = 0; i < wlengthof(drag_maximized_window_options); i++) { + if (strcasecmp(str, drag_maximized_window_options[i].db_value) == 0) + return i; + } + + wwarning(_("bad option value %s in WindowPlacement. Using default value"), str); return 0; } @@ -271,8 +272,8 @@ static void storeData(_Panel * panel) SetIntegerForKey(WMGetSliderValue(panel->resS), "EdgeResistance"); - SetStringForKey(dragMaximizedWindowOptions[WMGetPopUpButtonSelectedItem(panel->dragmaxP)], - "DragMaximizedWindow"); + SetStringForKey(drag_maximized_window_options[WMGetPopUpButtonSelectedItem(panel->dragmaxP)].db_value, + "DragMaximizedWindow"); SetIntegerForKey(WMGetSliderValue(panel->resizeS), "ResizeIncrement"); SetBoolForKey(WMGetButtonSelected(panel->resrB), "Attraction"); @@ -290,6 +291,7 @@ static void createPanel(Panel * p) int swidth, sheight; char *path; WMBox *hbox; + int i; panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); @@ -533,10 +535,9 @@ static void createPanel(Panel * p) panel->dragmaxP = WMCreatePopUpButton(panel->dragmaxF); WMResizeWidget(panel->dragmaxP, 269, 20); WMMoveWidget(panel->dragmaxP, 10, 20); - WMAddPopUpButtonItem(panel->dragmaxP, _("...change position (normal behavior)")); - WMAddPopUpButtonItem(panel->dragmaxP, _("...restore unmaximized geometry")); - WMAddPopUpButtonItem(panel->dragmaxP, _("...consider the window unmaximized")); - WMAddPopUpButtonItem(panel->dragmaxP, _("...do not move the window")); + + for (i = 0; i < wlengthof(drag_maximized_window_options); i++) + WMAddPopUpButtonItem(panel->dragmaxP, _(drag_maximized_window_options[i].label)); WMMapSubwidgets(panel->dragmaxF); -- 2.1.1 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.