Esempio n. 1
0
/**
 * atk_relation_set_add:
 * @set: an #AtkRelationSet
 * @relation: an #AtkRelation
 *
 * Add a new relation to the current relation set if it is not already
 * present.
 * This function ref's the AtkRelation so the caller of this function
 * should unref it to ensure that it will be destroyed when the AtkRelationSet
 * is destroyed.
 **/
void
atk_relation_set_add (AtkRelationSet *set,
                      AtkRelation    *relation)
{
  AtkRelationType relationship;

  g_return_if_fail (ATK_IS_RELATION_SET (set));
  g_return_if_fail (relation != NULL);

  if (set->relations == NULL)
  {
    set->relations = g_ptr_array_new ();
  }

  relationship = atk_relation_get_relation_type (relation);
  if (!atk_relation_set_contains (set, relationship))
  {
    g_ptr_array_add (set->relations, relation);
    g_object_ref (relation);
  }
  else
  {
    AtkRelation *exist_relation;
    gint i;
    exist_relation = atk_relation_set_get_relation_by_type (set, relationship);
    for (i = 0; i < relation->target->len; i++)
    {
      AtkObject *target = g_ptr_array_index(relation->target, i);
      atk_relation_add_target (exist_relation, target); 
    }
  }
}
Esempio n. 2
0
/**
 * atk_relation_set_remove:
 * @set: an #AtkRelationSet
 * @relation: an #AtkRelation
 *
 * Removes a relation from the relation set.
 * This function unref's the #AtkRelation so it will be deleted unless there
 * is another reference to it.
 **/
void
atk_relation_set_remove (AtkRelationSet *set,
                         AtkRelation    *relation)
{
  GPtrArray *array_item;
  AtkRelationType relationship;

  g_return_if_fail (ATK_IS_RELATION_SET (set));

  array_item = set->relations;
  if (array_item == NULL)
    return;

  if (g_ptr_array_remove (array_item, relation))
  {
    g_object_unref (relation);
  }
  else
  {
    relationship = atk_relation_get_relation_type (relation);
    if (atk_relation_set_contains (set, relationship))
    {
      AtkRelation *exist_relation;
      gint i;
      exist_relation = atk_relation_set_get_relation_by_type (set, relationship);
      for (i = 0; i < relation->target->len; i++)
      {
        AtkObject *target = g_ptr_array_index(relation->target, i);
        atk_relation_remove_target (exist_relation, target);
      }
    }
  }
}
Esempio n. 3
0
static void
gtk_cell_accessible_object_finalize (GObject *obj)
{
  AtkRelationSet *relation_set;
  AtkRelation *relation;
  GPtrArray *target;
  gpointer target_object;
  gint i;

  relation_set = atk_object_ref_relation_set (ATK_OBJECT (obj));
  if (ATK_IS_RELATION_SET (relation_set))
    {
      relation = atk_relation_set_get_relation_by_type (relation_set,
                                                        ATK_RELATION_NODE_CHILD_OF);
      if (relation)
        {
          target = atk_relation_get_target (relation);
          for (i = 0; i < target->len; i++)
            {
              target_object = g_ptr_array_index (target, i);
              if (GTK_IS_CELL_ACCESSIBLE (target_object))
                g_object_unref (target_object);
            }
        }
      g_object_unref (relation_set);
    }
  G_OBJECT_CLASS (_gtk_cell_accessible_parent_class)->finalize (obj);
}
Esempio n. 4
0
AtkRelationSet *
refRelationSetCB(AtkObject *aAtkObj)
{
    AtkRelationSet *relation_set = nsnull;
    relation_set = ATK_OBJECT_CLASS(parent_class)->ref_relation_set(aAtkObj);

    nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
    if (!accWrap) {
        return relation_set;
    }

    AtkRelation* relation;

    PRUint32 relationType[] = {nsIAccessibleRelation::RELATION_LABELLED_BY,
                               nsIAccessibleRelation::RELATION_LABEL_FOR,
                               nsIAccessibleRelation::RELATION_NODE_CHILD_OF,
                               nsIAccessibleRelation::RELATION_CONTROLLED_BY,
                               nsIAccessibleRelation::RELATION_CONTROLLER_FOR,
                               nsIAccessibleRelation::RELATION_EMBEDS,
                               nsIAccessibleRelation::RELATION_FLOWS_TO,
                               nsIAccessibleRelation::RELATION_FLOWS_FROM,
                               nsIAccessibleRelation::RELATION_DESCRIBED_BY,
                               nsIAccessibleRelation::RELATION_DESCRIPTION_FOR,
                              };

    for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(relationType); i++) {
        relation = atk_relation_set_get_relation_by_type(relation_set, static_cast<AtkRelationType>(relationType[i]));
        if (relation) {
            atk_relation_set_remove(relation_set, relation);
        }

        nsCOMPtr<nsIAccessibleRelation> geckoRelation;
        nsresult rv = accWrap->GetRelationByType(relationType[i],
                      getter_AddRefs(geckoRelation));
        if (NS_SUCCEEDED(rv) && geckoRelation) {
            PRUint32 targetsCount = 0;
            geckoRelation->GetTargetsCount(&targetsCount);
            if (targetsCount) {
                AtkObject** accessible_array = new AtkObject*[targetsCount];
                for (PRUint32 index = 0; index < targetsCount; index++) {
                    nsCOMPtr<nsIAccessible> geckoTarget;
                    geckoRelation->GetTarget(index, getter_AddRefs(geckoTarget));
                    accessible_array[index] =
                        nsAccessibleWrap::GetAtkObject(geckoTarget);
                }

                relation = atk_relation_new(accessible_array, targetsCount,
                                            static_cast<AtkRelationType>(relationType[i]));
                atk_relation_set_add(relation_set, relation);
                g_object_unref(relation);

                delete [] accessible_array;
            }
        }
    }

    return relation_set;
}
Esempio n. 5
0
static G_CONST_RETURN gchar*
gail_combo_box_get_keybinding (AtkAction *action,
		                    gint      i)
{
  GailComboBox *combo_box;
  gchar *return_value = NULL;
  switch (i)
  {
     case 0:
      {
	  GtkWidget *widget;
	  GtkWidget *label;
	  AtkRelationSet *set;
	  AtkRelation *relation;
	  GPtrArray *target;
	  gpointer target_object;
	  guint key_val;

	  combo_box = GAIL_COMBO_BOX (action);
	  widget = GTK_ACCESSIBLE (combo_box)->widget;
	  if (widget == NULL)
             return NULL;
	  set = atk_object_ref_relation_set (ATK_OBJECT (action));
	  if (!set)
             return NULL;
	  label = NULL;
	  relation = atk_relation_set_get_relation_by_type (set, ATK_RELATION_LABELLED_BY);
	  if (relation)
	  {
	     target = atk_relation_get_target (relation);
	     target_object = g_ptr_array_index (target, 0);
	     if (GTK_IS_ACCESSIBLE (target_object))
	     {
	        label = GTK_ACCESSIBLE (target_object)->widget;
	     }
	  }
	  g_object_unref (set);
	  if (GTK_IS_LABEL (label))
	  {
             key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label));
	     if (key_val != GDK_VoidSymbol)
             return_value = gtk_accelerator_name (key_val, GDK_MOD1_MASK);
	  }
	   g_free (combo_box->press_keybinding);
	   combo_box->press_keybinding = return_value;
	   break;
       }
    default:
	   break;
  }
  return return_value;
}
Esempio n. 6
0
static const gchar *
gtk_combo_box_accessible_get_keybinding (AtkAction *action,
        gint       i)
{
    GtkComboBoxAccessible *combo_box;
    GtkWidget *widget;
    GtkWidget *label;
    AtkRelationSet *set;
    AtkRelation *relation;
    GPtrArray *target;
    gpointer target_object;
    guint key_val;
    gchar *return_value = NULL;

    if (i != 0)
        return NULL;

    combo_box = GTK_COMBO_BOX_ACCESSIBLE (action);
    widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (combo_box));
    if (widget == NULL)
        return NULL;

    set = atk_object_ref_relation_set (ATK_OBJECT (action));
    if (set == NULL)
        return NULL;

    label = NULL;
    relation = atk_relation_set_get_relation_by_type (set, ATK_RELATION_LABELLED_BY);
    if (relation)
    {
        target = atk_relation_get_target (relation);
        target_object = g_ptr_array_index (target, 0);
        label = gtk_accessible_get_widget (GTK_ACCESSIBLE (target_object));
    }
    g_object_unref (set);
    if (GTK_IS_LABEL (label))
    {
        key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label));
        if (key_val != GDK_KEY_VoidSymbol)
            return_value = gtk_accelerator_name (key_val, GDK_MOD1_MASK);
    }

    return return_value;
}
Esempio n. 7
0
static AtkRelationSet*
gail_window_ref_relation_set (AtkObject *obj)
{
  GtkWidget *widget;
  AtkRelationSet *relation_set;
  AtkObject *array[1];
  AtkRelation* relation;
  GtkWidget *current_widget;

  gail_return_val_if_fail (GAIL_IS_WIDGET (obj), NULL);

  widget = GTK_ACCESSIBLE (obj)->widget;
  if (widget == NULL)
    /*
     * State is defunct
     */
    return NULL;

  relation_set = ATK_OBJECT_CLASS (gail_window_parent_class)->ref_relation_set (obj);

  if (atk_object_get_role (obj) == ATK_ROLE_TOOL_TIP)
    {
      relation = atk_relation_set_get_relation_by_type (relation_set, ATK_RELATION_POPUP_FOR);

      if (relation)
        {
          atk_relation_set_remove (relation_set, relation);
        }
      if (gtk_widget_get_visible(widget) && gtk_tooltips_get_info_from_tip_window (GTK_WINDOW (widget), NULL, &current_widget))
        {
          array [0] = gtk_widget_get_accessible (current_widget);

          relation = atk_relation_new (array, 1, ATK_RELATION_POPUP_FOR);
          atk_relation_set_add (relation_set, relation);
          g_object_unref (relation);
        }
    }
  return relation_set;
}
Esempio n. 8
0
/**
 * atk_relation_set_add_relation_by_type:
 * @set: an #AtkRelationSet
 * @relationship: an #AtkRelationType
 * @target: an #AtkObject
 *
 * Add a new relation of the specified type with the specified target to 
 * the current relation set if the relation set does not contain a relation
 * of that type. If it is does contain a relation of that typea the target
 * is added to the relation.
 *
 * Since: ATK 1.9
 **/
void
atk_relation_set_add_relation_by_type (AtkRelationSet  *set,
                                       AtkRelationType relationship,
                                       AtkObject       *target)
{
  AtkRelation *relation;

  g_return_if_fail (ATK_IS_RELATION_SET (set));
  g_return_if_fail (ATK_IS_OBJECT (target));

  relation = atk_relation_set_get_relation_by_type (set,
                                                    relationship);
  if (relation)
    {
      atk_relation_add_target (relation, target);
    } 
  else 
    {
      /* the relation hasn't been created yet ... */
      relation = atk_relation_new (&target, 1, relationship);
      atk_relation_set_add (set, relation);
      g_object_unref(relation);
    }
}
Esempio n. 9
0
File: gailbutton.c Progetto: BYC/gtk
static G_CONST_RETURN gchar*
gail_button_get_keybinding (AtkAction *action,
                            gint      i)
{
  GailButton *button;
  gchar *return_value = NULL;

  button = GAIL_BUTTON (action);
  if (button->default_is_press)
    {
      if (i == 0)
        i = 1;
      else if (i == 1)
        i = 0;
    }
  switch (i)
    {
    case 0:
      {
        /*
         * We look for a mnemonic on the label
         */
        GtkWidget *widget;
        GtkWidget *label;
        guint key_val; 

        widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (button));
        if (widget == NULL)
          /*
           * State is defunct
           */
          return NULL;

        g_return_val_if_fail (GTK_IS_BUTTON (widget), NULL);

        label = get_label_from_button (widget, 0, FALSE);
        if (GTK_IS_LABEL (label))
          {
            key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label)); 
            if (key_val != GDK_KEY_VoidSymbol)
              return_value = gtk_accelerator_name (key_val, GDK_MOD1_MASK);
          }
        if (return_value == NULL)
          {
            /* Find labelled-by relation */
            AtkRelationSet *set;
            AtkRelation *relation;
            GPtrArray *target;
            gpointer target_object;

            set = atk_object_ref_relation_set (ATK_OBJECT (action));
            if (set)
              {
                relation = atk_relation_set_get_relation_by_type (set, ATK_RELATION_LABELLED_BY);
                if (relation)
                  {              
                    target = atk_relation_get_target (relation);
            
                    target_object = g_ptr_array_index (target, 0);
                    label = gtk_accessible_get_widget (GTK_ACCESSIBLE (target_object));
                  }
                g_object_unref (set);
              }

            if (GTK_IS_LABEL (label))
              {
                key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label)); 
                if (key_val != GDK_KEY_VoidSymbol)
                  return_value = gtk_accelerator_name (key_val, GDK_MOD1_MASK);
              }
          }
        g_free (button->click_keybinding);
        button->click_keybinding = return_value;
        break;
      }
    default:
      break;
    }
  return return_value; 
}