From a995a11447ed9bf880d129c3e03fbce5395fbb74 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Mar 2011 10:57:30 -0500 Subject: Adding a nice little checking function --- libindicator/indicator-object.c | 30 ++++++++++++++++++++++++++++++ libindicator/indicator-object.h | 1 + 2 files changed, 31 insertions(+) diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index bac4826..a061215 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -621,3 +621,33 @@ indicator_object_get_environment (IndicatorObject * io) g_return_val_if_fail(INDICATOR_IS_OBJECT(io), NULL); return io->priv->environments; } + +/** + indicator_object_check_environment: + @io: #IndicatorObject to check on + @env: Environment that we're looking for + + Convience function to check to see if the specified environment + @env is in our list of environments. + + Return Value: Whether we're in environment @env +*/ +gboolean +indicator_object_check_environment (IndicatorObject * io, const gchar * env) +{ + g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE); + g_return_val_if_fail(env != NULL, FALSE); + + if (io->priv->environments == NULL) { + return FALSE; + } + + int i; + for (i = 0; io->priv->environments[i] != NULL; i++) { + if (g_strcmp0(env, io->priv->environments[i]) == 0) { + return TRUE; + } + } + + return FALSE; +} diff --git a/libindicator/indicator-object.h b/libindicator/indicator-object.h index 221f399..aa15c79 100644 --- a/libindicator/indicator-object.h +++ b/libindicator/indicator-object.h @@ -181,6 +181,7 @@ void indicator_object_entry_close (IndicatorObject * io, IndicatorObjectEntry void indicator_object_set_environment (IndicatorObject * io, const GStrv env); const GStrv indicator_object_get_environment (IndicatorObject * io); +gboolean indicator_object_check_environment (IndicatorObject * io, const gchar * env); G_END_DECLS -- cgit v1.2.3