Back to index

indicator-appmenu  12.10.0
Defines | Typedefs | Functions
hudmenumodelcollector.h File Reference
#include <libbamf/libbamf.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


#define HUD_TYPE_MENU_MODEL_COLLECTOR   (hud_menu_model_collector_get_type ())


typedef struct _HudMenuModelCollector


GType hud_menu_model_collector_get_type (void)
HudMenuModelCollector * hud_menu_model_collector_get (BamfWindow *window, const gchar *desktop_file, const gchar *icon)
 hud_menu_model_collector_get: : a #BamfWindow : the desktop file of the application of : the application icon's name

Define Documentation

(G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \

Definition at line 28 of file hudmenumodelcollector.h.

#define HUD_MENU_MODEL_COLLECTOR (   inst)
(G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
                                                             HUD_TYPE_MENU_MODEL_COLLECTOR,                          \

Definition at line 25 of file hudmenumodelcollector.h.

Definition at line 24 of file hudmenumodelcollector.h.

Typedef Documentation

typedef struct _HudMenuModelCollector

Definition at line 31 of file hudmenumodelcollector.h.

Function Documentation

HudMenuModelCollector* hud_menu_model_collector_get ( BamfWindow *  window,
const gchar *  desktop_file,
const gchar *  icon 

hud_menu_model_collector_get: : a #BamfWindow : the desktop file of the application of : the application icon's name

If the given has #GMenuModel-style menus then returns a collector for them, otherwise returns NULL.

is used for usage tracking.

Returns: a #HudMenuModelCollector, or NULL

Definition at line 427 of file hudmenumodelcollector.c.

  HudMenuModelCollector *collector;
  gchar *unique_bus_name;
  gchar *app_menu_object_path;
  gchar *menubar_object_path;
  gchar *application_object_path;
  gchar *window_object_path;
  GDBusConnection *session;

  unique_bus_name = bamf_window_get_utf8_prop (window, "_GTK_UNIQUE_BUS_NAME");

  if (!unique_bus_name)
    /* If this isn't set, we won't get very far... */
    return NULL;

  collector = g_object_new (HUD_TYPE_MENU_MODEL_COLLECTOR, NULL);

  app_menu_object_path = bamf_window_get_utf8_prop (window, "_GTK_APP_MENU_OBJECT_PATH");
  menubar_object_path = bamf_window_get_utf8_prop (window, "_GTK_MENUBAR_OBJECT_PATH");
  application_object_path = bamf_window_get_utf8_prop (window, "_GTK_APPLICATION_OBJECT_PATH");
  window_object_path = bamf_window_get_utf8_prop (window, "_GTK_WINDOW_OBJECT_PATH");

  session = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);

  if (app_menu_object_path)
      collector->app_menu = g_dbus_menu_model_get (session, unique_bus_name, app_menu_object_path);
      hud_menu_model_collector_add_model (collector, G_MENU_MODEL (collector->app_menu));

  if (menubar_object_path)
      collector->menubar = g_dbus_menu_model_get (session, unique_bus_name, menubar_object_path);
      hud_menu_model_collector_add_model (collector, G_MENU_MODEL (collector->menubar));

  if (application_object_path)
    collector->application = g_dbus_action_group_get (session, unique_bus_name, application_object_path);

  if (window_object_path)
    collector->window = g_dbus_action_group_get (session, unique_bus_name, window_object_path);

  collector->desktop_file = g_strdup (desktop_file);
  collector->icon = g_strdup (icon);

  /* when the action groups change, we could end up having items
   * enabled/disabled.  how to deal with that?

  g_free (unique_bus_name);
  g_free (app_menu_object_path);
  g_free (menubar_object_path);
  g_free (application_object_path);
  g_free (window_object_path);

  g_object_unref (session);

  return collector;

Here is the call graph for this function:

Here is the caller graph for this function: