Back to index

unity  6.0.0
Defines | Functions | Variables
panel-main.c File Reference
#include <glib.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include "panel-a11y.h"
#include "panel-service.h"

Go to the source code of this file.

Defines

#define S_NAME   "com.canonical.Unity.Panel.Service"
#define S_PATH   "/com/canonical/Unity/Panel/Service"
#define S_IFACE   "com.canonical.Unity.Panel.Service"

Functions

static void handle_method_call (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *method_name, GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data)
static void on_service_resync (PanelService *service, const gchar *indicator_id, GDBusConnection *connection)
static void on_service_entry_activated (PanelService *service, const gchar *entry_id, gint x, gint y, guint w, guint h, GDBusConnection *connection)
static void on_service_entry_activate_request (PanelService *service, const gchar *entry_id, GDBusConnection *connection)
static void on_service_entry_show_now_changed (PanelService *service, const gchar *entry_id, gboolean show_now_state, GDBusConnection *connection)
static void on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data)
static void on_name_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data)
static void on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data)
static void on_indicators_cleared (PanelService *service)
static void on_signal (int sig)
static void discard_log_message (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
gint main (gint argc, gchar **argv)

Variables

static GDBusNodeInfo * introspection_data = NULL
static const gchar introspection_xml [] = "</node>"
static const GDBusInterfaceVTable interface_vtable

Define Documentation

#define S_IFACE   "com.canonical.Unity.Panel.Service"

Definition at line 111 of file panel-main.c.

#define S_NAME   "com.canonical.Unity.Panel.Service"

Definition at line 109 of file panel-main.c.

#define S_PATH   "/com/canonical/Unity/Panel/Service"

Definition at line 110 of file panel-main.c.


Function Documentation

static void discard_log_message ( const gchar *  log_domain,
GLogLevelFlags  log_level,
const gchar *  message,
gpointer  user_data 
) [static]

Definition at line 387 of file panel-main.c.

{
  return;
}

Here is the caller graph for this function:

static void handle_method_call ( GDBusConnection *  connection,
const gchar *  sender,
const gchar *  object_path,
const gchar *  interface_name,
const gchar *  method_name,
GVariant *  parameters,
GDBusMethodInvocation *  invocation,
gpointer  user_data 
) [static]

Definition at line 136 of file panel-main.c.

{
  PanelService *service = PANEL_SERVICE (user_data);

  if (g_strcmp0 (method_name, "Sync") == 0)
    {
      g_dbus_method_invocation_return_value (invocation,
                                             panel_service_sync (service));
    }
  else if (g_strcmp0 (method_name, "SyncOne") == 0)
    {
      gchar *id;
      g_variant_get (parameters, "(s)", &id, NULL);
      g_dbus_method_invocation_return_value (invocation,
                                             panel_service_sync_one (service,
                                                                     id));
      g_free (id);
    }
  else if (g_strcmp0 (method_name, "SyncGeometries") == 0)
    {
      GVariantIter *iter;
      gchar *indicator_id, *entry_id;
      gint x, y, width, height;

      g_variant_get (parameters, "(a(ssiiii))", &iter);
      while (iter && g_variant_iter_loop (iter, "(ssiiii)",
                                  &indicator_id,
                                  &entry_id,
                                  &x,
                                  &y,
                                  &width,
                                  &height))
        {
          panel_service_sync_geometry (service, indicator_id,
                                       entry_id, x, y, width, height);
        }

      if (iter) g_variant_iter_free (iter);

      g_dbus_method_invocation_return_value (invocation, NULL);
    }
  else if (g_strcmp0 (method_name, "ShowEntry") == 0)
    {
      guint32 xid;
      gchar  *entry_id;
      gint32  x;
      gint32  y;
      guint32 button;
      guint32 timestamp;
      g_variant_get (parameters, "(suiiuu)", &entry_id, &xid, &x, &y, &button, &timestamp, NULL);

      panel_service_show_entry (service, entry_id, xid, x, y, button, timestamp);

      g_dbus_method_invocation_return_value (invocation, NULL);
      g_free (entry_id);
    }
  else if (g_strcmp0 (method_name, "ShowAppMenu") == 0)
    {
      guint32 xid;
      gint32  x;
      gint32  y;
      guint32 timestamp;
      g_variant_get (parameters, "(uiiu)", &xid, &x, &y, &timestamp, NULL);

      panel_service_show_app_menu (service, xid, x, y, timestamp);

      g_dbus_method_invocation_return_value (invocation, NULL);
    }
  else if (g_strcmp0 (method_name, "SecondaryActivateEntry") == 0)
    {
      gchar  *entry_id;
      guint32 timestamp;
      g_variant_get (parameters, "(su)", &entry_id, &timestamp, NULL);

      panel_service_secondary_activate_entry (service, entry_id, timestamp);

      g_dbus_method_invocation_return_value (invocation, NULL);
      g_free (entry_id);
    }
  else if (g_strcmp0 (method_name, "ScrollEntry") == 0)
    {
      gchar *entry_id;
      gint32 delta;
      g_variant_get (parameters, "(si)", &entry_id, &delta, NULL);
      panel_service_scroll_entry (service, entry_id, delta);
      g_dbus_method_invocation_return_value (invocation, NULL);
      g_free(entry_id);
    }
}

Here is the call graph for this function:

gint main ( gint  argc,
gchar **  argv 
)

Definition at line 394 of file panel-main.c.

{
  PanelService *service;
  guint         owner_id;

  g_unsetenv("UBUNTU_MENUPROXY");
  g_setenv ("NO_AT_BRIDGE", "1", TRUE);
  g_unsetenv ("NO_GAIL");

  gtk_init (&argc, &argv);
  gtk_icon_theme_append_search_path (gtk_icon_theme_get_default(),
                                 INDICATORICONDIR);

  if (g_getenv ("SILENT_PANEL_SERVICE") != NULL)
  {
    g_log_set_default_handler (discard_log_message, NULL);
  }

  introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
  g_assert (introspection_data != NULL);

  panel_a11y_init ();

  service = panel_service_get_default ();

  owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
                             S_NAME,
                             G_BUS_NAME_OWNER_FLAGS_NONE,
                             on_bus_acquired,
                             on_name_acquired,
                             on_name_lost,
                             service,
                             NULL);

  signal (SIGINT, on_signal);
  signal (SIGTERM, on_signal);

  gtk_main ();

  g_bus_unown_name (owner_id);
  g_dbus_node_info_unref (introspection_data);
  g_object_unref (service);

  return 0;
}

Here is the call graph for this function:

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

Definition at line 318 of file panel-main.c.

{
  PanelService *service = PANEL_SERVICE (user_data);
  guint         reg_id;

  reg_id = g_dbus_connection_register_object (connection,
                                              S_PATH,
                                              introspection_data->interfaces[0],
                                              &interface_vtable,
                                              service,
                                              NULL,
                                              NULL);
  g_signal_connect (service, "re-sync",
                    G_CALLBACK (on_service_resync), connection);
  g_signal_connect (service, "entry-activated",
                    G_CALLBACK (on_service_entry_activated), connection);
  g_signal_connect (service, "entry-activate-request",
                    G_CALLBACK (on_service_entry_activate_request), connection);
  g_signal_connect (service, "entry-show-now-changed",
                    G_CALLBACK (on_service_entry_show_now_changed), connection);

  g_debug ("%s", G_STRFUNC);
  g_assert (reg_id > 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void on_indicators_cleared ( PanelService *  service) [static]

Definition at line 372 of file panel-main.c.

{
  gtk_main_quit ();
}

Here is the caller graph for this function:

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

Definition at line 346 of file panel-main.c.

{
  g_debug ("Name Acquired");
}

Here is the caller graph for this function:

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

Definition at line 354 of file panel-main.c.

{
  PanelService *service = PANEL_SERVICE (user_data);
              
  g_debug ("%s", G_STRFUNC);
  if (service != NULL)
  {
    g_signal_handlers_disconnect_by_func (service, on_service_resync, connection);
    g_signal_handlers_disconnect_by_func (service, on_service_entry_activated, connection);
    g_signal_handlers_disconnect_by_func (service, on_service_entry_activate_request, connection);
    g_signal_handlers_disconnect_by_func (service, on_service_entry_show_now_changed, connection);
  }
  gtk_main_quit ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void on_service_entry_activate_request ( PanelService *  service,
const gchar *  entry_id,
GDBusConnection *  connection 
) [static]

Definition at line 274 of file panel-main.c.

{
  GError *error = NULL;
  g_warning ("%s, entry_id:%s", G_STRFUNC, entry_id);
  g_dbus_connection_emit_signal (connection,
                                 S_NAME,
                                 S_PATH,
                                 S_IFACE,
                                 "EntryActivateRequest",
                                 g_variant_new ("(s)", entry_id),
                                 &error);

  if (error)
    {
      g_warning ("Unable to emit EntryActivateRequest signal: %s", error->message);
      g_error_free (error);
    }
}

Here is the caller graph for this function:

static void on_service_entry_activated ( PanelService *  service,
const gchar *  entry_id,
gint  x,
gint  y,
guint  w,
guint  h,
GDBusConnection *  connection 
) [static]

Definition at line 252 of file panel-main.c.

{
  GError *error = NULL;
  g_dbus_connection_emit_signal (connection,
                                 S_NAME,
                                 S_PATH,
                                 S_IFACE,
                                 "EntryActivated",
                                 g_variant_new ("(s(iiuu))", entry_id, x, y, w, h),
                                 &error);

  if (error)
    {
      g_warning ("Unable to emit EntryActivated signal: %s", error->message);
      g_error_free (error);
    }
}

Here is the caller graph for this function:

static void on_service_entry_show_now_changed ( PanelService *  service,
const gchar *  entry_id,
gboolean  show_now_state,
GDBusConnection *  connection 
) [static]

Definition at line 296 of file panel-main.c.

{
  GError *error = NULL;
  g_dbus_connection_emit_signal (connection,
                                 S_NAME,
                                 S_PATH,
                                 S_IFACE,
                                 "EntryShowNowChanged",
                                 g_variant_new ("(sb)", entry_id, show_now_state),
                                 &error);

  if (error)
    {
      g_warning ("Unable to emit EntryShowNowChanged signal: %s", error->message);
      g_error_free (error);
    }
}

Here is the caller graph for this function:

static void on_service_resync ( PanelService *  service,
const gchar *  indicator_id,
GDBusConnection *  connection 
) [static]

Definition at line 234 of file panel-main.c.

{
  GError *error = NULL;
  g_dbus_connection_emit_signal (connection,
                                 S_NAME,
                                 S_PATH,
                                 S_IFACE,
                                 "ReSync",
                                 g_variant_new ("(s)", indicator_id),
                                 &error);
  if (error)
    {
      g_warning ("Unable to emit ReSync signal: %s", error->message);
      g_error_free (error);
    }
}

Here is the caller graph for this function:

static void on_signal ( int  sig) [static]

Definition at line 378 of file panel-main.c.

{
  PanelService *service = panel_service_get_default ();
  panel_service_clear_indicators (service);
  g_signal_connect (service, "indicators-cleared",
                    G_CALLBACK (on_indicators_cleared), NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const GDBusInterfaceVTable interface_vtable [static]
Initial value:
{
  handle_method_call,
  NULL,
  NULL
}

Definition at line 125 of file panel-main.c.

GDBusNodeInfo* introspection_data = NULL [static]

Definition at line 28 of file panel-main.c.

const gchar introspection_xml[] = "</node>" [static]

Definition at line 45 of file panel-main.c.