mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 04:20:27 +01:00
WPrefs: sort alphabetically the key shortcut actions and expert options
There are too many entries now in key shortcut actions and expert options, better to sort them dynamically.
This commit is contained in:
committed by
Carlos R. Mafra
parent
52a623729d
commit
a383074c99
@@ -25,7 +25,7 @@
|
||||
/* This structure containts the list of all the check-buttons to display in the
|
||||
* expert tab of the window with the corresponding information for effect
|
||||
*/
|
||||
static const struct {
|
||||
static struct expert_option {
|
||||
const char *label; /* Text displayed to user */
|
||||
|
||||
int def_state; /* True/False: the default value, if not defined in current config */
|
||||
@@ -172,6 +172,19 @@ static void upButtonCallback(WMWidget *self, void *data)
|
||||
changeIntTextfield(data, 1);
|
||||
}
|
||||
|
||||
static int cmpExpertOptions(const void *v1, const void *v2)
|
||||
{
|
||||
int rc;
|
||||
const struct expert_option *opt1 = (struct expert_option *)v1;
|
||||
const struct expert_option *opt2 = (struct expert_option *)v2;
|
||||
|
||||
if ((rc = strcmp(opt1->label, opt2->label)) < 0)
|
||||
return -1;
|
||||
else if (rc > 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void createPanel(Panel *p)
|
||||
{
|
||||
_Panel *panel = (_Panel *) p;
|
||||
@@ -195,6 +208,7 @@ static void createPanel(Panel *p)
|
||||
WMSetFrameRelief(f, WRFlat);
|
||||
|
||||
udb = WMGetStandardUserDefaults();
|
||||
qsort(expert_options, wlengthof(expert_options), sizeof(expert_options[0]), cmpExpertOptions);
|
||||
for (i = 0; i < wlengthof(expert_options); i++) {
|
||||
if (expert_options[i].class != OPTION_WMAKER_INT) {
|
||||
panel->swi[i] = WMCreateSwitchButton(f);
|
||||
|
||||
@@ -65,7 +65,7 @@ typedef struct _Panel {
|
||||
* First parameter is the internal keyword known by WMaker
|
||||
* Second is the text displayed to the user
|
||||
*/
|
||||
static const struct {
|
||||
static struct keyOption {
|
||||
const char *key;
|
||||
const char *title;
|
||||
} keyOptions[] = {
|
||||
@@ -541,6 +541,20 @@ static void paintItem(WMList * lPtr, int index, Drawable d, char *text, int stat
|
||||
WMDrawString(scr, d, panel->black, panel->font, x + 20, y, text, strlen(text));
|
||||
}
|
||||
|
||||
static int cmpKeyOptions(const void *v1, const void *v2)
|
||||
{
|
||||
int rc;
|
||||
const struct keyOption *opt1 = (struct keyOption *)v1;
|
||||
const struct keyOption *opt2 = (struct keyOption *)v2;
|
||||
|
||||
if ((rc = strcmp(opt1->title, opt2->title)) < 0)
|
||||
return -1;
|
||||
else if (rc > 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void createPanel(Panel * p)
|
||||
{
|
||||
_Panel *panel = (_Panel *) p;
|
||||
@@ -580,6 +594,7 @@ static void createPanel(Panel * p)
|
||||
WMSetListUserDrawProc(panel->actLs, paintItem);
|
||||
WMHangData(panel->actLs, panel);
|
||||
|
||||
qsort(keyOptions, wlengthof(keyOptions), sizeof(keyOptions[0]), cmpKeyOptions);
|
||||
for (i = 0; i < wlengthof(keyOptions); i++) {
|
||||
WMAddListItem(panel->actLs, _(keyOptions[i].title));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user