case OBT_DDPARSE_BOOLEAN:
case OBT_DDPARSE_NUMERIC:
case OBT_DDPARSE_ENUM_APPLICATION:
+ case OBT_DDPARSE_ENVIRONMENTS:
break;
default:
g_assert_not_reached();
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)
return FALSE;
}
break;
+ case OBT_DDPARSE_ENVIRONMENTS:
+ v.value.environments = parse_value_environments(val, parse, error);
+ break;
default:
g_assert_not_reached();
}
OBT_DDPARSE_BOOLEAN,
OBT_DDPARSE_NUMERIC,
OBT_DDPARSE_ENUM_APPLICATION,
+ OBT_DDPARSE_ENVIRONMENTS,
OBT_DDPARSE_NUM_VALUE_TYPES
} ObtDDParseValueType;
gboolean boolean;
gfloat numeric;
guint enumerable;
+ guint environments; /*!< A mask of flags from ObtLinkEnvMask */
} value;
} ObtDDParseValue;
gchar *generic; /*!< Generic name for the object (eg Web Browser) */
gchar *comment; /*!< Comment/description to display for the object */
gchar *icon; /*!< Name/path for an icon for the object */
+ guint env_required; /*!< The environments that must be present to use this
+ link. */
+ guint env_restricted; /*!< The environments that must _not_ be present to
+ use this link. */
union _ObtLinkData {
struct _ObtLinkApp {
if ((v = g_hash_table_lookup(keys, "Icon")))
link->icon = v->value.string, v->value.string = NULL;
- /* XXX handle Only/NotShowIn, better know the current environment */
+ if ((v = g_hash_table_lookup(keys, "OnlyShowIn")))
+ link->env_required = v->value.environments;
+ else
+ link->env_required = 0;
+
+ if ((v = g_hash_table_lookup(keys, "NotShowIn")))
+ link->env_restricted = v->value.environments;
+ else
+ link->env_restricted = 0;
if (link->type == OBT_LINK_TYPE_APPLICATION) {
if ((v = g_hash_table_lookup(keys, "TryExec"))) {
OBT_LINK_APP_STARTUP_LEGACY_SUPPORT
} ObtLinkAppStartup;
+/*! These bit flags are environments for links. Some links are used or not
+ used in various environments. */
+typedef enum {
+ OBT_LINK_ENV_OPENBOX = 1 << 0,
+ OBT_LINK_ENV_GNOME = 1 << 1,
+ OBT_LINK_ENV_KDE = 1 << 2,
+ OBT_LINK_ENV_LXDE = 1 << 3,
+ OBT_LINK_ENV_ROX = 1 << 4,
+ OBT_LINK_ENV_XFCE = 1 << 5,
+ OBT_LINK_ENV_OLD = 1 << 6
+} ObtLinkEnvFlags;
+
typedef enum {
/*! The app can be launched with a single local file */
OBT_LINK_APP_SINGLE_LOCAL = 1 << 0,