X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=obt%2Fddparse.c;h=c4be8e1edbb85454df449b3b4b31ff7df5226238;hb=d9d65b73853d485852f6d6bf6808af0ebb6a90f5;hp=fe7feb93cc3eea25440c8c4ccb416c060b561e1c;hpb=11bb31d3bc712aa31d73065383d32f1510393fe2;p=chaz%2Fopenbox diff --git a/obt/ddparse.c b/obt/ddparse.c index fe7feb93..c4be8e1e 100644 --- a/obt/ddparse.c +++ b/obt/ddparse.c @@ -17,6 +17,7 @@ */ #include "obt/ddparse.h" +#include "obt/link.h" #ifdef HAVE_STRING_H #include #endif @@ -77,8 +78,9 @@ static void parse_value_free(ObtDDParseValue *v) v->value.strings.n = 0; break; case OBT_DDPARSE_BOOLEAN: - break; case OBT_DDPARSE_NUMERIC: + case OBT_DDPARSE_ENUM_APPLICATION: + case OBT_DDPARSE_ENVIRONMENTS: break; default: g_assert_not_reached(); @@ -182,6 +184,69 @@ static gchar* parse_value_string(const gchar *in, return o; } +static guint parse_value_environments(const gchar *in, + const ObtDDParse *const parse, + gboolean *error) +{ + const gchar *s; + int i; + guint mask = 0; + + s = in; + while (*s) { + switch (*(s++)) { + case 'G': + if (strcmp(s, "NOME") == 0) { + mask |= OBT_LINK_ENV_GNOME; + s += 4; + } + break; + case 'K': + if (strcmp(s, "DE") == 0) { + mask |= OBT_LINK_ENV_KDE; + s += 2; + } + break; + case 'L': + if (strcmp(s, "XDE") == 0) { + mask |= OBT_LINK_ENV_LXDE; + s += 3; + } + break; + case 'R': + if (strcmp(s, "OX") == 0) { + mask |= OBT_LINK_ENV_ROX; + s += 2; + } + break; + case 'X': + if (strcmp(s, "FCE") == 0) { + mask |= OBT_LINK_ENV_XFCE; + s += 3; + } + break; + case 'O': + switch (*(s++)) { + case 'l': + if (strcmp(s, "d") == 0) { + mask |= OBT_LINK_ENV_OLD; + s += 1; + } + break; + case 'P': + if (strcmp(s, "ENBOX") == 0) { + mask |= OBT_LINK_ENV_OPENBOX; + s += 5; + } + break; + } + } + /* find the next string, or the end of the sequence */ + while (*s && *s != ';') ++s; + } + return mask; +} + static gboolean parse_value_boolean(const gchar *in, const ObtDDParse *const parse, gboolean *error) @@ -546,6 +611,21 @@ static gboolean parse_desktop_entry_value(gchar *key, const gchar *val, case OBT_DDPARSE_NUMERIC: v.value.numeric = parse_value_numeric(val, parse, error); break; + case OBT_DDPARSE_ENUM_APPLICATION: + if (val[0] == 'A' && strcmp(val+1, "pplication") == 0) + v.value.enumerable = OBT_LINK_TYPE_APPLICATION; + else if (val[0] == 'L' && strcmp(val+1, "ink") == 0) + v.value.enumerable = OBT_LINK_TYPE_URL; + else if (val[0] == 'D' && strcmp(val+1, "irectory") == 0) + v.value.enumerable = OBT_LINK_TYPE_DIRECTORY; + else { + parse_error("Unknown Type", parse, error); + return FALSE; + } + break; + case OBT_DDPARSE_ENVIRONMENTS: + v.value.environments = parse_value_environments(val, parse, error); + break; default: g_assert_not_reached(); }