listitemwidget: Have .activatable style class if the item is activatable

Match GtkListBox, so it's possible to use the same styles for them.

Update GtkListView and GtkGridView docs to reflect that, fix a few gtk-doc
formatting leftovers along the way.
This commit is contained in:
Alexander Mikhaylenko 2021-05-17 18:05:05 +05:00
parent 27e662cfd1
commit d56711b5d8
5 changed files with 33 additions and 11 deletions

View File

@ -64,17 +64,18 @@
*
* ```
* gridview
* child
* child[.activatable]
*
* child
* child[.activatable]
*
*
* [rubberband]
* ```
*
* `GtkGridView` uses a single CSS node with name gridview. Each child
* uses a single CSS node with name child. For rubberband selection,
* a subnode with name rubberband is used.
* `GtkGridView` uses a single CSS node with name `gridview`. Each child uses
* a single CSS node with name `child`. If the [property@Gtk.ListItem.activatable]
* property is set, the corresponding row will have the `.activatable` style
* class. For rubberband selection, a subnode with name `rubberband` is used.
*
* # Accessibility
*

View File

@ -460,5 +460,8 @@ gtk_list_item_set_activatable (GtkListItem *self,
self->activatable = activatable;
if (self->owner)
gtk_list_item_widget_set_activatable (self->owner, activatable);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ACTIVATABLE]);
}

View File

@ -509,6 +509,8 @@ gtk_list_item_widget_default_setup (GtkListItemWidget *self,
if (list_item->child)
gtk_list_item_widget_add_child (self, list_item->child);
gtk_list_item_widget_set_activatable (self, list_item->activatable);
if (priv->item)
g_object_notify (G_OBJECT (list_item), "item");
if (priv->position != GTK_INVALID_LIST_POSITION)
@ -531,6 +533,8 @@ gtk_list_item_widget_default_teardown (GtkListItemWidget *self,
if (list_item->child)
gtk_list_item_widget_remove_child (self, list_item->child);
gtk_list_item_widget_set_activatable (self, FALSE);
if (priv->item)
g_object_notify (G_OBJECT (list_item), "item");
if (priv->position != GTK_INVALID_LIST_POSITION)
@ -612,6 +616,16 @@ gtk_list_item_widget_set_single_click_activate (GtkListItemWidget *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SINGLE_CLICK_ACTIVATE]);
}
void
gtk_list_item_widget_set_activatable (GtkListItemWidget *self,
gboolean activatable)
{
if (activatable)
gtk_widget_add_css_class (GTK_WIDGET (self), "activatable");
else
gtk_widget_remove_css_class (GTK_WIDGET (self), "activatable");
}
void
gtk_list_item_widget_add_child (GtkListItemWidget *self,
GtkWidget *child)

View File

@ -74,6 +74,8 @@ void gtk_list_item_widget_set_factory (GtkListItemWidg
void gtk_list_item_widget_set_single_click_activate
(GtkListItemWidget *self,
gboolean single_click_activate);
void gtk_list_item_widget_set_activatable (GtkListItemWidget *self,
gboolean activatable);
void gtk_list_item_widget_add_child (GtkListItemWidget *self,
GtkWidget *child);
void gtk_list_item_widget_reorder_child (GtkListItemWidget *self,

View File

@ -117,18 +117,20 @@
*
* ```
* listview[.separators][.rich-list][.navigation-sidebar][.data-table]
* row
* row[.activatable]
*
* row
* row[.activatable]
*
*
* [rubberband]
* ```
*
* `GtkListView` uses a single CSS node named listview. It may carry the
* .separators style class, when `GtkListView`:show-separators property
* is set. Each child widget uses a single CSS node named row. For
* rubberband selection, a node with name rubberband is used.
* `GtkListView` uses a single CSS node named `listview`. It may carry the
* `.separators` style class, when [property@Gtk.ListView:show-separators]
* property is set. Each child widget uses a single CSS node named `row`.
* If the [property@Gtk.ListItem.activatable] property is set, the
* corresponding row will have the `.activatable` style class. For
* rubberband selection, a node with name `rubberband` is used.
*
* The main listview node may also carry style classes to select
* the style of [list presentation](ListContainers.html#list-styles):