Back to index

libindicator  12.10.0
Classes | Defines | Typedefs | Enumerations | Functions
indicator-object.h File Reference
#include <gtk/gtk.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _IndicatorObjectClass
 IndicatorObjectClass: : #GObjectClass : Gets the label for this object. More...
struct  _IndicatorObject
 IndicatorObject: : #GObject : A cached reference to the private data for the instance. More...
struct  _IndicatorObjectEntry
 IndicatorObjectEntry: : The #IndicatorObject that created this entry : The label to be shown on the panel. More...

Defines

#define INDICATOR_OBJECT_TYPE   (indicator_object_get_type ())
#define INDICATOR_OBJECT(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_OBJECT_TYPE, IndicatorObject))
#define INDICATOR_OBJECT_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATOR_OBJECT_TYPE, IndicatorObjectClass))
#define INDICATOR_IS_OBJECT(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_OBJECT_TYPE))
#define INDICATOR_IS_OBJECT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_OBJECT_TYPE))
#define INDICATOR_OBJECT_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_OBJECT_TYPE, IndicatorObjectClass))
#define INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED   "entry-added"
#define INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID   (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, INDICATOR_OBJECT_TYPE))
#define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED   "entry-removed"
#define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID   (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, INDICATOR_OBJECT_TYPE))
#define INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED   "entry-moved"
#define INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED_ID   (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, INDICATOR_OBJECT_TYPE))
#define INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED   "entry-scrolled"
#define INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED_ID   (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, INDICATOR_OBJECT_TYPE))
#define INDICATOR_OBJECT_SIGNAL_MENU_SHOW   "menu-show"
#define INDICATOR_OBJECT_SIGNAL_MENU_SHOW_ID   (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_MENU_SHOW, INDICATOR_OBJECT_TYPE))
#define INDICATOR_OBJECT_SIGNAL_SHOW_NOW_CHANGED   "show-now-changed"
#define INDICATOR_OBJECT_SIGNAL_SHOW_NOW_CHANGED_ID   (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_SHOW_NOW_CHANGED, INDICATOR_OBJECT_TYPE))
#define INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE   "accessible-desc-update"
#define INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID   (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, INDICATOR_OBJECT_TYPE))
#define INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE   "secondary-activate"
#define INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE_ID   (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE, INDICATOR_OBJECT_TYPE))
#define INDICATOR_OBJECT_DEFAULT_VISIBILITY   "indicator-object-default-visibility"

Typedefs

typedef struct _IndicatorObject
typedef struct _IndicatorObjectClass
typedef struct _IndicatorObjectPrivate
typedef struct _IndicatorObjectEntry

Enumerations

enum  IndicatorScrollDirection { INDICATOR_OBJECT_SCROLL_UP, INDICATOR_OBJECT_SCROLL_DOWN, INDICATOR_OBJECT_SCROLL_LEFT, INDICATOR_OBJECT_SCROLL_RIGHT }

Functions

GType indicator_object_get_type (void)
IndicatorObject * indicator_object_new_from_file (const gchar *file)
GList * indicator_object_get_entries (IndicatorObject *io)
 indicator_object_get_entries: : #IndicatorObject to query
guint indicator_object_get_location (IndicatorObject *io, IndicatorObjectEntry *entry)
 indicator_object_get_location: : #IndicatorObject to query : The #IndicatorObjectEntry to look for.
guint indicator_object_get_show_now (IndicatorObject *io, IndicatorObjectEntry *entry)
 indicator_object_get_show_now: : #IndicatorObject to query : The #IndicatorObjectEntry to look for.
void indicator_object_set_visible (IndicatorObject *io, gboolean visible)
 indicator_object_set_visible: : #IndicatorObject to check on : whether or not the entries should be visible
void indicator_object_entry_activate (IndicatorObject *io, IndicatorObjectEntry *entry, guint timestamp)
 indicator_object_entry_activate: : #IndicatorObject to query : The #IndicatorObjectEntry whose entry was shown : The X11 timestamp of the event
void indicator_object_entry_activate_window (IndicatorObject *io, IndicatorObjectEntry *entry, guint windowid, guint timestamp)
 indicator_object_entry_activate_window: : #IndicatorObject to query : The #IndicatorObjectEntry whose entry was shown : ID of the window that is currently focused (or will be very shortly) : The X11 timestamp of the event
void indicator_object_entry_close (IndicatorObject *io, IndicatorObjectEntry *entry, guint timestamp)
 indicator_object_entry_close: : #IndicatorObject to query : The #IndicatorObjectEntry whose menu was closed : The X11 timestamp of the event
void indicator_object_set_environment (IndicatorObject *io, GStrv env)
 indicator_object_set_environment: : #IndicatorObject to set on : List of enviroment names to use
GStrv indicator_object_get_environment (IndicatorObject *io)
 indicator_object_get_environment: : #IndicatorObject to get the environment from
gboolean indicator_object_check_environment (IndicatorObject *io, const gchar *env)
 indicator_object_check_environment: : #IndicatorObject to check on : Environment that we're looking for

Class Documentation

struct _IndicatorObject

IndicatorObject: : #GObject : A cached reference to the private data for the instance.

Definition at line 160 of file indicator-object.h.

Class Members
GObject parent
IndicatorObjectPrivate * priv

Define Documentation

#define INDICATOR_IS_OBJECT (   obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_OBJECT_TYPE))

Definition at line 42 of file indicator-object.h.

#define INDICATOR_IS_OBJECT_CLASS (   klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_OBJECT_TYPE))

Definition at line 43 of file indicator-object.h.

#define INDICATOR_OBJECT (   obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_OBJECT_TYPE, IndicatorObject))

Definition at line 40 of file indicator-object.h.

#define INDICATOR_OBJECT_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATOR_OBJECT_TYPE, IndicatorObjectClass))

Definition at line 41 of file indicator-object.h.

#define INDICATOR_OBJECT_DEFAULT_VISIBILITY   "indicator-object-default-visibility"

Definition at line 64 of file indicator-object.h.

#define INDICATOR_OBJECT_GET_CLASS (   obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_OBJECT_TYPE, IndicatorObjectClass))

Definition at line 44 of file indicator-object.h.

#define INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE   "accessible-desc-update"

Definition at line 58 of file indicator-object.h.

Definition at line 59 of file indicator-object.h.

#define INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED   "entry-added"

Definition at line 46 of file indicator-object.h.

Definition at line 47 of file indicator-object.h.

#define INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED   "entry-moved"

Definition at line 50 of file indicator-object.h.

Definition at line 51 of file indicator-object.h.

#define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED   "entry-removed"

Definition at line 48 of file indicator-object.h.

Definition at line 49 of file indicator-object.h.

#define INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED   "entry-scrolled"

Definition at line 52 of file indicator-object.h.

Definition at line 53 of file indicator-object.h.

#define INDICATOR_OBJECT_SIGNAL_MENU_SHOW   "menu-show"

Definition at line 54 of file indicator-object.h.

Definition at line 55 of file indicator-object.h.

#define INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE   "secondary-activate"

Definition at line 60 of file indicator-object.h.

Definition at line 61 of file indicator-object.h.

#define INDICATOR_OBJECT_SIGNAL_SHOW_NOW_CHANGED   "show-now-changed"

Definition at line 56 of file indicator-object.h.

Definition at line 57 of file indicator-object.h.

Definition at line 39 of file indicator-object.h.


Typedef Documentation

typedef struct _IndicatorObject

Definition at line 66 of file indicator-object.h.

typedef struct _IndicatorObjectClass

Definition at line 67 of file indicator-object.h.

typedef struct _IndicatorObjectEntry

Definition at line 69 of file indicator-object.h.

typedef struct _IndicatorObjectPrivate

Definition at line 68 of file indicator-object.h.


Enumeration Type Documentation

Enumerator:
INDICATOR_OBJECT_SCROLL_UP 
INDICATOR_OBJECT_SCROLL_DOWN 
INDICATOR_OBJECT_SCROLL_LEFT 
INDICATOR_OBJECT_SCROLL_RIGHT 

Definition at line 31 of file indicator-object.h.


Function Documentation

gboolean indicator_object_check_environment ( IndicatorObject *  io,
const gchar *  env 
)

indicator_object_check_environment: : #IndicatorObject to check on : Environment that we're looking for

Convience function to check to see if the specified environment is in our list of environments.

Return Value: Whether we're in environment

Definition at line 836 of file indicator-object.c.

{
       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;
}
void indicator_object_entry_activate ( IndicatorObject *  io,
IndicatorObjectEntry *  entry,
guint  timestamp 
)

indicator_object_entry_activate: : #IndicatorObject to query : The #IndicatorObjectEntry whose entry was shown : The X11 timestamp of the event

Used to signal to the indicator that the menu on an entry has been clicked on. This can either be an activate or a showing of the menu. Note, this does not actually show the menu that's left up to the reader.

Definition at line 715 of file indicator-object.c.

{
       g_return_if_fail(INDICATOR_IS_OBJECT(io));
       IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io);

       if (class->entry_activate != NULL) {
              return class->entry_activate(io, entry, timestamp);
       }

       return;
}

Here is the caller graph for this function:

void indicator_object_entry_activate_window ( IndicatorObject *  io,
IndicatorObjectEntry *  entry,
guint  windowid,
guint  timestamp 
)

indicator_object_entry_activate_window: : #IndicatorObject to query : The #IndicatorObjectEntry whose entry was shown : ID of the window that is currently focused (or will be very shortly) : The X11 timestamp of the event

Used to signal to the indicator that the menu on an entry has been clicked on. This can either be an activate or a showing of the menu. Also includes a window ID so that we can know what application is going to be getting focused soon. If there is no override of this function, it is the same as calling indicator_object_entry_activate and in general is preferable if you have that information available.

Definition at line 689 of file indicator-object.c.

{
       g_return_if_fail(INDICATOR_IS_OBJECT(io));
       IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io);

       if (class->entry_activate_window != NULL) {
              return class->entry_activate_window(io, entry, windowid, timestamp);
       } else {
              indicator_object_entry_activate(io, entry, timestamp);
       }

       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void indicator_object_entry_close ( IndicatorObject *  io,
IndicatorObjectEntry *  entry,
guint  timestamp 
)

indicator_object_entry_close: : #IndicatorObject to query : The #IndicatorObjectEntry whose menu was closed : The X11 timestamp of the event

Used to tell the indicator that a menu has been closed for the entry that is specified.

Definition at line 737 of file indicator-object.c.

{
       g_return_if_fail(INDICATOR_IS_OBJECT(io));
       IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io);

       if (class->entry_close != NULL) {
              return class->entry_close(io, entry, timestamp);
       }

       return;
}

Here is the caller graph for this function:

GList* indicator_object_get_entries ( IndicatorObject *  io)

indicator_object_get_entries: : #IndicatorObject to query

This function returns a list of visible entries. The list is built by calling the object's #IndicatorObjectClass::get_entries virtual function and testing each of the results for visibility. Callers should free the GList with g_list_free(), but the entries are owned by the IndicatorObject and should not be freed.

Return value: (element-type IndicatorObjectEntry) (transfer container): A list if #IndicatorObjectEntry structures or NULL on error.

Definition at line 596 of file indicator-object.c.

{
       GList * l;
       GList * ret = NULL;
       GList * all_entries = get_all_entries (io);
       const gboolean default_visibility = INDICATOR_OBJECT_GET_PRIVATE(io)->default_visibility;

       for (l=all_entries; l!=NULL; l=l->next)
       {
              gboolean show_me;
              IndicatorObjectEntry * entry = l->data;

              switch (entry_get_private(io,entry)->visibility) {
                     case ENTRY_VISIBLE:   show_me = TRUE; break;
                     case ENTRY_INVISIBLE: show_me = FALSE; break;
                     case ENTRY_INIT:      show_me = default_visibility; break;
                     default:              show_me = TRUE; g_warn_if_reached(); break;
              }

              if (show_me)
                     ret = g_list_prepend (ret, entry);
       }

       g_list_free (all_entries);
       return g_list_reverse (ret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

GStrv indicator_object_get_environment ( IndicatorObject *  io)

indicator_object_get_environment: : #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.

Definition at line 819 of file indicator-object.c.

{
       g_return_val_if_fail(INDICATOR_IS_OBJECT(io), NULL);
       return io->priv->environments;
}
guint indicator_object_get_location ( IndicatorObject *  io,
IndicatorObjectEntry *  entry 
)

indicator_object_get_location: : #IndicatorObject to query : The #IndicatorObjectEntry to look for.

This function looks on the class for the object and calls it's #IndicatorObjectClass::get_location function. If the function doesn't exist it returns zero.

Return value: Location of the in the display or zero if no location is specified.

Definition at line 636 of file indicator-object.c.

{
       g_return_val_if_fail(INDICATOR_IS_OBJECT(io), 0);
       IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io);

       if (class->get_location) {
              return class->get_location(io, entry);
       }

       return 0;
}

Here is the caller graph for this function:

guint indicator_object_get_show_now ( IndicatorObject *  io,
IndicatorObjectEntry *  entry 
)

indicator_object_get_show_now: : #IndicatorObject to query : The #IndicatorObjectEntry to look for.

This function returns whether the entry should be shown with priority on the panel. If the object does not support checking it assumes that its entries should never have priority.

Return value: Whether the entry should be shown with priority.

Definition at line 660 of file indicator-object.c.

{
       g_return_val_if_fail(INDICATOR_IS_OBJECT(io), 0);
       IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io);

       if (class->get_show_now) {
              return class->get_show_now(io, entry);
       }

       return FALSE;
}
GType indicator_object_get_type ( void  )
IndicatorObject* indicator_object_new_from_file ( const gchar *  file)

Definition at line 402 of file indicator-object.c.

{
       GObject * object = NULL;
       GModule * module = NULL;

       /* Check to make sure the name exists and that the
          file itself exists */
       if (file == NULL) {
              g_warning("Invalid filename.");
              return NULL;
       }

       if (!g_file_test(file, G_FILE_TEST_EXISTS)) {
              g_warning("File '%s' does not exist.", file);
              return NULL;
       }

       /* Grab the g_module reference, pull it in but let's
          keep the symbols local to avoid conflicts. */
       module = g_module_open(file,
                           G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
       if (module == NULL) {
              g_warning("Unable to load module: %s", file);
              return NULL;
       }

       /* Look for the version function, error if not found. */
       get_version_t lget_version = NULL;
       if (!g_module_symbol(module, INDICATOR_GET_VERSION_S, (gpointer *)(&lget_version))) {
              g_warning("Unable to get the symbol for getting the version.");
              return NULL;
       }

       /* Check the version with the macro and make sure we're
          all talking the same language. */
       if (!INDICATOR_VERSION_CHECK(lget_version())) {
              g_warning("Indicator using API version '%s' we're expecting '%s'", lget_version(), INDICATOR_VERSION);
              return NULL;
       }

       /* The function for grabbing a label from the module
          execute it, and make sure everything is a-okay */
       get_type_t lget_type = NULL;
       if (!g_module_symbol(module, INDICATOR_GET_TYPE_S, (gpointer *)(&lget_type))) {
              g_warning("Unable to get '" INDICATOR_GET_TYPE_S "' symbol from module: %s", file);
              goto unrefandout;
       }
       if (lget_type == NULL) {
              g_warning("Symbol '" INDICATOR_GET_TYPE_S "' is (null) in module: %s", file);
              goto unrefandout;
       }

       /* A this point we allocate the object, any code beyond
          here needs to deallocate it if we're returning in an
          error'd state. */
       object = g_object_new(lget_type(), NULL);
       if (object == NULL) {
              g_warning("Unable to build an object if type '%d' in module: %s", (gint)lget_type(), file);
              goto unrefandout;
       }
       if (!INDICATOR_IS_OBJECT(object)) {
              g_warning("Type '%d' in file %s is not a subclass of IndicatorObject.", (gint)lget_type(), file);
              goto unrefandout;
       }

       /* Now we can track the module */
       INDICATOR_OBJECT_GET_PRIVATE(object)->module = module;

       return INDICATOR_OBJECT(object);

       /* Error, let's drop the object and return NULL.  Sad when
          this happens. */
unrefandout:
       g_clear_object (&object);
       g_clear_object (&module);
       g_warning("Error building IndicatorObject from file: %s", file);
       return NULL;
}

Here is the caller graph for this function:

void indicator_object_set_environment ( IndicatorObject *  io,
GStrv  env 
)

indicator_object_set_environment: : #IndicatorObject to set on : 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.

Definition at line 793 of file indicator-object.c.

{
       /* FIXME: should this be a property? */
       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;
}
void indicator_object_set_visible ( IndicatorObject *  io,
gboolean  visible 
)

indicator_object_set_visible: : #IndicatorObject to check on : whether or not the entries should be visible

Used to set all of an indicator's entries to be visible or hidden.

Definition at line 863 of file indicator-object.c.

{
       g_return_if_fail(INDICATOR_IS_OBJECT(io));

       GList * l;
       GList * entries = get_all_entries (io);
       const guint signal_id = signals[visible ? ENTRY_ADDED : ENTRY_REMOVED];
       EntryVisibility visibility = visible ? ENTRY_VISIBLE : ENTRY_INVISIBLE;
       const GQuark detail = (GQuark)0;

       for (l=entries; l!=NULL; l=l->next) {
              IndicatorObjectEntry *entry = l->data;
              if (entry_get_private (io, entry)->visibility != visibility)
                     g_signal_emit(io, signal_id, detail, entry);
       }
       g_list_free (entries);
}

Here is the call graph for this function:

Here is the caller graph for this function: