static void gail_combo_real_initialize (AtkObject *obj, gpointer data) { GtkCombo *combo; GtkList *list; GList *slist; GailCombo *gail_combo; ATK_OBJECT_CLASS (gail_combo_parent_class)->initialize (obj, data); combo = GTK_COMBO (data); list = GTK_LIST (combo->list); slist = list->selection; gail_combo = GAIL_COMBO (obj); if (slist && slist->data) { gail_combo->old_selection = slist->data; } g_signal_connect (combo->list, "selection_changed", G_CALLBACK (gail_combo_selection_changed_gtk), data); atk_object_set_parent (gtk_widget_get_accessible (combo->entry), obj); atk_object_set_parent (gtk_widget_get_accessible (combo->popup), obj); obj->role = ATK_ROLE_COMBO_BOX; }
static void gtk_combo_box_accessible_initialize (AtkObject *obj, gpointer data) { GtkComboBox *combo_box; GtkComboBoxAccessible *accessible; AtkObject *popup; ATK_OBJECT_CLASS (_gtk_combo_box_accessible_parent_class)->initialize (obj, data); combo_box = GTK_COMBO_BOX (data); accessible = GTK_COMBO_BOX_ACCESSIBLE (obj); g_signal_connect (combo_box, "changed", G_CALLBACK (changed_cb), NULL); accessible->old_selection = gtk_combo_box_get_active (combo_box); popup = gtk_combo_box_get_popup_accessible (combo_box); if (popup) { atk_object_set_parent (popup, obj); accessible->popup_set = TRUE; } if (gtk_combo_box_get_has_entry (combo_box)) atk_object_set_parent (gtk_widget_get_accessible (gtk_bin_get_child (GTK_BIN (combo_box))), obj); obj->role = ATK_ROLE_COMBO_BOX; }
static void gail_combo_box_real_initialize (AtkObject *obj, gpointer data) { GtkComboBox *combo_box; GailComboBox *gail_combo_box; AtkObject *popup; ATK_OBJECT_CLASS (gail_combo_box_parent_class)->initialize (obj, data); combo_box = GTK_COMBO_BOX (data); gail_combo_box = GAIL_COMBO_BOX (obj); g_signal_connect (combo_box, "changed", G_CALLBACK (gail_combo_box_changed_gtk), NULL); gail_combo_box->old_selection = gtk_combo_box_get_active (combo_box); popup = gtk_combo_box_get_popup_accessible (combo_box); if (popup) { atk_object_set_parent (popup, obj); gail_combo_box->popup_set = TRUE; } if (GTK_IS_COMBO_BOX_ENTRY (combo_box)) atk_object_set_parent (gtk_widget_get_accessible (gtk_bin_get_child (GTK_BIN (combo_box))), obj); obj->role = ATK_ROLE_COMBO_BOX; }
static AtkObject * gtk_combo_box_accessible_ref_child (AtkObject *obj, gint i) { GtkWidget *widget; AtkObject *child; GtkComboBoxAccessible *box; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); if (widget == NULL) return NULL; if (i == 0) { child = gtk_combo_box_get_popup_accessible (GTK_COMBO_BOX (widget)); box = GTK_COMBO_BOX_ACCESSIBLE (obj); if (box->popup_set == FALSE) { atk_object_set_parent (child, obj); box->popup_set = TRUE; } } else if (i == 1 && gtk_combo_box_get_has_entry (GTK_COMBO_BOX (widget))) { child = gtk_widget_get_accessible (gtk_bin_get_child (GTK_BIN (widget))); } else { return NULL; } return g_object_ref (child); }
nsresult nsApplicationAccessibleWrap::AddRootAccessible(nsIAccessible *aRootAccWrap) { NS_ENSURE_ARG_POINTER(aRootAccWrap); // add by weak reference nsresult rv = nsApplicationAccessible::AddRootAccessible(aRootAccWrap); NS_ENSURE_SUCCESS(rv, rv); AtkObject *atkAccessible = nsAccessibleWrap::GetAtkObject(aRootAccWrap); atk_object_set_parent(atkAccessible, mAtkObject); PRUint32 count = 0; mChildren->GetLength(&count); g_signal_emit_by_name(mAtkObject, "children_changed::add", count - 1, atkAccessible, NULL); #ifdef MAI_LOGGING if (NS_SUCCEEDED(rv)) { MAI_LOG_DEBUG(("\nAdd RootAcc=%p OK, count=%d\n", (void*)aRootAccWrap, count)); } else MAI_LOG_DEBUG(("\nAdd RootAcc=%p Failed, count=%d\n", (void*)aRootAccWrap, count)); #endif return rv; }
static void set_role_for_button (AtkObject *accessible, GtkWidget *button) { GtkWidget *parent; AtkRole role; parent = gtk_widget_get_parent (button); if (GTK_IS_TREE_VIEW (parent)) { role = ATK_ROLE_TABLE_COLUMN_HEADER; /* * Even though the accessible parent of the column header will * be reported as the table because the parent widget of the * GtkTreeViewColumn's button is the GtkTreeView we set * the accessible parent for column header to be the table * to ensure that atk_object_get_index_in_parent() returns * the correct value; see gail_widget_get_index_in_parent(). */ atk_object_set_parent (accessible, gtk_widget_get_accessible (parent)); } else role = ATK_ROLE_PUSH_BUTTON; accessible->role = role; }
static void gtk_label_accessible_initialize (AtkObject *obj, gpointer data) { GtkWidget *widget; GtkLabelAccessible *accessible; ATK_OBJECT_CLASS (_gtk_label_accessible_parent_class)->initialize (obj, data); accessible = GTK_LABEL_ACCESSIBLE (obj); widget = GTK_WIDGET (data); accessible->text = g_strdup (gtk_label_get_text (GTK_LABEL (widget))); /* * Check whether ancestor of GtkLabel is a GtkButton and if so * set accessible parent for GtkLabelAccessible */ while (widget != NULL) { widget = gtk_widget_get_parent (widget); if (GTK_IS_BUTTON (widget)) { atk_object_set_parent (obj, gtk_widget_get_accessible (widget)); break; } } obj->role = ATK_ROLE_LABEL; }
AtkObject * refChildCB(AtkObject *aAtkObj, gint aChildIndex) { // aChildIndex should not be less than zero if (aChildIndex < 0) { return nsnull; } nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj); if (!accWrap || nsAccUtils::MustPrune(accWrap)) { return nsnull; } nsAccessible* accChild = accWrap->GetEmbeddedChildAt(aChildIndex); if (!accChild) return nsnull; AtkObject* childAtkObj = nsAccessibleWrap::GetAtkObject(accChild); NS_ASSERTION(childAtkObj, "Fail to get AtkObj"); if (!childAtkObj) return nsnull; g_object_ref(childAtkObj); //this will addref parent atk_object_set_parent(childAtkObj, aAtkObj); return childAtkObj; }
static void gtk_button_accessible_initialize (AtkObject *obj, gpointer data) { GtkWidget *parent; ATK_OBJECT_CLASS (gtk_button_accessible_parent_class)->initialize (obj, data); g_signal_connect (data, "state-flags-changed", G_CALLBACK (state_changed_cb), NULL); parent = gtk_widget_get_parent (gtk_accessible_get_widget (GTK_ACCESSIBLE (obj))); if (GTK_IS_TREE_VIEW (parent)) { /* Even though the accessible parent of the column header will * be reported as the table because the parent widget of the * GtkTreeViewColumn's button is the GtkTreeView we set * the accessible parent for column header to be the table * to ensure that atk_object_get_index_in_parent() returns * the correct value; see gail_widget_get_index_in_parent(). */ atk_object_set_parent (obj, gtk_widget_get_accessible (parent)); obj->role = ATK_ROLE_TABLE_COLUMN_HEADER; } else obj->role = ATK_ROLE_PUSH_BUTTON; }
PRBool nsApplicationAccessibleWrap::AppendChild(nsAccessible *aChild) { if (!nsApplicationAccessible::AppendChild(aChild)) return PR_FALSE; AtkObject *atkAccessible = nsAccessibleWrap::GetAtkObject(aChild); atk_object_set_parent(atkAccessible, mAtkObject); PRUint32 count = mChildren.Length(); // Emit children_changed::add in a timeout // to make sure aRootAccWrap is fully initialized. AtkRootAccessibleAddedEvent* eventData = (AtkRootAccessibleAddedEvent*) malloc(sizeof(AtkRootAccessibleAddedEvent)); if (eventData) { eventData->app_accessible = mAtkObject; eventData->root_accessible = atkAccessible; eventData->index = count -1; g_object_ref(mAtkObject); g_object_ref(atkAccessible); g_timeout_add(0, fireRootAccessibleAddedCB, eventData); } return PR_TRUE; }
static AtkObject * create_accessible (HTMLObject *o, AtkObject *parent) { AtkObject *accessible = NULL; switch (HTML_OBJECT_TYPE (o)) { case HTML_TYPE_CLUEFLOW: accessible = html_a11y_paragraph_new (o); break; case HTML_TYPE_TEXT: accessible = html_a11y_text_new (o); break; case HTML_TYPE_IMAGE: accessible = html_a11y_image_new (o); break; case HTML_TYPE_TABLE: accessible = html_a11y_table_new (o); break; case HTML_TYPE_TABLECELL: accessible = html_a11y_cell_new (o); break; case HTML_TYPE_RULE: accessible = html_a11y_new (o, ATK_ROLE_SEPARATOR); break; case HTML_TYPE_EMBEDDED: case HTML_TYPE_SELECT: case HTML_TYPE_RADIO: case HTML_TYPE_OBJECT: case HTML_TYPE_TEXTAREA: case HTML_TYPE_TEXTINPUT: case HTML_TYPE_BUTTON: case HTML_TYPE_CHECKBOX: case HTML_TYPE_IFRAME: if (HTML_EMBEDDED (o)-> widget) { accessible = gtk_widget_get_accessible (HTML_EMBEDDED (o)->widget); if (HTML_EMBEDDED (o)->name) { if ((accessible != NULL) && (atk_object_get_name (accessible) == NULL)) atk_object_set_name (accessible, HTML_EMBEDDED (o)->name); } } break; case HTML_TYPE_TEXTSLAVE: /* ignore */ break; default: accessible = html_a11y_new (o, ATK_ROLE_UNKNOWN); break; } if (accessible && parent) { /* printf ("set parent of %p to %p\n", accessible, parent); */ atk_object_set_parent (accessible, parent); } return accessible; }
void _gtk_container_cell_accessible_add_child (GtkContainerCellAccessible *container, GtkCellAccessible *child) { g_return_if_fail (GTK_IS_CONTAINER_CELL_ACCESSIBLE (container)); g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (child)); container->NChildren++; container->children = g_list_append (container->children, child); atk_object_set_parent (ATK_OBJECT (child), ATK_OBJECT (container)); }
PRBool nsApplicationAccessibleWrap::RemoveChild(nsAccessible* aChild) { PRInt32 index = aChild->GetIndexInParent(); AtkObject *atkAccessible = nsAccessibleWrap::GetAtkObject(aChild); atk_object_set_parent(atkAccessible, NULL); g_signal_emit_by_name(mAtkObject, "children_changed::remove", index, atkAccessible, NULL); return nsApplicationAccessible::RemoveChild(aChild); }
AtkObject * refChildCB(AtkObject *aAtkObj, gint aChildIndex) { // aChildIndex should not be less than zero if (aChildIndex < 0) { return nsnull; } // XXX Fix this so it is not O(n^2) to walk through the children! // Either we can cache the last accessed child so that we can just GetNextSibling() // or we should cache an array of children in each nsAccessible // (instead of mNextSibling on the children) nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj); if (!accWrap || nsAccUtils::MustPrune(accWrap)) { return nsnull; } nsCOMPtr<nsIAccessible> accChild; nsCOMPtr<nsIAccessibleHyperText> hyperText; accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperText), getter_AddRefs(hyperText)); if (hyperText) { // If HyperText, then number of links matches number of children nsCOMPtr<nsIAccessibleHyperLink> hyperLink; hyperText->GetLink(aChildIndex, getter_AddRefs(hyperLink)); accChild = do_QueryInterface(hyperLink); } else { nsCOMPtr<nsIAccessibleText> accText; accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText), getter_AddRefs(accText)); if (!accText) { // Accessible Text that is not HyperText has no children accWrap->GetChildAt(aChildIndex, getter_AddRefs(accChild)); } } if (!accChild) return nsnull; AtkObject* childAtkObj = nsAccessibleWrap::GetAtkObject(accChild); NS_ASSERTION(childAtkObj, "Fail to get AtkObj"); if (!childAtkObj) return nsnull; //this will addref parent atk_object_set_parent(childAtkObj, aAtkObj); g_object_ref(childAtkObj); return childAtkObj; }
void gucharmap_chartable_cell_accessible_initialise (GucharmapChartableCellAccessible *cell, GtkWidget *widget, AtkObject *parent, gint index) { cell->widget = widget; atk_object_set_parent (ATK_OBJECT (cell), parent); cell->index = index; cell->activate_description = g_strdup ("Activate the cell"); /* FIXMEchpe i18n !! */ g_signal_connect_object (G_OBJECT (widget), "destroy", G_CALLBACK (gucharmap_chartable_cell_accessible_destroyed), cell, 0); }
static void gail_label_real_initialize (AtkObject *obj, gpointer data) { GtkWidget *widget; GailLabel *gail_label; ATK_OBJECT_CLASS (gail_label_parent_class)->initialize (obj, data); gail_label = GAIL_LABEL (obj); gail_label->window_create_handler = 0; gail_label->has_top_level = FALSE; gail_label->cursor_position = 0; gail_label->selection_bound = 0; gail_label->textutil = NULL; gail_label->label_length = 0; widget = GTK_WIDGET (data); if (gtk_widget_get_mapped (widget)) gail_label_init_text_util (gail_label, widget); else g_signal_connect (widget, "map", G_CALLBACK (gail_label_map_gtk), gail_label); /* * Check whether ancestor of GtkLabel is a GtkButton and if so * set accessible parent for GailLabel */ while (widget != NULL) { widget = gtk_widget_get_parent (widget); if (GTK_IS_BUTTON (widget)) { atk_object_set_parent (obj, gtk_widget_get_accessible (widget)); break; } } if (GTK_IS_ACCEL_LABEL (widget)) obj->role = ATK_ROLE_ACCEL_LABEL; else obj->role = ATK_ROLE_LABEL; }
static void gtk_html_a11y_grab_focus_cb (GtkWidget *widget) { AtkObject *focus_object, *obj, *clue; focus_object = gtk_html_a11y_get_focus_object (widget); if (focus_object == NULL) return; obj = gtk_widget_get_accessible (widget); clue = html_utils_get_accessible (GTK_HTML (widget)->engine->clue, obj); atk_object_set_parent (clue, obj); gtk_html_a11y_focus_object = focus_object; atk_focus_tracker_notify (focus_object); }
AtkObject * getParentCB(AtkObject *aAtkObj) { if (!aAtkObj->accessible_parent) { nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj); if (!accWrap) { return nsnull; } nsAccessible* accParent = accWrap->GetParent(); if (!accParent) return nsnull; AtkObject *parent = nsAccessibleWrap::GetAtkObject(accParent); if (parent) atk_object_set_parent(aAtkObj, parent); } return aAtkObj->accessible_parent; }
static void gail_menu_item_real_initialize (AtkObject *obj, gpointer data) { GtkWidget *widget; GtkWidget *parent; ATK_OBJECT_CLASS (gail_menu_item_parent_class)->initialize (obj, data); g_signal_connect (data, "select", G_CALLBACK (menu_item_select), NULL); g_signal_connect (data, "deselect", G_CALLBACK (menu_item_deselect), NULL); widget = GTK_WIDGET (data); parent = gtk_widget_get_parent (widget); if (GTK_IS_MENU (parent)) { GtkWidget *parent_widget; parent_widget = gtk_menu_get_attach_widget (GTK_MENU (parent)); if (!GTK_IS_MENU_ITEM (parent_widget)) parent_widget = gtk_widget_get_parent (widget); if (parent_widget) { atk_object_set_parent (obj, gtk_widget_get_accessible (parent_widget)); } } g_object_set_data (G_OBJECT (obj), "atk-component-layer", GINT_TO_POINTER (ATK_LAYER_POPUP)); if (GTK_IS_TEAROFF_MENU_ITEM (data)) obj->role = ATK_ROLE_TEAR_OFF_MENU_ITEM; else if (GTK_IS_SEPARATOR_MENU_ITEM (data)) obj->role = ATK_ROLE_SEPARATOR; else obj->role = ATK_ROLE_MENU_ITEM; }
AtkObject * getParentCB(AtkObject *aAtkObj) { if (!aAtkObj->accessible_parent) { nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj); if (!accWrap) { return nsnull; } nsCOMPtr<nsIAccessible> accParent; nsresult rv = accWrap->GetParent(getter_AddRefs(accParent)); if (NS_FAILED(rv) || !accParent) return nsnull; AtkObject *parent = nsAccessibleWrap::GetAtkObject(accParent); if (parent) atk_object_set_parent(aAtkObj, parent); } return aAtkObj->accessible_parent; }
static gint notify_child_added (gpointer data) { GailNotebookPage *page; AtkObject *atk_object, *atk_parent; g_return_val_if_fail (GAIL_IS_NOTEBOOK_PAGE (data), FALSE); page = GAIL_NOTEBOOK_PAGE (data); atk_object = ATK_OBJECT (data); page->notify_child_added_id = 0; /* The widget page->notebook may be deleted before this handler is called */ if (page->notebook != NULL) { atk_parent = gtk_widget_get_accessible (GTK_WIDGET (page->notebook)); atk_object_set_parent (atk_object, atk_parent); g_signal_emit_by_name (atk_parent, "children_changed::add", page->index, atk_object, NULL); } return FALSE; }
static AtkObject* gail_combo_box_ref_child (AtkObject *obj, gint i) { GtkWidget *widget; AtkObject *child; GailComboBox *box; g_return_val_if_fail (GAIL_IS_COMBO_BOX (obj), NULL); widget = GTK_ACCESSIBLE (obj)->widget; if (widget == NULL) /* * State is defunct */ return NULL; if (i == 0) { child = gtk_combo_box_get_popup_accessible (GTK_COMBO_BOX (widget)); box = GAIL_COMBO_BOX (obj); if (box->popup_set == FALSE) { atk_object_set_parent (child, obj); box->popup_set = TRUE; } } else if (i == 1 && GTK_IS_COMBO_BOX_ENTRY (widget)) { child = gtk_widget_get_accessible (gtk_bin_get_child (GTK_BIN (widget))); } else { return NULL; } return g_object_ref (child); }
static void gtk_menu_item_accessible_initialize (AtkObject *obj, gpointer data) { GtkWidget *widget; GtkWidget *parent; GtkWidget *menu; ATK_OBJECT_CLASS (_gtk_menu_item_accessible_parent_class)->initialize (obj, data); g_signal_connect (data, "select", G_CALLBACK (menu_item_select), NULL); g_signal_connect (data, "deselect", G_CALLBACK (menu_item_deselect), NULL); widget = GTK_WIDGET (data); parent = gtk_widget_get_parent (widget); if (GTK_IS_MENU (parent)) { GtkWidget *parent_widget; parent_widget = gtk_menu_get_attach_widget (GTK_MENU (parent)); if (!GTK_IS_MENU_ITEM (parent_widget)) parent_widget = gtk_widget_get_parent (widget); if (parent_widget) atk_object_set_parent (obj, gtk_widget_get_accessible (parent_widget)); } GTK_WIDGET_ACCESSIBLE (obj)->layer = ATK_LAYER_POPUP; obj->role = ATK_ROLE_MENU_ITEM; menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (data)); if (menu) { g_signal_connect (menu, "add", G_CALLBACK (menu_item_add_gtk), NULL); g_signal_connect (menu, "remove", G_CALLBACK (menu_item_remove_gtk), NULL); } }
nsresult nsApplicationAccessibleWrap::RemoveRootAccessible(nsIAccessible *aRootAccWrap) { NS_ENSURE_ARG_POINTER(aRootAccWrap); PRUint32 index = 0; nsresult rv = NS_ERROR_FAILURE; // we must use weak ref to get the index nsCOMPtr<nsIWeakReference> weakPtr = do_GetWeakReference(aRootAccWrap); rv = mChildren->IndexOf(0, weakPtr, &index); AtkObject *atkAccessible = nsAccessibleWrap::GetAtkObject(aRootAccWrap); atk_object_set_parent(atkAccessible, NULL); g_signal_emit_by_name(mAtkObject, "children_changed::remove", index, atkAccessible, NULL); #ifdef MAI_LOGGING PRUint32 count = 0; mChildren->GetLength(&count); if (NS_SUCCEEDED(rv)) { rv = mChildren->RemoveElementAt(index); MAI_LOG_DEBUG(("\nRemove RootAcc=%p, count=%d\n", (void*)aRootAccWrap, (count-1))); } else MAI_LOG_DEBUG(("\nFail to Remove RootAcc=%p, count=%d\n", (void*)aRootAccWrap, count)); #else NS_ENSURE_SUCCESS(rv, rv); rv = mChildren->RemoveElementAt(index); #endif InvalidateChildren(); return rv; }