static DBusMessage *
impl_GetAttributes (DBusConnection * bus, DBusMessage * message,
                    void *user_data)
{
  AtkDocument *document = (AtkDocument *) user_data;
  DBusMessage *reply;
  AtkAttributeSet *attributes;
  DBusMessageIter iter;

  g_return_val_if_fail (ATK_IS_DOCUMENT (user_data),
                        droute_not_yet_handled_error (message));

  attributes = atk_document_get_attributes (document);

  reply = dbus_message_new_method_return (message);
  if (reply)
    {
      dbus_message_iter_init_append (reply, &iter);
      spi_object_append_attribute_set (&iter, attributes);
    }

  if (attributes)
    atk_attribute_set_free (attributes);
  return reply;
}
Example #2
0
static void
dump_text_attributes (GString         *string,
                      gint             depth,
                      const gchar     *name,
                      AtkAttributeSet *attributes)
{
  GSList *l;
  AtkAttribute *attr;
  const gchar *value;

  if (attributes == NULL)
    return;

  attributes = g_slist_sort (attributes, compare_attr);

  for (l = attributes; l; l = l->next)
    {
      attr = l->data;
      /* don't dump values that depend on the environment */
      if (strcmp (attr->name, "family-name") == 0 ||
          strcmp (attr->name, "size") == 0 ||
          strcmp (attr->name, "weight") == 0 ||
          strcmp (attr->name, "stretch") == 0 ||
          strcmp (attr->name, "variant") == 0 ||
          strcmp (attr->name, "style") == 0 ||
          strcmp (attr->name, "language") == 0 ||
          strcmp (attr->name, "fg-color") == 0 ||
          strcmp (attr->name, "bg-color") == 0 ||
          strcmp (attr->name, "direction") == 0)
        value = "<omitted>";
      else
        value = attr->value;

      if (name)
        {
          /* first time this loop is run */
          g_string_append_printf (string, "%*s%s: %s: %s\n", depth, "", name, attr->name, value);
          depth += strlen (name) + 2;
          name = NULL;
        }
      else
        {
          /* every other time */
          g_string_append_printf (string, "%*s%s: %s\n", depth, "", attr->name, value);
        }
    }

  atk_attribute_set_free (attributes);
}
Example #3
0
static String getAtkAttributeSetAsString(AtkObject* accessible)
{
    StringBuilder builder;

    AtkAttributeSet* attributeSet = atk_object_get_attributes(accessible);
    for (AtkAttributeSet* attributes = attributeSet; attributes; attributes = attributes->next) {
        AtkAttribute* attribute = static_cast<AtkAttribute*>(attributes->data);
        GOwnPtr<gchar> attributeData(g_strconcat(attribute->name, ":", attribute->value, NULL));
        builder.append(attributeData.get());
        if (attributes->next)
            builder.append(", ");
    }
    atk_attribute_set_free(attributeSet);

    return builder.toString();
}
Example #4
0
static String getAttributeSetValueForId(AtkObject* accessible, const char* id)
{
    const char* attributeValue = 0;
    AtkAttributeSet* attributeSet = atk_object_get_attributes(accessible);
    for (AtkAttributeSet* attributes = attributeSet; attributes; attributes = attributes->next) {
        AtkAttribute* atkAttribute = static_cast<AtkAttribute*>(attributes->data);
        if (!strcmp(atkAttribute->name, id)) {
            attributeValue = atkAttribute->value;
            break;
        }
    }

    String atkAttributeValue = String::fromUTF8(attributeValue);
    atk_attribute_set_free(attributeSet);

    return atkAttributeValue;
}
Example #5
0
static dbus_bool_t
impl_get_Attributes (DBusMessageIter * iter, void *user_data)
{
  DBusMessageIter iter_variant;
  AtkObject *object = (AtkObject *) user_data;
  AtkAttributeSet *attributes;

  g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE);

  attributes = atk_object_get_attributes (object);

  dbus_message_iter_open_container (iter, DBUS_TYPE_VARIANT, "a{ss}", &iter_variant);
  spi_object_append_attribute_set (&iter_variant, attributes);
  dbus_message_iter_close_container (iter, &iter_variant);

  atk_attribute_set_free (attributes);

  return TRUE;
}
Example #6
0
static DBusMessage *
impl_GetAttributes (DBusConnection * bus,
                    DBusMessage * message, void *user_data)
{
  AtkObject *object = (AtkObject *) user_data;
  AtkAttributeSet *attributes;
  DBusMessage *reply = NULL;
  DBusMessageIter iter;

  g_return_val_if_fail (ATK_IS_OBJECT (user_data),
                        droute_not_yet_handled_error (message));

  attributes = atk_object_get_attributes (object);

  reply = dbus_message_new_method_return (message);
  dbus_message_iter_init_append (reply, &iter);
  spi_object_append_attribute_set (&iter, attributes);

  atk_attribute_set_free (attributes);

  return reply;
}
Example #7
0
static Accessibility_AttributeSet*
impl_getAttributes (PortableServer_Servant servant,
		    CORBA_Environment *ev){
  
  AtkDocument *document = get_document_from_servant (servant);
  AtkAttributeSet *attributes = NULL;
  AtkAttribute *attr = NULL;
  Accessibility_AttributeSet *retval;
  gint n_attributes = 0;
  gint i;
  gchar *concat_str;
  
  g_return_val_if_fail (document != NULL, NULL);
  
  attributes = atk_document_get_attributes (document);

  /* according to atkobject.h, AtkAttributeSet is a GSList */
  if (attributes)
    n_attributes = g_slist_length (attributes);
    
  retval = CORBA_sequence_CORBA_string__alloc ();
  retval->_length = retval->_maximum = n_attributes;
  retval->_buffer = CORBA_sequence_CORBA_string_allocbuf (n_attributes);
  CORBA_sequence_set_release (retval, CORBA_TRUE);
  
  for (i = 0; i < n_attributes; ++i)
  {
      attr = g_slist_nth_data (attributes, i);
      concat_str = g_strconcat (attr->name, ":", attr->value, NULL);
      retval->_buffer [i] = CORBA_string_dup (concat_str);
      g_free (concat_str);
  }
    
  atk_attribute_set_free (attributes);

  return retval;
  
}
void my_atk_text_free_default_attributes(MyAtkText *text)
{
    atk_attribute_set_free(text->default_attributes);
    text->default_attributes = NULL;
}
void range_free(Range* range)
{
    atk_attribute_set_free(range->attributeSet);
    g_free(range);
}
//others functions
//sets default attributes
void my_atk_text_set_default_attributes(MyAtkText* text, AtkAttributeSet *set)
{
    atk_attribute_set_free(text->default_attributes);
    text->default_attributes = attribute_set_copy(set);
    g_signal_emit_by_name(text, "text-attributes-changed");
}