Back to index

unity  6.0.0
Defines | Functions
unity-switcher-accessible.cpp File Reference
#include <glib/gi18n.h>
#include "unity-switcher-accessible.h"
#include "unity-launcher-icon-accessible.h"
#include "unitya11y.h"
#include "SwitcherView.h"
#include "SwitcherModel.h"

Go to the source code of this file.

Defines

#define UNITY_SWITCHER_ACCESSIBLE_GET_PRIVATE(obj)

Functions

static void unity_switcher_accessible_class_init (UnitySwitcherAccessibleClass *klass)
static void unity_switcher_accessible_init (UnitySwitcherAccessible *self)
static void unity_switcher_accessible_finalize (GObject *object)
static void unity_switcher_accessible_initialize (AtkObject *accessible, gpointer data)
static gint unity_switcher_accessible_get_n_children (AtkObject *obj)
static AtkObject * unity_switcher_accessible_ref_child (AtkObject *obj, gint i)
static AtkStateSet * unity_switcher_accessible_ref_state_set (AtkObject *obj)
static void atk_selection_interface_init (AtkSelectionIface *iface)
static AtkObject * unity_switcher_accessible_ref_selection (AtkSelection *selection, gint i)
static gint unity_switcher_accessible_get_selection_count (AtkSelection *selection)
static gboolean unity_switcher_accessible_is_child_selected (AtkSelection *selection, gint i)
static gboolean unity_switcher_accessible_check_pending_notification (NuxAreaAccessible *self)
static void on_selection_changed_cb (AbstractLauncherIcon::Ptr icon, UnitySwitcherAccessible *switcher_accessible)
static void create_children (UnitySwitcherAccessible *self)
 G_DEFINE_TYPE_WITH_CODE (UnitySwitcherAccessible, unity_switcher_accessible, NUX_TYPE_VIEW_ACCESSIBLE, G_IMPLEMENT_INTERFACE(ATK_TYPE_SELECTION, atk_selection_interface_init)) struct _UnitySwitcherAccessiblePrivate
AtkObject * unity_switcher_accessible_new (nux::Object *object)

Define Documentation

Value:
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), UNITY_TYPE_SWITCHER_ACCESSIBLE,  \
                                UnitySwitcherAccessiblePrivate))

Function Documentation

static void atk_selection_interface_init ( AtkSelectionIface *  iface) [static]

Definition at line 256 of file unity-switcher-accessible.cpp.

{
  iface->ref_selection = unity_switcher_accessible_ref_selection;
  iface->get_selection_count = unity_switcher_accessible_get_selection_count;
  iface->is_child_selected = unity_switcher_accessible_is_child_selected;

  /* NOTE: for the moment we don't provide the implementation for the
     "interactable" methods, it is, the methods that allow to change
     the selected icon. The Switcher doesn't provide that API, and
     right now  we are focusing on a normal user input.*/
  /* iface->add_selection = unity_switcher_accessible_add_selection; */
  /* iface->clear_selection = unity_switcher_accessible_clear_selection; */
  /* iface->remove_selection = unity_switcher_accessible_remove_selection; */

  /* This method will never be implemented, as select all the switcher
     icons makes no sense */
  /* iface->select_all = unity_switcher_accessible_select_all_selection; */
}

Here is the call graph for this function:

static void create_children ( UnitySwitcherAccessible *  self) [static]

Definition at line 387 of file unity-switcher-accessible.cpp.

{
  gint index = 0;
  nux::Object* nux_object = NULL;
  SwitcherView* switcher = NULL;
  SwitcherModel::Ptr switcher_model;
  SwitcherModel::iterator it;
  AbstractLauncherIcon::Ptr child;
  AtkObject* child_accessible = NULL;

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(self));
  if (!nux_object) /* state is defunct */
    return;

  switcher = dynamic_cast<SwitcherView*>(nux_object);
  switcher_model = switcher->GetModel();

  if (switcher_model == NULL)
    return;

  for (it = switcher_model->begin(); it != switcher_model->end(); it++)
  {
    child = *it;
    child_accessible = unity_launcher_icon_accessible_new(child.GetPointer());
    atk_object_set_parent(child_accessible, ATK_OBJECT(self));
    self->priv->children = g_slist_append(self->priv->children,
                                          child_accessible);
    unity_launcher_icon_accessible_set_index(UNITY_LAUNCHER_ICON_ACCESSIBLE(child_accessible),
                                             index++);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

G_DEFINE_TYPE_WITH_CODE ( UnitySwitcherAccessible  ,
unity_switcher_accessible  ,
NUX_TYPE_VIEW_ACCESSIBLE  ,
G_IMPLEMENT_INTERFACE(ATK_TYPE_SELECTION, atk_selection_interface_init  
)

Definition at line 72 of file unity-switcher-accessible.cpp.

{
  /* We maintain the children. Although the LauncherIcon are shared
   * between the Switcher and Launcher, in order to keep a hierarchy
   * coherence, we create a different accessible object  */
  GSList* children;

  sigc::connection on_selection_changed_connection;
};
static void on_selection_changed_cb ( AbstractLauncherIcon::Ptr  icon,
UnitySwitcherAccessible *  switcher_accessible 
) [static]

Definition at line 380 of file unity-switcher-accessible.cpp.

{
  g_signal_emit_by_name(ATK_OBJECT(switcher_accessible), "selection-changed");
}

Here is the caller graph for this function:

static gboolean unity_switcher_accessible_check_pending_notification ( NuxAreaAccessible *  self) [static]

Definition at line 362 of file unity-switcher-accessible.cpp.

{
  g_return_val_if_fail(UNITY_IS_SWITCHER_ACCESSIBLE(self), FALSE);

  /* Overriding the method: the switcher doesn't get the key focus of
   * focus (Focusable) */
  /* From SwitcherController: it shows that the switcher only exists
   * to be shown to the user, so if the parent window gets actived, we
   * assume that the switcher will be automatically focused
   */
  atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_FOCUSED, TRUE);
  g_signal_emit_by_name(self, "focus-event", TRUE, NULL);

  return TRUE;
}

Here is the caller graph for this function:

static void unity_switcher_accessible_class_init ( UnitySwitcherAccessibleClass *  klass) [static]

Definition at line 91 of file unity-switcher-accessible.cpp.

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

  gobject_class->finalize = unity_switcher_accessible_finalize;

  /* AtkObject */
  atk_class->get_n_children = unity_switcher_accessible_get_n_children;
  atk_class->ref_child = unity_switcher_accessible_ref_child;
  atk_class->initialize = unity_switcher_accessible_initialize;
  atk_class->ref_state_set = unity_switcher_accessible_ref_state_set;

  /* NuxAreaAccessible */
  area_class->check_pending_notification = unity_switcher_accessible_check_pending_notification;

  g_type_class_add_private(gobject_class, sizeof(UnitySwitcherAccessiblePrivate));
}

Here is the call graph for this function:

static void unity_switcher_accessible_finalize ( GObject *  object) [static]

Definition at line 122 of file unity-switcher-accessible.cpp.

{
  UnitySwitcherAccessible* self = UNITY_SWITCHER_ACCESSIBLE(object);

  self->priv->on_selection_changed_connection.disconnect();

  if (self->priv->children)
  {
    g_slist_free_full(self->priv->children, g_object_unref);
    self->priv->children = NULL;
  }

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

Here is the caller graph for this function:

static gint unity_switcher_accessible_get_n_children ( AtkObject *  obj) [static]

Definition at line 188 of file unity-switcher-accessible.cpp.

{
  nux::Object* object = NULL;
  UnitySwitcherAccessible* self = NULL;

  g_return_val_if_fail(UNITY_IS_SWITCHER_ACCESSIBLE(obj), 0);
  self = UNITY_SWITCHER_ACCESSIBLE(obj);

  object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj));
  if (!object) /* state is defunct */
    return 0;

  return g_slist_length(self->priv->children);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gint unity_switcher_accessible_get_selection_count ( AtkSelection *  selection) [static]

Definition at line 310 of file unity-switcher-accessible.cpp.

{
  SwitcherView* switcher = NULL;
  SwitcherModel::Ptr switcher_model;
  AbstractLauncherIcon::Ptr selected_icon;
  nux::Object* nux_object = NULL;

  g_return_val_if_fail(UNITY_IS_SWITCHER_ACCESSIBLE(selection), 0);

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(selection));
  if (!nux_object) /* state is defunct */
    return 0;

  switcher = dynamic_cast<SwitcherView*>(nux_object);
  switcher_model = switcher->GetModel();

  selected_icon = switcher_model->Selection();

  if (!selected_icon)
    return 0;
  else
    return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void unity_switcher_accessible_init ( UnitySwitcherAccessible *  self) [static]

Definition at line 112 of file unity-switcher-accessible.cpp.

{
  UnitySwitcherAccessiblePrivate* priv =
    UNITY_SWITCHER_ACCESSIBLE_GET_PRIVATE(self);

  self->priv = priv;
  self->priv->children = NULL;
}
static void unity_switcher_accessible_initialize ( AtkObject *  accessible,
gpointer  data 
) [static]

Definition at line 154 of file unity-switcher-accessible.cpp.

{
  SwitcherView* switcher = NULL;
  nux::Object* nux_object = NULL;
  UnitySwitcherAccessible* self = NULL;
  SwitcherModel::Ptr model;

  ATK_OBJECT_CLASS(unity_switcher_accessible_parent_class)->initialize(accessible, data);

  atk_object_set_role(accessible, ATK_ROLE_TOOL_BAR);

  self = UNITY_SWITCHER_ACCESSIBLE(accessible);
  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
  switcher = dynamic_cast<SwitcherView*>(nux_object);
  if (switcher == NULL)
    return;

  model = switcher->GetModel();

  if (model)
  {
    self->priv->on_selection_changed_connection  =
      model->selection_changed.connect(sigc::bind(sigc::ptr_fun(on_selection_changed_cb),
                                                  self));

    create_children(self);
  }

  /* To force being connected to the window::activate signal */
  nux_area_accessible_parent_window_active(NUX_AREA_ACCESSIBLE(self));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean unity_switcher_accessible_is_child_selected ( AtkSelection *  selection,
gint  i 
) [static]

Definition at line 335 of file unity-switcher-accessible.cpp.

{
  SwitcherView* switcher = NULL;
  SwitcherModel::Ptr switcher_model;
  SwitcherModel::iterator it;
  nux::Object* nux_object = NULL;
  gint selected_index = 0;

  g_return_val_if_fail(UNITY_IS_SWITCHER_ACCESSIBLE(selection), FALSE);

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(selection));
  if (!nux_object) /* state is defunct */
    return 0;

  switcher = dynamic_cast<SwitcherView*>(nux_object);
  switcher_model = switcher->GetModel();
  selected_index = switcher_model->SelectionIndex();

  if (selected_index == i)
    return TRUE;
  else
    return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

AtkObject* unity_switcher_accessible_new ( nux::Object *  object)

Definition at line 138 of file unity-switcher-accessible.cpp.

{
  AtkObject* accessible = NULL;

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

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

  atk_object_initialize(accessible, object);
  atk_object_set_name(accessible, _("Switcher"));

  return accessible;
}

Here is the caller graph for this function:

static AtkObject * unity_switcher_accessible_ref_child ( AtkObject *  obj,
gint  i 
) [static]

Definition at line 204 of file unity-switcher-accessible.cpp.

{
  gint num = 0;
  nux::Object* nux_object = NULL;
  AtkObject* child_accessible = NULL;
  UnitySwitcherAccessible* self = NULL;

  g_return_val_if_fail(UNITY_IS_SWITCHER_ACCESSIBLE(obj), NULL);
  num = atk_object_get_n_accessible_children(obj);
  g_return_val_if_fail((i < num) && (i >= 0), NULL);
  self = UNITY_SWITCHER_ACCESSIBLE(obj);

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj));
  if (!nux_object) /* state is defunct */
    return 0;

  child_accessible = ATK_OBJECT(g_slist_nth_data(self->priv->children, i));

  g_object_ref(child_accessible);

  return child_accessible;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static AtkObject * unity_switcher_accessible_ref_selection ( AtkSelection *  selection,
gint  i 
) [static]

Definition at line 276 of file unity-switcher-accessible.cpp.

{
  SwitcherView* switcher = NULL;
  SwitcherModel::Ptr switcher_model;
  nux::Object* nux_object = NULL;
  gint selected_index = 0;
  AtkObject* accessible_selected = NULL;
  UnitySwitcherAccessible* self = NULL;

  g_return_val_if_fail(UNITY_IS_SWITCHER_ACCESSIBLE(selection), 0);
  /* there can be only just item selected */
  g_return_val_if_fail(i == 0, NULL);
  self = UNITY_SWITCHER_ACCESSIBLE(selection);

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(selection));
  if (!nux_object) /* state is defunct */
    return 0;

  switcher = dynamic_cast<SwitcherView*>(nux_object);

  switcher_model = switcher->GetModel();
  selected_index = switcher_model->SelectionIndex();

  accessible_selected = ATK_OBJECT(g_slist_nth_data(self->priv->children,
                                                    selected_index));

  if (accessible_selected != NULL)
    g_object_ref(accessible_selected);

  return accessible_selected;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 229 of file unity-switcher-accessible.cpp.

{
  AtkStateSet* state_set = NULL;
  nux::Object* nux_object = NULL;

  g_return_val_if_fail(UNITY_IS_SWITCHER_ACCESSIBLE(obj), NULL);

  state_set =
    ATK_OBJECT_CLASS(unity_switcher_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;

  /* The Switcher is always focusable */
  atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE);

  /* The Switcher is always focused. Looking SwitcherController code,
   * SwitcherView is only created to be presented to the user */
  atk_state_set_add_state(state_set, ATK_STATE_FOCUSED);

  return state_set;
}

Here is the call graph for this function:

Here is the caller graph for this function: