[gtk/gtk-3-24: 2/5] GtkFileChooserWidget: export a11y action "show_location"
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-3-24: 2/5] GtkFileChooserWidget: export a11y action "show_location"
- Date: Tue, 25 May 2021 12:57:13 +0000 (UTC)
commit 50cbb8f9a2436eb4abbaadb88d2bf90e2ae0ca53
Author: Yann Dirson <ydirson free fr>
Date: Mon Oct 19 20:49:06 2020 +0200
GtkFileChooserWidget: export a11y action "show_location"
Note that this changes the accessible role of the widget to "file
chooser" instead of "filler".
gtk/a11y/Makefile.inc | 2 +
gtk/a11y/gtkfilechooserwidgetaccessible.c | 122 ++++++++++++++++++++++++++++++
gtk/a11y/gtkfilechooserwidgetaccessible.h | 57 ++++++++++++++
gtk/a11y/meson.build | 2 +
gtk/gtkfilechooserwidget.c | 2 +
5 files changed, 185 insertions(+)
---
diff --git a/gtk/a11y/Makefile.inc b/gtk/a11y/Makefile.inc
index 35c35cfc0d..c116a1f131 100644
--- a/gtk/a11y/Makefile.inc
+++ b/gtk/a11y/Makefile.inc
@@ -11,6 +11,7 @@ a11y_h_sources = \
a11y/gtkcontainercellaccessible.h \
a11y/gtkentryaccessible.h \
a11y/gtkexpanderaccessible.h \
+ a11y/gtkfilechooserwidgetaccessible.h \
a11y/gtkflowboxaccessible.h \
a11y/gtkflowboxchildaccessible.h \
a11y/gtkframeaccessible.h \
@@ -88,6 +89,7 @@ a11y_c_sources = \
a11y/gtkcontainercellaccessible.c \
a11y/gtkentryaccessible.c \
a11y/gtkexpanderaccessible.c \
+ a11y/gtkfilechooserwidgetaccessible.c \
a11y/gtkflowboxaccessible.c \
a11y/gtkflowboxchildaccessible.c \
a11y/gtkframeaccessible.c \
diff --git a/gtk/a11y/gtkfilechooserwidgetaccessible.c b/gtk/a11y/gtkfilechooserwidgetaccessible.c
new file mode 100644
index 0000000000..9f4e362efb
--- /dev/null
+++ b/gtk/a11y/gtkfilechooserwidgetaccessible.c
@@ -0,0 +1,122 @@
+/* GTK+ - accessibility implementations
+ * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <glib/gi18n-lib.h>
+#include "gtkfilechooserwidgetaccessible.h"
+
+
+static void atk_action_interface_init (AtkActionIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkFileChooserWidgetAccessible, gtk_file_chooser_widget_accessible,
GTK_TYPE_CONTAINER_ACCESSIBLE,
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init))
+
+static void
+gtk_file_chooser_widget_accessible_initialize (AtkObject *obj,
+ gpointer data)
+{
+ ATK_OBJECT_CLASS (gtk_file_chooser_widget_accessible_parent_class)->initialize (obj, data);
+ obj->role = ATK_ROLE_FILE_CHOOSER;
+}
+
+static void
+gtk_file_chooser_widget_accessible_class_init (GtkFileChooserWidgetAccessibleClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+ GtkContainerAccessibleClass *container_class = (GtkContainerAccessibleClass*)klass;
+
+ class->initialize = gtk_file_chooser_widget_accessible_initialize;
+
+ container_class->add_gtk = NULL;
+ container_class->remove_gtk = NULL;
+}
+
+static void
+gtk_file_chooser_widget_accessible_init (GtkFileChooserWidgetAccessible *file_chooser_widget)
+{
+}
+
+static gboolean
+gtk_file_chooser_widget_accessible_do_action (AtkAction *action,
+ gint i)
+{
+ GtkWidget *widget;
+
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
+ if (widget == NULL)
+ return FALSE;
+
+ if (!gtk_widget_is_sensitive (widget) || !gtk_widget_get_visible (widget))
+ return FALSE;
+
+ switch (i)
+ {
+ case 0:
+ g_signal_emit_by_name (GTK_FILE_CHOOSER_WIDGET (widget), "location-popup", "");
+ return TRUE;
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+
+static gint
+gtk_file_chooser_widget_accessible_get_n_actions (AtkAction *action)
+{
+ return 1;
+}
+
+static const gchar *
+gtk_file_chooser_widget_accessible_action_get_name (AtkAction *action,
+ gint i)
+{
+ if (i == 0)
+ return "show_location";
+ return NULL;
+}
+
+static const gchar *
+gtk_file_chooser_widget_accessible_action_get_localized_name (AtkAction *action,
+ gint i)
+{
+ if (i == 0)
+ return C_("Action name", "Show location");
+ return NULL;
+}
+
+static const gchar *
+gtk_file_chooser_widget_accessible_action_get_description (AtkAction *action,
+ gint i)
+{
+ if (i == 0)
+ return C_("Action description", "Show the File Chooser's Location text field");
+ return NULL;
+}
+
+static void
+atk_action_interface_init (AtkActionIface *iface)
+{
+ iface->do_action = gtk_file_chooser_widget_accessible_do_action;
+ iface->get_n_actions = gtk_file_chooser_widget_accessible_get_n_actions;
+ iface->get_name = gtk_file_chooser_widget_accessible_action_get_name;
+ iface->get_localized_name = gtk_file_chooser_widget_accessible_action_get_localized_name;
+ iface->get_description = gtk_file_chooser_widget_accessible_action_get_description;
+}
diff --git a/gtk/a11y/gtkfilechooserwidgetaccessible.h b/gtk/a11y/gtkfilechooserwidgetaccessible.h
new file mode 100644
index 0000000000..6310c35921
--- /dev/null
+++ b/gtk/a11y/gtkfilechooserwidgetaccessible.h
@@ -0,0 +1,57 @@
+/* GTK+ - accessibility implementations
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_FILE_CHOOSER_WIDGET_ACCESSIBLE_H__
+#define __GTK_FILE_CHOOSER_WIDGET_ACCESSIBLE_H__
+
+#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk-a11y.h> can be included directly."
+#endif
+
+#include <gtk/a11y/gtkcontaineraccessible.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_FILE_CHOOSER_WIDGET_ACCESSIBLE
(gtk_file_chooser_widget_accessible_get_type ())
+#define GTK_FILE_CHOOSER_WIDGET_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GTK_TYPE_FILE_CHOOSER_WIDGET_ACCESSIBLE, GtkFileChooserWidgetAccessible))
+#define GTK_FILE_CHOOSER_WIDGET_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GTK_TYPE_FILE_CHOOSER_WIDGET_ACCESSIBLE, GtkFileChooserWidgetAccessibleClass))
+#define GTK_IS_FILE_CHOOSER_WIDGET_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GTK_TYPE_FILE_CHOOSER_WIDGET_ACCESSIBLE))
+#define GTK_IS_FILE_CHOOSER_WIDGET_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GTK_TYPE_FILE_CHOOSER_WIDGET_ACCESSIBLE))
+#define GTK_FILE_CHOOSER_WIDGET_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GTK_TYPE_FILE_CHOOSER_WIDGET_ACCESSIBLE, GtkFileChooserWidgetAccessibleClass))
+
+typedef struct _GtkFileChooserWidgetAccessible GtkFileChooserWidgetAccessible;
+typedef struct _GtkFileChooserWidgetAccessibleClass GtkFileChooserWidgetAccessibleClass;
+typedef struct _GtkFileChooserWidgetAccessiblePrivate GtkFileChooserWidgetAccessiblePrivate;
+
+struct _GtkFileChooserWidgetAccessible
+{
+ GtkContainerAccessible parent;
+
+ GtkFileChooserWidgetAccessiblePrivate *priv;
+};
+
+struct _GtkFileChooserWidgetAccessibleClass
+{
+ GtkContainerAccessibleClass parent_class;
+};
+
+GDK_AVAILABLE_IN_ALL
+GType gtk_file_chooser_widget_accessible_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GTK_FILE_CHOOSER_WIDGET_ACCESSIBLE_H__ */
diff --git a/gtk/a11y/meson.build b/gtk/a11y/meson.build
index a250319c77..8c615c84cf 100644
--- a/gtk/a11y/meson.build
+++ b/gtk/a11y/meson.build
@@ -14,6 +14,7 @@ a11y_sources = files(
'gtkcontainercellaccessible.c',
'gtkentryaccessible.c',
'gtkexpanderaccessible.c',
+ 'gtkfilechooserwidgetaccessible.c',
'gtkflowboxaccessible.c',
'gtkflowboxchildaccessible.c',
'gtkframeaccessible.c',
@@ -72,6 +73,7 @@ a11y_headers = files(
'gtkcontainercellaccessible.h',
'gtkentryaccessible.h',
'gtkexpanderaccessible.h',
+ 'gtkfilechooserwidgetaccessible.h',
'gtkflowboxaccessible.h',
'gtkflowboxchildaccessible.h',
'gtkframeaccessible.h',
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index d75a3f7857..6a29f3fcf8 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -69,6 +69,7 @@
#include "gtkcheckbutton.h"
#include "gtkwindowgroup.h"
#include "gtkintl.h"
+#include "a11y/gtkfilechooserwidgetaccessible.h"
#include "gtkshow.h"
#include "gtkmain.h"
#include "gtkscrollable.h"
@@ -8752,6 +8753,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
gtk_widget_class_bind_template_callback (widget_class, rename_file_rename_clicked);
gtk_widget_class_bind_template_callback (widget_class, rename_file_end);
+ gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_FILE_CHOOSER_WIDGET_ACCESSIBLE);
gtk_widget_class_set_css_name (widget_class, "filechooser");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]