mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
WPrefs: created macro 'wlengthof_nocheck' for the cases were wlengthof cannot be used
Because the macro wlengthof preforms a check of validity of its argument with static_assert, there is a use case where it fails with a compiler error. This patch introduces an alternate macro without the check, to be used only for this specific case. To be able to use the size of the array, a few of those array declaration have to be moved before the structure in which their size is used. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
7d09b2c04f
commit
6ac27ba842
@@ -31,6 +31,62 @@
|
|||||||
|
|
||||||
#include "TexturePanel.h"
|
#include "TexturePanel.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const struct {
|
||||||
|
const char *key;
|
||||||
|
const char *default_value;
|
||||||
|
const char *label;
|
||||||
|
WMRect preview; /* The rectangle where the corresponding object is displayed */
|
||||||
|
WMPoint hand; /* The coordinate where the hand is drawn when pointing this item */
|
||||||
|
} colorOptions[] = {
|
||||||
|
/* Related to Window titles */
|
||||||
|
{ "FTitleColor", "white", N_("Focused Window Title"),
|
||||||
|
{ { 30, 10 }, { 190, 20 } }, { 5, 10 } },
|
||||||
|
{ "UTitleColor", "black", N_("Unfocused Window Title"),
|
||||||
|
{ { 30, 40 }, { 190, 20 } }, { 5, 40 } },
|
||||||
|
{ "PTitleColor", "white", N_("Owner of Focused Window Title"),
|
||||||
|
{ { 30, 70 }, { 190, 20 } }, { 5, 70 } },
|
||||||
|
|
||||||
|
/* Related to Menus */
|
||||||
|
{ "MenuTitleColor", "white", N_("Menu Title") ,
|
||||||
|
{ { 30, 120 }, { 90, 20 } }, { 5, 120 } },
|
||||||
|
{ "MenuTextColor", "black", N_("Menu Item Text") ,
|
||||||
|
{ { 30, 140 }, { 90, 20 } }, { 5, 140 } },
|
||||||
|
{ "MenuDisabledColor", "#616161", N_("Disabled Menu Item Text") ,
|
||||||
|
{ { 30, 160 }, { 90, 20 } }, { 5, 160 } },
|
||||||
|
{ "HighlightColor", "white", N_("Menu Highlight Color") ,
|
||||||
|
{ { 30, 180 }, { 90, 20 } }, { 5, 180 } },
|
||||||
|
{ "HighlightTextColor", "black", N_("Highlighted Menu Text Color") ,
|
||||||
|
{ { 30, 200 }, { 90, 20 } }, { 5, 180 } },
|
||||||
|
/*
|
||||||
|
* yuck kluge: the coordinate for HighlightTextColor are actually those of the last "Normal item"
|
||||||
|
* at the bottom when user clicks it, the "yuck kluge" in the function 'previewClick' will swap it
|
||||||
|
* for the MenuTextColor selection as user would expect
|
||||||
|
*
|
||||||
|
* Note that the entries are reffered by their index for performance
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Related to Window's border */
|
||||||
|
{ "FrameFocusedBorderColor", "black", N_("Focused Window Border Color") ,
|
||||||
|
{ { 0, 0 }, { 0, 0 } }, { -22, -21 } },
|
||||||
|
{ "FrameBorderColor", "black", N_("Window Border Color") ,
|
||||||
|
{ { 0, 0 }, { 0, 0 } }, { -22, -21 } },
|
||||||
|
{ "FrameSelectedBorderColor", "white", N_("Selected Window Border Color") ,
|
||||||
|
{ { 0, 0 }, { 0, 0 } }, { -22, -21 } },
|
||||||
|
|
||||||
|
/* Related to Icons and Clip */
|
||||||
|
{ "IconTitleColor", "white", N_("Miniwindow Title") ,
|
||||||
|
{ { 155, 130 }, { 64, 64 } }, { 130, 132 } },
|
||||||
|
{ "IconTitleBack", "black", N_("Miniwindow Title Back") ,
|
||||||
|
{ { 155, 130 }, { 64, 64 } }, { 130, 132 } },
|
||||||
|
{ "ClipTitleColor", "black", N_("Clip Title") ,
|
||||||
|
{ { 155, 130 }, { 64, 64 } }, { 130, 132 } },
|
||||||
|
{ "CClipTitleColor", "#454045", N_("Collapsed Clip Title") ,
|
||||||
|
{ { 155, 130 }, { 64, 64 } }, { 130, 132 } }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/********************************************************************/
|
||||||
typedef struct _Panel {
|
typedef struct _Panel {
|
||||||
WMBox *box;
|
WMBox *box;
|
||||||
char *sectionName;
|
char *sectionName;
|
||||||
@@ -60,7 +116,7 @@ typedef struct _Panel {
|
|||||||
WMFrame *colF;
|
WMFrame *colF;
|
||||||
|
|
||||||
WMPopUpButton *colP;
|
WMPopUpButton *colP;
|
||||||
WMColor *colors[15];
|
WMColor *colors[wlengthof_nocheck(colorOptions)];
|
||||||
|
|
||||||
WMColorWell *colW;
|
WMColorWell *colW;
|
||||||
|
|
||||||
@@ -369,59 +425,6 @@ enum {
|
|||||||
CCLIP_COL
|
CCLIP_COL
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct {
|
|
||||||
const char *key;
|
|
||||||
const char *default_value;
|
|
||||||
const char *label;
|
|
||||||
WMRect preview; /* The rectangle where the corresponding object is displayed */
|
|
||||||
WMPoint hand; /* The coordinate where the hand is drawn when pointing this item */
|
|
||||||
} colorOptions[] = {
|
|
||||||
/* Related to Window titles */
|
|
||||||
{ "FTitleColor", "white", N_("Focused Window Title"),
|
|
||||||
{ { 30, 10 }, { 190, 20 } }, { 5, 10 } },
|
|
||||||
{ "UTitleColor", "black", N_("Unfocused Window Title"),
|
|
||||||
{ { 30, 40 }, { 190, 20 } }, { 5, 40 } },
|
|
||||||
{ "PTitleColor", "white", N_("Owner of Focused Window Title"),
|
|
||||||
{ { 30, 70 }, { 190, 20 } }, { 5, 70 } },
|
|
||||||
|
|
||||||
/* Related to Menus */
|
|
||||||
{ "MenuTitleColor", "white", N_("Menu Title") ,
|
|
||||||
{ { 30, 120 }, { 90, 20 } }, { 5, 120 } },
|
|
||||||
{ "MenuTextColor", "black", N_("Menu Item Text") ,
|
|
||||||
{ { 30, 140 }, { 90, 20 } }, { 5, 140 } },
|
|
||||||
{ "MenuDisabledColor", "#616161", N_("Disabled Menu Item Text") ,
|
|
||||||
{ { 30, 160 }, { 90, 20 } }, { 5, 160 } },
|
|
||||||
{ "HighlightColor", "white", N_("Menu Highlight Color") ,
|
|
||||||
{ { 30, 180 }, { 90, 20 } }, { 5, 180 } },
|
|
||||||
{ "HighlightTextColor", "black", N_("Highlighted Menu Text Color") ,
|
|
||||||
{ { 30, 200 }, { 90, 20 } }, { 5, 180 } },
|
|
||||||
/*
|
|
||||||
* yuck kluge: the coordinate for HighlightTextColor are actually those of the last "Normal item"
|
|
||||||
* at the bottom when user clicks it, the "yuck kluge" in the function 'previewClick' will swap it
|
|
||||||
* for the MenuTextColor selection as user would expect
|
|
||||||
*
|
|
||||||
* Note that the entries are reffered by their index for performance
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Related to Window's border */
|
|
||||||
{ "FrameFocusedBorderColor", "black", N_("Focused Window Border Color") ,
|
|
||||||
{ { 0, 0 }, { 0, 0 } }, { -22, -21 } },
|
|
||||||
{ "FrameBorderColor", "black", N_("Window Border Color") ,
|
|
||||||
{ { 0, 0 }, { 0, 0 } }, { -22, -21 } },
|
|
||||||
{ "FrameSelectedBorderColor", "white", N_("Selected Window Border Color") ,
|
|
||||||
{ { 0, 0 }, { 0, 0 } }, { -22, -21 } },
|
|
||||||
|
|
||||||
/* Related to Icons and Clip */
|
|
||||||
{ "IconTitleColor", "white", N_("Miniwindow Title") ,
|
|
||||||
{ { 155, 130 }, { 64, 64 } }, { 130, 132 } },
|
|
||||||
{ "IconTitleBack", "black", N_("Miniwindow Title Back") ,
|
|
||||||
{ { 155, 130 }, { 64, 64 } }, { 130, 132 } },
|
|
||||||
{ "ClipTitleColor", "black", N_("Clip Title") ,
|
|
||||||
{ { 155, 130 }, { 64, 64 } }, { 130, 132 } },
|
|
||||||
{ "CClipTitleColor", "#454045", N_("Collapsed Clip Title") ,
|
|
||||||
{ { 155, 130 }, { 64, 64 } }, { 130, 132 } }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static void str2rcolor(RContext * rc, const char *name, RColor * color)
|
static void str2rcolor(RContext * rc, const char *name, RColor * color)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,28 @@
|
|||||||
|
|
||||||
#include "WPrefs.h"
|
#include "WPrefs.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const struct {
|
||||||
|
const char *key;
|
||||||
|
const char *string;
|
||||||
|
} auto_delay[] = {
|
||||||
|
{ "ClipAutoexpandDelay", N_("Before auto-expansion") },
|
||||||
|
{ "ClipAutocollapseDelay", N_("Before auto-collapsing") },
|
||||||
|
{ "ClipAutoraiseDelay", N_("Before auto-raise") },
|
||||||
|
{ "ClipAutolowerDelay", N_("Before auto-lowering") }
|
||||||
|
};
|
||||||
|
|
||||||
|
static char *autoDelayPresetValues[5] = { "0", "100", "250", "600", "1000" };
|
||||||
|
|
||||||
|
static const struct {
|
||||||
|
const char *disable_key;
|
||||||
|
const char *icon_file;
|
||||||
|
} dock_config[] = {
|
||||||
|
{ "DisableDock", "dock" },
|
||||||
|
{ "DisableClip", "clip" },
|
||||||
|
{ "DisableDrawers", "drawer" }
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct _Panel {
|
typedef struct _Panel {
|
||||||
WMBox *box;
|
WMBox *box;
|
||||||
|
|
||||||
@@ -33,13 +55,13 @@ typedef struct _Panel {
|
|||||||
WMWidget *parent;
|
WMWidget *parent;
|
||||||
|
|
||||||
WMFrame *autoDelayF[2];
|
WMFrame *autoDelayF[2];
|
||||||
WMLabel *autoDelayL[4];
|
WMLabel *autoDelayL[wlengthof_nocheck(auto_delay)];
|
||||||
WMButton *autoDelayB[4][5];
|
WMButton *autoDelayB[wlengthof_nocheck(auto_delay)][wlengthof_nocheck(autoDelayPresetValues)];
|
||||||
WMTextField *autoDelayT[4];
|
WMTextField *autoDelayT[wlengthof_nocheck(auto_delay)];
|
||||||
WMLabel *autoDelayMsL[4];
|
WMLabel *autoDelayMsL[wlengthof_nocheck(auto_delay)];
|
||||||
|
|
||||||
WMFrame *dockF;
|
WMFrame *dockF;
|
||||||
WMButton *docksB[3];
|
WMButton *docksB[wlengthof_nocheck(dock_config)];
|
||||||
} _Panel;
|
} _Panel;
|
||||||
|
|
||||||
#define ICON_FILE "dockclipdrawersection"
|
#define ICON_FILE "dockclipdrawersection"
|
||||||
@@ -48,28 +70,6 @@ typedef struct _Panel {
|
|||||||
#define DELAY_ICON "timer%i"
|
#define DELAY_ICON "timer%i"
|
||||||
#define DELAY_ICON_S "timer%is"
|
#define DELAY_ICON_S "timer%is"
|
||||||
|
|
||||||
static const struct {
|
|
||||||
const char *key;
|
|
||||||
const char *string;
|
|
||||||
} auto_delay[] = {
|
|
||||||
{ "ClipAutoexpandDelay", N_("Before auto-expansion") },
|
|
||||||
{ "ClipAutocollapseDelay", N_("Before auto-collapsing") },
|
|
||||||
{ "ClipAutoraiseDelay", N_("Before auto-raise") },
|
|
||||||
{ "ClipAutolowerDelay", N_("Before auto-lowering") }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static char *autoDelayPresetValues[5] = { "0", "100", "250", "600", "1000" };
|
|
||||||
|
|
||||||
static const struct {
|
|
||||||
const char *disable_key;
|
|
||||||
const char *icon_file;
|
|
||||||
} dock_config[] = {
|
|
||||||
{ "DisableDock", "dock" },
|
|
||||||
{ "DisableClip", "clip" },
|
|
||||||
{ "DisableDrawers", "drawer" }
|
|
||||||
};
|
|
||||||
|
|
||||||
static void showData(_Panel *panel);
|
static void showData(_Panel *panel);
|
||||||
static void storeData(_Panel *panel);
|
static void storeData(_Panel *panel);
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ typedef struct _Panel {
|
|||||||
|
|
||||||
WMWidget *parent;
|
WMWidget *parent;
|
||||||
|
|
||||||
WMButton *swi[sizeof(expert_options) / sizeof(expert_options[0])];
|
WMButton *swi[wlengthof_nocheck(expert_options)];
|
||||||
|
|
||||||
} _Panel;
|
} _Panel;
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,20 @@
|
|||||||
/* Needed for HAVE_LIBINTL_H and EXTENDED_WINDOWSHORTCUT */
|
/* Needed for HAVE_LIBINTL_H and EXTENDED_WINDOWSHORTCUT */
|
||||||
#include "../src/wconfig.h"
|
#include "../src/wconfig.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The macro 'wlengthof' should be used as much as possible, this macro
|
||||||
|
* is reserved for the cases where wlengthof cannot be used because the
|
||||||
|
* static_assert. Typical symptom is this compiler error (gcc):
|
||||||
|
*
|
||||||
|
* error: braced-group within expression allowed only inside a function
|
||||||
|
*
|
||||||
|
* which appears when you try to create an array whose size is determined using
|
||||||
|
* wlengthof on some other array.
|
||||||
|
*/
|
||||||
|
#define wlengthof_nocheck(array) \
|
||||||
|
(sizeof(array) / sizeof(array[0]))
|
||||||
|
|
||||||
|
|
||||||
/****/
|
/****/
|
||||||
|
|
||||||
extern char *NOptionValueChanged;
|
extern char *NOptionValueChanged;
|
||||||
|
|||||||
Reference in New Issue
Block a user