Back to index

libindicate  12.10.0
Classes | Defines | Typedefs | Enumerations | Functions | Variables
indicator.c File Reference
#include <glib.h>
#include "indicator.h"
#include "server.h"

Go to the source code of this file.

Classes

struct  _IndicateIndicatorPrivate

Defines

#define INDICATE_INDICATOR_GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATE_TYPE_INDICATOR, IndicateIndicatorPrivate))

Typedefs

typedef struct _IndicateIndicatorPrivate

Enumerations

enum  {
  HIDE, SHOW, USER_DISPLAY, MODIFIED,
  DISPLAYED, LAST_SIGNAL
}

Functions

 G_DEFINE_TYPE (IndicateIndicator, indicate_indicator, G_TYPE_OBJECT)
static void indicate_indicator_finalize (GObject *object)
static void set_property (IndicateIndicator *indicator, const gchar *key, GVariant *data)
static GVariant * get_property (IndicateIndicator *indicator, const gchar *key)
static GPtrArray * list_properties (IndicateIndicator *indicator)
static void indicate_indicator_class_init (IndicateIndicatorClass *class)
static void _g_variant_unref (gpointer data)
static void indicate_indicator_init (IndicateIndicator *indicator)
IndicateIndicator * indicate_indicator_new (void)
 indicate_indicator_get_type:
IndicateIndicator * indicate_indicator_new_with_server (IndicateServer *server)
 indicate_indicator_new_with_server: : The server that should be associated with this indicator.
void indicate_indicator_set_server (IndicateIndicator *indicator, IndicateServer *server)
 indicate_indicator_set_server: : a #IndicateIndicator to act on : the #IndicateServer which should be associated with
void indicate_indicator_show (IndicateIndicator *indicator)
 indicate_indicator_show: : a #IndicateIndicator to act on
void indicate_indicator_hide (IndicateIndicator *indicator)
 indicate_indicator_hide: : a #IndicateIndicator to act on
gboolean indicate_indicator_is_visible (IndicateIndicator *indicator)
 indicate_indicator_is_visible: : a #IndicateIndicator to act on
guint indicate_indicator_get_id (IndicateIndicator *indicator)
 indicate_indicator_get_id: : a #IndicateIndicator to act on
IndicateServer * indicate_indicator_get_server (IndicateIndicator *indicator)
 indicate_indicator_get_server: : a #IndicateIndicator to act on
void indicate_indicator_user_display (IndicateIndicator *indicator, guint timestamp)
 indicate_indicator_user_display: : a #IndicateIndicator to act on : The time that the event happened
void indicate_indicator_set_property (IndicateIndicator *indicator, const gchar *key, const gchar *data)
 indicate_indicator_set_property: : a #IndicateIndicator to act on : name of the property : value of the property
void indicate_indicator_set_property_time (IndicateIndicator *indicator, const gchar *key, GTimeVal *time)
 indicate_indicator_set_property_time: : a #IndicateIndicator to act on : name of the property : time to set property with
void indicate_indicator_set_property_int (IndicateIndicator *indicator, const gchar *key, gint value)
 indicate_indicator_set_property_int: : a #IndicateIndicator to act on : name of the property : integer to set property with
void indicate_indicator_set_property_bool (IndicateIndicator *indicator, const gchar *key, gboolean value)
 indicate_indicator_set_property_bool: : a #IndicateIndicator to act on : name of the property : integer to set property with
void indicate_indicator_set_property_variant (IndicateIndicator *indicator, const gchar *key, GVariant *value)
const gchar * indicate_indicator_get_property (IndicateIndicator *indicator, const gchar *key)
 indicate_indicator_get_property: : a #IndicateIndicator to act on : name of the property
GVariant * indicate_indicator_get_property_variant (IndicateIndicator *indicator, const gchar *key)
GPtrArray * indicate_indicator_list_properties (IndicateIndicator *indicator)
 indicate_indicator_list_properties: : (in): a #IndicateIndicator to act on
void indicate_indicator_set_displayed (IndicateIndicator *indicator, gboolean displayed)
 indicate_indicator_set_displayed: : The #IndicateIndicator to configure : Whether or not the indicator is visible to users
gboolean indicate_indicator_get_displayed (IndicateIndicator *indicator)
 indicate_indicator_get_displayed: : The #IndicateIndicator to query

Variables

static guint signals [LAST_SIGNAL] = { 0 }

Class Documentation

struct _IndicateIndicatorPrivate

Definition at line 47 of file indicator.c.

Class Members
guint id
gboolean is_displayed
gboolean is_visible
GHashTable * properties
IndicateServer * server

Define Documentation

#define INDICATE_INDICATOR_GET_PRIVATE (   o)    (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATE_TYPE_INDICATOR, IndicateIndicatorPrivate))

Definition at line 56 of file indicator.c.


Typedef Documentation

typedef struct _IndicateIndicatorPrivate

Definition at line 46 of file indicator.c.


Enumeration Type Documentation

anonymous enum
Enumerator:
HIDE 
SHOW 
USER_DISPLAY 
MODIFIED 
DISPLAYED 
LAST_SIGNAL 

Definition at line 35 of file indicator.c.


Function Documentation

static void _g_variant_unref ( gpointer  data) [static]

Definition at line 171 of file indicator.c.

{
       if (data == NULL) return;
       GVariant * value = (GVariant*)data;
       g_variant_unref(value);
       return;
}

Here is the caller graph for this function:

G_DEFINE_TYPE ( IndicateIndicator  ,
indicate_indicator  ,
G_TYPE_OBJECT   
)
static GVariant * get_property ( IndicateIndicator *  indicator,
const gchar *  key 
) [static]

Definition at line 585 of file indicator.c.

{
       g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), NULL);

       IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);

       return (GVariant *)g_hash_table_lookup(priv->properties, key);
}

Here is the caller graph for this function:

static void indicate_indicator_class_init ( IndicateIndicatorClass *  class) [static]

IndicateIndicator::display: : The #IndicateIndicator object

Emitted when the user has clicked on this indicator. In the messaging indicator this would be when someone clicks on the menu item for the indicator.

IndicateIndicator::hide: : The #IndicateIndicator object

Emitted every time this indicator is hidden. This is mostly used by #IndicateServer.

Typically this results in an emition of #IndicateServer::indicator-removed.

IndicateIndicator::show: : The #IndicateIndicator object

Emitted every time this indicator is shown. This is mostly used by #IndicateServer.

Typically this results in an emition of #IndicateServer::indicator-added.

IndicateIndicator::modified: : The #IndicateIndicator object : The name of the property that changed.

Emitted every time an indicator property is changed. This is mostly used by #IndicateServer.

Typically this results in an emition of #IndicateServer::indicator-modified.

IndicateIndicator::displayed: : The #IndicateIndicator object : Whether the indicator has been displayed

This is the signal that the indicator has been displayed, or hidden by a listener. In most cases, the signal will be that it has been displayed as most folks don't go hiding it later.

Definition at line 69 of file indicator.c.

{
       /* g_debug("Indicator Class Initialized."); */

       GObjectClass * gobj;
       gobj = G_OBJECT_CLASS(class);

       g_type_class_add_private (class, sizeof (IndicateIndicatorPrivate));

       gobj->finalize = indicate_indicator_finalize;

       signals[USER_DISPLAY] = g_signal_new(INDICATE_INDICATOR_SIGNAL_DISPLAY,
                                            G_TYPE_FROM_CLASS(class),
                                            G_SIGNAL_RUN_LAST,
                                            G_STRUCT_OFFSET(IndicateIndicatorClass, user_display),
                                            NULL, NULL,
                                            g_cclosure_marshal_VOID__UINT,
                                            G_TYPE_NONE, 1, G_TYPE_UINT);
       signals[HIDE] = g_signal_new(INDICATE_INDICATOR_SIGNAL_HIDE,
                                            G_TYPE_FROM_CLASS(class),
                                            G_SIGNAL_RUN_LAST,
                                            G_STRUCT_OFFSET(IndicateIndicatorClass, hide),
                                            NULL, NULL,
                                            g_cclosure_marshal_VOID__VOID,
                                            G_TYPE_NONE, 0);
       signals[SHOW] = g_signal_new(INDICATE_INDICATOR_SIGNAL_SHOW,
                                            G_TYPE_FROM_CLASS(class),
                                            G_SIGNAL_RUN_LAST,
                                            G_STRUCT_OFFSET(IndicateIndicatorClass, show),
                                            NULL, NULL,
                                            g_cclosure_marshal_VOID__VOID,
                                            G_TYPE_NONE, 0);
       signals[MODIFIED] = g_signal_new(INDICATE_INDICATOR_SIGNAL_MODIFIED,
                                            G_TYPE_FROM_CLASS(class),
                                            G_SIGNAL_RUN_LAST,
                                            G_STRUCT_OFFSET(IndicateIndicatorClass, modified),
                                            NULL, NULL,
                                            g_cclosure_marshal_VOID__STRING,
                                            G_TYPE_NONE, 1, G_TYPE_STRING);
       signals[DISPLAYED] = g_signal_new(INDICATE_INDICATOR_SIGNAL_DISPLAYED,
                                            G_TYPE_FROM_CLASS(class),
                                            G_SIGNAL_RUN_LAST,
                                            G_STRUCT_OFFSET(IndicateIndicatorClass, displayed),
                                            NULL, NULL,
                                            g_cclosure_marshal_VOID__BOOLEAN,
                                            G_TYPE_NONE, 1, G_TYPE_BOOLEAN);

       class->set_property = set_property;
       class->get_property = get_property;
       class->list_properties = list_properties;

       return;
}

Here is the call graph for this function:

static void indicate_indicator_finalize ( GObject *  object) [static]

Definition at line 199 of file indicator.c.

{
       IndicateIndicator * indicator = INDICATE_INDICATOR(obj);
       IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);

       indicate_server_remove_indicator(priv->server, indicator);
       g_object_unref(priv->server);
       priv->server = NULL;

       G_OBJECT_CLASS (indicate_indicator_parent_class)->finalize (obj);
       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean indicate_indicator_get_displayed ( IndicateIndicator *  indicator)

indicate_indicator_get_displayed: : The #IndicateIndicator to query

Checks to see if the indicator is visible to users in some way.

Return value: Whether or not this indicator can be seen by a user or not.

Definition at line 645 of file indicator.c.

{
       g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), FALSE);
       IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
       return priv->is_visible && priv->is_displayed;
}
guint indicate_indicator_get_id ( IndicateIndicator *  indicator)

indicate_indicator_get_id: : a #IndicateIndicator to act on

Gets the ID value of the .

Return value: The ID of the indicator. Can not be zero. Zero represents an error.

Definition at line 364 of file indicator.c.

{
       g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), 0);
       IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
       return priv->id;
}

Here is the caller graph for this function:

const gchar* indicate_indicator_get_property ( IndicateIndicator *  indicator,
const gchar *  key 
)

indicate_indicator_get_property: : a #IndicateIndicator to act on : name of the property

Returns the value that is set for a property or NULL if that property is not set.

Return value: A constant string or NULL.

Definition at line 525 of file indicator.c.

{
       IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
       if (class->get_property == NULL) {
              return NULL;
       }

       GVariant * val = class->get_property(indicator, key);
       if (val == NULL) {
              return NULL;
       } else {
              return g_variant_get_string(val, NULL);
       }
}
GVariant* indicate_indicator_get_property_variant ( IndicateIndicator *  indicator,
const gchar *  key 
)

Definition at line 541 of file indicator.c.

{
       IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
       if (class->get_property == NULL) {
              return NULL;
       }

       return class->get_property(indicator, key);
}

Here is the caller graph for this function:

IndicateServer* indicate_indicator_get_server ( IndicateIndicator *  indicator)

indicate_indicator_get_server: : a #IndicateIndicator to act on

Gets the server of the .

Return value: (transfer none): The server associated with the indicator or NULL if error.

Definition at line 381 of file indicator.c.

{
       g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), NULL);
       IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
       return priv->server;
}

Here is the caller graph for this function:

void indicate_indicator_hide ( IndicateIndicator *  indicator)

indicate_indicator_hide: : a #IndicateIndicator to act on

Hides the indicator from the bus. Does not effect the indicator's #IndicateServer in any way.

Definition at line 322 of file indicator.c.

{
       IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);

       if (!priv->is_visible) {
              return;
       }

       priv->is_visible = FALSE;
       g_signal_emit(indicator, signals[HIDE], 0, TRUE);
       priv->is_displayed = FALSE;
       g_signal_emit(G_OBJECT(indicator), signals[DISPLAYED], 0, priv->is_displayed, TRUE);

       return;
}
static void indicate_indicator_init ( IndicateIndicator *  indicator) [static]

Definition at line 180 of file indicator.c.

{
       /* g_debug("Indicator Object Initialized."); */
       IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);

       priv->is_visible = FALSE;
       priv->is_displayed = FALSE;

       priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_variant_unref);

       priv->server = indicate_server_ref_default();
       priv->id = indicate_server_get_next_id(priv->server);

       indicate_server_add_indicator(priv->server, indicator);

       return;
}

Here is the call graph for this function:

gboolean indicate_indicator_is_visible ( IndicateIndicator *  indicator)

indicate_indicator_is_visible: : a #IndicateIndicator to act on

Checkes the visibility status of .

Return value: TRUE if the indicator is visible else FALSE.

Definition at line 347 of file indicator.c.

{
       g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), FALSE);
       IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
       return priv->is_visible;
}

Here is the caller graph for this function:

GPtrArray* indicate_indicator_list_properties ( IndicateIndicator *  indicator)

indicate_indicator_list_properties: : (in): a #IndicateIndicator to act on

This function gets a list of all the properties that exist on a . The array may have zero entries.

Return value: (transfer full) (array) (element-type utf8): An array of strings that is the keys of all the properties on this indicator.

Definition at line 552 of file indicator.c.

{
       IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
       if (class->list_properties == NULL) {
              return g_ptr_array_new();
       }

       return class->list_properties(indicator);
}

Here is the caller graph for this function:

IndicateIndicator* indicate_indicator_new ( void  )

indicate_indicator_get_type:

Gets a unique #GType for the #IndicateIndicator objects.

Return value: A unique #GType value. indicate_indicator_new:

Builds a new indicator object using g_object_new().

Return value: A pointer to a new #IndicateIndicator object.

Definition at line 228 of file indicator.c.

{
       IndicateIndicator * indicator = g_object_new(INDICATE_TYPE_INDICATOR, NULL);
       return indicator;
}

Here is the caller graph for this function:

IndicateIndicator* indicate_indicator_new_with_server ( IndicateServer *  server)

indicate_indicator_new_with_server: : The server that should be associated with this indicator.

Builds a new indicator object using g_object_new() and sets the server to the specified server. Also, adds a reference to the server.

Return value: A pointer to a new #IndicateIndicator object.

Definition at line 245 of file indicator.c.

{
       g_return_val_if_fail(server != NULL, NULL);

       IndicateIndicator * indicator = g_object_new(INDICATE_TYPE_INDICATOR, NULL);

       indicate_indicator_set_server (indicator, server);

       return indicator;
}

Here is the call graph for this function:

void indicate_indicator_set_displayed ( IndicateIndicator *  indicator,
gboolean  displayed 
)

indicate_indicator_set_displayed: : The #IndicateIndicator to configure : Whether or not the indicator is visible to users

Sets whether or not the indicator is visible to the user from a listener. This does not include things like whether the menu is open, but more whether it's in the menu to be found.

Definition at line 622 of file indicator.c.

{
       g_return_if_fail(INDICATE_IS_INDICATOR(indicator));
       IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);

       if (priv->is_displayed != displayed) {
              priv->is_displayed = displayed;
              g_signal_emit(G_OBJECT(indicator), signals[DISPLAYED], 0, displayed, TRUE);
       }

       return;
}

Here is the caller graph for this function:

void indicate_indicator_set_property ( IndicateIndicator *  indicator,
const gchar *  key,
const gchar *  data 
)

indicate_indicator_set_property: : a #IndicateIndicator to act on : name of the property : value of the property

Sets a simple string property on . If the property had previously been set it will replace it with the new value, otherwise it will create the property. This will include an emition of #IndicateIndicator::modified if the property value was changed.

Definition at line 422 of file indicator.c.

{
       IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
       if (class->set_property == NULL) {
              return;
       }

       GVariant * variant = g_variant_new_string(data);
       return class->set_property(indicator, key, variant);
}

Here is the caller graph for this function:

void indicate_indicator_set_property_bool ( IndicateIndicator *  indicator,
const gchar *  key,
gboolean  value 
)

indicate_indicator_set_property_bool: : a #IndicateIndicator to act on : name of the property : integer to set property with

This is a helper function that wraps around indicate_indicator_set_property but takes a boolean property and turns into a string and uses that data to call indicate_indicator_set_property.

Definition at line 492 of file indicator.c.

{
       IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
       if (class->set_property == NULL) {
              return;
       }

       GVariant * variant = g_variant_new_boolean(value);
       return class->set_property(indicator, key, variant);
}

Here is the caller graph for this function:

void indicate_indicator_set_property_int ( IndicateIndicator *  indicator,
const gchar *  key,
gint  value 
)

indicate_indicator_set_property_int: : a #IndicateIndicator to act on : name of the property : integer to set property with

This is a helper function that wraps around indicate_indicator_set_property but takes an integer property and turns into a string and uses that data to call indicate_indicator_set_property.

Definition at line 466 of file indicator.c.

{
       IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
       if (class->set_property == NULL) {
              return;
       }

       GValue intval = {0};
       g_value_init(&intval, G_TYPE_INT);
       g_value_set_int(&intval, value);

       GVariant * variant = g_variant_new_int32(value);
       return class->set_property(indicator, key, variant);
}

Here is the caller graph for this function:

void indicate_indicator_set_property_time ( IndicateIndicator *  indicator,
const gchar *  key,
GTimeVal *  time 
)

indicate_indicator_set_property_time: : a #IndicateIndicator to act on : name of the property : time to set property with

This is a helper function that wraps around indicate_indicator_set_property but takes an #GTimeVal parameter. It then takes the parameter converts it to an ISO 8601 time string and uses that data to call indicate_indicator_set_property.

Definition at line 445 of file indicator.c.

{
       gchar * timestr = g_time_val_to_iso8601(time);
       if (timestr != NULL) {
              indicate_indicator_set_property(indicator, key, timestr);
              g_free(timestr);
       }
       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void indicate_indicator_set_property_variant ( IndicateIndicator *  indicator,
const gchar *  key,
GVariant *  value 
)

Definition at line 504 of file indicator.c.

{
       IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
       if (class->set_property == NULL) {
              return;
       }

       return class->set_property(indicator, key, value);
}
void indicate_indicator_set_server ( IndicateIndicator *  indicator,
IndicateServer *  server 
)

indicate_indicator_set_server: : a #IndicateIndicator to act on : the #IndicateServer which should be associated with

Defines which server this indicator must be associated to. Also, adds a reference to the server.

Definition at line 265 of file indicator.c.

{
       IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);

       if (server != NULL) {
              g_object_ref(server);
       }

       if (priv->server != NULL) {
              indicate_server_remove_indicator (priv->server, indicator);
              g_object_unref(priv->server);
       }

       priv->server = server;
       if (server != NULL) {
              indicate_server_add_indicator (server, indicator);
       }

       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void indicate_indicator_show ( IndicateIndicator *  indicator)

indicate_indicator_show: : a #IndicateIndicator to act on

Shows this indicator on the bus. If the #IndicateServer that it's connected to is not shown itself this function will show the server as well using indicate_server_show.

Definition at line 296 of file indicator.c.

{
       IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);

       if (priv->is_visible) {
              return;
       }

       if (priv->server) {
              indicate_server_show(priv->server);
       }

       priv->is_visible = TRUE;
       g_signal_emit(indicator, signals[SHOW], 0, TRUE);

       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void indicate_indicator_user_display ( IndicateIndicator *  indicator,
guint  timestamp 
)

indicate_indicator_user_display: : a #IndicateIndicator to act on : The time that the event happened

Emits the #IndicateIndicator::user-display signal simliar to a user clicking on over the bus. Signal will not be sent if the is not visible.

Definition at line 398 of file indicator.c.

{
       IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
       if (!priv->is_visible) {
              return;
       }

       g_signal_emit(indicator, signals[USER_DISPLAY], 0, timestamp, TRUE);
       return;
}

Here is the caller graph for this function:

static GPtrArray * list_properties ( IndicateIndicator *  indicator) [static]

Definition at line 595 of file indicator.c.

{
       g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), g_ptr_array_new());
       IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);

       GList * keys = g_hash_table_get_keys(priv->properties);
       GPtrArray * properties = g_ptr_array_sized_new(g_list_length(keys) + 1);

       GList * l;
       for (l=keys; l!=NULL; l=l->next) {
              g_ptr_array_add(properties, g_strdup(l->data));
       }

       g_list_free (keys);
       return properties;
}

Here is the caller graph for this function:

static void set_property ( IndicateIndicator *  indicator,
const gchar *  key,
GVariant *  data 
) [static]

Definition at line 563 of file indicator.c.

{
       g_return_if_fail(INDICATE_IS_INDICATOR(indicator));

       IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);

       gchar * newkey = g_strdup(key);
       if (data != NULL) {
              g_variant_ref(data);
       }

       g_hash_table_replace(priv->properties, newkey, data);

       if (indicate_indicator_is_visible(indicator)) {
              /* g_debug("Indicator property modified: %s", key); */
              g_signal_emit(indicator, signals[MODIFIED], 0, key, TRUE);
       }

       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

guint signals[LAST_SIGNAL] = { 0 } [static]

Definition at line 44 of file indicator.c.