Example #1
0
/**
 * Wrapper for atk_state_set_or_sets().
 */
static PyObject*
_atkstateset_or_sets (PyAtkStateSet *self, PyObject *args)
{
    PyObject *val;
    AtkStateSet *result;
    PyAtkStateSet *retval;

    debug ("_atkstateset_or_sets\n");

    if (!PyArg_ParseTuple (args, "O:or_sets", &val))
        return NULL;

    if (!PyObject_TypeCheck (val, &PyAtkStateSet_Type))
    {
        PyErr_SetString (PyExc_TypeError, "parameter must be an AtkStateSet");
        return NULL;
    }

    result = atk_state_set_or_sets (ATKSTATESET (self), ATKSTATESET (val));
    if (result)
    {
        retval = PyObject_New (PyAtkStateSet, &PyAtkStateSet_Type);
        retval->obj = result;
        return (PyObject *) retval;
    }
    Py_RETURN_NONE;
}
Example #2
0
/* page accessible's state set is a copy ev-view accessible's state
 * set but removing ATK_STATE_SHOWING if the page is not on screen and
 * ATK_STATE_FOCUSED if it is not the relevant page. */
static AtkStateSet *
ev_page_accessible_ref_state_set (AtkObject *accessible)
{
	AtkStateSet *state_set;
	AtkStateSet *copy_set;
	AtkStateSet *view_accessible_state_set;
	EvPageAccessible *self;
	EvView *view;
	gint relevant_page;

	g_return_val_if_fail (EV_IS_PAGE_ACCESSIBLE (accessible), NULL);
	self = EV_PAGE_ACCESSIBLE (accessible);
	view = ev_page_accessible_get_view (self);

	state_set = ATK_OBJECT_CLASS (ev_page_accessible_parent_class)->ref_state_set (accessible);
	atk_state_set_clear_states (state_set);

	view_accessible_state_set = atk_object_ref_state_set (ATK_OBJECT (self->priv->view_accessible));
	copy_set = atk_state_set_or_sets (state_set, view_accessible_state_set);

	if (self->priv->page >= view->start_page && self->priv->page <= view->end_page)
		atk_state_set_add_state (copy_set, ATK_STATE_SHOWING);
	else
		atk_state_set_remove_state (copy_set, ATK_STATE_SHOWING);

	relevant_page = ev_view_accessible_get_relevant_page (self->priv->view_accessible);
	if (atk_state_set_contains_state (view_accessible_state_set, ATK_STATE_FOCUSED) &&
	    self->priv->page == relevant_page)
		atk_state_set_add_state (copy_set, ATK_STATE_FOCUSED);
	else
		atk_state_set_remove_state (copy_set, ATK_STATE_FOCUSED);

	relevant_page = ev_view_accessible_get_relevant_page (self->priv->view_accessible);
	if (atk_state_set_contains_state (view_accessible_state_set, ATK_STATE_FOCUSED) &&
	    self->priv->page == relevant_page)
		atk_state_set_add_state (copy_set, ATK_STATE_FOCUSED);
	else
		atk_state_set_remove_state (copy_set, ATK_STATE_FOCUSED);

	g_object_unref (state_set);
	g_object_unref (view_accessible_state_set);

	return copy_set;
}
static AtkStateSet *
gtk_notebook_page_accessible_ref_state_set (AtkObject *accessible)
{
  AtkStateSet *state_set, *label_state_set, *merged_state_set;
  AtkObject *atk_label;
  GtkWidget *label;

  state_set = ATK_OBJECT_CLASS (_gtk_notebook_page_accessible_parent_class)->ref_state_set (accessible);

  label = get_label_from_notebook_page (GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible));
  if (label)
    {
      atk_label = gtk_widget_get_accessible (label);
      label_state_set = atk_object_ref_state_set (atk_label);
      merged_state_set = atk_state_set_or_sets (state_set, label_state_set);
      g_object_unref (label_state_set);
      g_object_unref (state_set);
    }
  else
    {
      AtkObject *child;

      child = atk_object_ref_accessible_child (accessible, 0);
      if (!child)
        return state_set;

      merged_state_set = state_set;
      state_set = atk_object_ref_state_set (child);
      if (atk_state_set_contains_state (state_set, ATK_STATE_VISIBLE))
        {
          atk_state_set_add_state (merged_state_set, ATK_STATE_VISIBLE);
          if (atk_state_set_contains_state (state_set, ATK_STATE_ENABLED))
              atk_state_set_add_state (merged_state_set, ATK_STATE_ENABLED);
          if (atk_state_set_contains_state (state_set, ATK_STATE_SHOWING))
              atk_state_set_add_state (merged_state_set, ATK_STATE_SHOWING);

        }
      g_object_unref (state_set);
      g_object_unref (child);
    }
  return merged_state_set;
}
Example #4
0
static AtkStateSet*
gail_notebook_page_ref_state_set (AtkObject *accessible)
{
  AtkStateSet *state_set, *label_state_set, *merged_state_set;
  AtkObject *atk_label;

  g_return_val_if_fail (GAIL_NOTEBOOK_PAGE (accessible), NULL);

  state_set = ATK_OBJECT_CLASS (gail_notebook_page_parent_class)->ref_state_set (accessible);

  atk_label = _gail_notebook_page_get_tab_label (GAIL_NOTEBOOK_PAGE (accessible));
  if (atk_label)
    {
      label_state_set = atk_object_ref_state_set (atk_label);
      merged_state_set = atk_state_set_or_sets (state_set, label_state_set);
      g_object_unref (label_state_set);
      g_object_unref (state_set);
    }
  else
    {
      AtkObject *child;

      child = atk_object_ref_accessible_child (accessible, 0);
      gail_return_val_if_fail (child, state_set);

      merged_state_set = state_set;
      state_set = atk_object_ref_state_set (child);
      if (atk_state_set_contains_state (state_set, ATK_STATE_VISIBLE))
        {
          atk_state_set_add_state (merged_state_set, ATK_STATE_VISIBLE);
          if (atk_state_set_contains_state (state_set, ATK_STATE_ENABLED))
              atk_state_set_add_state (merged_state_set, ATK_STATE_ENABLED);
          if (atk_state_set_contains_state (state_set, ATK_STATE_SHOWING))
              atk_state_set_add_state (merged_state_set, ATK_STATE_SHOWING);

        } 
      g_object_unref (state_set);
      g_object_unref (child);
    }
  return merged_state_set;
}
Example #5
0
static VALUE
rg_or(VALUE self, VALUE compare_set)
{
    return GOBJ2RVAL(atk_state_set_or_sets(_SELF(self), _SELF(compare_set)));
}
Example #6
0
static gboolean
test_state_set (void)
{
  AtkStateSet *state_set1, *state_set2, *state_set3;
  AtkStateType state_array[3];
  gboolean b_val;

  state_set1 = atk_state_set_new ();

  b_val = atk_state_set_is_empty (state_set1);  
  if (b_val)
  {
    g_print ("New state set is not empty\n");
    return FALSE;
  }

  b_val = atk_state_set_add_state (state_set1, ATK_STATE_ACTIVE);
  if (!b_val)
  {
    g_print ("Adding new state set failed\n");
    return FALSE;
  }

  b_val = atk_state_set_is_empty (state_set1);  
  if (!b_val)
  {
    g_print ("New state set is empty when it should not be\n");
    return FALSE;
  }

  b_val = atk_state_set_add_state (state_set1, ATK_STATE_ACTIVE);
  if (b_val)
  {
    g_print ("Adding new state set succeeded when it should not have\n");
    return FALSE;
  }

  state_array[0] = ATK_STATE_ACTIVE;
  state_array[1] = ATK_STATE_VISIBLE;
  state_array[2] = ATK_STATE_BUSY;
  atk_state_set_add_states (state_set1, state_array, 3);

  b_val = atk_state_set_contains_state (state_set1, ATK_STATE_ACTIVE);
  if (!b_val)
  {
    g_print ("Contains state failed for ATK_STATE_ACTIVE but should not have\n");
    return FALSE;
  }
 
  b_val = atk_state_set_contains_state (state_set1, ATK_STATE_VISIBLE);
  if (!b_val)
  {
    g_print ("Contains state failed for ATK_STATE_VISIBLE but should not have\n");
    return FALSE;
  }
 
  b_val = atk_state_set_contains_state (state_set1, ATK_STATE_BUSY);
  if (!b_val)
  {
    g_print ("Contains state failed for ATK_STATE_BUSY but should not have\n");
    return FALSE;
  }
 
  b_val = atk_state_set_contains_state (state_set1, ATK_STATE_VERTICAL);
  if (b_val)
  {
    g_print ("Contains state succeeded for ATK_STATE_VERTICAL but should not have\n");
    return FALSE;
  }
 
  atk_state_set_remove_state (state_set1, ATK_STATE_BUSY);
  b_val = atk_state_set_contains_state (state_set1, ATK_STATE_BUSY);
  if (b_val)
  {
    g_print ("Contains state succeeded for ATK_STATE_BUSY but should not have\n");
    return FALSE;
  }
  b_val = atk_state_set_contains_state (state_set1, ATK_STATE_VISIBLE);
  if (!b_val)
  {
    g_print ("Contains state failed for ATK_STATE_VISIBLE but should not have\n");
    return FALSE;
  }

  b_val = atk_state_set_contains_states (state_set1, state_array, 3);
  if (b_val)
  {
    g_print ("Contains states succeeded should not have\n");
    return FALSE;
  }

  b_val = atk_state_set_contains_states (state_set1, state_array, 2);
  if (!b_val)
  {
    g_print ("Contains states failed should not have\n");
    return FALSE;
  }

  state_array[0] = ATK_STATE_SINGLE_LINE;
  state_array[1] = ATK_STATE_VISIBLE;
  state_array[2] = ATK_STATE_VERTICAL;
 
  state_set2 = atk_state_set_new();
  atk_state_set_add_states (state_set2, state_array, 3);

  state_set3 = atk_state_set_and_sets (state_set1, state_set2);
  b_val = atk_state_set_contains_state (state_set3, ATK_STATE_VISIBLE);
  if (!b_val)
  {
    g_print ("Contains state failed for ATK_STATE_VISIBLE after and but should not have\n");
    return FALSE;
  }
  b_val = atk_state_set_contains_state (state_set3, ATK_STATE_BUSY);
  if (b_val)
  {
    g_print ("Contains state succeeded for ATK_STATE_BUSY after and but should not have\n");
    return FALSE;
  }
  g_object_unref (state_set3);

  atk_state_set_remove_state (state_set1, ATK_STATE_VISIBLE);
  state_set3 = atk_state_set_and_sets (state_set1, state_set2);
  if (state_set3)
  {
    g_print ("state_set 3 is not NULL after and but should be\n");
    return FALSE;
  }
 
  state_set3 = atk_state_set_or_sets (state_set1, state_set2);
  b_val = atk_state_set_contains_state (state_set3, ATK_STATE_VISIBLE);
  if (!b_val)
  {
    g_print ("Contains state failed for ATK_STATE_VISIBLE after or but should not have\n");
    return FALSE;
  }

  b_val = atk_state_set_contains_state (state_set3, ATK_STATE_INVALID);
  if (b_val)
  {
    g_print ("Contains state succeeded for ATK_STATE_INVALID after or but should not have\n");
    return FALSE;
  }
  g_object_unref (state_set3);

  b_val = atk_state_set_add_state (state_set1, ATK_STATE_VISIBLE);
  if (!b_val)
  {
    g_print ("Adding new state set failed\n");
    return FALSE;
  }
  state_set3 = atk_state_set_xor_sets (state_set1, state_set2);
  b_val = atk_state_set_contains_state (state_set3, ATK_STATE_VISIBLE);
  if (b_val)
  {
    g_print ("Contains state succeeded for ATK_STATE_VISIBLE after xor but should not have\n");
    return FALSE;
  }

  b_val = atk_state_set_contains_state (state_set3, ATK_STATE_ACTIVE);
  if (!b_val)
  {
    g_print ("Contains state failed for ATK_STATE_ACTIVE after xor but should not have\n");
    return FALSE;
  }

  atk_state_set_clear_states (state_set1);
  b_val = atk_state_set_contains_state (state_set1, ATK_STATE_ACTIVE);
  if (b_val)
  {
    g_print ("Contains state succeeded for ATK_STATE_ACTIVE but should not have\n");
    return FALSE;
  }

  g_object_unref (state_set1);
  g_object_unref (state_set2);
  g_object_unref (state_set3);
  return TRUE;

}