Back to index

unity  6.0.0
Classes | Defines | Typedefs | Functions
panel-service.h File Reference
#include <glib-object.h>
#include <libindicator/indicator.h>
#include <libindicator/indicator-object.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _PanelService
struct  _PanelServiceClass

Defines

#define PANEL_TYPE_SERVICE   (panel_service_get_type ())
#define PANEL_SERVICE(obj)
#define PANEL_SERVICE_CLASS(klass)
#define PANEL_IS_SERVICE(obj)
#define PANEL_IS_SERVICE_CLASS(klass)
#define PANEL_SERVICE_GET_CLASS(obj)

Typedefs

typedef struct _PanelService
typedef struct _PanelServiceClass
typedef struct _PanelServicePrivate

Functions

GType panel_service_get_type (void) G_GNUC_CONST
PanelService * panel_service_get_default ()
PanelService * panel_service_get_default_with_indicators (GList *indicators)
guint panel_service_get_n_indicators (PanelService *self)
IndicatorObject * panel_service_get_indicator_nth (PanelService *self, guint position)
IndicatorObject * panel_service_get_indicator (PanelService *self, const gchar *indicator_id)
void panel_service_remove_indicator (PanelService *self, IndicatorObject *indicator)
void panel_service_clear_indicators (PanelService *self)
GVariant * panel_service_sync (PanelService *self)
GVariant * panel_service_sync_one (PanelService *self, const gchar *indicator_id)
void panel_service_sync_geometry (PanelService *self, const gchar *indicator_id, const gchar *entry_id, gint x, gint y, gint width, gint height)
void panel_service_show_entry (PanelService *self, const gchar *entry_id, guint32 xid, gint32 x, gint32 y, guint32 button, guint32 timestamp)
void panel_service_show_app_menu (PanelService *self, guint32 xid, gint32 x, gint32 y, guint32 timestamp)
void panel_service_secondary_activate_entry (PanelService *self, const gchar *entry_id, guint32 timestamp)
void panel_service_scroll_entry (PanelService *self, const gchar *entry_id, gint32 delta)

Class Documentation

struct _PanelService

Definition at line 49 of file panel-service.h.

Class Members
GObject parent
PanelServicePrivate * priv

Define Documentation

#define PANEL_IS_SERVICE (   obj)
Value:
(G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
       PANEL_TYPE_SERVICE))

Definition at line 36 of file panel-service.h.

#define PANEL_IS_SERVICE_CLASS (   klass)
Value:
(G_TYPE_CHECK_CLASS_TYPE ((klass),\
       PANEL_TYPE_SERVICE))

Definition at line 39 of file panel-service.h.

#define PANEL_SERVICE (   obj)
Value:
(G_TYPE_CHECK_INSTANCE_CAST ((obj),\
       PANEL_TYPE_SERVICE, PanelService))

Definition at line 30 of file panel-service.h.

#define PANEL_SERVICE_CLASS (   klass)
Value:
(G_TYPE_CHECK_CLASS_CAST ((klass),\
       PANEL_TYPE_SERVICE, PanelServiceClass))

Definition at line 33 of file panel-service.h.

#define PANEL_SERVICE_GET_CLASS (   obj)
Value:
(G_TYPE_INSTANCE_GET_CLASS ((obj),\
       PANEL_TYPE_SERVICE, PanelServiceClass))

Definition at line 42 of file panel-service.h.

Definition at line 28 of file panel-service.h.


Typedef Documentation

typedef struct _PanelService

Definition at line 45 of file panel-service.h.

typedef struct _PanelServiceClass

Definition at line 46 of file panel-service.h.

typedef struct _PanelServicePrivate

Definition at line 47 of file panel-service.h.


Function Documentation

void panel_service_clear_indicators ( PanelService *  self)

Definition at line 729 of file panel-service.c.

{
  g_return_if_fail (PANEL_IS_SERVICE (self));
  GSList *l = self->priv->indicators;

  while (l)
    {
      IndicatorObject *ind = l->data;
      l = l->next;
      panel_service_remove_indicator (self, ind);
    }

  g_idle_add ((GSourceFunc)panel_service_check_cleared, self);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PanelService* panel_service_get_default ( )

Definition at line 651 of file panel-service.c.

{
  if (static_service == NULL || !PANEL_IS_SERVICE (static_service))
    static_service = g_object_new (PANEL_TYPE_SERVICE, NULL);

  return static_service;
}

Here is the caller graph for this function:

PanelService* panel_service_get_default_with_indicators ( GList *  indicators)

Definition at line 660 of file panel-service.c.

{
  PanelService *service = panel_service_get_default ();
  GList        *i;

  for (i = indicators; i; i = i->next)
    {
      IndicatorObject *object = i->data;
      if (INDICATOR_IS_OBJECT (object))
          load_indicator (service, object, NULL);
    }

  return service;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IndicatorObject* panel_service_get_indicator ( PanelService *  self,
const gchar *  indicator_id 
)

Definition at line 691 of file panel-service.c.

{
  g_return_val_if_fail (PANEL_IS_SERVICE (self), NULL);
  GSList *l;

  for (l = self->priv->indicators; l; l = l->next)
    {
      if (g_strcmp0 (indicator_id,
                     g_object_get_data (G_OBJECT (l->data), "id")) == 0)
        {
          return (IndicatorObject *) l->data;
        }
    }

  return NULL;
}

Here is the caller graph for this function:

IndicatorObject* panel_service_get_indicator_nth ( PanelService *  self,
guint  position 
)

Definition at line 683 of file panel-service.c.

{
  g_return_val_if_fail (PANEL_IS_SERVICE (self), NULL);

  return (IndicatorObject *) g_slist_nth_data (self->priv->indicators, position);
}

Here is the caller graph for this function:

guint panel_service_get_n_indicators ( PanelService *  self)

Definition at line 675 of file panel-service.c.

{
  g_return_val_if_fail (PANEL_IS_SERVICE (self), 0);

  return g_slist_length (self->priv->indicators);
}

Here is the caller graph for this function:

GType panel_service_get_type ( void  )
void panel_service_remove_indicator ( PanelService *  self,
IndicatorObject *  indicator 
)

Definition at line 709 of file panel-service.c.

{
  g_return_if_fail (PANEL_IS_SERVICE (self));
  g_return_if_fail (INDICATOR_IS_OBJECT (indicator));

  gpointer timeout = g_object_get_data (G_OBJECT (indicator), "remove-timeout");

  if (timeout)
    g_source_remove (GPOINTER_TO_UINT (timeout));

  g_object_set_data (G_OBJECT (indicator), "remove", GINT_TO_POINTER (TRUE));
  notify_object (indicator);

  guint id = g_timeout_add_seconds (1,
                                    (GSourceFunc) panel_service_indicator_remove_timeout,
                                    indicator);
  g_object_set_data (G_OBJECT (indicator), "remove-timeout", GUINT_TO_POINTER (id));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void panel_service_scroll_entry ( PanelService *  self,
const gchar *  entry_id,
gint32  delta 
)

Definition at line 1824 of file panel-service.c.

{
  IndicatorObject      *object;
  IndicatorObjectEntry *entry;

  entry = get_indicator_entry_by_id (self, entry_id);
  g_return_if_fail (entry);

  GdkScrollDirection direction = delta < 0 ? GDK_SCROLL_DOWN : GDK_SCROLL_UP;

  object = get_entry_parent_indicator (entry);
  g_signal_emit_by_name(object, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, entry,
                        abs(delta/120), direction);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void panel_service_secondary_activate_entry ( PanelService *  self,
const gchar *  entry_id,
guint32  timestamp 
)

Definition at line 1808 of file panel-service.c.

{
  IndicatorObject      *object;
  IndicatorObjectEntry *entry;

  entry = get_indicator_entry_by_id (self, entry_id);
  g_return_if_fail (entry);

  object = get_entry_parent_indicator (entry);
  g_signal_emit_by_name(object, INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE, entry,
                        timestamp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void panel_service_show_app_menu ( PanelService *  self,
guint32  xid,
gint32  x,
gint32  y,
guint32  timestamp 
)

Definition at line 1781 of file panel-service.c.

{
  IndicatorObject      *object;
  IndicatorObjectEntry *entry;
  GList                *entries;

  g_return_if_fail (PANEL_IS_SERVICE (self));

  object = panel_service_get_indicator (self, "libappmenu.so");
  g_return_if_fail (INDICATOR_IS_OBJECT (object));

  entries = indicator_object_get_entries (object);

  if (entries)
    {
      entry = entries->data;
      g_list_free (entries);

      panel_service_show_entry_common (self, object, entry, xid, x, y, 1, timestamp);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void panel_service_show_entry ( PanelService *  self,
const gchar *  entry_id,
guint32  xid,
gint32  x,
gint32  y,
guint32  button,
guint32  timestamp 
)

Definition at line 1761 of file panel-service.c.

{
  IndicatorObject      *object;
  IndicatorObjectEntry *entry;

  g_return_if_fail (PANEL_IS_SERVICE (self));

  entry = get_indicator_entry_by_id (self, entry_id);
  object = get_entry_parent_indicator (entry);

  panel_service_show_entry_common (self, object, entry, xid, x, y, button, timestamp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

GVariant* panel_service_sync ( PanelService *  self)

Definition at line 1280 of file panel-service.c.

{
  GVariantBuilder b;
  GSList *i;

  g_variant_builder_init (&b, G_VARIANT_TYPE ("(a(ssssbbusbbi))"));
  g_variant_builder_open (&b, G_VARIANT_TYPE ("a(ssssbbusbbi)"));

  for (i = self->priv->indicators; i; i = i->next)
    {
      const gchar *indicator_id = g_object_get_data (G_OBJECT (i->data), "id");
      gint position;

      /* Set the sync back to neutral */
      position = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (i->data), "position"));
      self->priv->timeouts[position] = SYNC_NEUTRAL;
      indicator_object_to_variant (i->data, indicator_id, &b);
    }

  g_variant_builder_close (&b);
  return g_variant_builder_end (&b);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void panel_service_sync_geometry ( PanelService *  self,
const gchar *  indicator_id,
const gchar *  entry_id,
gint  x,
gint  y,
gint  width,
gint  height 
)

Definition at line 1342 of file panel-service.c.

{
  IndicatorObject      *object;
  IndicatorObjectEntry *entry;
  gboolean valid_entry = TRUE;
  PanelServicePrivate  *priv = self->priv;

  entry = get_indicator_entry_by_id (self, entry_id);

  /* If the entry we read is not valid, maybe it has already been removed
   * or unparented, so we need to make sure that the related key on the
   * entry2geometry_hash is correctly removed and the value is free'd */
  if (!entry)
    {
      IndicatorObjectEntry *invalid_entry;
      if (sscanf (entry_id, "%p", &invalid_entry) == 1)
        {
          entry = invalid_entry;
          valid_entry = FALSE;
        }
    }

  if (entry)
    {
      GHashTable *entry2geometry_hash = g_hash_table_lookup (priv->panel2entries_hash, panel_id);

      if (width < 0 || height < 0 || !valid_entry)
        {
          if (entry2geometry_hash)
            {
              if (g_hash_table_size (entry2geometry_hash) > 1)
                {
                  g_hash_table_remove (entry2geometry_hash, entry);
                }
              else
                {
                  g_hash_table_remove (priv->panel2entries_hash, panel_id);
                }
            }

          /* If the entry has been removed let's make sure that its menu is closed */
          if (valid_entry && GTK_IS_MENU (priv->last_menu) && priv->last_menu == entry->menu)
            {
              gtk_menu_popdown (entry->menu);
            }
        }
      else
        {
          GdkRectangle *geo = NULL;

          if (entry2geometry_hash == NULL)
            {
              entry2geometry_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal,
                                                           NULL, g_free);
              g_hash_table_insert (priv->panel2entries_hash, g_strdup (panel_id),
                                   entry2geometry_hash);
            }
          else
            {
              geo = g_hash_table_lookup (entry2geometry_hash, entry);
            }

          if (geo == NULL)
            {
              geo = g_new0 (GdkRectangle, 1);
              g_hash_table_insert (entry2geometry_hash, entry, geo);
            }

          /* If the current entry geometry has changed, we need to move the menu
           * accordingly to the change we recorded! */
          if (GTK_IS_MENU (priv->last_menu) && priv->last_menu == entry->menu)
            {
              GtkWidget *top_widget = gtk_widget_get_toplevel (GTK_WIDGET (priv->last_menu));

              if (GTK_IS_WINDOW (top_widget))
                {
                  GtkWindow *top_win = GTK_WINDOW (top_widget);
                  gint old_x, old_y;

                  gtk_window_get_position (top_win, &old_x, &old_y);
                  gtk_window_move (top_win, old_x - (geo->x - x), old_y - (geo->y - y));
                }
            }

          geo->x = x;
          geo->y = y;
          geo->width = width;
          geo->height = height;
        }

      if (valid_entry)
        {
          object = get_entry_parent_indicator (entry);
          g_signal_emit (self, _service_signals[GEOMETRIES_CHANGED], 0, object, entry, x, y, width, height);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

GVariant* panel_service_sync_one ( PanelService *  self,
const gchar *  indicator_id 
)

Definition at line 1304 of file panel-service.c.

{
  GVariantBuilder b;
  GSList *i;

  g_variant_builder_init (&b, G_VARIANT_TYPE ("(a(ssssbbusbbi))"));
  g_variant_builder_open (&b, G_VARIANT_TYPE ("a(ssssbbusbbi)"));

  for (i = self->priv->indicators; i; i = i->next)
    {
      if (g_strcmp0 (indicator_id,
                     g_object_get_data (G_OBJECT (i->data), "id")) == 0)
        {
          gint position;

          /* Set the sync back to neutral */
          position = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (i->data), "position"));
          self->priv->timeouts[position] = SYNC_NEUTRAL;

          if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (i->data), "remove")) != TRUE)
            {
              indicator_object_to_variant (i->data, indicator_id, &b);
            }
          else
            {
              indicator_entry_null_to_variant (indicator_id, &b);
              panel_service_actually_remove_indicator (self, i->data);
            }

          break;
        }
    }

  g_variant_builder_close (&b);
  return g_variant_builder_end (&b);
}

Here is the call graph for this function:

Here is the caller graph for this function: