forked from AuroraMiddleware/gtk
columnview: Set accessible roles
Use the TREE_GRID, ROW, COLUMN_HEADER and GRID_CELL roles for the various widgets involved in a GtkColumnView. To enable this, we subclass GtkListView for the internal list in the column view.
This commit is contained in:
parent
6d562b6176
commit
c7bf33a3de
@ -48,9 +48,10 @@ Each role name is part of the #GtkAccessibleRole enumeration.
|
||||
| `BUTTON` | A control that performs an action when pressed | #GtkButton, #GtkLinkButton, #GtkExpander |
|
||||
| `CHECKBOX` | A control that has three possible value: `true`, `false`, or `undefined` | #GtkCheckButton |
|
||||
| `COMBOBOX` | A control that can be expanded to show a list of possible values to select | #GtkComboBox |
|
||||
| `COLUMN_HEADER` | A header in a columned list | #GtkColumnView |
|
||||
| `DIALOG` | A dialog that prompts the user to enter information or require a response | #GtkDialog and subclasses |
|
||||
| `GRID` | A grid of items | #GtkFlowBox |
|
||||
| `GRID_CELL` | An item in a grid | #GtkFlowBoxChild |
|
||||
| `GRID` | A grid of items | #GtkFlowBox, #GtkGridView |
|
||||
| `GRID_CELL` | An item in a grid | #GtkFlowBoxChild, #GtkGridView, #GtkColumnView |
|
||||
| `IMG` | An image | #GtkImage, #GtkPicture |
|
||||
| `LABEL` | A visible name or caption for a user interface component | #GtkLabel |
|
||||
| `LIST` | A list of items | #GtkListBox |
|
||||
@ -58,6 +59,7 @@ Each role name is part of the #GtkAccessibleRole enumeration.
|
||||
| `METER` | Represents a value within a known range | #GtkLevelBar |
|
||||
| `PROGRESS_BAR` | An element that display progress | #GtkProgressBar |
|
||||
| `RADIO` | A checkable input in a group of radio roles | #GtkCheckButton |
|
||||
| `ROW` | A row in a columned list | #GtkColumnView |
|
||||
| `SCROLLBAR` | A graphical object controlling the scrolling of content | #GtkScrollbar |
|
||||
| `SEARCH_BOX` | A text box for entering search criteria | #GtkSearchEntry |
|
||||
| `SEPARATOR` | A divider that separates sections of content or groups of items | #GtkSeparator |
|
||||
@ -67,6 +69,7 @@ Each role name is part of the #GtkAccessibleRole enumeration.
|
||||
| `TAB_LIST` | A list of tabs for switching pages | #GtkStackSwitcher, #GtkNotebook |
|
||||
| `TAB_PANEL` | A page in a notebook or stack | #GtkStack |
|
||||
| `TEXT_BOX` | A type of input that allows free-form text as its value. | #GtkEntry, #GtkPasswordEntry, #GtkTextView |
|
||||
| `TREE_GRID` | A treeview-like columned list | #GtkColumnView |
|
||||
| `WINDOW` | An application window | #GtkWindow |
|
||||
| `...` | … |
|
||||
|
||||
|
@ -102,7 +102,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkInfoBar, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkLevelBar, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkLinkButton, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkListStore, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkListView, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkLockButton, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkMenuButton, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkMessageDialog, g_object_unref)
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtkdropcontrollermotion.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtklistview.h"
|
||||
#include "gtklistviewprivate.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkscrollable.h"
|
||||
@ -106,6 +106,44 @@
|
||||
* .rich-list, .navigation-sidebar or .data-table.
|
||||
*/
|
||||
|
||||
/* We create a subclass of GtkListView for the sole purpose of overriding
|
||||
* some parameters for item creation.
|
||||
*/
|
||||
|
||||
#define GTK_TYPE_COLUMN_LIST_VIEW (gtk_column_list_view_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GtkColumnListView, gtk_column_list_view, GTK, COLUMN_LIST_VIEW, GtkListView)
|
||||
|
||||
struct _GtkColumnListView
|
||||
{
|
||||
GtkListView parent_instance;
|
||||
};
|
||||
|
||||
struct _GtkColumnListViewClass
|
||||
{
|
||||
GtkListViewClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkColumnListView, gtk_column_list_view, GTK_TYPE_LIST_VIEW)
|
||||
|
||||
static void
|
||||
gtk_column_list_view_init (GtkColumnListView *view)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_column_list_view_class_init (GtkColumnListViewClass *klass)
|
||||
{
|
||||
GtkListBaseClass *list_base_class = GTK_LIST_BASE_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
list_base_class->list_item_name = "row";
|
||||
list_base_class->list_item_role = GTK_ACCESSIBLE_ROLE_ROW;
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("listview"));
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_LIST);
|
||||
}
|
||||
|
||||
|
||||
struct _GtkColumnView
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
@ -733,6 +771,7 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
|
||||
g_cclosure_marshal_VOID__UINTv);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("columnview"));
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_TREE_GRID);
|
||||
}
|
||||
|
||||
static void update_column_resize (GtkColumnView *self,
|
||||
@ -1136,7 +1175,7 @@ gtk_column_view_init (GtkColumnView *self)
|
||||
|
||||
self->columns = g_list_store_new (GTK_TYPE_COLUMN_VIEW_COLUMN);
|
||||
|
||||
self->header = gtk_list_item_widget_new (NULL, "header", GTK_ACCESSIBLE_ROLE_WIDGET);
|
||||
self->header = gtk_list_item_widget_new (NULL, "header", GTK_ACCESSIBLE_ROLE_ROW);
|
||||
gtk_widget_set_can_focus (self->header, FALSE);
|
||||
gtk_widget_set_layout_manager (self->header, gtk_column_view_layout_new (self));
|
||||
gtk_widget_set_parent (self->header, GTK_WIDGET (self));
|
||||
@ -1164,8 +1203,8 @@ gtk_column_view_init (GtkColumnView *self)
|
||||
|
||||
self->sorter = GTK_SORTER (gtk_column_view_sorter_new ());
|
||||
self->factory = gtk_column_list_item_factory_new (self);
|
||||
self->listview = GTK_LIST_VIEW (gtk_list_view_new (NULL,
|
||||
GTK_LIST_ITEM_FACTORY (g_object_ref (self->factory))));
|
||||
self->listview = GTK_LIST_VIEW (g_object_new (GTK_TYPE_COLUMN_LIST_VIEW, NULL));
|
||||
gtk_list_view_set_factory (self->listview, GTK_LIST_ITEM_FACTORY (self->factory));
|
||||
gtk_widget_set_hexpand (GTK_WIDGET (self->listview), TRUE);
|
||||
gtk_widget_set_vexpand (GTK_WIDGET (self->listview), TRUE);
|
||||
g_signal_connect (self->listview, "activate", G_CALLBACK (gtk_column_view_activate_cb), self);
|
||||
|
@ -204,6 +204,7 @@ gtk_column_view_cell_class_init (GtkColumnViewCellClass *klass)
|
||||
gobject_class->dispose = gtk_column_view_cell_dispose;
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("cell"));
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GRID_CELL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -171,6 +171,7 @@ gtk_column_view_title_class_init (GtkColumnViewTitleClass *klass)
|
||||
gobject_class->dispose = gtk_column_view_title_dispose;
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("button"));
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_COLUMN_HEADER);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1161,7 +1161,7 @@ typedef enum {
|
||||
* @GTK_ACCESSIBLE_ROLE_CELL: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_CHECKBOX: A checkable input element that has
|
||||
* three possible values: `true`, `false`, or `mixed`
|
||||
* @GTK_ACCESSIBLE_ROLE_COLUMN_HEADER: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_COLUMN_HEADER: A header in a columned list.
|
||||
* @GTK_ACCESSIBLE_ROLE_COMBO_BOX: An input that controls another element,
|
||||
* such as a list or a grid, that can dynamically pop up to help the user
|
||||
* set the value of the input
|
||||
@ -1176,7 +1176,7 @@ typedef enum {
|
||||
* @GTK_ACCESSIBLE_ROLE_FORM: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_GENERIC: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_GRID: A grid of items.
|
||||
* @GTK_ACCESSIBLE_ROLE_GRID_CELL: An item in a grid.
|
||||
* @GTK_ACCESSIBLE_ROLE_GRID_CELL: An item in a grid or tree grid.
|
||||
* @GTK_ACCESSIBLE_ROLE_GROUP: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_HEADING: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_IMG: An image.
|
||||
@ -1210,7 +1210,7 @@ typedef enum {
|
||||
* @GTK_ACCESSIBLE_ROLE_RADIO_GROUP: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_RANGE: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_REGION: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_ROW: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_ROW: A row in a columned list.
|
||||
* @GTK_ACCESSIBLE_ROLE_ROW_GROUP: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_ROW_HEADER: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_SCROLLBAR: A graphical object that controls the scrolling
|
||||
@ -1243,7 +1243,7 @@ typedef enum {
|
||||
* @GTK_ACCESSIBLE_ROLE_TOOLBAR: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_TOOLTIP: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_TREE: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_TREE_GRID: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_TREE_GRID: A treeview-like, columned list.
|
||||
* @GTK_ACCESSIBLE_ROLE_TREE_ITEM: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_WIDGET: An interactive component of a graphical user
|
||||
* interface. This is the role that GTK uses by default for widgets.
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtklistview.h"
|
||||
#include "gtklistviewprivate.h"
|
||||
|
||||
#include "gtkbitset.h"
|
||||
#include "gtkintl.h"
|
||||
@ -141,21 +141,6 @@
|
||||
typedef struct _ListRow ListRow;
|
||||
typedef struct _ListRowAugment ListRowAugment;
|
||||
|
||||
struct _GtkListView
|
||||
{
|
||||
GtkListBase parent_instance;
|
||||
|
||||
GtkListItemManager *item_manager;
|
||||
gboolean show_separators;
|
||||
|
||||
int list_width;
|
||||
};
|
||||
|
||||
struct _GtkListViewClass
|
||||
{
|
||||
GtkListBaseClass parent_class;
|
||||
};
|
||||
|
||||
struct _ListRow
|
||||
{
|
||||
GtkListItemManagerItem parent;
|
||||
|
@ -81,6 +81,8 @@ void gtk_list_view_set_enable_rubberband (GtkListView
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_list_view_get_enable_rubberband (GtkListView *self);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkListView, g_object_unref)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_LIST_VIEW_H__ */
|
||||
|
45
gtk/gtklistviewprivate.h
Normal file
45
gtk/gtklistviewprivate.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright © 2020 Red Hat, 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.1 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/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_LIST_VIEW_PRIVATE_H__
|
||||
#define __GTK_LIST_VIEW_PRIVATE_H__
|
||||
|
||||
#include <gtk/gtklistview.h>
|
||||
#include <gtk/gtklistbaseprivate.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
struct _GtkListView
|
||||
{
|
||||
GtkListBase parent_instance;
|
||||
|
||||
GtkListItemManager *item_manager;
|
||||
gboolean show_separators;
|
||||
|
||||
int list_width;
|
||||
};
|
||||
|
||||
struct _GtkListViewClass
|
||||
{
|
||||
GtkListBaseClass parent_class;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_LIST_VIEW_H__ */
|
Loading…
Reference in New Issue
Block a user