{
return obt_ddparse_file_to_id(filename);
}
+
+gboolean obt_link_display(ObtLink *e, const guint environments)
+{
+ return
+ /* display if the link wants to be displayed and TryExec passed */
+ e->display &&
+ /* display if no environment is required, or we match at least one of
+ the requirements */
+ (!e->env_required || (e->env_required & environments)) &&
+ /* display if no environment is restricted, or we do not match any of
+ the restrictions */
+ (!e->env_restricted || !(e->env_restricted & environments));
+}
/*! Returns TRUE if the .desktop file should be displayed to users, given the
current environment. If FALSE, the .desktop file should not be showed.
This also uses the TryExec option if it is present.
- @env A semicolon-deliminated list of environemnts. Can be one or more of:
- GNOME, KDE, ROX, XFCE. Other environments not listed here may also
- be supported. This can be null also if not listing any environment. */
-gboolean obt_link_display(ObtLink *e, const gchar *env);
+ @param environments A bitflags of values from ObtLinkEnvFlags indicating
+ the active environments. */
+gboolean obt_link_display(ObtLink *e, const guint environments);
const gchar* obt_link_name (ObtLink *e);
const gchar* obt_link_generic_name (ObtLink *e);
struct _ObtLinkBase {
gint ref;
+ /*! A bitflag of values from ObtLinkEnvFlags indicating which environments
+ are to be considered active. */
+ guint environments;
+
const gchar *language;
const gchar *country;
const gchar *modifier;
}
if (add) {
- ObtLinkBaseEntry *e = g_slice_new(ObtLinkBaseEntry);
- e->priority = *priority;
- e->link = obt_link_from_ddfile(full_path, self->paths,
- self->language, self->country,
- self->modifier);
- list = g_slist_insert_before(list, it, e);
+ ObtLink *link;
- /* this will free 'id' */
- g_hash_table_insert(self->base, id, list);
- id = NULL;
+ link = obt_link_from_ddfile(full_path, self->paths,
+ self->language, self->country,
+ self->modifier);
+ if (!obt_link_display(link, self->environments)) {
+ obt_link_unref(link);
+ }
+ else {
+ ObtLinkBaseEntry *e = g_slice_new(ObtLinkBaseEntry);
+ e->priority = *priority;
+ e->link = link;
+ list = g_slist_insert_before(list, it, e);
+
+ /* this will free 'id' */
+ g_hash_table_insert(self->base, id, list);
+ id = NULL;
+ }
}
g_free(id);
}
-ObtLinkBase* obt_linkbase_new(ObtPaths *paths, const gchar *locale)
+ObtLinkBase* obt_linkbase_new(ObtPaths *paths, const gchar *locale,
+ guint environments)
{
ObtLinkBase *self;
GSList *it;
gint i;
self = g_slice_new0(ObtLinkBase);
+ self->environments = environments;
self->watch = obt_watch_new();
self->base = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
(GDestroyNotify)base_entry_list_free);
/*! Create a new database of ObtLinks.
@param paths An ObtPaths structure.
@param locale The value of LC_MESSAGES.
+ @param environments A bitflag of values from ObtLinkEnvFlags indicating
+ which environments are to be considered active.
*/
-ObtLinkBase* obt_linkbase_new(struct _ObtPaths *paths, const gchar *locale);
+ObtLinkBase* obt_linkbase_new(struct _ObtPaths *paths, const gchar *locale,
+ guint environments);
void obt_linkbase_ref(ObtLinkBase *lb);
void obt_linkbase_unref(ObtLinkBase *lb);