aboutsummaryrefslogtreecommitdiff
path: root/libindicator
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-03-23 13:17:30 -0500
committerTed Gould <ted@gould.cx>2011-03-23 13:17:30 -0500
commit50607d3ff1fbbfec73be70d4220e9f826237b846 (patch)
treed7f2713c72ba7e96a8f7a8623be7449ee5b2f3c3 /libindicator
parente2b7096a53ed1d32ef7d4d3b53c7a095d8594394 (diff)
parentf9f5cee34bada7ed1fb0c3bbada7a5a545dbadd4 (diff)
downloadlibayatana-indicator-50607d3ff1fbbfec73be70d4220e9f826237b846.tar.gz
libayatana-indicator-50607d3ff1fbbfec73be70d4220e9f826237b846.tar.bz2
libayatana-indicator-50607d3ff1fbbfec73be70d4220e9f826237b846.zip
Import upstream version 0.3.22
Diffstat (limited to 'libindicator')
-rw-r--r--libindicator/indicator-object.c80
-rw-r--r--libindicator/indicator-object.h4
2 files changed, 84 insertions, 0 deletions
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