Back to index

unity  6.0.0
Defines | Functions
unity-launcher-icon-accessible.cpp File Reference
#include "unity-launcher-icon-accessible.h"
#include "unity-launcher-accessible.h"
#include "Launcher.h"
#include "LauncherIcon.h"
#include "unitya11y.h"

Go to the source code of this file.

Defines

#define UNITY_LAUNCHER_ICON_ACCESSIBLE_GET_PRIVATE(obj)

Functions

static void unity_launcher_icon_accessible_class_init (UnityLauncherIconAccessibleClass *klass)
static void unity_launcher_icon_accessible_init (UnityLauncherIconAccessible *launcher_icon_accessible)
static void unity_launcher_icon_accessible_dispose (GObject *object)
static void unity_launcher_icon_accessible_initialize (AtkObject *accessible, gpointer data)
static AtkStateSet * unity_launcher_icon_accessible_ref_state_set (AtkObject *obj)
static const gchar * unity_launcher_icon_accessible_get_name (AtkObject *obj)
static gint unity_launcher_icon_accessible_get_index_in_parent (AtkObject *obj)
static void atk_component_interface_init (AtkComponentIface *iface)
static guint unity_launcher_icon_accessible_add_focus_handler (AtkComponent *component, AtkFocusHandler handler)
static void unity_launcher_icon_accessible_remove_focus_handler (AtkComponent *component, guint handler_id)
static void unity_launcher_icon_accessible_focus_handler (AtkObject *accessible, gboolean focus_in)
static void atk_action_interface_init (AtkActionIface *iface)
static gboolean unity_launcher_icon_accessible_do_action (AtkAction *action, gint i)
static gint unity_launcher_icon_accessible_get_n_actions (AtkAction *action)
static const gchar * unity_launcher_icon_accessible_get_name (AtkAction *action, gint i)
static void check_selected (UnityLauncherIconAccessible *self)
static void on_parent_selection_change_cb (AtkSelection *selection, gpointer data)
static void on_parent_focus_event_cb (AtkObject *object, gboolean in, gpointer data)
 G_DEFINE_TYPE_WITH_CODE (UnityLauncherIconAccessible, unity_launcher_icon_accessible, NUX_TYPE_OBJECT_ACCESSIBLE, G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT, atk_component_interface_init) G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION, atk_action_interface_init)) struct _UnityLauncherIconAccessiblePrivate
AtkObject * unity_launcher_icon_accessible_new (nux::Object *object)
static void on_parent_change_cb (gchar *property, GValue *value, gpointer data)
void unity_launcher_icon_accessible_set_index (UnityLauncherIconAccessible *self, gint index)

Define Documentation

Value:
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), UNITY_TYPE_LAUNCHER_ICON_ACCESSIBLE, \
                                UnityLauncherIconAccessiblePrivate))

Function Documentation

static void atk_action_interface_init ( AtkActionIface *  iface) [static]

Definition at line 446 of file unity-launcher-icon-accessible.cpp.

Here is the call graph for this function:

static void atk_component_interface_init ( AtkComponentIface *  iface) [static]

Definition at line 369 of file unity-launcher-icon-accessible.cpp.

{
  g_return_if_fail(iface != NULL);

  /* focus management */
  iface->add_focus_handler    = unity_launcher_icon_accessible_add_focus_handler;
  iface->remove_focus_handler = unity_launcher_icon_accessible_remove_focus_handler;

  /* FIXME: still missing the size and position methods. Remember that
   * this is not a nux::Area, and probably we would require to poke
   * the Launcher to get those positions
   */
}

Here is the call graph for this function:

static void check_selected ( UnityLauncherIconAccessible *  self) [static]

Definition at line 307 of file unity-launcher-icon-accessible.cpp.

{
  AtkObject* parent = NULL;
  gboolean found = FALSE;

  parent = atk_object_get_parent(ATK_OBJECT(self));
  if  (parent == NULL)
    return;

  found = atk_selection_is_child_selected(ATK_SELECTION(parent),
                                          self->priv->index_in_parent);

  if ((found) && (self->priv->parent_focused == FALSE))
    return;

  if (found != self->priv->selected)
  {
    gboolean return_val = FALSE;

    self->priv->selected = found;
    atk_object_notify_state_change(ATK_OBJECT(self),
                                   ATK_STATE_SELECTED,
                                   found);
    atk_object_notify_state_change(ATK_OBJECT(self),
                                   ATK_STATE_ACTIVE,
                                   found);

    g_signal_emit_by_name(self, "focus-event", self->priv->selected, &return_val);
    atk_focus_tracker_notify(ATK_OBJECT(self));
  }
}

Here is the caller graph for this function:

G_DEFINE_TYPE_WITH_CODE ( UnityLauncherIconAccessible  ,
unity_launcher_icon_accessible  ,
NUX_TYPE_OBJECT_ACCESSIBLE  ,
G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT,atk_component_interface_init) G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION,atk_action_interface_init  
)

Definition at line 92 of file unity-launcher-icon-accessible.cpp.

{
  /* Cached values (used to avoid extra notifications) */
  gboolean selected;
  gboolean parent_focused;
  gboolean index_in_parent;

  guint on_parent_change_id;
  guint on_parent_selection_change_id;
  guint on_parent_focus_event_id;
};
static void on_parent_change_cb ( gchar *  property,
GValue *  value,
gpointer  data 
) [static]

Definition at line 183 of file unity-launcher-icon-accessible.cpp.

{
  AtkObject* parent = NULL;
  UnityLauncherIconAccessible* self = NULL;
  AtkStateSet* state_set = NULL;

  g_return_if_fail(UNITY_IS_LAUNCHER_ICON_ACCESSIBLE(data));

  self = UNITY_LAUNCHER_ICON_ACCESSIBLE(data);
  parent = atk_object_get_parent(ATK_OBJECT(data));

  if (parent == NULL)
    return;

  self->priv->on_parent_selection_change_id =
    g_signal_connect(parent, "selection-changed",
                     G_CALLBACK(on_parent_selection_change_cb), self);

  self->priv->on_parent_focus_event_id =
    g_signal_connect(parent, "focus-event",
                     G_CALLBACK(on_parent_focus_event_cb), self);

  state_set = atk_object_ref_state_set(parent);
  if (atk_state_set_contains_state(state_set, ATK_STATE_FOCUSED))
  {
    self->priv->parent_focused = TRUE;
  }
  g_object_unref(state_set);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void on_parent_focus_event_cb ( AtkObject *  object,
gboolean  in,
gpointer  data 
) [static]

Definition at line 350 of file unity-launcher-icon-accessible.cpp.

{
  UnityLauncherIconAccessible* self = NULL;

  g_return_if_fail(UNITY_IS_LAUNCHER_ICON_ACCESSIBLE(data));

  self = UNITY_LAUNCHER_ICON_ACCESSIBLE(data);
  self->priv->parent_focused = in;

  /* we check the selection stuff again, to report the focus change
     now */
  check_selected(self);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void on_parent_selection_change_cb ( AtkSelection *  selection,
gpointer  data 
) [static]

Definition at line 340 of file unity-launcher-icon-accessible.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static guint unity_launcher_icon_accessible_add_focus_handler ( AtkComponent *  component,
AtkFocusHandler  handler 
) [static]

Definition at line 392 of file unity-launcher-icon-accessible.cpp.

{
  GSignalMatchType match_type;
  gulong ret;
  guint signal_id;

  g_return_val_if_fail(UNITY_IS_LAUNCHER_ICON_ACCESSIBLE(component), 0);

  match_type = (GSignalMatchType)(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC);
  signal_id = g_signal_lookup("focus-event", ATK_TYPE_OBJECT);

  ret = g_signal_handler_find(component, match_type, signal_id, 0, NULL,
                              (gpointer) handler, NULL);
  if (!ret)
  {
    return g_signal_connect_closure_by_id(component,
                                          signal_id, 0,
                                          g_cclosure_new(G_CALLBACK(handler), NULL,
                                                         (GClosureNotify) NULL),
                                          FALSE);
  }
  else
    return 0;
}

Here is the caller graph for this function:

static void unity_launcher_icon_accessible_class_init ( UnityLauncherIconAccessibleClass *  klass) [static]

Definition at line 117 of file unity-launcher-icon-accessible.cpp.

{
  GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
  AtkObjectClass* atk_class = ATK_OBJECT_CLASS(klass);

  gobject_class->dispose = unity_launcher_icon_accessible_dispose;

  /* AtkObject */
  atk_class->initialize = unity_launcher_icon_accessible_initialize;
  atk_class->get_name = unity_launcher_icon_accessible_get_name;
  atk_class->ref_state_set = unity_launcher_icon_accessible_ref_state_set;
  // atk_class->get_parent = unity_launcher_icon_accessible_get_parent;
  atk_class->get_index_in_parent = unity_launcher_icon_accessible_get_index_in_parent;

  g_type_class_add_private(gobject_class, sizeof(UnityLauncherIconAccessiblePrivate));
}

Here is the call graph for this function:

static void unity_launcher_icon_accessible_dispose ( GObject *  object) [static]

Definition at line 144 of file unity-launcher-icon-accessible.cpp.

{
  UnityLauncherIconAccessible* self = UNITY_LAUNCHER_ICON_ACCESSIBLE(object);
  AtkObject* parent = NULL;

  parent = atk_object_get_parent(ATK_OBJECT(object));

  if (parent != NULL)
  {
    if (self->priv->on_parent_selection_change_id != 0)
      g_signal_handler_disconnect(parent, self->priv->on_parent_selection_change_id);

    if (self->priv->on_parent_focus_event_id != 0)
      g_signal_handler_disconnect(parent, self->priv->on_parent_focus_event_id);
  }

  if (self->priv->on_parent_change_id != 0)
    g_signal_handler_disconnect(object, self->priv->on_parent_change_id);

  G_OBJECT_CLASS(unity_launcher_icon_accessible_parent_class)->dispose(object);
}

Here is the caller graph for this function:

static gboolean unity_launcher_icon_accessible_do_action ( AtkAction *  action,
gint  i 
) [static]

Definition at line 454 of file unity-launcher-icon-accessible.cpp.

{
  LauncherIcon* icon = NULL;
  nux::Object* nux_object = NULL;

  g_return_val_if_fail(UNITY_IS_LAUNCHER_ICON_ACCESSIBLE(action), FALSE);

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(action));
  if (nux_object == NULL)
    return FALSE;

  icon = dynamic_cast<LauncherIcon*>(nux_object);

  icon->Activate(ActionArg(ActionArg::LAUNCHER, 0));

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void unity_launcher_icon_accessible_focus_handler ( AtkObject *  accessible,
gboolean  focus_in 
) [static]

Definition at line 428 of file unity-launcher-icon-accessible.cpp.

{
  g_return_if_fail(UNITY_IS_LAUNCHER_ICON_ACCESSIBLE(accessible));

  atk_object_notify_state_change(accessible, ATK_STATE_FOCUSED, focus_in);
}

Here is the caller graph for this function:

static gint unity_launcher_icon_accessible_get_index_in_parent ( AtkObject *  obj) [static]

Definition at line 437 of file unity-launcher-icon-accessible.cpp.

{
  g_return_val_if_fail(UNITY_IS_LAUNCHER_ICON_ACCESSIBLE(obj), -1);

  return UNITY_LAUNCHER_ICON_ACCESSIBLE(obj)->priv->index_in_parent;
}

Here is the caller graph for this function:

static gint unity_launcher_icon_accessible_get_n_actions ( AtkAction *  action) [static]

Definition at line 474 of file unity-launcher-icon-accessible.cpp.

{
  g_return_val_if_fail(UNITY_IS_LAUNCHER_ICON_ACCESSIBLE(action), 0);

  return 1;
}

Here is the caller graph for this function:

static const gchar * unity_launcher_icon_accessible_get_name ( AtkObject *  obj) [static]

Definition at line 237 of file unity-launcher-icon-accessible.cpp.

{
  const gchar* name;

  g_return_val_if_fail(UNITY_IS_LAUNCHER_ICON_ACCESSIBLE(obj), NULL);

  name = ATK_OBJECT_CLASS(unity_launcher_icon_accessible_parent_class)->get_name(obj);
  if (name == NULL)
  {
    LauncherIcon* icon = NULL;

    icon = dynamic_cast<LauncherIcon*>(nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj)));

    if (icon == NULL) /* State is defunct */
      name = NULL;
    else
      name = icon->tooltip_text().c_str();
  }

  return name;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static const gchar * unity_launcher_icon_accessible_get_name ( AtkAction *  action,
gint  i 
) [static]

Definition at line 482 of file unity-launcher-icon-accessible.cpp.

{
  g_return_val_if_fail(UNITY_IS_LAUNCHER_ICON_ACCESSIBLE(action), NULL);
  g_return_val_if_fail(i == 0, NULL);

  return "activate";
}
static void unity_launcher_icon_accessible_init ( UnityLauncherIconAccessible *  launcher_icon_accessible) [static]

Definition at line 135 of file unity-launcher-icon-accessible.cpp.

{
  UnityLauncherIconAccessiblePrivate* priv =
    UNITY_LAUNCHER_ICON_ACCESSIBLE_GET_PRIVATE(launcher_icon_accessible);

  launcher_icon_accessible->priv = priv;
}
static void unity_launcher_icon_accessible_initialize ( AtkObject *  accessible,
gpointer  data 
) [static]

Definition at line 216 of file unity-launcher-icon-accessible.cpp.

{
  UnityLauncherIconAccessible* self = NULL;

  ATK_OBJECT_CLASS(unity_launcher_icon_accessible_parent_class)->initialize(accessible, data);
  self = UNITY_LAUNCHER_ICON_ACCESSIBLE(accessible);

  accessible->role = ATK_ROLE_PUSH_BUTTON;

  atk_component_add_focus_handler(ATK_COMPONENT(accessible),
                                  unity_launcher_icon_accessible_focus_handler);

  /* we could do that by redefining ->set_parent */
  self->priv->on_parent_change_id =
    g_signal_connect(accessible, "notify::accessible-parent",
                     G_CALLBACK(on_parent_change_cb), self);
}

Here is the call graph for this function:

Here is the caller graph for this function:

AtkObject* unity_launcher_icon_accessible_new ( nux::Object *  object)

Definition at line 168 of file unity-launcher-icon-accessible.cpp.

{
  AtkObject* accessible = NULL;

  g_return_val_if_fail(dynamic_cast<LauncherIcon*>(object), NULL);

  accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_LAUNCHER_ICON_ACCESSIBLE, NULL));

  atk_object_initialize(accessible, object);

  return accessible;
}

Here is the caller graph for this function:

static AtkStateSet * unity_launcher_icon_accessible_ref_state_set ( AtkObject *  obj) [static]

Definition at line 260 of file unity-launcher-icon-accessible.cpp.

{
  AtkStateSet* state_set = NULL;
  UnityLauncherIconAccessible* self = NULL;
  nux::Object* nux_object = NULL;
  LauncherIcon* icon = NULL;

  g_return_val_if_fail(UNITY_IS_LAUNCHER_ICON_ACCESSIBLE(obj), NULL);
  self = UNITY_LAUNCHER_ICON_ACCESSIBLE(obj);

  state_set = ATK_OBJECT_CLASS(unity_launcher_icon_accessible_parent_class)->ref_state_set(obj);

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj));

  if (nux_object == NULL) /* defunct */
    return state_set;

  /* by default */
  atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE);
  atk_state_set_add_state(state_set, ATK_STATE_ENABLED);
  atk_state_set_add_state(state_set, ATK_STATE_SENSITIVE);

  icon = dynamic_cast<LauncherIcon*>(nux_object);

  if (icon->GetQuirk(LauncherIcon::QUIRK_VISIBLE))
  {
    atk_state_set_add_state(state_set, ATK_STATE_VISIBLE);
    atk_state_set_add_state(state_set, ATK_STATE_SHOWING);
  }

  if (self->priv->selected)
  {
    atk_state_set_add_state(state_set, ATK_STATE_FOCUSED);
    atk_state_set_add_state(state_set, ATK_STATE_SELECTED);
    atk_state_set_add_state(state_set, ATK_STATE_ACTIVE);
  }

  return state_set;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void unity_launcher_icon_accessible_remove_focus_handler ( AtkComponent *  component,
guint  handler_id 
) [static]

Definition at line 419 of file unity-launcher-icon-accessible.cpp.

{
  g_return_if_fail(NUX_IS_VIEW_ACCESSIBLE(component));

  g_signal_handler_disconnect(component, handler_id);
}

Here is the caller graph for this function:

void unity_launcher_icon_accessible_set_index ( UnityLauncherIconAccessible *  self,
gint  index 
)

Definition at line 494 of file unity-launcher-icon-accessible.cpp.

{
  g_return_if_fail(UNITY_IS_LAUNCHER_ICON_ACCESSIBLE(self));

  self->priv->index_in_parent = index;
}

Here is the caller graph for this function: