forked from AuroraMiddleware/gtk
listview: Set accessible roles
Use the LIST and LIST_ITEM roles for GtkListView and its children. Use the GRID and GRID_CELL roles for GtkGridView and its children.
This commit is contained in:
parent
1bf21d3dba
commit
6d562b6176
@ -1136,7 +1136,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");
|
||||
self->header = gtk_list_item_widget_new (NULL, "header", GTK_ACCESSIBLE_ROLE_WIDGET);
|
||||
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));
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksingleselection.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkmultiselection.h"
|
||||
|
||||
/* Maximum number of list items created by the gridview.
|
||||
* For debugging, you can set this to G_MAXUINT to ensure
|
||||
@ -1025,6 +1026,7 @@ gtk_grid_view_class_init (GtkGridViewClass *klass)
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
list_base_class->list_item_name = "child";
|
||||
list_base_class->list_item_role = GTK_ACCESSIBLE_ROLE_GRID_CELL;
|
||||
list_base_class->list_item_size = sizeof (Cell);
|
||||
list_base_class->list_item_augment_size = sizeof (CellAugment);
|
||||
list_base_class->list_item_augment_func = cell_augment;
|
||||
@ -1157,6 +1159,7 @@ gtk_grid_view_class_init (GtkGridViewClass *klass)
|
||||
gtk_grid_view_activate_item);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("gridview"));
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GRID);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1246,6 +1249,10 @@ gtk_grid_view_set_model (GtkGridView *self,
|
||||
if (!gtk_list_base_set_model (GTK_LIST_BASE (self), model))
|
||||
return;
|
||||
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
|
||||
GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE, GTK_IS_MULTI_SELECTION (model),
|
||||
-1);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODEL]);
|
||||
}
|
||||
|
||||
|
@ -1794,6 +1794,7 @@ gtk_list_base_init_real (GtkListBase *self,
|
||||
|
||||
priv->item_manager = gtk_list_item_manager_new_for_size (GTK_WIDGET (self),
|
||||
g_class->list_item_name,
|
||||
g_class->list_item_role,
|
||||
g_class->list_item_size,
|
||||
g_class->list_item_augment_size,
|
||||
g_class->list_item_augment_func);
|
||||
|
@ -35,6 +35,7 @@ struct _GtkListBaseClass
|
||||
GtkWidgetClass parent_class;
|
||||
|
||||
const char * list_item_name;
|
||||
GtkAccessibleRole list_item_role;
|
||||
gsize list_item_size;
|
||||
gsize list_item_augment_size;
|
||||
GtkRbTreeAugmentFunc list_item_augment_func;
|
||||
|
@ -35,6 +35,7 @@ struct _GtkListItemManager
|
||||
GtkListItemFactory *factory;
|
||||
gboolean single_click_activate;
|
||||
const char *item_css_name;
|
||||
GtkAccessibleRole item_role;
|
||||
|
||||
GtkRbTree *items;
|
||||
GSList *trackers;
|
||||
@ -111,6 +112,7 @@ gtk_list_item_manager_clear_node (gpointer _item)
|
||||
GtkListItemManager *
|
||||
gtk_list_item_manager_new_for_size (GtkWidget *widget,
|
||||
const char *item_css_name,
|
||||
GtkAccessibleRole item_role,
|
||||
gsize element_size,
|
||||
gsize augment_size,
|
||||
GtkRbTreeAugmentFunc augment_func)
|
||||
@ -126,6 +128,7 @@ gtk_list_item_manager_new_for_size (GtkWidget *widget,
|
||||
/* not taking a ref because the widget refs us */
|
||||
self->widget = widget;
|
||||
self->item_css_name = g_intern_string (item_css_name);
|
||||
self->item_role = item_role;
|
||||
|
||||
self->items = gtk_rb_tree_new_for_size (element_size,
|
||||
augment_size,
|
||||
@ -923,7 +926,8 @@ gtk_list_item_manager_acquire_list_item (GtkListItemManager *self,
|
||||
g_return_val_if_fail (prev_sibling == NULL || GTK_IS_WIDGET (prev_sibling), NULL);
|
||||
|
||||
result = gtk_list_item_widget_new (self->factory,
|
||||
self->item_css_name);
|
||||
self->item_css_name,
|
||||
self->item_role);
|
||||
|
||||
gtk_list_item_widget_set_single_click_activate (GTK_LIST_ITEM_WIDGET (result), self->single_click_activate);
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define __GTK_LIST_ITEM_MANAGER_H__
|
||||
|
||||
#include "gtk/gtktypes.h"
|
||||
#include "gtk/gtkenums.h"
|
||||
|
||||
#include "gtk/gtklistitemfactory.h"
|
||||
#include "gtk/gtkrbtreeprivate.h"
|
||||
@ -58,6 +59,7 @@ GType gtk_list_item_manager_get_type (void) G_GNUC_CO
|
||||
|
||||
GtkListItemManager * gtk_list_item_manager_new_for_size (GtkWidget *widget,
|
||||
const char *item_css_name,
|
||||
GtkAccessibleRole item_role,
|
||||
gsize element_size,
|
||||
gsize augment_size,
|
||||
GtkRbTreeAugmentFunc augment_func);
|
||||
|
@ -453,12 +453,14 @@ gtk_list_item_widget_init (GtkListItemWidget *self)
|
||||
|
||||
GtkWidget *
|
||||
gtk_list_item_widget_new (GtkListItemFactory *factory,
|
||||
const char *css_name)
|
||||
const char *css_name,
|
||||
GtkAccessibleRole role)
|
||||
{
|
||||
g_return_val_if_fail (css_name != NULL, NULL);
|
||||
|
||||
return g_object_new (GTK_TYPE_LIST_ITEM_WIDGET,
|
||||
"css-name", css_name,
|
||||
"accessible-role", role,
|
||||
"factory", factory,
|
||||
NULL);
|
||||
}
|
||||
@ -480,6 +482,10 @@ gtk_list_item_widget_update (GtkListItemWidget *self,
|
||||
gtk_widget_set_state_flags (GTK_WIDGET (self), GTK_STATE_FLAG_SELECTED, FALSE);
|
||||
else
|
||||
gtk_widget_unset_state_flags (GTK_WIDGET (self), GTK_STATE_FLAG_SELECTED);
|
||||
|
||||
gtk_accessible_update_state (GTK_ACCESSIBLE (self),
|
||||
GTK_ACCESSIBLE_STATE_SELECTED, selected,
|
||||
-1);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -50,7 +50,8 @@ struct _GtkListItemWidgetClass
|
||||
GType gtk_list_item_widget_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gtk_list_item_widget_new (GtkListItemFactory *factory,
|
||||
const char *css_name);
|
||||
const char *css_name,
|
||||
GtkAccessibleRole role);
|
||||
|
||||
void gtk_list_item_widget_update (GtkListItemWidget *self,
|
||||
guint position,
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "gtkrbtreeprivate.h"
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkmultiselection.h"
|
||||
|
||||
/* Maximum number of list items created by the listview.
|
||||
* For debugging, you can set this to G_MAXUINT to ensure
|
||||
@ -800,6 +801,7 @@ gtk_list_view_class_init (GtkListViewClass *klass)
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
list_base_class->list_item_name = "row";
|
||||
list_base_class->list_item_role = GTK_ACCESSIBLE_ROLE_LIST_ITEM;
|
||||
list_base_class->list_item_size = sizeof (ListRow);
|
||||
list_base_class->list_item_augment_size = sizeof (ListRowAugment);
|
||||
list_base_class->list_item_augment_func = list_row_augment;
|
||||
@ -916,6 +918,7 @@ gtk_list_view_class_init (GtkListViewClass *klass)
|
||||
gtk_list_view_activate_item);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("listview"));
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_LIST);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1001,6 +1004,10 @@ gtk_list_view_set_model (GtkListView *self,
|
||||
if (!gtk_list_base_set_model (GTK_LIST_BASE (self), model))
|
||||
return;
|
||||
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
|
||||
GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE, GTK_IS_MULTI_SELECTION (model),
|
||||
-1);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODEL]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user