[gtk/wip/exalm/activatable] listitemwidget: Have .activatable style class if the item is activatable
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/exalm/activatable] listitemwidget: Have .activatable style class if the item is activatable
- Date: Mon, 17 May 2021 13:07:09 +0000 (UTC)
commit 5657748f02516cd34919267ea248825d41c2b85f
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon May 17 18:05:05 2021 +0500
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.
gtk/gtkgridview.c | 11 ++++++-----
gtk/gtklistitem.c | 3 +++
gtk/gtklistitemwidget.c | 21 +++++++++++++++++++++
gtk/gtklistitemwidgetprivate.h | 2 ++
gtk/gtklistview.c | 14 ++++++++------
5 files changed, 40 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c
index f32400d3cd..0f5e544d1e 100644
--- a/gtk/gtkgridview.c
+++ b/gtk/gtkgridview.c
@@ -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
*
diff --git a/gtk/gtklistitem.c b/gtk/gtklistitem.c
index 89171369a5..b4371b8c93 100644
--- a/gtk/gtklistitem.c
+++ b/gtk/gtklistitem.c
@@ -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]);
}
diff --git a/gtk/gtklistitemwidget.c b/gtk/gtklistitemwidget.c
index 09ac15d1bf..6bc369cfa6 100644
--- a/gtk/gtklistitemwidget.c
+++ b/gtk/gtklistitemwidget.c
@@ -509,6 +509,9 @@ gtk_list_item_widget_default_setup (GtkListItemWidget *self,
if (list_item->child)
gtk_list_item_widget_add_child (self, list_item->child);
+ if (list_item->activatable)
+ gtk_widget_add_css_class (GTK_WIDGET (self), "activatable");
+
if (priv->item)
g_object_notify (G_OBJECT (list_item), "item");
if (priv->position != GTK_INVALID_LIST_POSITION)
@@ -531,6 +534,9 @@ gtk_list_item_widget_default_teardown (GtkListItemWidget *self,
if (list_item->child)
gtk_list_item_widget_remove_child (self, list_item->child);
+ if (list_item->activatable)
+ gtk_widget_remove_css_class (GTK_WIDGET (self), "activatable");
+
if (priv->item)
g_object_notify (G_OBJECT (list_item), "item");
if (priv->position != GTK_INVALID_LIST_POSITION)
@@ -556,6 +562,11 @@ gtk_list_item_widget_default_update (GtkListItemWidget *self,
g_object_notify (G_OBJECT (list_item), "item");
}
+ if (list_item && list_item->activatable)
+ gtk_widget_add_css_class (GTK_WIDGET (self), "activatable");
+ else
+ gtk_widget_remove_css_class (GTK_WIDGET (self), "activatable");
+
if (priv->position != position)
{
priv->position = position;
@@ -612,6 +623,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)
diff --git a/gtk/gtklistitemwidgetprivate.h b/gtk/gtklistitemwidgetprivate.h
index 8f78b1a7a2..eca2d21c6b 100644
--- a/gtk/gtklistitemwidgetprivate.h
+++ b/gtk/gtklistitemwidgetprivate.h
@@ -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,
diff --git a/gtk/gtklistview.c b/gtk/gtklistview.c
index 63446efdb0..8e2a02180b 100644
--- a/gtk/gtklistview.c
+++ b/gtk/gtklistview.c
@@ -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):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]