diff options
author | Ted Gould <ted@gould.cx> | 2011-03-22 10:57:30 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-03-22 10:57:30 -0500 |
commit | a995a11447ed9bf880d129c3e03fbce5395fbb74 (patch) | |
tree | 0553a7b86a25c48953f21ed51589e330d8468e17 | |
parent | 5712d441abe82bb1c328102040ff5cb6212c911c (diff) | |
download | libayatana-indicator-a995a11447ed9bf880d129c3e03fbce5395fbb74.tar.gz libayatana-indicator-a995a11447ed9bf880d129c3e03fbce5395fbb74.tar.bz2 libayatana-indicator-a995a11447ed9bf880d129c3e03fbce5395fbb74.zip |
Adding a nice little checking function
-rw-r--r-- | libindicator/indicator-object.c | 30 | ||||
-rw-r--r-- | libindicator/indicator-object.h | 1 |
2 files changed, 31 insertions, 0 deletions
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 |