X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fopenbox;a=blobdiff_plain;f=obt%2Flink.c;h=9a05370716e39758a3bb677f4e27c229e0bbfb65;hp=8249118d210a8e8e19d08cb9d2247cf30f828477;hb=3121146eccd031a56d410eb48f3002558f41b40a;hpb=67bed35b7c1b1c9470aa8d0ba33974eabd66e089 diff --git a/obt/link.c b/obt/link.c index 8249118d..9a053707 100644 --- a/obt/link.c +++ b/obt/link.c @@ -18,6 +18,7 @@ #include "obt/link.h" #include "obt/ddparse.h" +#include "obt/paths.h" #include struct _ObtLink { @@ -25,6 +26,10 @@ struct _ObtLink { ObtLinkType type; gchar *name; /*!< Specific name for the object (eg Firefox) */ + gboolean display; /*ref = 1; - /* XXX turn the values in the .desktop file into an ObtLink */ + /* check that required keys exist */ - return lnk; + if (!(type = g_hash_table_lookup(keys, "Type"))) + { g_hash_table_destroy(groups); return NULL; } + if (!(name = g_hash_table_lookup(keys, "Name"))) + { g_hash_table_destroy(groups); return NULL; } + + if (type->value.enumerable == OBT_LINK_TYPE_APPLICATION) { + if (!(target = g_hash_table_lookup(keys, "Exec"))) + { g_hash_table_destroy(groups); return NULL; } + } + else if (type->value.enumerable == OBT_LINK_TYPE_URL) { + if (!(target = g_hash_table_lookup(keys, "URL"))) + { g_hash_table_destroy(groups); return NULL; } + } + else + target = NULL; + + /* parse all the optional keys and build ObtLink (steal the strings) */ + link = g_slice_new0(ObtLink); + link->ref = 1; + link->type = type->value.enumerable; + if (link->type == OBT_LINK_TYPE_APPLICATION) + link->d.app.exec = target->value.string, target->value.string = NULL; + else if (link->type == OBT_LINK_TYPE_URL) + link->d.url.addr = target->value.string, target->value.string = NULL; + link->display = TRUE; + + if ((v = g_hash_table_lookup(keys, "Hidden"))) + link->deleted = v->value.boolean; + + if ((v = g_hash_table_lookup(keys, "NoDisplay"))) + link->display = !v->value.boolean; + + if ((v = g_hash_table_lookup(keys, "GenericName"))) + link->generic = v->value.string, v->value.string = NULL; + + if ((v = g_hash_table_lookup(keys, "Comment"))) + link->comment = v->value.string, v->value.string = NULL; + + 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 (link->type == OBT_LINK_TYPE_APPLICATION) { + if ((v = g_hash_table_lookup(keys, "TryExec"))) { + /* XXX spawn a thread to check TryExec? */ + link->display = link->display && + obt_paths_try_exec(p, v->value.string); + } + + /* XXX there's more app specific stuff */ + } + + else if (link->type == OBT_LINK_TYPE_URL) { + /* XXX there's URL specific stuff */ + } + + return link; } void obt_link_ref(ObtLink *dd)