static gchar* gail_label_get_text (AtkText *text, gint start_pos, gint end_pos) { GtkWidget *widget; GtkLabel *label; const gchar *label_text; widget = GTK_ACCESSIBLE (text)->widget; if (widget == NULL) /* State is defunct */ return NULL; label = GTK_LABEL (widget); label_text = gtk_label_get_text (label); if (label_text == NULL) return NULL; else { if (GAIL_LABEL (text)->textutil == NULL) gail_label_init_text_util (GAIL_LABEL (text), widget); return gail_text_util_get_substring (GAIL_LABEL(text)->textutil, start_pos, end_pos); } }
static gint gail_expander_get_n_children (AtkObject* obj) { GtkWidget *widget; GList *children; gint count = 0; g_return_val_if_fail (GAIL_IS_CONTAINER (obj), count); widget = GTK_ACCESSIBLE (obj)->widget; if (widget == NULL) return 0; children = gtk_container_get_children (GTK_CONTAINER(widget)); count = g_list_length (children); g_list_free (children); /* See if there is a label - if there is, reduce our count by 1 * since we don't want the label included with the children. */ if (gtk_expander_get_label_widget (GTK_EXPANDER (widget))) count -= 1; return count; }
static gchar* gail_expander_get_text (AtkText *text, gint start_pos, gint end_pos) { GtkWidget *widget; GailExpander *expander; const gchar *label_text; widget = GTK_ACCESSIBLE (text)->widget; if (widget == NULL) /* State is defunct */ return NULL; expander = GAIL_EXPANDER (text); if (!expander->textutil) gail_expander_init_textutil (expander, GTK_EXPANDER (widget)); label_text = gail_expander_get_full_text (GTK_EXPANDER (widget)); if (label_text == NULL) return NULL; else return gail_text_util_get_substring (expander->textutil, start_pos, end_pos); }
static gboolean idle_do_action (gpointer data) { GtkWidget *widget; GailExpander *gail_expander; GDK_THREADS_ENTER (); gail_expander = GAIL_EXPANDER (data); gail_expander->action_idle_handler = 0; widget = GTK_ACCESSIBLE (gail_expander)->widget; if (widget == NULL /* State is defunct */ || !GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget)) { GDK_THREADS_LEAVE (); return FALSE; } gtk_widget_activate (widget); GDK_THREADS_LEAVE (); return FALSE; }
static gunichar gail_expander_get_character_at_offset (AtkText *text, gint offset) { GtkWidget *widget; GtkWidget *label; const gchar *string; gchar *index; widget = GTK_ACCESSIBLE (text)->widget; if (widget == NULL) /* State is defunct */ return '\0'; label = gtk_expander_get_label_widget (GTK_EXPANDER (widget)); if (!GTK_IS_LABEL(label)) return '\0'; string = gtk_label_get_text (GTK_LABEL (label)); if (offset >= g_utf8_strlen (string, -1)) return '\0'; index = g_utf8_offset_to_pointer (string, offset); return g_utf8_get_char (index); }
static int panel_menu_button_accessible_get_n_children (AtkObject *obj) { g_return_val_if_fail (PANEL_IS_MENU_BUTTON_ACCESSIBLE (obj), 0); return GTK_ACCESSIBLE (obj)->widget ? 1 : 0; }
static void gail_window_get_size (AtkComponent *component, gint *width, gint *height) { GtkWidget *widget = GTK_ACCESSIBLE (component)->widget; GdkRectangle rect; if (widget == NULL) /* * State is defunct */ return; gail_return_if_fail (GTK_IS_WINDOW (widget)); if (!gtk_widget_is_toplevel (widget)) { AtkComponentIface *parent_iface; parent_iface = (AtkComponentIface *) g_type_interface_peek_parent (ATK_COMPONENT_GET_IFACE (component)); parent_iface->get_size (component, width, height); return; } gdk_window_get_frame_extents (widget->window, &rect); *width = rect.width; *height = rect.height; }
static const char * get_name (AtkObject *accessible) { char *name; name = g_object_get_data (G_OBJECT (accessible), "gtk-accessibility-dump-name"); if (name) return name; if (GTK_IS_ACCESSIBLE (accessible)) { GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); name = g_strdup (gtk_buildable_get_name (GTK_BUILDABLE (widget))); } if (name == NULL && ATK_IS_TEXT (accessible)) { name = atk_text_get_text (ATK_TEXT (accessible), 0, -1); } if (name == NULL) { /* Generate a unique, repeatable name */ name = g_strdup_printf ("unnamed-%s-%d", G_OBJECT_TYPE_NAME (accessible), unnamed_object_count++); } g_object_set_data_full (G_OBJECT (accessible), "gtk-accessibility-dump-name", name, g_free); return name; }
static gboolean gtk_menu_shell_accessible_is_child_selected (AtkSelection *selection, gint i) { GtkMenuShell *shell; GList *kids; gint j; GtkWidget *widget; GtkWidget *item; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection)); if (widget == NULL) return FALSE; shell = GTK_MENU_SHELL (widget); item = gtk_menu_shell_get_selected_item (shell); if (item == NULL) return FALSE; kids = gtk_container_get_children (GTK_CONTAINER (shell)); j = g_list_index (kids, item); g_list_free (kids); return j==i; }
static gint gail_label_get_offset_at_point (AtkText *text, gint x, gint y, AtkCoordType coords) { GtkWidget *widget; GtkLabel *label; gint index, x_layout, y_layout; widget = GTK_ACCESSIBLE (text)->widget; if (widget == NULL) /* State is defunct */ return -1; label = GTK_LABEL (widget); gtk_label_get_layout_offsets (label, &x_layout, &y_layout); index = gail_misc_get_index_at_point_in_layout (widget, gtk_label_get_layout (label), x_layout, y_layout, x, y, coords); if (index == -1) { if (coords == ATK_XY_WINDOW || coords == ATK_XY_SCREEN) return g_utf8_strlen (label->text, -1); return index; } else return g_utf8_pointer_to_offset (label->text, label->text + index); }
static void gail_pixmap_get_image_size (AtkImage *obj, gint *width, gint *height) { GtkWidget *widget; GtkPixmap *pixmap; *width = -1; *height = -1; g_return_if_fail (GAIL_IS_PIXMAP (obj)); widget = GTK_ACCESSIBLE (obj)->widget; if (widget == 0) /* State is defunct */ return; g_return_if_fail (GTK_IS_PIXMAP (widget)); pixmap = GTK_PIXMAP (widget); if (pixmap->pixmap) gdk_drawable_get_size (pixmap->pixmap, width, height); }
static gboolean gail_label_set_selection (AtkText *text, gint selection_num, gint start_pos, gint end_pos) { GtkWidget *widget; GtkLabel *label; gint start, end; widget = GTK_ACCESSIBLE (text)->widget; if (widget == NULL) /* State is defunct */ return FALSE; if (selection_num != 0) return FALSE; label = GTK_LABEL (widget); if (!gtk_label_get_selectable (label)) return FALSE; if (gtk_label_get_selection_bounds (label, &start, &end)) { gtk_label_select_region (label, start_pos, end_pos); return TRUE; } else return FALSE; }
static gchar* gail_label_get_selection (AtkText *text, gint selection_num, gint *start_pos, gint *end_pos) { GtkWidget *widget; GtkLabel *label; widget = GTK_ACCESSIBLE (text)->widget; if (widget == NULL) /* State is defunct */ return NULL; label = GTK_LABEL (widget); /* Only let the user get the selection if one is set, and if the * selection_num is 0. */ if (!gtk_label_get_selectable( label) || selection_num != 0) return NULL; if (gtk_label_get_selection_bounds (label, start_pos, end_pos)) { const gchar* label_text = gtk_label_get_text (label); if (label_text == NULL) return 0; else return gail_text_util_get_substring (GAIL_LABEL (text)->textutil, *start_pos, *end_pos); } else return NULL; }
static gchar* gail_label_get_text_after_offset (AtkText *text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset) { GtkWidget *widget; GtkLabel *label; widget = GTK_ACCESSIBLE (text)->widget; if (widget == NULL) { /* State is defunct */ return NULL; } /* Get label */ label = GTK_LABEL (widget); return gail_text_util_get_text (GAIL_LABEL (text)->textutil, gtk_label_get_layout (label), GAIL_AFTER_OFFSET, boundary_type, offset, start_offset, end_offset); }
static gboolean ev_view_accessible_action_do_action (AtkAction *action, gint i) { EvViewAccessiblePriv* priv = EV_VIEW_ACCESSIBLE_GET_PRIVATE (action); if (gtk_accessible_get_widget (GTK_ACCESSIBLE (action)) == NULL) return FALSE; if (priv->action_idle_handler) return FALSE; switch (i) { case ACTION_SCROLL_UP: priv->idle_scroll = GTK_SCROLL_PAGE_BACKWARD; break; case ACTION_SCROLL_DOWN: priv->idle_scroll = GTK_SCROLL_PAGE_FORWARD; break; default: return FALSE; } priv->action_idle_handler = g_idle_add (ev_view_accessible_idle_do_action, action); return TRUE; }
static gboolean gtk_menu_shell_accessible_add_selection (AtkSelection *selection, gint i) { GList *kids; GtkWidget *item; guint length; GtkWidget *widget; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection)); if (widget == NULL) return FALSE; kids = gtk_container_get_children (GTK_CONTAINER (widget)); length = g_list_length (kids); if (i < 0 || i > length) { g_list_free (kids); return FALSE; } item = g_list_nth_data (kids, i); g_list_free (kids); g_return_val_if_fail (GTK_IS_MENU_ITEM (item), FALSE); gtk_menu_shell_select_item (GTK_MENU_SHELL (widget), item); return TRUE; }
static AtkStateSet * gtk_check_menu_item_accessible_ref_state_set (AtkObject *accessible) { AtkStateSet *state_set; GtkCheckMenuItem *check_menu_item; GtkWidget *widget; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); if (widget == NULL) return NULL; state_set = ATK_OBJECT_CLASS (gtk_check_menu_item_accessible_parent_class)->ref_state_set (accessible); check_menu_item = GTK_CHECK_MENU_ITEM (widget); if (gtk_check_menu_item_get_active (check_menu_item)) atk_state_set_add_state (state_set, ATK_STATE_CHECKED); if (gtk_check_menu_item_get_inconsistent (check_menu_item)) { atk_state_set_remove_state (state_set, ATK_STATE_ENABLED); atk_state_set_add_state (state_set, ATK_STATE_INDETERMINATE); } return state_set; }
static AtkObject * gtk_menu_shell_accessible_ref_selection (AtkSelection *selection, gint i) { GtkMenuShell *shell; AtkObject *obj; GtkWidget *widget; GtkWidget *item; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection)); if (widget == NULL) return NULL; if (i != 0) return NULL; shell = GTK_MENU_SHELL (widget); item = gtk_menu_shell_get_selected_item (shell); if (item != NULL) { obj = gtk_widget_get_accessible (item); g_object_ref (obj); return obj; } return NULL; }
static AtkStateSet* gail_window_ref_state_set (AtkObject *accessible) { AtkStateSet *state_set; GtkWidget *widget; GtkWindow *window; GdkWindowState state; state_set = ATK_OBJECT_CLASS (gail_window_parent_class)->ref_state_set (accessible); widget = GTK_ACCESSIBLE (accessible)->widget; if (widget == NULL) return state_set; window = GTK_WINDOW (widget); if (window->has_focus) atk_state_set_add_state (state_set, ATK_STATE_ACTIVE); if (widget->window) { state = gdk_window_get_state (widget->window); if (state & GDK_WINDOW_STATE_ICONIFIED) atk_state_set_add_state (state_set, ATK_STATE_ICONIFIED); } if (gtk_window_get_modal (window)) atk_state_set_add_state (state_set, ATK_STATE_MODAL); if (gtk_window_get_resizable (window)) atk_state_set_add_state (state_set, ATK_STATE_RESIZABLE); return state_set; }
static gchar* ev_view_accessible_get_text (AtkText *text, gint start_pos, gint end_pos) { GtkWidget *widget; GtkTextIter start, end; GtkTextBuffer *buffer; gchar *retval; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text)); if (widget == NULL) /* State is defunct */ return NULL; buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget)); if (!buffer) return NULL; gtk_text_buffer_get_iter_at_offset (buffer, &start, start_pos); gtk_text_buffer_get_iter_at_offset (buffer, &end, end_pos); retval = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); return retval; }
static gboolean gail_expander_do_action (AtkAction *action, gint i) { GtkWidget *widget; GailExpander *expander; gboolean return_value = TRUE; widget = GTK_ACCESSIBLE (action)->widget; if (widget == NULL) /* * State is defunct */ return FALSE; if (!GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget)) return FALSE; expander = GAIL_EXPANDER (action); switch (i) { case 0: if (expander->action_idle_handler) return_value = FALSE; else expander->action_idle_handler = g_idle_add (idle_do_action, expander); break; default: return_value = FALSE; break; } return return_value; }
static gunichar ev_view_accessible_get_character_at_offset (AtkText *text, gint offset) { GtkWidget *widget; GtkTextIter start, end; GtkTextBuffer *buffer; gchar *string; gunichar unichar; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text)); if (widget == NULL) /* State is defunct */ return '\0'; buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget)); if (!buffer) return '\0'; if (offset >= gtk_text_buffer_get_char_count (buffer)) return '\0'; gtk_text_buffer_get_iter_at_offset (buffer, &start, offset); end = start; gtk_text_iter_forward_char (&end); string = gtk_text_buffer_get_slice (buffer, &start, &end, FALSE); unichar = g_utf8_get_char (string); g_free(string); return unichar; }
static void gail_expander_get_character_extents (AtkText *text, gint offset, gint *x, gint *y, gint *width, gint *height, AtkCoordType coords) { GtkWidget *widget; GtkWidget *label; PangoRectangle char_rect; gint index, x_layout, y_layout; const gchar *label_text; widget = GTK_ACCESSIBLE (text)->widget; if (widget == NULL) /* State is defunct */ return; label = gtk_expander_get_label_widget (GTK_EXPANDER (widget)); if (!GTK_IS_LABEL(label)) return; gtk_label_get_layout_offsets (GTK_LABEL (label), &x_layout, &y_layout); label_text = gtk_label_get_text (GTK_LABEL (label)); index = g_utf8_offset_to_pointer (label_text, offset) - label_text; pango_layout_index_to_pos (gtk_label_get_layout (GTK_LABEL (label)), index, &char_rect); gail_misc_get_extents_from_pango_rectangle (label, &char_rect, x_layout, y_layout, x, y, width, height, coords); }
static gchar* ev_view_accessible_get_text_after_offset (AtkText *text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset) { GtkWidget *widget; gpointer layout = NULL; GailTextUtil *gail_text = NULL; gchar *retval = NULL; GtkTextBuffer *buffer; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text)); if (widget == NULL) /* State is defunct */ return NULL; buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget)); if (!buffer) return NULL; gail_text = gail_text_util_new (); gail_text_util_buffer_setup (gail_text, buffer); retval = gail_text_util_get_text (gail_text, layout, GAIL_AFTER_OFFSET, boundary_type, offset, start_offset, end_offset); g_object_unref (gail_text); return retval; }
static G_CONST_RETURN gchar* gail_expander_get_name (AtkObject *obj) { G_CONST_RETURN gchar *name; g_return_val_if_fail (GAIL_IS_EXPANDER (obj), NULL); name = ATK_OBJECT_CLASS (gail_expander_parent_class)->get_name (obj); if (name != NULL) return name; else { /* * Get the text on the label */ GtkWidget *widget; widget = GTK_ACCESSIBLE (obj)->widget; if (widget == NULL) /* * State is defunct */ return NULL; g_return_val_if_fail (GTK_IS_EXPANDER (widget), NULL); return gail_expander_get_full_text (GTK_EXPANDER (widget)); } }
static gint ev_view_accessible_get_n_selections (AtkText *text) { GtkWidget *widget; GtkTextBuffer *buffer; GtkTextIter start, end; gint select_start, select_end; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text)); if (widget == NULL) /* State is defunct */ return -1; buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget)); if (!buffer) return -1; gtk_text_buffer_get_selection_bounds (buffer, &start, &end); select_start = gtk_text_iter_get_offset (&start); select_end = gtk_text_iter_get_offset (&end); if (select_start != select_end) return 1; else return 0; }
static gboolean gail_expander_do_action (AtkAction *action, gint i) { GtkWidget *widget; GailExpander *expander; gboolean return_value = TRUE; widget = GTK_ACCESSIBLE (action)->widget; if (widget == NULL) /* * State is defunct */ return FALSE; if (!gtk_widget_is_sensitive (widget) || !gtk_widget_get_visible (widget)) return FALSE; expander = GAIL_EXPANDER (action); switch (i) { case 0: if (expander->action_idle_handler) return_value = FALSE; else expander->action_idle_handler = gdk_threads_add_idle (idle_do_action, expander); break; default: return_value = FALSE; break; } return return_value; }
static gchar* ev_view_accessible_get_selection (AtkText *text, gint selection_num, gint *start_pos, gint *end_pos) { GtkWidget *widget; GtkTextBuffer *buffer; GtkTextIter start, end; gchar *retval = NULL; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text)); if (widget == NULL) /* State is defunct */ return NULL; if (selection_num != 0) return NULL; buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget)); if (!buffer) return NULL; gtk_text_buffer_get_selection_bounds (buffer, &start, &end); *start_pos = gtk_text_iter_get_offset (&start); *end_pos = gtk_text_iter_get_offset (&end); if (*start_pos != *end_pos) retval = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); return retval; }
static gchar* gail_expander_get_text_after_offset (AtkText *text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset) { GtkWidget *widget; GailExpander *expander; GtkWidget *label; widget = GTK_ACCESSIBLE (text)->widget; if (widget == NULL) /* State is defunct */ return NULL; expander = GAIL_EXPANDER (text); if (!expander->textutil) gail_expander_init_textutil (expander, GTK_EXPANDER (widget)); label = gtk_expander_get_label_widget (GTK_EXPANDER (widget)); if (!GTK_IS_LABEL(label)) return NULL; return gail_text_util_get_text (expander->textutil, gtk_label_get_layout (GTK_LABEL (label)), GAIL_AFTER_OFFSET, boundary_type, offset, start_offset, end_offset); }
static const gchar* gail_label_get_name (AtkObject *accessible) { const gchar *name; g_return_val_if_fail (GAIL_IS_LABEL (accessible), NULL); name = ATK_OBJECT_CLASS (gail_label_parent_class)->get_name (accessible); if (name != NULL) return name; else { /* * Get the text on the label */ GtkWidget *widget; widget = GTK_ACCESSIBLE (accessible)->widget; if (widget == NULL) /* * State is defunct */ return NULL; g_return_val_if_fail (GTK_IS_LABEL (widget), NULL); return gtk_label_get_text (GTK_LABEL (widget)); } }