diff options
author | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2010-07-30 17:45:36 +0200 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2010-07-30 17:45:36 +0200 |
commit | d3046d174245920c01f2e19fa43f2cccdba9540b (patch) | |
tree | d2893ab841490e9e88f21ec6653e227a7b80c395 /src/settings.c | |
parent | df4022ccda870f2a1b0e4e254f4a298da48fc4f9 (diff) | |
download | pianobar-d3046d174245920c01f2e19fa43f2cccdba9540b.tar.gz pianobar-d3046d174245920c01f2e19fa43f2cccdba9540b.tar.bz2 pianobar-d3046d174245920c01f2e19fa43f2cccdba9540b.zip |
Feature: Custom station sorting
Sort stations by name and/or isquickmix.
Diffstat (limited to 'src/settings.c')
-rw-r--r-- | src/settings.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/settings.c b/src/settings.c index 1dee0ea..8aa764c 100644 --- a/src/settings.c +++ b/src/settings.c @@ -87,7 +87,6 @@ void BarSettingsDestroy (BarSettings_t *settings) { void BarSettingsRead (BarSettings_t *settings) { /* FIXME: what is the max length of a path? */ char configfile[1024], key[256], val[256]; - size_t i; FILE *configfd; /* _must_ have same order as in BarKeyShortcutId_t */ const char defaultKeys[] = {'?', '+', '-', 'a', 'c', 'd', 'e', 'g', @@ -113,6 +112,7 @@ void BarSettingsRead (BarSettings_t *settings) { #endif #endif settings->history = 5; + settings->sortOrder = BAR_SORT_NAME_AZ; memcpy (settings->keys, defaultKeys, sizeof (defaultKeys)); BarGetXdgConfigDir (PACKAGE "/config", configfile, sizeof (configfile)); @@ -138,6 +138,7 @@ void BarSettingsRead (BarSettings_t *settings) { } else if (strcmp ("password", key) == 0) { settings->password = strdup (val); } else if (memcmp ("act_", key, 4) == 0) { + size_t i; /* keyboard shortcuts */ for (i = 0; i < BAR_KS_COUNT; i++) { if (strcmp (shortcutFileKeys[i], key) == 0) { @@ -159,6 +160,21 @@ void BarSettingsRead (BarSettings_t *settings) { settings->eventCmd = strdup (val); } else if (strcmp ("history", key) == 0) { settings->history = atoi (val); + } else if (strcmp ("sort", key) == 0) { + size_t i; + char *mapping[] = {"name_az", + "name_za", + "quickmix_01_name_az", + "quickmix_01_name_za", + "quickmix_10_name_az", + "quickmix_10_name_za", + }; + for (i = 0; i < BAR_SORT_COUNT; i++) { + if (strcmp (mapping[i], val) == 0) { + settings->sortOrder = i; + break; + } + } } } |