From cb9c99c5f424496a2fb8526a8c2e492d41140e9e Mon Sep 17 00:00:00 2001 From: Li Yuan Date: Mon, 1 Nov 2004 05:04:37 +0000 Subject: Add a name for timezone combox. Make accessibility name and description 2004-10-28 Li Yuan * e-timezone-dialog/e-timezone-dialog.glade: Add a name for timezone combox. * misc/e-calendar.c: (e_calendar_init), (e_calendar_new): Make accessibility name and description translatable. Add a atk name for the two buttons so that they can be UI grabbed by GOK. * misc/e-dateedit.c: (e_date_edit_new), (create_children): Add a name for atk object. Make accessibility name and description translatable. Add name and description for the date_entry, date_button and time_combo. (e_date_edit_show_date_popup), (hide_date_popup): Grab and ungrab keyboard. add_relation(): New function to add labelled_by relation for entry and combobox. * misc/e-map.c: (e_map_new): Add a name for world map widget. Make accessibility name and description translatable. Set the atk role to image. * misc/e-multi-config-dialog.c: (e_multi_config_dialog_add_page): Add an atk name for the page. svn path=/trunk/; revision=27776 --- widgets/misc/e-calendar.c | 9 ++++++ widgets/misc/e-dateedit.c | 60 ++++++++++++++++++++++++++++++++++++ widgets/misc/e-map.c | 6 ++++ widgets/misc/e-multi-config-dialog.c | 11 ++++++- 4 files changed, 85 insertions(+), 1 deletion(-) (limited to 'widgets/misc') diff --git a/widgets/misc/e-calendar.c b/widgets/misc/e-calendar.c index 402e390df0..5fca4ab074 100644 --- a/widgets/misc/e-calendar.c +++ b/widgets/misc/e-calendar.c @@ -42,6 +42,7 @@ #include #include #include +#include #define E_CALENDAR_SMALL_FONT_PTSIZE 6 @@ -140,6 +141,7 @@ e_calendar_init (ECalendar *cal) GnomeCanvasGroup *canvas_group; PangoFontDescription *small_font_desc; GtkWidget *button, *pixmap; + AtkObject *a11y; /* Create the small font. */ @@ -179,6 +181,8 @@ e_calendar_init (ECalendar *cal) gnome_canvas_widget_get_type (), "widget", button, NULL); + a11y = gtk_widget_get_accessible (button); + atk_object_set_name (a11y, _("Previous Button")); button = gtk_button_new (); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); @@ -201,6 +205,8 @@ e_calendar_init (ECalendar *cal) gnome_canvas_widget_get_type (), "widget", button, NULL); + a11y = gtk_widget_get_accessible (button); + atk_object_set_name (a11y, _("Previous Button")); cal->min_rows = 1; cal->min_cols = 1; @@ -221,8 +227,11 @@ GtkWidget * e_calendar_new (void) { GtkWidget *cal; + AtkObject *a11y; cal = gtk_type_new (e_calendar_get_type ()); + a11y = gtk_widget_get_accessible (cal); + atk_object_set_name (a11y, _("Month Calendar")); return cal; } diff --git a/widgets/misc/e-dateedit.c b/widgets/misc/e-dateedit.c index 3044ae0ddd..be244861cf 100644 --- a/widgets/misc/e-dateedit.c +++ b/widgets/misc/e-dateedit.c @@ -55,6 +55,8 @@ #include #include #include +#include +#include #include #include #include "e-util/e-time-utils.h" @@ -304,8 +306,11 @@ GtkWidget * e_date_edit_new (void) { EDateEdit *dedit; + AtkObject *a11y; dedit = g_object_new (E_TYPE_DATE_EDIT, NULL); + a11y = gtk_widget_get_accessible (GTK_WIDGET (dedit)); + atk_object_set_name (a11y, _("Date and Time Entry")); return GTK_WIDGET (dedit); } @@ -318,10 +323,14 @@ create_children (EDateEdit *dedit) ECalendar *calendar; GtkWidget *frame, *arrow; GtkWidget *vbox, *bbox; + AtkObject *a11y; priv = dedit->priv; priv->date_entry = gtk_entry_new (); + a11y = gtk_widget_get_accessible (priv->date_entry); + atk_object_set_description (a11y, _("Text entry to input date")); + atk_object_set_name (a11y, _("Text Date Entry")); gtk_box_pack_start (GTK_BOX (dedit), priv->date_entry, FALSE, TRUE, 0); g_signal_connect (priv->date_entry, "key_press_event", @@ -337,6 +346,9 @@ create_children (EDateEdit *dedit) G_CALLBACK (on_date_button_clicked), dedit); gtk_box_pack_start (GTK_BOX (dedit), priv->date_button, FALSE, FALSE, 0); + a11y = gtk_widget_get_accessible (priv->date_button); + atk_object_set_description (a11y, _("Click this button to show a calendar")); + atk_object_set_name (a11y, _("Date Button")); arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); gtk_container_add (GTK_CONTAINER (priv->date_button), arrow); @@ -355,6 +367,9 @@ create_children (EDateEdit *dedit) priv->time_combo = gtk_combo_new (); gtk_box_pack_start (GTK_BOX (dedit), priv->time_combo, FALSE, TRUE, 0); rebuild_time_popup (dedit); + a11y = gtk_widget_get_accessible (priv->time_combo); + atk_object_set_description (a11y, _("Combo box to select time")); + atk_object_set_name (a11y, _("Time Combo Box")); g_signal_connect (GTK_COMBO (priv->time_combo)->entry, "key_press_event", @@ -1185,6 +1200,7 @@ e_date_edit_show_date_popup (EDateEdit *dedit) | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), NULL, NULL, GDK_CURRENT_TIME); + gdk_keyboard_grab (priv->cal_popup->window, TRUE, GDK_CURRENT_TIME); gdk_window_focus (priv->cal_popup->window, GDK_CURRENT_TIME); } @@ -1364,6 +1380,7 @@ hide_date_popup (EDateEdit *dedit) gtk_widget_hide (dedit->priv->cal_popup); gtk_grab_remove (dedit->priv->cal_popup); gdk_pointer_ungrab (GDK_CURRENT_TIME); + gdk_keyboard_ungrab (GDK_CURRENT_TIME); } @@ -1580,6 +1597,45 @@ on_time_entry_focus_out (GtkEntry *entry, return FALSE; } +static void +add_relation (EDateEdit *dedit, GtkWidget *widget) +{ + AtkObject *a11yEdit, *a11yWidget; + AtkRelationSet *set; + AtkRelation *relation; + GPtrArray *target; + gpointer target_object; + + /* add a labelled_by relation for widget for accessibility */ + + a11yEdit = gtk_widget_get_accessible (GTK_WIDGET (dedit)); + a11yWidget = gtk_widget_get_accessible (widget); + + set = atk_object_ref_relation_set (a11yWidget); + if (set != NULL) { + relation = atk_relation_set_get_relation_by_type (set, + ATK_RELATION_LABELLED_BY); + /* check whether has a labelled_by relation already */ + if (relation != NULL) + return; + } + + set = atk_object_ref_relation_set (a11yEdit); + if (!set) + return; + + relation = atk_relation_set_get_relation_by_type (set, + ATK_RELATION_LABELLED_BY); + if (relation != NULL) { + target = atk_relation_get_target (relation); + target_object = g_ptr_array_index (target, 0); + if (ATK_IS_OBJECT (target_object)) { + atk_object_add_relationship (a11yWidget, + ATK_RELATION_LABELLED_BY, + ATK_OBJECT (target_object)); + } + } +} /* This sets the text in the date entry according to the current settings. */ static void @@ -1604,6 +1660,8 @@ e_date_edit_update_date_entry (EDateEdit *dedit) e_utf8_strftime (buffer, sizeof (buffer), _("%m/%d/%Y"), &tmp_tm); gtk_entry_set_text (GTK_ENTRY (priv->date_entry), buffer); } + + add_relation (dedit, priv->date_entry); } @@ -1642,6 +1700,8 @@ e_date_edit_update_time_entry (EDateEdit *dedit) gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->time_combo)->entry), buffer); } + + add_relation (dedit, priv->time_combo); } diff --git a/widgets/misc/e-map.c b/widgets/misc/e-map.c index 4e9a377460..f2a28f0dda 100644 --- a/widgets/misc/e-map.c +++ b/widgets/misc/e-map.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "e-map.h" @@ -639,8 +640,13 @@ EMap * e_map_new () { GtkWidget *widget; + AtkObject *a11y; widget = GTK_WIDGET (gtk_type_new (TYPE_E_MAP)); + a11y = gtk_widget_get_accessible (widget); + atk_object_set_name (a11y, _("World Map")); + atk_object_set_role (a11y, ATK_ROLE_IMAGE); + atk_object_set_description (a11y, _("Mouse-based interactive map widget for selecting timezone. Keyboard users should select the timezone from the below combo box instead.")); return (E_MAP (widget)); } diff --git a/widgets/misc/e-multi-config-dialog.c b/widgets/misc/e-multi-config-dialog.c index aa38ad1e34..71b9457e7d 100644 --- a/widgets/misc/e-multi-config-dialog.c +++ b/widgets/misc/e-multi-config-dialog.c @@ -395,6 +395,8 @@ e_multi_config_dialog_add_page (EMultiConfigDialog *dialog, EConfigPage *page_widget) { EMultiConfigDialogPrivate *priv; + AtkObject *a11y; + gint page_no; g_return_if_fail (E_IS_MULTI_CONFIG_DIALOG (dialog)); g_return_if_fail (title != NULL); @@ -411,10 +413,17 @@ e_multi_config_dialog_add_page (EMultiConfigDialog *dialog, fill_in_pixbufs (dialog, e_table_model_row_count (priv->list_e_table_model) - 1); } - gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), + page_no = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), create_page_container (description, GTK_WIDGET (page_widget)), NULL); + a11y = gtk_widget_get_accessible (GTK_WIDGET(priv->notebook)); + AtkObject *a11yPage = atk_object_ref_accessible_child (a11y, page_no); + if (a11yPage != NULL) { + if (atk_object_get_role (a11yPage) == ATK_ROLE_PAGE_TAB) + atk_object_set_name (a11yPage, title); + g_object_unref (a11yPage); + } if (priv->pages->next == NULL) { ETable *table; -- cgit