Exemplo n.º 1
0
double AccessibilityUIElement::minValue()
{
    GValue value = { 0, { { 0 } } };

    if (!ATK_IS_VALUE(m_element))
        return 0.0f;

    atk_value_get_minimum_value(ATK_VALUE(m_element), &value);

    if (G_VALUE_HOLDS_DOUBLE(&value))
        return g_value_get_double(&value);
    else if (G_VALUE_HOLDS_INT(&value))
        return static_cast<double>(g_value_get_int(&value));
    else
        return 0.0f;
}
Exemplo n.º 2
0
static void _value_change_handler (AtkObject   *obj,
                                   AtkPropertyValues   *values)
{
  const gchar *type_name = g_type_name (G_TYPE_FROM_INSTANCE (obj));
   GValue *value_back, val;

  value_back = &val;
    
  if (!ATK_IS_VALUE (obj)) { 
   	return;
  }

  if (strcmp (values->property_name, "accessible-value") == 0) {
	g_print ("_value_change_handler: Accessible Type: %s\n",
           type_name ? type_name : "NULL");
	if(G_VALUE_HOLDS_DOUBLE (&values->new_value))
    {
		g_print( "adjustment value changed : new value: %f\n", 
		g_value_get_double (&values->new_value));
 	}

	g_print("Now calling the AtkValue interface functions\n");

  	atk_value_get_current_value (ATK_VALUE(obj), value_back);
  	g_return_if_fail (G_VALUE_HOLDS_DOUBLE (value_back));
  	g_print ("atk_value_get_current_value returns %f\n",
			g_value_get_double (value_back)	);

  	atk_value_get_maximum_value (ATK_VALUE (obj), value_back);
  	g_return_if_fail (G_VALUE_HOLDS_DOUBLE (value_back));
  	g_print ("atk_value_get_maximum returns %f\n",
			g_value_get_double (value_back));

  	atk_value_get_minimum_value (ATK_VALUE (obj), value_back);
  	g_return_if_fail (G_VALUE_HOLDS_DOUBLE (value_back));
  	g_print ("atk_value_get_minimum returns %f\n", 
			g_value_get_double (value_back));
	
 
    }
  
}
Exemplo n.º 3
0
static void _set_values (AtkObject *obj) {

  GValue *value_back, val;
  static gint count = 0;
  gdouble double_value;

  value_back = &val;

  if(ATK_IS_VALUE(obj)) {
	/* Spin button also inherits the text interfaces from GailEntry. 
	 * Check when spin button recieves focus.
     */

	if(ATK_IS_TEXT(obj) && ATK_IS_EDITABLE_TEXT(obj)) {
		if(count == 0) {	
			gint x;
			gchar* text;
			count++;
			x = atk_text_get_character_count (ATK_TEXT (obj));
  			text = atk_text_get_text (ATK_TEXT (obj), 0, x);
			g_print("Text : %s\n", text);
			text = "5.7";
			atk_editable_text_set_text_contents(ATK_EDITABLE_TEXT(obj),text);
			g_print("Set text to %s\n",text);
			atk_value_get_current_value(ATK_VALUE(obj), value_back);
			g_return_if_fail (G_VALUE_HOLDS_DOUBLE (value_back));
			g_print("atk_value_get_current_value returns %f\n", 
				g_value_get_double( value_back));
			} 
	} else {
		memset (value_back, 0, sizeof (GValue));
		g_value_init (value_back, G_TYPE_DOUBLE);
		g_value_set_double (value_back, 10.0);	
		if (atk_value_set_current_value (ATK_VALUE (obj), value_back))
		{
 			double_value = g_value_get_double (value_back);
  			g_print("atk_value_set_current_value returns %f\n", 
			double_value);
		}
	}
  }
}
Exemplo n.º 4
0
void AXObjectCache::postPlatformNotification(AccessibilityObject* coreObject, AXNotification notification)
{
    AtkObject* axObject = coreObject->wrapper();
    if (!axObject)
        return;

    switch (notification) {
    case AXCheckedStateChanged:
        if (!coreObject->isCheckboxOrRadio())
            return;
        atk_object_notify_state_change(axObject, ATK_STATE_CHECKED, coreObject->isChecked());
        break;

    case AXSelectedChildrenChanged:
    case AXMenuListValueChanged:
        if (notification == AXMenuListValueChanged && coreObject->isMenuList()) {
            g_signal_emit_by_name(axObject, "focus-event", true);
            atk_object_notify_state_change(axObject, ATK_STATE_FOCUSED, true);
        }
        notifyChildrenSelectionChange(coreObject);
        break;

    case AXValueChanged:
        if (ATK_IS_VALUE(axObject)) {
            AtkPropertyValues propertyValues;
            propertyValues.property_name = "accessible-value";

            memset(&propertyValues.new_value,  0, sizeof(GValue));
            atk_value_get_current_value(ATK_VALUE(axObject), &propertyValues.new_value);

            g_signal_emit_by_name(ATK_OBJECT(axObject), "property-change::accessible-value", &propertyValues, NULL);
        }
        break;

    case AXInvalidStatusChanged:
        atk_object_notify_state_change(axObject, ATK_STATE_INVALID_ENTRY, coreObject->invalidStatus() != "false");
        break;

    default:
        break;
    }
}
Exemplo n.º 5
0
static void alterCurrentValue(PlatformUIElement element, int factor)
{
    if (!element || !ATK_IS_VALUE(element.get()))
        return;

    GValue currentValue = G_VALUE_INIT;
    atk_value_get_current_value(ATK_VALUE(element.get()), &currentValue);

    GValue increment = G_VALUE_INIT;
    atk_value_get_minimum_increment(ATK_VALUE(element.get()), &increment);

    GValue newValue = G_VALUE_INIT;
    g_value_init(&newValue, G_TYPE_DOUBLE);

    g_value_set_float(&newValue, g_value_get_float(&currentValue) + factor * g_value_get_float(&increment));
    atk_value_set_current_value(ATK_VALUE(element.get()), &newValue);

    g_value_unset(&newValue);
    g_value_unset(&increment);
    g_value_unset(&currentValue);
}
Exemplo n.º 6
0
static void
_do_test(AtkObject *obj)
{
   int child_count = 0;
   child_count = atk_object_get_n_accessible_children(obj);
   g_assert(child_count == 2);
   _printf("n_accessible_children - done\n");

   AtkStateSet *state_set = atk_object_ref_state_set(obj);
   gboolean v_contains = atk_state_set_contains_state(state_set,
                                                      ATK_STATE_VERTICAL);
   gboolean h_contains = atk_state_set_contains_state(state_set,
                                                      ATK_STATE_HORIZONTAL);
   g_object_unref(state_set);
   g_assert(v_contains || h_contains);
   _printf("ref_state_set - done\n");

   /*AtkValue iface tests*/
   g_assert(ATK_IS_VALUE(obj));
   GValue value = G_VALUE_INIT;
   double d_value;
   atk_value_get_maximum_value(ATK_VALUE(obj), &value);
   d_value = g_value_get_double(&value);
   g_assert(d_value == 1.0);
   atk_value_get_minimum_value(ATK_VALUE(obj), &value);
   d_value = g_value_get_double(&value);
   g_assert(d_value == 0.0);
   g_value_set_double(&value, 0.3);
   gboolean success = atk_value_set_current_value(ATK_VALUE(obj), &value);
   g_assert(success);
   atk_value_get_current_value(ATK_VALUE(obj), &value);
   g_assert(G_VALUE_HOLDS_DOUBLE(&value));
   d_value = g_value_get_double(&value);
   g_assert(d_value == 0.3);
   _printf("atk_value - done\n");

   eailu_test_atk_focus(obj, TRUE);
}
Exemplo n.º 7
0
void AXObjectCache::postPlatformNotification(AccessibilityObject* coreObject, AXNotification notification)
{
    AtkObject* axObject = coreObject->wrapper();
    if (!axObject)
        return;

    switch (notification) {
    case AXCheckedStateChanged:
        if (!coreObject->isCheckboxOrRadio() && !coreObject->isSwitch())
            return;
        atk_object_notify_state_change(axObject, ATK_STATE_CHECKED, coreObject->isChecked());
        break;

    case AXSelectedChildrenChanged:
    case AXMenuListValueChanged:
        // Accessible focus claims should not be made if the associated widget is not focused.
        if (notification == AXMenuListValueChanged && coreObject->isMenuList() && coreObject->isFocused()) {
            g_signal_emit_by_name(axObject, "focus-event", true);
            atk_object_notify_state_change(axObject, ATK_STATE_FOCUSED, true);
        }
        notifyChildrenSelectionChange(coreObject);
        break;

    case AXValueChanged:
        if (ATK_IS_VALUE(axObject)) {
            AtkPropertyValues propertyValues;
            propertyValues.property_name = "accessible-value";

            memset(&propertyValues.new_value,  0, sizeof(GValue));
#if ATK_CHECK_VERSION(2,11,92)
            double value;
            atk_value_get_value_and_text(ATK_VALUE(axObject), &value, nullptr);
            g_value_set_double(g_value_init(&propertyValues.new_value, G_TYPE_DOUBLE), value);
#else
            atk_value_get_current_value(ATK_VALUE(axObject), &propertyValues.new_value);
#endif

            g_signal_emit_by_name(ATK_OBJECT(axObject), "property-change::accessible-value", &propertyValues, NULL);
        }
        break;

    case AXInvalidStatusChanged:
        atk_object_notify_state_change(axObject, ATK_STATE_INVALID_ENTRY, coreObject->invalidStatus() != "false");
        break;

    case AXElementBusyChanged:
        atk_object_notify_state_change(axObject, ATK_STATE_BUSY, coreObject->isBusy());
        break;

    case AXCurrentChanged:
        atk_object_notify_state_change(axObject, ATK_STATE_ACTIVE, coreObject->currentState() != AccessibilityCurrentState::False);
        break;

    case AXRowExpanded:
        atk_object_notify_state_change(axObject, ATK_STATE_EXPANDED, true);
        break;

    case AXRowCollapsed:
        atk_object_notify_state_change(axObject, ATK_STATE_EXPANDED, false);
        break;

    case AXExpandedChanged:
        atk_object_notify_state_change(axObject, ATK_STATE_EXPANDED, coreObject->isExpanded());
        break;

    case AXDisabledStateChanged: {
        bool enabledState = coreObject->isEnabled();
        atk_object_notify_state_change(axObject, ATK_STATE_ENABLED, enabledState);
        atk_object_notify_state_change(axObject, ATK_STATE_SENSITIVE, enabledState);
        break;
    }

    case AXPressedStateChanged:
        atk_object_notify_state_change(axObject, ATK_STATE_PRESSED, coreObject->isPressed());
        break;

    case AXReadOnlyStatusChanged:
#if ATK_CHECK_VERSION(2,15,3)
        atk_object_notify_state_change(axObject, ATK_STATE_READ_ONLY, !coreObject->canSetValueAttribute());
#endif
        break;

    case AXRequiredStatusChanged:
        atk_object_notify_state_change(axObject, ATK_STATE_REQUIRED, coreObject->isRequired());
        break;

    case AXActiveDescendantChanged:
        if (AccessibilityObject* descendant = coreObject->activeDescendant())
            platformHandleFocusedUIElementChanged(nullptr, descendant->node());
        break;

    default:
        break;
    }
}
Exemplo n.º 8
0
SpiAccessible *
spi_accessible_construct (GType type, AtkObject *o)
{
    SpiAccessible *retval;
    CORBA_Environment ev;

    CORBA_exception_init (&ev);

    g_assert (o);
    g_assert (g_type_is_a (type, SPI_ACCESSIBLE_TYPE));

    if ((retval = g_hash_table_lookup (get_public_refs (), o)))
      {
        bonobo_object_ref (BONOBO_OBJECT (retval));
	return retval;
      }
    else
      {
        retval = g_object_new (type, NULL);
        spi_base_construct (SPI_BASE (retval), G_OBJECT(o));
      }
    
    g_hash_table_insert (get_public_refs (), o, retval);
    g_signal_connect (G_OBJECT (retval), "destroy",
		      G_CALLBACK (de_register_public_ref),
		      NULL);

    /* aggregate appropriate SPI interfaces based on ATK interfaces */
 
    if (ATK_IS_ACTION (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
		BONOBO_OBJECT (spi_action_interface_new (o)));
      }

    if (ATK_IS_COMPONENT (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_component_interface_new (o)));
      }

    if (ATK_IS_EDITABLE_TEXT (o))
      {
         bonobo_object_add_interface (bonobo_object (retval),
				      BONOBO_OBJECT(spi_editable_text_interface_new (o)));
      }

    else if (ATK_IS_TEXT (o))
       {
         bonobo_object_add_interface (bonobo_object (retval),
				      BONOBO_OBJECT (spi_text_interface_new (o)));
       }

    if (ATK_IS_HYPERTEXT (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_hypertext_interface_new (o)));
      }

    if (ATK_IS_IMAGE (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_image_interface_new (o)));
      }

    if (ATK_IS_SELECTION (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_selection_interface_new (o)));
      }

    if (ATK_IS_TABLE (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_table_interface_new (o)));
      }

    if (ATK_IS_VALUE (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_value_interface_new (o)));
      }

    if (ATK_IS_STREAMABLE_CONTENT (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_streamable_interface_new (o)));
      }
    if (ATK_IS_DOCUMENT (o)) /* We add collection interface to document */
      {

	   
	 SpiDocument *doc = spi_document_interface_new (o);
	 bonobo_object_add_interface (BONOBO_OBJECT (doc), 
				      BONOBO_OBJECT (spi_collection_interface_new (o)));

	 bonobo_object_add_interface (bonobo_object (retval),
					BONOBO_OBJECT (doc));
      }
    if (ATK_IS_HYPERLINK_IMPL (o))
      {
	  /* !!! the cast below is used instead of the ATK_HYPERLINK macro, since 
	   the object 'o' is not really a hyperlink, but is in fact an AtkHyperlinkImpl.
	   Ouch.  This works since it gets cast back to GObject, but it's nasty and needs
	   to be cleaned up.
	  */
	bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_hyperlink_new ((AtkHyperlink*)o)));
      }

    return retval;
}