Back to index

indicator-appmenu  12.10.0
Classes | Typedefs | Functions | Variables
hudindicatorsource.c File Reference
#include "hudindicatorsource.h"
#include <glib/gi18n.h>
#include <gio/gio.h>
#include "hudsettings.h"
#include "huddbusmenucollector.h"
#include "hudsource.h"

Go to the source code of this file.

Classes

struct  IndicatorInfo
 SECTION:hudindicatorsource :HudIndicatorSource : a #HudSource to search through the menus of indicators. More...
struct  HudIndicatorSourceIndicator
struct  _HudIndicatorSource

Typedefs

typedef GObjectClass HudIndicatorSourceClass

Functions

static void hud_indicator_source_iface_init (HudSourceInterface *iface)
 G_DEFINE_TYPE_WITH_CODE (HudIndicatorSource, hud_indicator_source, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(HUD_TYPE_SOURCE, hud_indicator_source_iface_init))
static void hud_indicator_source_unuse (HudSource *hud_source)
static void hud_indicator_source_search (HudSource *hud_source, GPtrArray *results_array, HudTokenList *search_string)
static void hud_indicator_source_finalize (GObject *object)
static void hud_indicator_source_collector_changed (HudSource *source, gpointer user_data)
static void hud_indicator_source_name_appeared (GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data)
static void hud_indicator_source_name_vanished (GDBusConnection *connection, const gchar *name, gpointer user_data)
static void hud_indicator_source_init (HudIndicatorSource *source)
static void hud_indicator_source_class_init (HudIndicatorSourceClass *class)
HudIndicatorSource * hud_indicator_source_new (void)
 hud_indicator_source_new:

Variables

static const IndicatorInfo indicator_info []

Class Documentation

struct IndicatorInfo

SECTION:hudindicatorsource :HudIndicatorSource : a #HudSource to search through the menus of indicators.

HudIndicatorSource searches through the menu items of the

indicators. HudIndicatorSource:

This is an opaque structure type.

Definition at line 45 of file hudindicatorsource.c.

Class Members
const gchar * dbus_menu_path
const gchar * dbus_name
const gchar * icon
const gchar * indicator_name
const gchar * user_visible_name
struct HudIndicatorSourceIndicator

Definition at line 92 of file hudindicatorsource.c.

Collaboration diagram for HudIndicatorSourceIndicator:
Class Members
HudSource * collector
const IndicatorInfo * info
HudIndicatorSource * source
struct _HudIndicatorSource

Definition at line 99 of file hudindicatorsource.c.

Collaboration diagram for _HudIndicatorSource:
Class Members
HudIndicatorSourceIndicator * indicators
gint n_indicators
GObject parent_instance
gint use_count

Typedef Documentation

typedef GObjectClass HudIndicatorSourceClass

Definition at line 108 of file hudindicatorsource.c.


Function Documentation

G_DEFINE_TYPE_WITH_CODE ( HudIndicatorSource  ,
hud_indicator_source  ,
G_TYPE_OBJECT  ,
G_IMPLEMENT_INTERFACE(HUD_TYPE_SOURCE, hud_indicator_source_iface_init  
)

Definition at line 111 of file hudindicatorsource.c.

{
  HudIndicatorSource *source = HUD_INDICATOR_SOURCE (hud_source);
  gint i;

  if (source->use_count == 0)
    {
      for (i = 0; i < source->n_indicators; i++)
        if (source->indicators[i].collector)
          hud_source_use (source->indicators[i].collector);
    }

  source->use_count++;
}

Here is the call graph for this function:

static void hud_indicator_source_class_init ( HudIndicatorSourceClass class) [static]

Definition at line 248 of file hudindicatorsource.c.

{
  class->finalize = hud_indicator_source_finalize;
}

Here is the call graph for this function:

static void hud_indicator_source_collector_changed ( HudSource *  source,
gpointer  user_data 
) [static]

Definition at line 168 of file hudindicatorsource.c.

{
  HudIndicatorSourceIndicator *indicator = user_data;

  hud_source_changed (HUD_SOURCE (indicator->source));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_indicator_source_finalize ( GObject *  object) [static]

Definition at line 162 of file hudindicatorsource.c.

{
  g_assert_not_reached ();
}

Here is the caller graph for this function:

static void hud_indicator_source_iface_init ( HudSourceInterface *  iface) [static]

Definition at line 240 of file hudindicatorsource.c.

{
  iface->use = hud_indicator_source_use;
  iface->unuse = hud_indicator_source_unuse;
  iface->search = hud_indicator_source_search;
}

Here is the call graph for this function:

static void hud_indicator_source_init ( HudIndicatorSource *  source) [static]

Definition at line 220 of file hudindicatorsource.c.

{
  gint i;

  source->n_indicators = G_N_ELEMENTS (indicator_info);
  source->indicators = g_new0 (HudIndicatorSourceIndicator, source->n_indicators);

  for (i = 0; i < source->n_indicators; i++)
    {
      HudIndicatorSourceIndicator *indicator = &source->indicators[i];

      indicator->info = &indicator_info[i];
      indicator->source = source;

      g_bus_watch_name (G_BUS_TYPE_SESSION, indicator->info->dbus_name, G_BUS_NAME_WATCHER_FLAGS_NONE,
                        hud_indicator_source_name_appeared, hud_indicator_source_name_vanished, indicator, NULL);
    }
}

Here is the call graph for this function:

static void hud_indicator_source_name_appeared ( GDBusConnection *  connection,
const gchar *  name,
const gchar *  name_owner,
gpointer  user_data 
) [static]

Definition at line 177 of file hudindicatorsource.c.

{
  HudIndicatorSourceIndicator *indicator = user_data;
  HudDbusmenuCollector *collector;

  collector = hud_dbusmenu_collector_new_for_endpoint (indicator->info->indicator_name,
                                                       _(indicator->info->user_visible_name),
                                                       indicator->info->icon,
                                                       hud_settings.indicator_penalty,
                                                       name_owner, indicator->info->dbus_menu_path);
  g_signal_connect (collector, "changed", G_CALLBACK (hud_indicator_source_collector_changed), indicator);
  indicator->collector = HUD_SOURCE (collector);

  /* Set initial use count on new indicator if query is active. */
  if (indicator->source->use_count)
    hud_source_use (indicator->collector);

  hud_source_changed (HUD_SOURCE (indicator->source));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_indicator_source_name_vanished ( GDBusConnection *  connection,
const gchar *  name,
gpointer  user_data 
) [static]

Definition at line 201 of file hudindicatorsource.c.

{
  HudIndicatorSourceIndicator *indicator = user_data;

  if (indicator->collector)
    {
      g_signal_handlers_disconnect_by_func (indicator->collector, hud_indicator_source_collector_changed, indicator);
      /* Drop our use count on dying indicator (if any) */
      if (indicator->source->use_count)
        hud_source_unuse (indicator->collector);
      g_clear_object (&indicator->collector);
    }

  hud_source_changed (HUD_SOURCE (indicator->source));
}

Here is the call graph for this function:

Here is the caller graph for this function:

HudIndicatorSource* hud_indicator_source_new ( void  )

hud_indicator_source_new:

Creates a #HudIndicatorSource.

Returns: a new #HudIndicatorSource

Definition at line 261 of file hudindicatorsource.c.

{
  return g_object_new (HUD_TYPE_INDICATOR_SOURCE, NULL);
}

Here is the caller graph for this function:

static void hud_indicator_source_search ( HudSource *  hud_source,
GPtrArray *  results_array,
HudTokenList *  search_string 
) [static]

Definition at line 149 of file hudindicatorsource.c.

{
  HudIndicatorSource *source = HUD_INDICATOR_SOURCE (hud_source);
  gint i;

  for (i = 0; i < source->n_indicators; i++)
    if (source->indicators[i].collector)
      hud_source_search (source->indicators[i].collector, results_array, search_string);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_indicator_source_unuse ( HudSource *  hud_source) [static]

Definition at line 131 of file hudindicatorsource.c.

{
  HudIndicatorSource *source = HUD_INDICATOR_SOURCE (hud_source);
  gint i;

  g_return_if_fail (source->use_count > 0);

  source->use_count--;

  if (source->use_count == 0)
    {
      for (i = 0; i < source->n_indicators; i++)
        if (source->indicators[i].collector)
          hud_source_unuse (source->indicators[i].collector);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const IndicatorInfo indicator_info[] [static]

Definition at line 54 of file hudindicatorsource.c.