Back to index

unity  6.0.0
Defines | Functions
unity-rvgrid-accessible.cpp File Reference
#include <glib/gi18n.h>
#include "unity-rvgrid-accessible.h"
#include "unity-result-accessible.h"
#include "unity-places-group-accessible.h"
#include "unitya11y.h"
#include "ResultViewGrid.h"
#include "PlacesGroup.h"

Go to the source code of this file.

Defines

#define UNITY_RVGRID_ACCESSIBLE_GET_PRIVATE(obj)

Functions

static void unity_rvgrid_accessible_class_init (UnityRvgridAccessibleClass *klass)
static void unity_rvgrid_accessible_init (UnityRvgridAccessible *self)
static void unity_rvgrid_accessible_finalize (GObject *object)
static void unity_rvgrid_accessible_initialize (AtkObject *accessible, gpointer data)
static AtkStateSet * unity_rvgrid_accessible_ref_state_set (AtkObject *obj)
static gint unity_rvgrid_accessible_get_n_children (AtkObject *obj)
static AtkObject * unity_rvgrid_accessible_ref_child (AtkObject *obj, gint i)
static void atk_selection_interface_init (AtkSelectionIface *iface)
static AtkObject * unity_rvgrid_accessible_ref_selection (AtkSelection *selection, gint i)
static gint unity_rvgrid_accessible_get_selection_count (AtkSelection *selection)
static gboolean unity_rvgrid_accessible_is_child_selected (AtkSelection *selection, gint i)
 G_DEFINE_TYPE_WITH_CODE (UnityRvgridAccessible, unity_rvgrid_accessible, NUX_TYPE_VIEW_ACCESSIBLE, G_IMPLEMENT_INTERFACE(ATK_TYPE_SELECTION, atk_selection_interface_init)) struct _UnityRvgridAccessiblePrivate
AtkObject * unity_rvgrid_accessible_new (nux::Object *object)
static void check_selection (UnityRvgridAccessible *self)
static void on_selection_change_cb (UnityRvgridAccessible *self)
static void search_for_label (UnityRvgridAccessible *self)
static gboolean check_selection_on_idle (gpointer data)
static void on_focus_event_cb (AtkObject *object, gboolean in, gpointer data)

Define Documentation

Value:
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), UNITY_TYPE_RVGRID_ACCESSIBLE,    \
                                UnityRvgridAccessiblePrivate))

Function Documentation

static void atk_selection_interface_init ( AtkSelectionIface *  iface) [static]

Definition at line 334 of file unity-rvgrid-accessible.cpp.

{
  iface->ref_selection = unity_rvgrid_accessible_ref_selection;
  iface->get_selection_count = unity_rvgrid_accessible_get_selection_count;
  iface->is_child_selected = unity_rvgrid_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 Rvgrid doesn't provide that API, and
     right now  we are focusing on a normal user input.*/
  /* iface->add_selection = unity_rvgrid_accessible_add_selection; */
  /* iface->clear_selection = unity_rvgrid_accessible_clear_selection; */
  /* iface->remove_selection = unity_rvgrid_accessible_remove_selection; */

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

Here is the call graph for this function:

static void check_selection ( UnityRvgridAccessible *  self) [static]

Definition at line 145 of file unity-rvgrid-accessible.cpp.

{
  AtkObject* child = NULL;
  gint index = 0;
  ResultView::ResultList result_list;
  Result* result;
  nux::Object* object = NULL;
  ResultViewGrid* rvgrid = NULL;
  std::string name;

  /* we don't notify until the grid is focused */
  if (self->priv->focused == FALSE)
    return;

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

  rvgrid = dynamic_cast<ResultViewGrid*>(object);

  result_list = rvgrid->GetResultList();
  index = rvgrid->GetSelectedIndex();

  if (index >= 0)
  {
    result = &result_list[index];
    name = result->name;

    child = ATK_OBJECT(self->priv->result);
    self->priv->has_selection = TRUE;
    atk_object_set_name(child, name.c_str());
  }
  else
  {
    child = NULL;
    self->priv->has_selection = FALSE;
  }

  g_signal_emit_by_name(self, "active-descendant-changed", child);
  g_signal_emit_by_name(self, "selection-changed");
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean check_selection_on_idle ( gpointer  data) [static]

Definition at line 232 of file unity-rvgrid-accessible.cpp.

{
  check_selection(UNITY_RVGRID_ACCESSIBLE(data));

  return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

G_DEFINE_TYPE_WITH_CODE ( UnityRvgridAccessible  ,
unity_rvgrid_accessible  ,
NUX_TYPE_VIEW_ACCESSIBLE  ,
G_IMPLEMENT_INTERFACE(ATK_TYPE_SELECTION, atk_selection_interface_init  
)

Definition at line 66 of file unity-rvgrid-accessible.cpp.

{
  sigc::connection on_selection_change_connection;

  /* dummy selected result object */
  UnityResultAccessible* result;
  gboolean has_selection;
  gboolean focused;
};
static void on_focus_event_cb ( AtkObject *  object,
gboolean  in,
gpointer  data 
) [static]

Definition at line 240 of file unity-rvgrid-accessible.cpp.

{
  UnityRvgridAccessible* self = NULL;

  g_return_if_fail(UNITY_IS_RVGRID_ACCESSIBLE(data));

  self = UNITY_RVGRID_ACCESSIBLE(data);
  self->priv->focused = in;

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

Here is the call graph for this function:

Here is the caller graph for this function:

static void on_selection_change_cb ( UnityRvgridAccessible *  self) [static]

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

{
  check_selection(self);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void search_for_label ( UnityRvgridAccessible *  self) [static]

Definition at line 194 of file unity-rvgrid-accessible.cpp.

{
  AtkObject* label_accessible = NULL;
  nux::Object* nux_object = NULL;
  unity::PlacesGroup* group = NULL;
  AtkObject* iter = NULL;
  nux::StaticCairoText* label = NULL;

  /* Search for the places group */
  for (iter = atk_object_get_parent(ATK_OBJECT(self)); iter != NULL;
       iter = atk_object_get_parent(iter))
  {
    if (UNITY_IS_PLACES_GROUP_ACCESSIBLE(iter))
      break;
  }
  if (iter == NULL)
    return;

  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(iter));
  group = dynamic_cast<unity::PlacesGroup*>(nux_object);

  if (group == NULL)
    return;

  label = group->GetLabel();

  label_accessible = unity_a11y_get_accessible(label);

  if (label_accessible == NULL)
    return;

  /* FIXME: I had a froze using relations, require further
     investigation, meanwhile setting directly the name can do the
     work*/
  atk_object_set_name(ATK_OBJECT(self), atk_object_get_name(label_accessible));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void unity_rvgrid_accessible_class_init ( UnityRvgridAccessibleClass *  klass) [static]

Definition at line 85 of file unity-rvgrid-accessible.cpp.

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

  /* GObject */
  gobject_class->finalize = unity_rvgrid_accessible_finalize;

  /* AtkObject */
  atk_class->get_n_children = unity_rvgrid_accessible_get_n_children;
  atk_class->ref_child = unity_rvgrid_accessible_ref_child;
  atk_class->initialize = unity_rvgrid_accessible_initialize;
  atk_class->ref_state_set = unity_rvgrid_accessible_ref_state_set;

  g_type_class_add_private(gobject_class, sizeof(UnityRvgridAccessiblePrivate));
}

Here is the call graph for this function:

static void unity_rvgrid_accessible_finalize ( GObject *  object) [static]

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

{
  UnityRvgridAccessible* self = UNITY_RVGRID_ACCESSIBLE(object);

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

  if (self->priv->result != NULL)
  {
    g_object_unref(self->priv->result);
    self->priv->result = NULL;
  }

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

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

Here is the caller graph for this function:

static gint unity_rvgrid_accessible_get_n_children ( AtkObject *  obj) [static]

Definition at line 289 of file unity-rvgrid-accessible.cpp.

{
  g_return_val_if_fail(UNITY_IS_RVGRID_ACCESSIBLE(obj), 0);

  /* we have the state MANAGES_DESCENDANT, clients should not ask for
     the children, and just taking care of the relevant signals. So we
     just don't expose the children */
  return 0;
}

Here is the caller graph for this function:

static gint unity_rvgrid_accessible_get_selection_count ( AtkSelection *  selection) [static]

Definition at line 370 of file unity-rvgrid-accessible.cpp.

{
  UnityRvgridAccessible* self = NULL;

  g_return_val_if_fail(UNITY_IS_RVGRID_ACCESSIBLE(selection), 0);

  self = UNITY_RVGRID_ACCESSIBLE(selection);

  if (self->priv->has_selection)
    return 0;
  else
    return 1;
}

Here is the caller graph for this function:

static void unity_rvgrid_accessible_init ( UnityRvgridAccessible *  self) [static]

Definition at line 103 of file unity-rvgrid-accessible.cpp.

{
  UnityRvgridAccessiblePrivate* priv =
    UNITY_RVGRID_ACCESSIBLE_GET_PRIVATE(self);

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

Definition at line 257 of file unity-rvgrid-accessible.cpp.

{
  UnityRvgridAccessible* self = NULL;
  ResultViewGrid* rvgrid = NULL;
  nux::Object* nux_object = NULL;

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

  atk_object_set_role(accessible, ATK_ROLE_TOOL_BAR);

  self = UNITY_RVGRID_ACCESSIBLE(accessible);
  nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));

  rvgrid = dynamic_cast<ResultViewGrid*>(nux_object);

  if (rvgrid == NULL)
    return;

  self->priv->on_selection_change_connection =
    rvgrid->selection_change.connect(sigc::bind(sigc::ptr_fun(on_selection_change_cb), self));

  g_signal_connect(self, "focus-event",
                   G_CALLBACK(on_focus_event_cb), self);

  self->priv->result = UNITY_RESULT_ACCESSIBLE(unity_result_accessible_new());
  atk_object_set_parent(ATK_OBJECT(self->priv->result), ATK_OBJECT(self));

  search_for_label(self);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 385 of file unity-rvgrid-accessible.cpp.

{
  UnityRvgridAccessible* self = NULL;

  g_return_val_if_fail(UNITY_IS_RVGRID_ACCESSIBLE(selection), FALSE);

  self = UNITY_RVGRID_ACCESSIBLE(selection);

  if (self->priv->has_selection && i == 0)
    return TRUE;
  else
    return FALSE;
}

Here is the caller graph for this function:

AtkObject* unity_rvgrid_accessible_new ( nux::Object *  object)

Definition at line 130 of file unity-rvgrid-accessible.cpp.

{
  AtkObject* accessible = NULL;

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

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

  atk_object_initialize(accessible, object);

  return accessible;
}

Here is the caller graph for this function:

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

Definition at line 300 of file unity-rvgrid-accessible.cpp.

{
  g_return_val_if_fail(UNITY_IS_RVGRID_ACCESSIBLE(obj), NULL);

  /* we have the state MANAGES_DESCENDANT, clients should not ask for
     the children, and just taking care of the relevant signals. So we
     just don't expose the children */
  return NULL;
}

Here is the caller graph for this function:

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

Definition at line 354 of file unity-rvgrid-accessible.cpp.

{
  UnityRvgridAccessible* self = NULL;

  g_return_val_if_fail(UNITY_IS_RVGRID_ACCESSIBLE(selection), NULL);

  self = UNITY_RVGRID_ACCESSIBLE(selection);

  if (self->priv->has_selection)
    return ATK_OBJECT(g_object_ref(self->priv->result));
  else
    return NULL;
}

Here is the caller graph for this function:

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

Definition at line 312 of file unity-rvgrid-accessible.cpp.

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

  g_return_val_if_fail(UNITY_IS_RVGRID_ACCESSIBLE(obj), NULL);

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

  atk_state_set_add_state(state_set, ATK_STATE_MANAGES_DESCENDANTS);

  return state_set;
}

Here is the call graph for this function:

Here is the caller graph for this function: