diff options
author | Ted Gould <ted@gould.cx> | 2011-03-22 14:59:41 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-03-22 14:59:41 -0500 |
commit | 118b8f09a020a4123549ca01e7814d52780247fe (patch) | |
tree | a7127eb9e08b13fca0f5c411a65e2c12eeb8efdb | |
parent | a07522770934ada0818a5dadc9e4ab4a8282c0bd (diff) | |
parent | a995a11447ed9bf880d129c3e03fbce5395fbb74 (diff) | |
download | libayatana-indicator-118b8f09a020a4123549ca01e7814d52780247fe.tar.gz libayatana-indicator-118b8f09a020a4123549ca01e7814d52780247fe.tar.bz2 libayatana-indicator-118b8f09a020a4123549ca01e7814d52780247fe.zip |
* Upstream Merge
* Adding the ability to know the environment the indicator
object is in.
-rw-r--r-- | debian/changelog | 8 | ||||
-rw-r--r-- | libindicator/indicator-object.c | 80 | ||||
-rw-r--r-- | libindicator/indicator-object.h | 4 |
3 files changed, 92 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index d538d26..399e111 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +libindicator (0.3.21-0ubuntu2~ppa1) UNRELEASED; urgency=low + + * Upstream Merge + * Adding the ability to know the environment the indicator + object is in. + + -- Ted Gould <ted@ubuntu.com> Tue, 22 Mar 2011 14:59:11 -0500 + libindicator (0.3.21-0ubuntu1) natty; urgency=low * New upstream release. diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index 73c1ca7..a061215 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -48,6 +48,8 @@ struct _IndicatorObjectPrivate { /* For get_entries_default */ IndicatorObjectEntry entry; gboolean gotten_entries; + + GStrv environments; }; #define INDICATOR_OBJECT_GET_PRIVATE(o) (INDICATOR_OBJECT(o)->priv) @@ -260,6 +262,8 @@ indicator_object_init (IndicatorObject *self) self->priv->gotten_entries = FALSE; + self->priv->environments = NULL; + return; } @@ -290,6 +294,11 @@ indicator_object_finalize (GObject *object) { IndicatorObjectPrivate * priv = INDICATOR_OBJECT_GET_PRIVATE(object); + if (priv->environments != NULL) { + g_strfreev(priv->environments); + priv->environments = NULL; + } + if (priv->module != NULL) { /* Wow, this is convoluted. So basically we want to unref the module which will cause the code it included to be @@ -571,3 +580,74 @@ indicator_object_entry_close (IndicatorObject * io, IndicatorObjectEntry * entry return; } + +/** + indicator_object_set_environment: + @io: #IndicatorObject to set on + @env: List of enviroment names to use + + Sets the names of the environment that the indicator is being + loaded into. This allows for indicators to behave differently + in different hosts if need be. +*/ +void +indicator_object_set_environment (IndicatorObject * io, const GStrv env) +{ + g_return_if_fail(INDICATOR_IS_OBJECT(io)); + + if (io->priv->environments != NULL) { + g_strfreev(io->priv->environments); + io->priv->environments = NULL; + } + + io->priv->environments = g_strdupv(env); + + return; +} + +/** + indicator_object_get_environment: + @io: #IndicatorObject to get the environment from + + Gets the list of environment strings that this object is + placed into. + + Return value: (transfer none): Gets the list of strings that + represent the environment or NULL if none were given. +*/ +const GStrv +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 67a3bda..aa15c79 100644 --- a/libindicator/indicator-object.h +++ b/libindicator/indicator-object.h @@ -179,6 +179,10 @@ guint indicator_object_get_show_now (IndicatorObject * io, IndicatorObjectEntr void indicator_object_entry_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); void indicator_object_entry_close (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); +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 #endif |