Back to index

indicator-appmenu  12.10.0
Classes | Defines | Typedefs | Functions
huddbusmenucollector.c File Reference
#include "huddbusmenucollector.h"
#include <libdbusmenu-glib/client.h>
#include <string.h>
#include "hudappmenuregistrar.h"
#include "hudresult.h"
#include "hudsource.h"

Go to the source code of this file.

Classes

struct  HudDbusmenuItem
 SECTION:huddbusmenucollector : HudDbusmenuCollector : a #HudSource that collects #HudItems from Dbusmenu. More...
struct  _HudDbusmenuCollector

Defines

#define G_LOG_DOMAIN   "huddbusmenucollector"

Typedefs

typedef HudItemClass HudDbusmenuItemClass
typedef GObjectClass HudDbusmenuCollectorClass

Functions

static void hud_dbusmenu_item_activate (HudItem *hud_item, GVariant *platform_data)
static void hud_dbusmenu_item_finalize (GObject *object)
static void hud_dbusmenu_item_init (HudDbusmenuItem *item)
static void hud_dbusmenu_item_class_init (HudDbusmenuItemClass *class)
static const gchar * hud_dbusmenu_item_get_label_property (const gchar *type)
static HudDbusmenuItemhud_dbusmenu_item_new (HudStringList *context, const gchar *desktop_file, const gchar *icon, DbusmenuMenuitem *menuitem)
static void hud_dbusmenu_collector_iface_init (HudSourceInterface *iface)
 G_DEFINE_TYPE_WITH_CODE (HudDbusmenuCollector, hud_dbusmenu_collector, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(HUD_TYPE_SOURCE, hud_dbusmenu_collector_iface_init))
static void hud_dbusmenu_collector_close_submenu (gpointer key, gpointer value, gpointer user_data)
static void hud_dbusmenu_collector_use (HudSource *source)
static void hud_dbusmenu_collector_unuse (HudSource *source)
static void hud_dbusmenu_collector_search (HudSource *source, GPtrArray *results_array, HudTokenList *search_string)
static void hud_dbusmenu_collector_add_item (HudDbusmenuCollector *collector, HudStringList *context, DbusmenuMenuitem *menuitem)
static void hud_dbusmenu_collector_remove_item (HudDbusmenuCollector *collector, DbusmenuMenuitem *menuitem)
static void hud_dbusmenu_collector_child_added (DbusmenuMenuitem *menuitem, DbusmenuMenuitem *child, guint position, gpointer user_data)
static void hud_dbusmenu_collector_child_removed (DbusmenuMenuitem *menuitem, DbusmenuMenuitem *child, gpointer user_data)
static void hud_dbusmenu_collector_property_changed (DbusmenuMenuitem *menuitem, const gchar *property_name, GVariant *new_value, gpointer user_data)
static void hud_dbusmenu_collector_setup_root (HudDbusmenuCollector *collector, DbusmenuMenuitem *root)
static void hud_dbusmenu_collector_root_changed (DbusmenuClient *client, DbusmenuMenuitem *root, gpointer user_data)
static void hud_dbusmenu_collector_setup_endpoint (HudDbusmenuCollector *collector, const gchar *bus_name, const gchar *object_path)
static void hud_dbusmenu_collector_registrar_observer_func (HudAppMenuRegistrar *registrar, guint xid, const gchar *bus_name, const gchar *object_path, gpointer user_data)
static void hud_dbusmenu_collector_finalize (GObject *object)
static void hud_dbusmenu_collector_init (HudDbusmenuCollector *collector)
static void hud_dbusmenu_collector_class_init (HudDbusmenuCollectorClass *class)
HudDbusmenuCollector * hud_dbusmenu_collector_new_for_endpoint (const gchar *application_id, const gchar *prefix, const gchar *icon, guint penalty, const gchar *bus_name, const gchar *object_path)
 hud_dbusmenu_collector_new_for_endpoint: : a unique identifier for the application : the title to prefix to all items : the icon for the appliction : the penalty to apply to all results : a D-Bus bus name : an object path at the destination given by
HudDbusmenuCollector * hud_dbusmenu_collector_new_for_window (BamfWindow *window, const gchar *desktop_file, const gchar *icon)
 hud_dbusmenu_collector_new_for_window: : a #BamfWindow
void hud_dbusmenu_collector_set_prefix (HudDbusmenuCollector *collector, const gchar *prefix)
 hud_dbusmenu_collector_set_prefix: : a #HudDbusmenuCollector : the new prefix to use
void hud_dbusmenu_collector_set_icon (HudDbusmenuCollector *collector, const gchar *icon)
 hud_dbusmenu_collector_set_icon: : a #HudDbusmenuCollector : the application icon

Class Documentation

struct HudDbusmenuItem

SECTION:huddbusmenucollector : HudDbusmenuCollector : a #HudSource that collects #HudItems from Dbusmenu.

The #HudDbusmenuCollector collects menu items from a #DbusmenuClient.

There are two modes of operation.

In the simple mode, the collector is created with a specified endpoint using hud_dbusmenu_collector_new_for_endpoint(). A

DbusmenuClient is constructed using this endpoint and the collector

constructs #HudItems for the contents of the menu found there. This mode is intended for use with indicators.

For menus associated with application windows (ie: menubars), we must consult the AppMenu registrar in order to discover the endpoint to use. This second mode of the collector is used by calling hud_dbusmenu_collector_new_for_window(). HudDbusmenuCollector:

This is an opaque structure type.

Definition at line 59 of file huddbusmenucollector.c.

Class Members
gboolean is_opened
DbusmenuMenuitem * menuitem
HudItem parent_instance
struct _HudDbusmenuCollector

Definition at line 207 of file huddbusmenucollector.c.

Class Members
gboolean alive
gchar * application_id
DbusmenuClient * client
gchar * icon
GHashTable * items
GObject parent_instance
guint penalty
HudStringList * prefix
gboolean reentrance_check
DbusmenuMenuitem * root
gint use_count
guint xid

Define Documentation

#define G_LOG_DOMAIN   "huddbusmenucollector"

Definition at line 20 of file huddbusmenucollector.c.


Typedef Documentation

typedef GObjectClass HudDbusmenuCollectorClass

Definition at line 224 of file huddbusmenucollector.c.

typedef HudItemClass HudDbusmenuItemClass

Definition at line 67 of file huddbusmenucollector.c.


Function Documentation

G_DEFINE_TYPE_WITH_CODE ( HudDbusmenuCollector  ,
hud_dbusmenu_collector  ,
G_TYPE_OBJECT  ,
G_IMPLEMENT_INTERFACE(HUD_TYPE_SOURCE, hud_dbusmenu_collector_iface_init  
)

Definition at line 227 of file huddbusmenucollector.c.

{
  DbusmenuMenuitem *menuitem = key;
  HudDbusmenuItem *item = value;

  if (dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY))
    {
      dbusmenu_menuitem_handle_event (menuitem, DBUSMENU_MENUITEM_EVENT_OPENED, NULL, 0);
      item->is_opened = TRUE;
    }
}
static void hud_dbusmenu_collector_add_item ( HudDbusmenuCollector *  collector,
HudStringList *  context,
DbusmenuMenuitem *  menuitem 
) [static]

Definition at line 396 of file huddbusmenucollector.c.

{
  HudDbusmenuItem *item;
  GList *child;

  item = hud_dbusmenu_item_new (context, collector->application_id, collector->icon, menuitem);
  context = hud_item_get_tokens (HUD_ITEM (item));

  g_signal_connect (menuitem, "property-changed", G_CALLBACK (hud_dbusmenu_collector_property_changed), collector);
  g_signal_connect (menuitem, "child-added", G_CALLBACK (hud_dbusmenu_collector_child_added), collector);
  g_signal_connect (menuitem, "child-removed", G_CALLBACK (hud_dbusmenu_collector_child_removed), collector);

  /* If we're actively being queried and we add a new submenu item, open it. */
  if (collector->use_count && dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY))
    {
      dbusmenu_menuitem_handle_event (menuitem, DBUSMENU_MENUITEM_EVENT_OPENED, NULL, 0);
      item->is_opened = TRUE;
    }

  g_hash_table_insert (collector->items, menuitem, item);

  for (child = dbusmenu_menuitem_get_children (menuitem); child; child = child->next)
    hud_dbusmenu_collector_add_item (collector, context, child->data);

  if (collector->alive)
    hud_source_changed (HUD_SOURCE (collector));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_dbusmenu_collector_child_added ( DbusmenuMenuitem *  menuitem,
DbusmenuMenuitem *  child,
guint  position,
gpointer  user_data 
) [static]

Definition at line 321 of file huddbusmenucollector.c.

{
  HudDbusmenuCollector *collector = user_data;
  HudStringList *context;
  HudItem *item;

  g_assert (!collector->reentrance_check);

  item = g_hash_table_lookup (collector->items, menuitem);
  g_assert (item != NULL);

  context = hud_item_get_tokens (item);

  hud_dbusmenu_collector_add_item (collector, context, child);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_dbusmenu_collector_child_removed ( DbusmenuMenuitem *  menuitem,
DbusmenuMenuitem *  child,
gpointer  user_data 
) [static]

Definition at line 341 of file huddbusmenucollector.c.

{
  HudDbusmenuCollector *collector = user_data;

  g_assert (!collector->reentrance_check);

  hud_dbusmenu_collector_remove_item (collector, child);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 558 of file huddbusmenucollector.c.

{
  class->finalize = hud_dbusmenu_collector_finalize;
}

Here is the call graph for this function:

static void hud_dbusmenu_collector_close_submenu ( gpointer  key,
gpointer  value,
gpointer  user_data 
) [static]

Definition at line 246 of file huddbusmenucollector.c.

{
  DbusmenuMenuitem *menuitem = key;
  HudDbusmenuItem *item = value;

  if (item->is_opened)
    {
      dbusmenu_menuitem_handle_event (menuitem, DBUSMENU_MENUITEM_EVENT_CLOSED, NULL, 0);
      item->is_opened = FALSE;
    }
}

Here is the caller graph for this function:

static void hud_dbusmenu_collector_finalize ( GObject *  object) [static]

Definition at line 517 of file huddbusmenucollector.c.

{
  HudDbusmenuCollector *collector = HUD_DBUSMENU_COLLECTOR (object);

  if (collector->xid)
    hud_app_menu_registrar_remove_observer (hud_app_menu_registrar_get (), collector->xid,
                                            hud_dbusmenu_collector_registrar_observer_func, collector);

  /* remove all the items without firing change signals */
  collector->alive = FALSE;
  hud_dbusmenu_collector_setup_endpoint (collector, NULL, NULL);

  /* make sure the table is empty before we free it */
  g_assert (g_hash_table_size (collector->items) == 0);
  g_hash_table_unref (collector->items);

  g_free (collector->application_id);
  g_free (collector->icon);

  hud_string_list_unref (collector->prefix);
  g_clear_object (&collector->client);

  G_OBJECT_CLASS (hud_dbusmenu_collector_parent_class)
    ->finalize (object);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_dbusmenu_collector_iface_init ( HudSourceInterface *  iface) [static]

Definition at line 550 of file huddbusmenucollector.c.

Here is the call graph for this function:

static void hud_dbusmenu_collector_init ( HudDbusmenuCollector *  collector) [static]

Definition at line 544 of file huddbusmenucollector.c.

{
  collector->items = g_hash_table_new_full (NULL, NULL, NULL, g_object_unref);
}
HudDbusmenuCollector* hud_dbusmenu_collector_new_for_endpoint ( const gchar *  application_id,
const gchar *  prefix,
const gchar *  icon,
guint  penalty,
const gchar *  bus_name,
const gchar *  object_path 
)

hud_dbusmenu_collector_new_for_endpoint: : a unique identifier for the application : the title to prefix to all items : the icon for the appliction : the penalty to apply to all results : a D-Bus bus name : an object path at the destination given by

Creates a new #HudDbusmenuCollector for the specified endpoint.

Internally, a #DbusmenuClient is created for this endpoint. Searches are performed against the contents of those menus.

This call is intended to be used for indicators.

If is non-NULL (which, for indicators, it ought to be), then it is prefixed to every item created by the collector.

If is non-zero then all results returned from the collector have their distance increased by a percentage equal to the penalty. This allows items from indicators to score lower than they would otherwise.

Returns: a new #HudDbusmenuCollector

Definition at line 590 of file huddbusmenucollector.c.

{
  HudDbusmenuCollector *collector;

  collector = g_object_new (HUD_TYPE_DBUSMENU_COLLECTOR, NULL);
  collector->application_id = g_strdup (application_id);
  collector->icon = g_strdup (icon);
  if (prefix)
    collector->prefix = hud_string_list_cons (prefix, NULL);
  collector->penalty = penalty;
  hud_dbusmenu_collector_setup_endpoint (collector, bus_name, object_path);

  collector->alive = TRUE;

  return collector;
}

Here is the call graph for this function:

Here is the caller graph for this function:

HudDbusmenuCollector* hud_dbusmenu_collector_new_for_window ( BamfWindow *  window,
const gchar *  desktop_file,
const gchar *  icon 
)

hud_dbusmenu_collector_new_for_window: : a #BamfWindow

Creates a new #HudDbusmenuCollector for the endpoint indicated by the

HudAppMenuRegistrar for .

This call is intended to be used for application menus.

Returns: a new #HudDbusmenuCollector

Definition at line 624 of file huddbusmenucollector.c.

{
  HudDbusmenuCollector *collector;

  collector = g_object_new (HUD_TYPE_DBUSMENU_COLLECTOR, NULL);
  collector->application_id = g_strdup (desktop_file);
  collector->icon = g_strdup (icon);
  collector->xid = bamf_window_get_xid (window);
  g_debug ("dbusmenu on %d", collector->xid);
  hud_app_menu_registrar_add_observer (hud_app_menu_registrar_get (), collector->xid,
                                       hud_dbusmenu_collector_registrar_observer_func, collector);

  collector->alive = TRUE;

  return collector;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_dbusmenu_collector_property_changed ( DbusmenuMenuitem *  menuitem,
const gchar *  property_name,
GVariant *  new_value,
gpointer  user_data 
) [static]

Definition at line 353 of file huddbusmenucollector.c.

{
  HudDbusmenuCollector *collector = user_data;
  DbusmenuMenuitem *parent;
  HudStringList *context;
  HudDbusmenuItem *item;
  gboolean was_open;

  g_assert (!collector->reentrance_check);

  parent = dbusmenu_menuitem_get_parent (menuitem);

  if (parent)
    {
      HudItem *parentitem;

      parentitem = g_hash_table_lookup (collector->items, parent);
      context = hud_item_get_tokens (parentitem);
    }
  else
    context = collector->prefix;

  item = g_hash_table_lookup (collector->items, menuitem);
  was_open = item->is_opened;
  g_hash_table_remove (collector->items, menuitem);

  item = hud_dbusmenu_item_new (context, collector->application_id, collector->icon, menuitem);

  if (collector->use_count && !was_open && dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY))
    {
      dbusmenu_menuitem_handle_event (menuitem, DBUSMENU_MENUITEM_EVENT_OPENED, NULL, 0);
      item->is_opened = TRUE;
    }

  g_hash_table_insert (collector->items, menuitem, item);

  hud_source_changed (HUD_SOURCE (collector));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_dbusmenu_collector_registrar_observer_func ( HudAppMenuRegistrar *  registrar,
guint  xid,
const gchar *  bus_name,
const gchar *  object_path,
gpointer  user_data 
) [static]

Definition at line 504 of file huddbusmenucollector.c.

{
  HudDbusmenuCollector *collector = user_data;

  hud_dbusmenu_collector_setup_endpoint (collector, bus_name, object_path);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_dbusmenu_collector_remove_item ( HudDbusmenuCollector *  collector,
DbusmenuMenuitem *  menuitem 
) [static]

Definition at line 427 of file huddbusmenucollector.c.

{
  GList *child;

  g_signal_handlers_disconnect_by_func (menuitem, hud_dbusmenu_collector_property_changed, collector);
  g_signal_handlers_disconnect_by_func (menuitem, hud_dbusmenu_collector_child_added, collector);
  g_signal_handlers_disconnect_by_func (menuitem, hud_dbusmenu_collector_child_removed, collector);
  g_hash_table_remove (collector->items, menuitem);

  for (child = dbusmenu_menuitem_get_children (menuitem); child; child = child->next)
    hud_dbusmenu_collector_remove_item (collector, child->data);

  if (collector->alive)
    hud_source_changed (HUD_SOURCE (collector));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_dbusmenu_collector_root_changed ( DbusmenuClient *  client,
DbusmenuMenuitem *  root,
gpointer  user_data 
) [static]

Definition at line 469 of file huddbusmenucollector.c.

{
  HudDbusmenuCollector *collector = user_data;

  g_assert (!collector->reentrance_check);

  hud_dbusmenu_collector_setup_root (collector, root);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_dbusmenu_collector_search ( HudSource *  source,
GPtrArray *  results_array,
HudTokenList *  search_string 
) [static]

Definition at line 293 of file huddbusmenucollector.c.

{
  HudDbusmenuCollector *collector = HUD_DBUSMENU_COLLECTOR (source);
  GHashTableIter iter;
  gpointer item;

  g_hash_table_iter_init (&iter, collector->items);
  while (g_hash_table_iter_next (&iter, NULL, &item))
    {
      HudResult *result;

      result = hud_result_get_if_matched (item, search_string, collector->penalty);
      if (result)
        g_ptr_array_add (results_array, result);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void hud_dbusmenu_collector_set_icon ( HudDbusmenuCollector *  collector,
const gchar *  icon 
)

hud_dbusmenu_collector_set_icon: : a #HudDbusmenuCollector : the application icon

Changes the application icon used for all items of the collector.

This will involve destroying all of the items and recreating them (since each item's icon has to be changed).

Definition at line 673 of file huddbusmenucollector.c.

{
  g_free (collector->icon);
  collector->icon = g_strdup (icon);
  hud_dbusmenu_collector_setup_root (collector, collector->root);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void hud_dbusmenu_collector_set_prefix ( HudDbusmenuCollector *  collector,
const gchar *  prefix 
)

hud_dbusmenu_collector_set_prefix: : a #HudDbusmenuCollector : the new prefix to use

Changes the prefix applied to all items of the collector.

This will involve destroying all of the items and recreating them (since each item's prefix has to be changed).

Definition at line 654 of file huddbusmenucollector.c.

{
  hud_string_list_unref (collector->prefix);
  collector->prefix = hud_string_list_cons (prefix, NULL);
  hud_dbusmenu_collector_setup_root (collector, collector->root);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_dbusmenu_collector_setup_endpoint ( HudDbusmenuCollector *  collector,
const gchar *  bus_name,
const gchar *  object_path 
) [static]

Definition at line 481 of file huddbusmenucollector.c.

{
  g_debug ("endpoint is %s %s", bus_name, object_path);

  if (collector->client)
    {
      g_signal_handlers_disconnect_by_func (collector->client, hud_dbusmenu_collector_root_changed, collector);
      hud_dbusmenu_collector_setup_root (collector, NULL);
      g_clear_object (&collector->client);
    }

  if (bus_name && object_path)
    {
      collector->client = dbusmenu_client_new (bus_name, object_path);
      g_signal_connect_object (collector->client, "root-changed",
                               G_CALLBACK (hud_dbusmenu_collector_root_changed), collector, 0);
      hud_dbusmenu_collector_setup_root (collector, dbusmenu_client_get_root (collector->client));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_dbusmenu_collector_setup_root ( HudDbusmenuCollector *  collector,
DbusmenuMenuitem *  root 
) [static]

Definition at line 445 of file huddbusmenucollector.c.

{
  if (collector->root)
    {
      /* If the collector has the submenus opened, close them before we
       * remove them all.  The use_count being non-zero will cause them
       * to be reopened as they are added back below (if they will be).
       */
      if (collector->use_count > 0)
        g_hash_table_foreach (collector->items, hud_dbusmenu_collector_close_submenu, NULL);

      hud_dbusmenu_collector_remove_item (collector, collector->root);
      g_clear_object (&collector->root);
    }

  if (root)
    {
      hud_dbusmenu_collector_add_item (collector, collector->prefix, root);
      collector->root = g_object_ref (root);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_dbusmenu_collector_unuse ( HudSource *  source) [static]

Definition at line 276 of file huddbusmenucollector.c.

{
  HudDbusmenuCollector *collector = HUD_DBUSMENU_COLLECTOR (source);

  g_return_if_fail (collector->use_count > 0);

  collector->reentrance_check = TRUE;

  collector->use_count--;

  if (collector->use_count == 0)
    g_hash_table_foreach (collector->items, hud_dbusmenu_collector_close_submenu, NULL);

  collector->reentrance_check = FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_dbusmenu_collector_use ( HudSource *  source) [static]

Definition at line 261 of file huddbusmenucollector.c.

{
  HudDbusmenuCollector *collector = HUD_DBUSMENU_COLLECTOR (source);

  collector->reentrance_check = TRUE;

  if (collector->use_count == 0)
    g_hash_table_foreach (collector->items, hud_dbusmenu_collector_open_submenu, NULL);

  collector->use_count++;

  collector->reentrance_check = FALSE;
}

Here is the caller graph for this function:

static void hud_dbusmenu_item_activate ( HudItem *  hud_item,
GVariant *  platform_data 
) [static]

Definition at line 72 of file huddbusmenucollector.c.

{
  HudDbusmenuItem *item = (HudDbusmenuItem *) hud_item;
  const gchar *startup_id;
  guint32 timestamp = 0;

  if (g_variant_lookup (platform_data, "desktop-startup-id", "&s", &startup_id))
    {
      const gchar *time_tag;

      if ((time_tag = strstr (startup_id, "_TIME")))
        {
          gint64 result;

          result = g_ascii_strtoll (time_tag + 5, NULL, 10);

          if (0 <= result && result <= G_MAXINT32)
           timestamp = result;
        }
    }

  dbusmenu_menuitem_handle_event(item->menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, NULL, timestamp);
}

Here is the caller graph for this function:

static void hud_dbusmenu_item_class_init ( HudDbusmenuItemClass class) [static]

Definition at line 114 of file huddbusmenucollector.c.

{
  GObjectClass *gobject_class = G_OBJECT_CLASS (class);

  gobject_class->finalize = hud_dbusmenu_item_finalize;
  class->activate = hud_dbusmenu_item_activate;
}

Here is the call graph for this function:

static void hud_dbusmenu_item_finalize ( GObject *  object) [static]

Definition at line 98 of file huddbusmenucollector.c.

{
  HudDbusmenuItem *item = (HudDbusmenuItem *) object;

  g_object_unref (item->menuitem);

  G_OBJECT_CLASS (hud_dbusmenu_item_parent_class)
    ->finalize (object);
}

Here is the caller graph for this function:

static const gchar* hud_dbusmenu_item_get_label_property ( const gchar *  type) [static]

Definition at line 123 of file huddbusmenucollector.c.

{
  static const gchar * const property_table[][2] =
  {
    { DBUSMENU_CLIENT_TYPES_DEFAULT,                 DBUSMENU_MENUITEM_PROP_LABEL                         },
    /* Indicator Messages */
    { "application-item",                            DBUSMENU_MENUITEM_PROP_LABEL                         },
    { "indicator-item",                              "indicator-label"                                    },
    /* Indicator Datetime */
    { "appointment-item",                            "appointment-label"                                  },
    { "timezone-item",                               "timezone-name"                                      },
    /* Indicator Sound */
    { "x-canonical-sound-menu-player-metadata-type", "x-canonical-sound-menu-player-metadata-player-name" },
    { "x-canonical-sound-menu-mute-type",            DBUSMENU_MENUITEM_PROP_LABEL                         },
    /* Indicator User */
    { "x-canonical-user-item",                       "user-item-name"                                     }
  };
  static GHashTable *property_hash;

  if G_UNLIKELY (property_hash == NULL)
    {
      gint i;

      property_hash = g_hash_table_new (g_str_hash, g_str_equal);

      for (i = 0; i < G_N_ELEMENTS (property_table); i++)
        g_hash_table_insert (property_hash, (gpointer) property_table[i][0], (gpointer) property_table[i][1]);
    }

  if (type == NULL)
    return DBUSMENU_MENUITEM_PROP_LABEL;

  return g_hash_table_lookup (property_hash, type);
}

Here is the caller graph for this function:

static void hud_dbusmenu_item_init ( HudDbusmenuItem item) [static]

Definition at line 109 of file huddbusmenucollector.c.

{
}
static HudDbusmenuItem* hud_dbusmenu_item_new ( HudStringList *  context,
const gchar *  desktop_file,
const gchar *  icon,
DbusmenuMenuitem *  menuitem 
) [static]

Definition at line 160 of file huddbusmenucollector.c.

{
  HudStringList *tokens;
  HudDbusmenuItem *item;
  const gchar *type;
  const gchar *prop;
  gboolean enabled;

  type = dbusmenu_menuitem_property_get (menuitem, DBUSMENU_MENUITEM_PROP_TYPE);
  prop = hud_dbusmenu_item_get_label_property (type);

  if (prop && dbusmenu_menuitem_property_exist (menuitem, prop))
    {
      const gchar *label;

      label = dbusmenu_menuitem_property_get (menuitem, prop);
      tokens = hud_string_list_cons_label (label, context);
      enabled = TRUE;
    }
  else
    {
      tokens = hud_string_list_ref (context);
      enabled = FALSE;
    }

  if (enabled)
    enabled &= !dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE) ||
               dbusmenu_menuitem_property_get_bool (menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE);

  if (enabled)
    enabled &= !dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_ENABLED) ||
               dbusmenu_menuitem_property_get_bool (menuitem, DBUSMENU_MENUITEM_PROP_ENABLED);

  if (enabled)
    enabled &= !dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY);

  item = hud_item_construct (hud_dbusmenu_item_get_type (), tokens, desktop_file, icon, enabled);
  item->menuitem = g_object_ref (menuitem);

  hud_string_list_unref (tokens);

  return item;
}

Here is the call graph for this function:

Here is the caller graph for this function: